You are right. Toilet paper is over now. I am going to play with the code for next day or two and will put my findings and problems here. Thanks for the advise.
You are right. Toilet paper is over now. I am going to play with the code for next day or two and will put my findings and problems here. Thanks for the advise.
Hi, Ok, I have the following code now:
STRING: $GPRMC,123339.000,A,5134.2770,N,00007.8480,E,1.14, 254.38,271009,,*09
ab:
DEBUGIN 2000,ab,[WAIT("$GPRMC"),skip 14,DEC2 ladeg,DEC2 lamin,skip 1,DEC4 lasec1,skip 3,DEC3 lodeg,DEC2 lomin,skip 1,DEC4 losec1]
losec=lasec1 * 6 : lasec=lasec1 * 6
pause 1000
DEBUG "Lat ",DEC2 ladeg," Deg ", DEC2 lamin," Min ",DEC2 lasec," Sec ",10,"Lon ",DEC3 lodeg, " Deg ", DEC2 lomin," Min ",DEC2 losec," Sec ",13,10,10
goto ab
And the WRONG result on my screen is the following:
Lat 51 Deg 34 Min 36 Sec
Lon 000 Deg 07 Min 36 Sec
Can you advise me please of what am I doing wrong here?
I got the co-ordinates working now. Just wondering how to go about getting the speed into variable as it keeps changing, 1.14 knots now, may be 100.20 knots later!
Last edited by FromTheCockpit; - 2nd November 2009 at 01:57.
That's great!
To convert knots to Km/h:
so for above example, if you had 30.0 knots as speed thenCode:knots var word 'xx.x knots is going to have to become xxx knots for this math kmph var word temp var word temp = knots * 1852 'first part of div32 function kmph = div32 1000 'this result should be printed out with one decimal 'in other words result xxx should be printed as xx.x km/h
knots = 300
temp = knots * 1852 = 555600
(you may notice this is bigger than 16 bits, but that's ok. The div32 lets us have up to a 31 bit number, so not to worry).
555600/1000 = 555
So, the answer must be printed out in decimal as 55.5 km/h
which is the pbp way to do knots * 1.852 = km/h
Last edited by ScaleRobotics; - 2nd November 2009 at 04:34.
http://www.scalerobotics.com
How can I get xx.x into xxx as there is an "." in the middle and also the datasheet says about only one digit before decimal -Which I wonder WHY? as speed will become two digits once it goes above 9 knots. How do I use the SKIP in a problem like this where decimal will change place?Code:knots var word 'xx.x knots is going to have to become xxx knots for this math kmph var word temp var word temp = knots * 1852 'first part of div32 function kmph = div32 1000 'this result should be printed out with one decimal 'in other words result xxx should be printed as xx.x km/h
I get what you are saying now. I think my gps example had a static xxx.x output, but most of the new (non handheld) ones (like yours) do not.
This should do the trick, hopefully not too much trouble shooting involved.
It reads in 5 characters to the array named raw_speed[x]. Then it counts decimal places to the "." character. Then adds the digits together after multiplying them by the right power of 10.
Code:raw_speed var byte[5] 'create an array to put each possible character for speed i var byte decimal var byte speed var word DEBUGIN 2000,ab,[WAIT("$GPRMC"),skip 14,DEC2 ladeg,DEC2 lamin,skip 1,DEC3 lasec1,skip 4,DEC3 lodeg,DEC2 lomin,skip 1,DEC3 losec1,skip 4,raw_speed[0],raw_speed[1],raw_speed[2],raw_speed[3],raw_speed[4]] for i = 1 to 3 'find which character is the decimal point if raw_speed[i]="." then decimal = i next i 'combine single digits to form whole speed number. Varies from 0.0 to 999.0 select case decimal 'if our gps gives us 1.4, then this will convert it to 14 'the -48 is a way to convert an ascii number to a number case 1 'decimal is in x.x position speed=(10*(raw_speed[0]-48))+(raw_speed[2]-48) case 2 'decimal is in xx.x position speed=(100*(raw_speed[0]-48))+(10*(raw_speed[1]-48))+(raw_speed[3]-48) case 3 'decimal is in xxx.x position speed=(1000*(raw_speed[0]-48))+(100*(raw_speed[1]-48))+(10*(raw_speed[2]-48))+(raw_speed[4]-48) end select
Last edited by ScaleRobotics; - 3rd November 2009 at 08:14.
http://www.scalerobotics.com
Scalerobotics, thanks a lot. I am now able to get what I want and how I want it from my GPS module. Love this Forum.
Can I request you answer my one question on the following forum as well please:
http://www.picbasic.co.uk/forum/showthread.php?t=6927
Thanks again.
Bookmarks