Is 16-bit floating point library available ?

View: New views
4 Messages — Rating Filter:   Alert me  

Is 16-bit floating point library available ?

by vaclavpe :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello all,

my question is maybe slight off-topic, but, did anybody have implemented half-precision floating point library for PIC16F processors ?

I'd like to implement fast Goertzel DFT algorithm over the data from 12-bit ADC and 32-bit seems to me overkill.

Or does anybody have a better idea how to do it, than I have ?

Thank you in advance,
Vasek

---------------------------------------------------------------------
To unsubscribe, e-mail: gnupic-unsubscribe@...
For additional commands, e-mail: gnupic-help@...


Re: Is 16-bit floating point library available ?

by Scott Dattalo :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Vasek,

> I'd like to implement fast Goertzel DFT algorithm over the data from
> 12-bit ADC and 32-bit seems to me overkill.

What are you trying to do that requires the Goertzel algorithm? Do you
need to detect a tone in the presence of noise?

It may be possible (depending on your application) to use quadrature
square waves instead of sines and cosines. For example, the frequency
you're trying to measure has a period T. Break T into for quadrants. Find
the sum of your input signal over each quadrant. The sum of the first two
quadrants minus the sum of the last two is like multiplying by a sine wave
(quantized to 1,-1). Similarly, the sum of the middle two quadrants minus
the sum of the first and last quadrant is like multiplying by a cosine.

If square waves are too coarse, then you can break the interval into 8'ths
or 16'ths and use quantized sines and cosines (i.e. 3 or 4 level steps)

The magnitude (square root of the sum of the sine-squared and
cosine-squared outputs) can be estimate with relatively simple arithmetic
(look for 'magnitude estimators')

Scott

---------------------------------------------------------------------
To unsubscribe, e-mail: gnupic-unsubscribe@...
For additional commands, e-mail: gnupic-help@...


Re: Is 16-bit floating point library available ?

by vaclavpe :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Scott,

>
> > I'd like to implement fast Goertzel DFT algorithm over the data from
> > 12-bit ADC and 32-bit seems to me overkill.
>
> What are you trying to do that requires the Goertzel algorithm? Do you
> need to detect a tone in the presence of noise?

Yes, I need to detect amplitude and phase of the sinus signal generated in PIC and then going through the device back to ADC.

> It may be possible (depending on your application) to use quadrature
> square waves instead of sines and cosines. For example, the frequency
> you're trying to measure has a period T. Break T into for quadrants. Find
> the sum of your input signal over each quadrant. The sum of the first two
> quadrants minus the sum of the last two is like multiplying by a sine wave
> (quantized to 1,-1). Similarly, the sum of the middle two quadrants minus
> the sum of the first and last quadrant is like multiplying by a cosine.
>
> If square waves are too coarse, then you can break the interval into 8'ths
> or 16'ths and use quantized sines and cosines (i.e. 3 or 4 level steps)

Is it something like quadrature demodulation ? It can be interesting idea as well. I plan to have 8 samples per period.

Then I can use just sqrt(I^2 + Q^2) for amplitude and atan(I/Q) for phase, correct ? For 12bit ADC it seems to me that 16 bits for registers is enough.

I need to evaluate it somehow to find if such method fulfills my accuracy requirements. I simulated Goertzel and 8 samples were sufficient for me.

Another idea was to use fixed point arithmetics 8-bit point 8-bit and rescale ADC values. But I-Q method is still simpler.

Thank you,
Vasek

---------------------------------------------------------------------
To unsubscribe, e-mail: gnupic-unsubscribe@...
For additional commands, e-mail: gnupic-help@...


Re: Is 16-bit floating point library available ?

by Walter Banks :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



Vaclav Peroutka wrote:

> my question is maybe slight off-topic, but, did anybody have implemented half-precision floating point library for PIC16F processors ?
>  . . .
> I need to evaluate it somehow to find if such method fulfills my accuracy requirements. I simulated Goertzel and 8 samples were sufficient for me.
>
> Another idea was to use fixed point arithmetics 8-bit point 8-bit and rescale ADC values. But I-Q method is still simpler.

Scott may very well have the solution you need but some
comments on Fixed8:8 vs half IEEE 754R floats might be useful if
this comes back into consideration.

A couple years ago we did some work on fixed point libraries for
embedded processors. Part of this was benchmarking fixed
point against floating point. What we found was the real trade-off was
dynamic range vs precision. For data types of equal length
the computational complexity was order of magnitude the same.

In your example a half float has a dynamic range of 2^32 and a
precision of 11 bits.  A fixed 8:8 has bit more than 15 bit precision
and a 2^8 dynamic range.


Regards,


--
Walter Banks
Byte Craft Limited
http://www.bytecraft.com



---------------------------------------------------------------------
To unsubscribe, e-mail: gnupic-unsubscribe@...
For additional commands, e-mail: gnupic-help@...