P1 GPS Simulator
pic18f2550
Posts: 400
Hello,
Is there a tool in Spin for the P1 with which I can generate GPS data for testing purposes?
Thank you.
Comments
I would just download ucenter from ublox that does just about everything you need to do with a GPS.
It has a capture option that you can save to a file.
u-center
Mike
If you have a GPS you can use this to view the data.
This is all the wrong direction.
I want to create a NEMA string from defaults.
Attached is a program I used in teaching a robotics class. You can modify it to vary lat_min and lon_min to form whatever trajectory you wish.
-Phil
A good document:
http://freenmea.net/docs
Nice teaching program, Phil!
Okay, I can do something with that.
What is still missing is the checksum calculation.
hexadecimal representation of the checksum
(The checksum is calculated by XORing all data bytes between (each excluding) the dollar sign '$' and the asterisk '*').
Should not be a problem though.
You might also be able to make use of my GPSMath object posted here:
https://forums.parallax.com/discussion/comment/1431330/#Comment_1431330
-Phil
I can't insert code?
This is how we control crc of nmea buffer
This is the format I use in a lot of NMEA translators.
I can't still get a good layout for code ??
I did the CRC calculation with a small intermediate routine.
Furthermore the question arises how do I suppress leading zeros?
num.decx(5, 4) ->> 0005
Is there a variant where I can output floating point values to a string?
Hi @Ltech !
Click the Cog icon (top right of your post), then Edit. You will see the formatting changes I just made to your post to display code.
In short, use 3 backticks top and bottom. And keep the first line of code on the next line after the backticks, otherwise the code preview won't appear when the forum page renders.
Ugh. Don't use floating point. Attached is an object I wrote (expanding on Chip and Jon's object) that allows scaled integers to be written in fixed-point format.
-Phil
In my variation of FDS there is a method called dpdec() that will take a fixed-point number (I'm will Phil on this) and insert a decimal point where you want it. If your value is 12345 and you want to output 123.45 you might do something like this:
This will insert the decimal point before the last two digits of the value (inserting 0s if needed).
This object also allows formatted strings, so you could do something like this
The %f is for "make it look like floating point."
Spin stores the float value in a long.
Is there a way to extend the precision by a few digits? e.g. in two longs?
I am currently working with "FloatString.spin".
''*****************************************
''* Floating-Point <-> Strings v 1.1 *
''* Single-precision IEEE-754 *
''* Authors: Chip Gracey and Cam Thompson *
''* (C) 2006 Parallax, Inc. *
''* See end of file for terms of use. *
''*****************************************
Why are you using floating point? It's so unnecessary (and inappropriate) for what you're trying to accomplish. For example, this number:
12247.16062 (longitude)
is just 1224716062 (which fits in a long) printed with a decimal point between the fifth and sixth digits. Both Jon and I have provided you with ways to do this.
For example, using my Simple Numbers Plus, the above longitude can be inserted into a $GPRMS string, thus:
assuming the decimal point is already there.
-Phil
Phil Pilgrim (PhiPi)
Of these only 9 digits are usable the 1. can only 0..2.
But I need 12 digits, better 14.
For floating point numbers in double long format there is no spin object.
To the not would be also some arithmetic possible which works on double long basis. Addition, subtraction, multiplication and division are enough.
In this case I would extend / shorten and output the decimal place.
But even with 12 digits, the format is ddmm.mmmmmmm (lat) or dddmm.mmmmmmm (lon). That's still only nine digits for the minutes, which can easily be separated from the degrees, and precise to 0.1855mm. I still don't see what the problem is.
-Phil
The problem is that in long only 23 bits are available for the number sequence, 8 bits for the exponent and 1 bit for the sign.
All values above 8.388.607 are error-prone because the value of the smallest digit is replaced by a 0.
It is not only a matter of displaying GPS values, there is still a bit of calculation to be done. But that is another topic.
No, the problem is that you're trying to use floating point. Just don't!
Use two longs: one for the degrees, the other for the minutes scaled up to integer values. The output and computations will be both simple and accurate. For example, the longitude:
dddmm.mmmmmmm
can be represented by two longs:
ddd and mmmmmmmmm
Each fits in a long. You don't need the decimal point to do the math -- only to output the result.
-Phil
OK, I guess we were talking about something else.
ddd and mmmmmmmmm would also be a possibility.
But it would complicate all the comma-crossing arithmetic.
Therefore, I would prefer an integer arithmetic with double longs. Because this is easier to handle.
The output would work like this.
- Output of the number as a string
- shifting the lower decimal places
- insert the decimal point
1234567890+chr(0)+chr(0)
12344567890+chr(0)
123.4567890+chr(0)