PDA

View Full Version : 32 and 64bit Floating Point, PBP and a 16F648A...



johnmaetta
- 26th September 2010, 00:55
I need to process some GPS data that is in 32bit and 64bit Floating Point format.
My PIC16F648A project gathers serial data from a GPS Disciplined Oscillator unit and stores it in a array.

This past week I didn't even know what 32 or 64bit Floating Point was, now I understand how to assemble the floating point data into a decimal number, from the HEX bytes, on paper. But, I need to have PBP do the math for me.

Here is an example of the oscillator temperature data in 32bit FP:
MSB..........LSB
41E99BBE

Here is what I have been trying to do with PBP...
The following code ignores the 'Sign' bit in Byte1 and is to extract the 'Exponent' from the next 11 bits.

B0 = 0 'EXPONENT
B1 = BYTE1.BIT6
IF B1 = 1 THEN LET B0 = B0 + 128

B1 = BYTE1.BIT5
IF B1 = 1 THEN LET B0 = B0 + 64
.
.
.


The following code example is to extract the Mantissa from the remaining bits

B2 = 0 'MANTISSA
B3 = BYTE2.BIT3
IF B3 = 1 THEN LET B2 = B2 + .5

B3 = BYTE2.BIT2
IF B3 = 1 THEN LET B2 = B2 + .125
.
.
.

Unfortunately, I get the following PBP messages when trying to compile.:

ERROR Line 158: Bad variable modifier: .125.
ERROR Line 158: Bad expression. (vmon5_0.pbp)

Is there an easier way?

Thanks,

John

Normnet
- 26th September 2010, 05:19
See N-Bit_MATH (http://www.picbasic.co.uk/forum/showthread.php?t=12433&highlight=math)

Norm

N6VMO_
- 27th September 2010, 20:11
Thanks Norm, I will see if that thread can help me out. I should have mentioned the oscillator temp of $41E99BBE is decimal 36.25xxxxxx degs C.

John

N6VMO_
- 6th October 2010, 19:40
I give up, how do I get $3FE3586328F97ED5 AND $C000D1A6DD4B949E into the N-Bit Math Value32 variable?

The above two 64 bit hex numbers reside in an array and represent latitude (34.xxxxxx) and longitude (-120.xxxxxx).

John

ScaleRobotics
- 6th October 2010, 19:50
Wow, is your gps accurate to 3.6 inches? I wish mine was.

Darrel Taylor
- 7th October 2010, 01:33
I give up, how do I get $3FE3586328F97ED5 AND $C000D1A6DD4B949E into the N-Bit Math Value32 variable?

What format are they in the array. ASCII hex digits or Binary values?
Are they always the same length? With padding 0's to the left if lower values?

And you mean a Value64 variable, right?

N6VMO_
- 7th October 2010, 15:37
Him Darrel,

The data is stored in ASCII hex digits and are always the same length. Yes, I meant Value64. :)



What format are they in the array. ASCII hex digits or Binary values?
Are they always the same length? With padding 0's to the left if lower values?

And you mean a Value64 variable, right?

Darrel Taylor
- 7th October 2010, 20:25
Well, assuming you have PBP 2.60, and the number starts at the beginning of the array, you could do this ...

ARRAYREAD MyArray,[HEX2 Value64(7),HEX2 Value64(6),HEX2 Value64(5),HEX2 Value64(4), _
HEX2 Value64(3),HEX2 Value64(2),HEX2 Value64(1),HEX2 Value64(0)]

You can add a SKIP n, if it starts later in the array.

HTH,