EmbeddedRelated.com
Forums
Memfault Beyond the Launch

2 Byte (16Bit) Mini-Float

Started by Anbeyon January 10, 2008
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.
Anbeyon wrote:
> 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.
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.
On Jan 10, 10:51=A0am, Anbeyon <anbe...@btinternet.com> wrote:
> 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. =A0We 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. =A0 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.
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

Anbeyon wrote:

> 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.
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 http://www.abvolt.com
On Jan 10, 7:51 am, Anbeyon <anbe...@btinternet.com> wrote:
> 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.
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.

Memfault Beyond the Launch