2 Byte (16Bit) Mini-Float

Hi

I am hoping someone might be able to help point me in the right direction.

I have an embeeded application running in a PIC in which is sending sensor data over a wireless network. We want to keep the number of bytes in each packet sent to an absolute minimum.

Some of the values we want to send back and forth are Floats which takes 4 bytes. We'd like represent some of the values as 2 Byte mini floats.

Has anyone out there ever implemented standard 4 byte C float conversion to 2 byte minifloats and back ?

If anyone has any info or links that can send me I'd really appreciate it.

Thanks in advance

Anbeyon.

Reply to
Anbeyon
Loading thread data ...

For typical sensors it makes more sense to use 16 bit fixed point values.

If that's not an option, specify the required range and precision.

Reply to
Arlet Ottens

you don't mention anything about accuracy requirements so it's hard to give an answer

I would just convert the floats to a 16 bit signed scaled integer, scaled appropriately for each sensor, send over wirelessly, and convert back to floats on the receive end

Reply to
steve

There is a standard short float with 11 bits of mantissa, 4 bits of exponent and a sign bit: s eeee mmmmmmmmmmm Short float supports for the denormalized representation. The conversion to and from the 4-byte float is fairly straightforward.

Vladimir Vassilevsky DSP and Mixed Signal Design Consultant

formatting link

Reply to
Vladimir Vassilevsky

BTDT. I've created 16-bit and 24-bit floating point packages. (Yes, there are applications for these.)

Get comfortable enough with a search engine that you can find out how floating point numbers are represented. You should be able to find source code for a floating point package, but writing one is NOT that hard. You'll want to write it in assembly; every 'C' floating point package I've seen was very inefficient.

Decide how many bits you want for the significand and mantissa, and implement a floating point package for your requirements. If you impliment your numbers in the conventional format, you'll discover that conversion between resolutions is trivial.

G.

Reply to
ghelbig

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.