08-12-2014 03:53 PM
Hi,
I have ran into a situation were I need to use floating point numbers(IEEE Floating Standard) when communicating. How can I send and recieve floating point numbers? What converstions need to be made? Is there a good resource on this?
Thanks,
Ken
08-12-2014 03:58 PM
Hi Ken,
are we talking about CAN communication?
With CAN you usually exchange integer numbers - with a gain and offset defined in the message description. You may also communicate floats too - but probably you will need to do the parsing on your own…
What kind of floats do you want to exchange? SGL, DBL, EXT, CDB?
What's the purpose/background of this discussion?
08-13-2014 08:01 AM
GerdW,
We are using CAN communication to communicate between a microcontroller and a PC via a CAN to USB converter box. We are thinking we need to use single SGL floats in order to communicate some calculated measurement values that require a higher resoultion and precision than integers are able to achieve. In the past integers have always been used but in this particular case the resolution we would see via integers is not acceptable. I am not sure that floats NEED to be used, but we need to acheive a higher resolution than we are currently able to achieve with integers. What are the routes people have taken in order to perform these actions? What is the most efficient way of doing so? Is there a good resource on this subject?
Thanks,
Ken
08-13-2014 08:12 AM - edited 08-13-2014 08:21 AM
Hi K.,
in automotive a lot of fractional values are exchanged via CAN communication, but still the CAN protocol is based on using integer numbers (of variable bit size)…
We are thinking we need to use single SGL floats ... that require a higher resoultion and precision
What is the needed resolution and "precision"? SGL transports 23 bits of mantissa: you can easily pack them into an I32 value!
Lets make an example:
I have a signal with a value range of 100…1000 and a resolution of 0.125. To send this over CAN I need to use 13 bits and scale the value with a gain of 0.125 and an offset of 100. Values will be send in an integer representation:
msgdata value 0 100 500 162.5
501 162.625 1000 225 5000 725 7200 1000
The formula to translate msgdata to value is easy: value := msgdata*gain+offset.
Another example: the car I test at the moment sends it's current speed as 16 bit integer value with a range of 0…65532. The gain is 0.01 so speed translates to 0.00…655.32 km/h. The values 65533-65535 have special meanings to indicate errors…
So again: What is your needed resolution and data range?
Another option: send the SGL as it is: just 4 bytes. Receive those 4 bytes on your PC as I32/U32 and typecast them to SGL…
08-13-2014 09:15 AM
Hi GerdW,
@GerdW wrote:
So again: What is your needed resolution and data range?
Another option: send the SGL as it is: just 4 bytes. Receive those 4 bytes on your PC as I32/U32 and typecast them to SGL…
We need to transmit a data range of about from 0 to 100,000 with a resolution of roughly 0.01.
If we send the 4 byte SGL, how do you typecast them back in LabVIEW?
Thanks,
Ken
08-13-2014 09:25 AM - edited 08-13-2014 09:26 AM
Hi Ken,
If we send the 4 byte SGL, how do you typecast them back in LabVIEW?
Well, using TypeCast?
data range of about from 0 to 100,000 with a resolution of roughly 0.01.
That makes a range of 0…10M (needing 24bits), a gain of 0.01 and an offset of zero…