Use Picaexe to convert serial NMEA String with negative and positive numbers

delucaide

New Member
Goodmorning everybody,
I would have your help about a project.
As described in the title, what i would to do is an NMEA string converter.
I've a compass module that come out with the serial 232 NMEA string "PRDID" and i would to convert it in NMEA string "TCM"
The real problem for me is when i try to get the values, coming from "PRDID" string because, sometimes, the values could go to be negatives.
Actually i'm doing it using the simulator.
I know that, the Picaxe's chip cannot manage negative numbers but, maybe i could have some chances with your help.
Anybody can help me on which method can i use?

Thanks everybody
 

hippy

Technical Support
Staff member
Welcome to the PICAXE Forum.

The PRDID message format seems well defined ( $PRDID,+/-pitch,+/-roll,heading*checksum ) but there does not seem to be anything by way of the TCM message format.

If you can provide more details of the TCM format or the conversion required it should be possible to provide additional advice.
 

BESQUEUT

Senior Member
I know that, the Picaxe's chip cannot manage negative numbers but, maybe i could have some chances with your help.
Anybody can help me on which method can i use?
NMEA is an ASCII protocol. IMHO, you only have to manage character strings, not numbers.
Picaxe are not that good to manage character strings, but this is doable. As said by Hippy, we need more info about TCM format. Is it that ?
Can you give us an original NMEA dataset and expected result TCM formatted ?
 

delucaide

New Member
Hi Hippy & BESQUEUT,
thanks for your reply.
The TCM string should be like this: $C320.5P0.2R-18.3T19.0*3C
Where: C= Heading P=Pitch R=Roll T=Temp.
For sure, i'll let the Temp fixed to Zero because i have no temp in the PRDID string.
One of important thing is that i need to rotate the heading coming from the PRDID by 180°
 
Last edited:

hippy

Technical Support
Staff member
It should be possible, and perhaps quite easily once you have input parsing and output routines written.

The heading 000.00 to 359.99 can be multiplied by 100 and held as a 16-bit unsigned number, the pitch and roll -180.00 to +180.00 multiplied by 100 can be held as a 16-bit signed number.

That allows those numbers to be extracted, modified as required, and output in the desired order.
 

delucaide

New Member
Hi Hippy,
many thanks for your suggestion,
could you please write for me an example of Serin command that should be read the PRDID string?
I've tried many times but what happens is that sometimes, the string length is variable and i think PICAXE can not handle delimiter in serial In string to avoid confusion when the string change his lenght.
Best regards
 

hippy

Technical Support
Staff member
could you please write for me an example of Serin command that should be read the PRDID string?
I've tried many times but what happens is that sometimes, the string length is variable and i think PICAXE can not handle delimiter in serial In string to avoid confusion when the string change his lenght.
The SERIN command is not suited to variable length data. Variable length data requires polling with a SERIN or HSERIN for each character, buffering those while looking for a terminator, or using HSERIN and buffered background receive which is only available on X2 devices.

The 'datasheet' section of the store page for the GPS010 includes some example code for reading GPS variable length strings which may be of some use -

http://www.picaxestore.com/gps010

It may be useful to describe what PICAXE programming experience you have, the PICAXE you are planning on using.
 
Top