PDA

View Full Version : PBP 2.50 and Longs



mikendee
- 21st May 2008, 20:34
Hi,
I'm currently using PBP 2.47 and Byte Arrays to get data from a GPS. This works OK but doing any maths is compicated.

Am I right in thinking that if I upgrade to PBP 2.50 and use an 18F that I can read a 7 digit number as an integer and then do maths on it.

Eg: If I want to read 3557.1542361. Can I use:

LATDEG VAR WORD
LATMIN VAR LONG

SERIN2 RXPIN, 16468,[DEC4 LATDEG, DEC7 LATMIN]

If it works as easily as this is it possible to have more accarate trig and SQRT functions as well.

Thanks for anyy help.

Mike

skimask
- 21st May 2008, 21:16
Am I right in thinking that if I upgrade to PBP 2.50 and use an 18F that I can read a 7 digit number as an integer and then do maths on it.
Eg: If I want to read 3557.1542361. Can I use:
LATDEG VAR WORD
LATMIN VAR LONG
SERIN2 RXPIN, 16468,[DEC4 LATDEG,,".", DEC7 LATMIN]
If it works as easily as this is it possible to have more accarate trig and SQRT functions as well.
The accuracy won't improve any, since PBP only handles straight integer numbers, doesn't do anything with fractions.
However, you can multiply the numbers up a bit, say by 10000, then work on them.
You'll end up with a simulated decimal point at 1/10000...but you'll have to correct for that when displaying/sending that data.
That probably won't help any with SIN/COS and SQRT functions at all unless you start getting creative with your math.