Pages: 1 [2]   Go Down
Author Topic: conversion double float recieved to int?  (Read 4006 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 300
Posts: 26218
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
So what your saying is there is no way to directly work with 64 bit numbers on the 8bit AVR MCU?
Who said that?
The "long long" data type is supported, giving 64 bit support.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Ayer, Massachusetts, USA
Offline Offline
Edison Member
*
Karma: 54
Posts: 1847
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Note, it occurs to me that while the AVR compiler converts 'double' into being a 32-bit representation (same as 'float'), that ARM chips will provide a 64-bit IEEE format, and for the the OP, this might solve a lot of headaches to switch processors.  On October 22nd, the DUE will be available and it should be fairly compatible with the current AVR based Arduino's, but there are various other ARM solutions out there right now that you might need to learn a new IDE for.  Or if you don't need hard realtime, the Raspberry Pi is available.

Now, if you are doing lots and lots of floating point arithmetic, you might want to get a chip with hardware floating point (unfortunately the DUE will not have hardware FP).
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 65
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So unless theres some way to convert with the bits themselves it sounds like I need a seperate PC program to work with the 64 bit floats. So after I do message order checking I'll have to pass the full message array to a PC to be changed to RTCM standard format or start with a different imbedded processor.

I was looking at the spec sheet for a AVR32UC which you can get with an FPU built in, but it looks like it is set up for 32 bit acess also.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 300
Posts: 26218
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
This is also confusing as it states it should be a 38bit int but says it holds +/-13,743,895.3471meters.

Quote
(2^38) / 13743895.3471 = 2000.  So the divisor is 2000

This thread started going off-track very early.
238 / 13,743,895.3471 is 20 000, not 2000.

A simpler way of looking at the problem is to examine the value 237 (don't forget the sign bit) = 137 438 953 472.
Look familiar? Now divide it by 10 000, giving the 1/10 mm resolution already mentioned.
I can't believe that converting a 64 bit IEE754 number to this representation is all that difficult using "long long" arithmetic.
It won't be fast, but things that use numbers with this sort of range rarely (in my experience) require speedy calculations.

However, if there is a similarly-priced platform that will handle 64 bit IEE754 natively, that's the solution I'd go for.
« Last Edit: October 04, 2012, 08:44:33 am by AWOL » Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Jr. Member
**
Karma: 0
Posts: 65
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So if I could take the 52 numerical bits into a long long int 64bit (or should I just work with the bytes in a second array), then read the 11 exponent bits into an int, sutract 1023 from it for the actual exponent. I would need to determine how many decimal places the exponent indicates shifting and add 4 more shifts to the right. This should be the trunication point of the real int number. Then I need to use those bits 37 places left for my interger and add the sign bit.

OK that said I've got my head confused. If I work with it all at the byte/bit level, would the sign bit be the leftmost bit in the lowest addressed byte in the array of 8 bytes making up the original float?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 300
Posts: 26218
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Really useful reference
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Ayer, Massachusetts, USA
Offline Offline
Edison Member
*
Karma: 54
Posts: 1847
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
This is also confusing as it states it should be a 38bit int but says it holds +/-13,743,895.3471meters.

Quote
(2^38) / 13743895.3471 = 2000.  So the divisor is 2000

This thread started going off-track very early.
238 / 13,743,895.3471 is 20 000, not 2000.

A simpler way of looking at the problem is to examine the value 237 (don't forget the sign bit) = 137 438 953 472.
Look familiar? Now divide it by 10 000, giving the 1/10 mm resolution already mentioned.
I can't believe that converting a 64 bit IEE754 number to this representation is all that difficult using "long long" arithmetic.
It won't be fast, but things that use numbers with this sort of range rarely (in my experience) require speedy calculations.

However, if there is a similarly-priced platform that will handle 64 bit IEE754 natively, that's the solution I'd go for.
Sure it can be done.  It is just a matter of getting all of the details correct.

Lets see, Adafruit has just started selling the Teeny 3.0 chips for $28 (US): http://www.adafruit.com/products/1044.  The teeny provides an IDE based on the Arduino IDE, so it should be similar to what you are used to.  Note, it does not do FP in hardware, but does it via software emulation.

Raspberry Pi is around $40, and it does support hardware FP, but it runs Linux instead of the standalone environment used on Arduinos.  You can get pi-plates (i.e. shields) to get access to the GPIO pins, but it is not a hard realtime system.  http://www.adafruit.com/products/998

As I mentioned DUE is supposed to be formally announced on October 22nd.  It does not have hardware FP.  The rumored price is $49.

Itead Simplecortex, $45, software FP: http://imall.iteadstudio.com/featured-product/im120410002.html

Iteadmaple, $22, software FP: http://imall.iteadstudio.com/special-product/im120411012.html[
« Last Edit: October 04, 2012, 09:46:31 am by MichaelMeissner » Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 206
Posts: 12849
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
This thread started going off-track very early.

Sorry about that.  smiley-red
Logged

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What about the Cortex-M4 boards? ST has them for <$20, and TI for < $5.
Logged

Pages: 1 [2]   Go Up
Jump to: