Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : MiniMM Golf GPS
Page 1 of 2 | |||||
Author | Message | ||||
palcal Guru Joined: 12/10/2011 Location: AustraliaPosts: 1805 |
If anyone is interested in a Golf Course GPS (distance to green) I have a Beta version running. Paul. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
paceman Guru Joined: 07/10/2011 Location: AustraliaPosts: 1329 |
How does it work Paul? This sounds like a brilliant little project for a box to carry around with you. Presumably it needs a list of Lat/Longs for the greens you play, a little LCD screen and keypad to select which course. Maybe temp and humidity sensors? Altitude? - no, you can get that from the Lat/Long list ) You could include one of those compass chips and get an exact bearing for the green if it's not in sight. A recommended club could even be programmed. I'm no golfer but have a friend or two who are. This would be saleable!! Greg |
||||
palcal Guru Joined: 12/10/2011 Location: AustraliaPosts: 1805 |
Paceman, Funnily enough the MM was being used for time, temperature, humidity and dew point temp as well as the tide. To save money I stripped it to build the GPS. It works as you say by putting the coordinates of the 18 greens in a data statement and with a bit of number crunching works out the distance. As for being sale able they are already available and you can even get an app. for your phone. The cost of a miniMM, EM-408 and 16x2 display makes the project a bit pricey. However that is all the hardware needed besides a 10K resistor for the data line. At the moment it measures the distance to the hole and when it is within 30 metres and no longer needed it automatically switches to the next hole. I am going to try more courses by adding in the data and see if I can get it to choose the course from its current location, doing away with the need for any buttons. Paul. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3167 |
That is a great project Paul - what a neat application !! I guess that you power it by batteries, what is the battery life like? Also, do you have a photo? Geoff Geoff Graham - http://geoffg.net |
||||
palcal Guru Joined: 12/10/2011 Location: AustraliaPosts: 1805 |
Yes it runs off batteries, draws 200ma. I have an electric golf buggy so can run it off that (12v). For testing I'm using 2 li-ion cells. No photo yet it is built into a jiffy box (120x70x30). Just fine tuning the program and getting rid of the line nos. (an old habit). Will post a photo and the code soon. Paul. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
paceman Guru Joined: 07/10/2011 Location: AustraliaPosts: 1329 |
How accurate is the GPS position? If you put in the Lat/Longs of the tees it could automatically select the hole. Guess you'd need to be able to confirm it was working on the right hole - especially if you were in the rough - or the adjacent fairway! Greg |
||||
palcal Guru Joined: 12/10/2011 Location: AustraliaPosts: 1805 |
Not real sure of the accuracy as I have only used coordinates from google earth. Hopefully next week I will use my Navman GPS to get some more accurate coords. But it seems to be fairly accurate. I guess there are a lot of refinements that can be made, but as I said it is only a Beta version. I'm a bit busy as I'm moving from Sydney to Townsville, yes to a golf course estate (and by the beach). Paul. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
palcal Guru Joined: 12/10/2011 Location: AustraliaPosts: 1805 |
OK. Just did a couple of accuracy tests. Firstly the Google Earth coordinates when entered were only out by 2 metres. And secondly the distance measurement was also very accurate. I only did one test but all looks OK. Paul. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
palcal Guru Joined: 12/10/2011 Location: AustraliaPosts: 1805 |
Mystic Sands is the name of the golf estate I'm moving to. I have only entered the coords for 9 holes as it is only a nine hole course. The restore statement in line 19 restores the data for the second time around. The coordinates are not real they are an imaginary course around my local area for test purposes. I would post a picture but I couldn't figure out how. Paul. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''' ' Golf Course GPS (Distance to Green) ' Paul Cahill - January 2013 ' MYSTIC SANDS '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''' ' Thanks to Geoff Graham for the GPS and LCD routines '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''' GoSub INIT ' initialise the LCD R = 6371009 ' radius of the earth in metres ' Get GPS Data max = 20 ' maximum nbr of params Dim arg$(max) ' used to hold the data fields Open "COM2:4800" As #1 ' pin 19 is COM2 in y = 1 START: If y = 19 Then GoTo OVER ' game over H$ = Str$(y) If y<10 Then H$=" "+H$ If y = 10 Then Restore Read Lat1,Lon1 ' read the coordinates of the hole Do ' loop forever GPS: GoSub GPS2 ' get the next line of sat. data If arg$(0) = "GPRMC" Then ' GPRMC contains lat/long If arg$(2) = "A" Then ' "A" means locked on to satellites ' convert lat and lon to decimal degrees Lat2 = Val(Left$(arg$(3), 2))+Val(Mid$(arg$(3), 3))/60 Lon2 = Val(Left$(arg$(5), 3))+Val(Mid$(arg$(5), 4))/60 If Lat1 > Lat2 Then Dlat = Lat1-Lat2 Else Dlat = Lat2-Lat1 ' Dlat is Delta Latitude ( ie the difference) If Lon1 > Lon2 Then Dlon = Lon1-Lon2 Else Dlon = Lon2-Lon1 Mlat = (Lat1 + Lat2)/2 ' Mlat is the mean latitude Dlat = Rad(Dlat) ' Convert to radians for the formula Dlon = Rad(Dlon) ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''' ' routine to calculate distance between coordinates ' D = R*Sqr((Dlat^2)+(Cos(Mlat)*(Dlon))^2) ' D = distance to hole D = Int(D) D$ = Str$(D) If D<100 Then D$=" "+D$ LCD_line1$ = " MYSTIC SANDS " LCD_line2$ = "HOLE "+H$+" "+D$+" M." GoSub LCD1 ' send to the LCD If D<30 Then GoTo BACK ' closer tham 30 metres go to next hole GoTo GPS ' LCD1: '' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''' ' send the two lines to the LCD ' the text is in LCD_Line1$ and LCD_Line2$ ' _LCD_byte = &H80 : GoSub LCD2 ' select the 1st line For _LCD = 1 To 16 _LCD_byte = Asc(Mid$(LCD_Line1$, _LCD, 1)) Pin(17) = 1 : GoSub LCD2 ' send the character Next _LCD _LCD_byte = &B11000000 : GoSub LCD2 ' select the 2nd line For _LCD = 1 To 16 _LCD_byte = Asc(Mid$(LCD_Line2$, _LCD, 1)) Pin(17) = 1 : GoSub LCD2 ' send the character Next _LCD Return ' ' LCD2: ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''' ' Send a byte to the LCD ' the data to be sent is in _LCD_byte ' Pin(13) = _LCD_byte And &B00010000 ' output the 1st 4 bits Pin(14) = _LCD_byte And &B00100000 Pin(15) = _LCD_byte And &B01000000 Pin(16) = _LCD_byte And &B10000000 Pin(12) = 1 : Pin(12) = 0 ' tell lcd to accept data LCD3: ' Entry point to send just 4 bits to the LCD Pin(13) = _LCD_byte And &B00000001 ' output the 2nd 4 bits Pin(14) = _LCD_byte And &B00000010 Pin(15) = _LCD_byte And &B00000100 Pin(16) = _LCD_byte And &B00001000 Pin(12) = 1 : Pin(12) = 0 : Pin(17) = 0 ' tell lcd to accept data Return Else Print "GPS searching..." EndIf EndIf Loop BACK: y = y+1 : GoTo START ' increment to next hole ''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''' ' subroutine to load the GPS data fields into the array arg$() ' returns with the array populated GPS2: Do ' subroutine start Do While Input$(1, #1) <> "$" : Loop ' wait for the start For i = 0 To max arg$(i) = "" ' clear ready for data Do ' loops until a specific exit x$ = Input$(1, #1) ' get the character If x$ = "," Then Exit ' new data field, increment i If x$ = "*" Then Return ' we have all the data so return arg$(i) = arg$(i) + x$ ' add to the data Loop ' loop back for the next char Next i ' move to the next data field Print "Corrupt data..." ' exceeded max data items Loop ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''' ' data of coordinates of the 9 greens ' Mystic Sands is 9 holes line 19 restores after 9 holes Data 33.7810471,150.8457138,33.779722,150.8444444,33.779444,150.8 452777 Data 33.7808749,150.8465527,33.7810471,150.8457138,33.779722,150. 8444444 Data 33.779444,150.8452777,33.7808749,150.8465527,33.7954276,150. 8457138 ' INIT: ' Initialise the LCD ' For i = 12 To 17 : SetPin i, 9 : Next i ' all open collector _LCD_byte = &B0011 : GoSub LCD3 : Pause 5 ' reset _LCD_byte = &B0011 : GoSub LCD3 : Pause 5 ' reset _LCD_byte = &B0011 : GoSub LCD3 : Pause 5 ' reset _LCD_byte = &B0010 : GoSub LCD3 : Pause 2 ' 4 bit mode _LCD_byte = &B00101100 : GoSub LCD2 ' select 4 bit, 2 lines _LCD_byte = &B00001100 : GoSub LCD2 ' display on, no cursor _LCD_byte = &B00000110 : GoSub LCD2 ' increment on write _LCD_byte = &B00000001 : GoSub LCD2 ' clear the display Return OVER: LCD_line1$ = " HOPE YOU HAD " LCD_line2$ = " A GOOD DAY " GoSub LCD1 GoTo OVER "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
palcal Guru Joined: 12/10/2011 Location: AustraliaPosts: 1805 |
For some reason the posted code is not indented, sorry about that. I must have done something wrong. I copied and pasted the code. Paul. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
James_From_Canb Senior Member Joined: 19/06/2011 Location: AustraliaPosts: 265 |
Paul, To retain your code's indent, click on the Code button and embed your code between the two fields. For example A normal line An indented line James My mind is aglow with whirling, transient nodes of thought careening through a cosmic vapor of invention. Hedley Lamarr, Blazing Saddles (1974) |
||||
paceman Guru Joined: 07/10/2011 Location: AustraliaPosts: 1329 |
That's pretty amazing. I remember reading something a year or so ago where someone was checking accuracies of GPS modules against several official geo-reference points. Google was, I think, the third most accurate and was out by 10metres or something. The most accurate one (don't remember what it was) was only out by 2.5 meters. Then a few months ago I read that Google was up-grading its Google Earth systems and I guess if you've just found it's out by only that much then they're right up there now. BTW to post code with all the indents etc. just click the "code" box above the post screen and then click between the square brackets that come up, and paste there. To upload a photo (.jpg or .gif format only) click on either of the two boxes with trees on them - second and third from the right end. The left one puts the photo into the post, the second one (with the arrow) uploads it to Glenn's server and puts a link in the post. There's info in the "settings" menu at the top of the forum pages. |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 5923 |
I don't think you have converted the mean latitude to radians for this line: D = R*Sqr((Dlat^2)+(Cos(Mlat)*(Dlon))^2) ' D = distance to hole You would save a bit of accuracy if you remove the whole number of degrees while still a string. You would need to take it into account if the golf course is right on a whole degree. You could use my bigint routines to get the Dlat and Dlon and then revert to normal maths for the remainder. The radius of the earth depends on the latitude. There is about a 1 percent increase as you reach the poles. Lat kM/d lat kM/d lon 0 110.574 111.32 15 110.649 107.551 30 110.852 96.486 45 111.132 78.847 60 111.412 55.8 75 111.618 28.902 90 111.694 0 Considering that most GPS output will wander around by more than 10 meters, it is not worth trying to get too accurate. Jim (who thinks golf is one way to ruin a good walk) VK7JH MMedit MMBasic Help |
||||
palcal Guru Joined: 12/10/2011 Location: AustraliaPosts: 1805 |
The mean latitude does not have to be converted to radians it is the cosine of the angle in degrees. Paul "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
Talbit Senior Member Joined: 07/06/2011 Location: AustraliaPosts: 210 |
Jim, I think if you've got one of Paul's GPS gizmos then you would have something interesting to do rather than trying to hit those infuriating little white balls! Trevor Talbit |
||||
Talbit Senior Member Joined: 07/06/2011 Location: AustraliaPosts: 210 |
Paceman, Ray B did some work on GPS accuracy on the Cocos(Keeling) Islands - 13 May 2012 "Accuracy of Mobile Phone GPS & Google" Go to the member list and you'll find it under his name. Trevor Talbit |
||||
palcal Guru Joined: 12/10/2011 Location: AustraliaPosts: 1805 |
I'm not too worried about it being too accurate, golf courses are usually marked to some extent anyway, sometimes all the sprinkler heads are marked with the distance. But sometimes it is very deceptive if you don't have any markers and the land is not even. If there is a depression in front of the green, that you can't see for example,from 150 metres out it will look much closer than it is. I've done without one for 40 years, it was just a challenge so I did it. The GPS units are now quite popular even to the extent that some courses have them permanently installed in their carts. As for the accuracy I got of 2 metres, it was only one test, next time it could quite easily be 12 metres. I really won't know until I use it regularly in about 6 weeks. Paul. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
palcal Guru Joined: 12/10/2011 Location: AustraliaPosts: 1805 |
Doing this for my own reasons more than anything to see if I have learnt the ropes. Picture and code for my Golf GPS. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''
' Golf Course GPS (Distance to Green) ' Paul Cahill - January 2013 ' MYSTIC SANDS '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''' ' Thanks to Geoff Graham for the GPS and LCD routines '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''' GoSub INIT ' initialise the LCD R = 6371009 ' radius of the earth in metres ' Get GPS Data max = 20 ' maximum nbr of params Dim arg$(max) ' used to hold the data fields Open "COM2:4800" As #1 ' pin 19 is COM2 in y = 1 START: If y = 19 Then GoTo OVER ' game over H$ = Str$(y) If y<10 Then H$=" "+H$ If y = 10 Then Restore Read Lat1,Lon1 ' read the coordinates of the hole Do ' loop forever GPS: GoSub GPS2 ' get the next line of sat. data If arg$(0) = "GPRMC" Then ' GPRMC contains lat/long If arg$(2) = "A" Then ' "A" means locked on to satellites ' convert lat and lon to decimal degrees Lat2 = Val(Left$(arg$(3), 2))+Val(Mid$(arg$(3), 3))/60 Lon2 = Val(Left$(arg$(5), 3))+Val(Mid$(arg$(5), 4))/60 If Lat1 > Lat2 Then Dlat = Lat1-Lat2 Else Dlat = Lat2-Lat1 ' Dlat is Delta Latitude ( ie the difference) If Lon1 > Lon2 Then Dlon = Lon1-Lon2 Else Dlon = Lon2-Lon1 Mlat = (Lat1 + Lat2)/2 ' Mlat is the mean latitude Dlat = Rad(Dlat) ' Convert to radians for the formula Dlon = Rad(Dlon) ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''' ' routine to calculate distance between coordinates ' D = R*Sqr((Dlat^2)+(Cos(Mlat)*(Dlon))^2) ' D = distance to hole D = Int(D) D$ = Str$(D) If D<100 Then D$=" "+D$ LCD_line1$ = " MYSTIC SANDS " LCD_line2$ = "HOLE "+H$+" "+D$+" M." GoSub LCD1 ' send to the LCD If D<30 Then GoTo BACK ' closer tham 30 metres go to next hole GoTo GPS ' LCD1: '' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''' ' send the two lines to the LCD ' the text is in LCD_Line1$ and LCD_Line2$ ' _LCD_byte = &H80 : GoSub LCD2 ' select the 1st line For _LCD = 1 To 16 _LCD_byte = Asc(Mid$(LCD_Line1$, _LCD, 1)) Pin(17) = 1 : GoSub LCD2 ' send the character Next _LCD _LCD_byte = &B11000000 : GoSub LCD2 ' select the 2nd line For _LCD = 1 To 16 _LCD_byte = Asc(Mid$(LCD_Line2$, _LCD, 1)) Pin(17) = 1 : GoSub LCD2 ' send the character Next _LCD Return ' ' LCD2: ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''' ' Send a byte to the LCD ' the data to be sent is in _LCD_byte ' Pin(13) = _LCD_byte And &B00010000 ' output the 1st 4 bits Pin(14) = _LCD_byte And &B00100000 Pin(15) = _LCD_byte And &B01000000 Pin(16) = _LCD_byte And &B10000000 Pin(12) = 1 : Pin(12) = 0 ' tell lcd to accept data LCD3: ' Entry point to send just 4 bits to the LCD Pin(13) = _LCD_byte And &B00000001 ' output the 2nd 4 bits Pin(14) = _LCD_byte And &B00000010 Pin(15) = _LCD_byte And &B00000100 Pin(16) = _LCD_byte And &B00001000 Pin(12) = 1 : Pin(12) = 0 : Pin(17) = 0 ' tell lcd to accept data Return Else Print "GPS searching..." EndIf EndIf Loop BACK: y = y+1 : GoTo START ' increment to next hole ''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''' ' subroutine to load the GPS data fields into the array arg$() ' returns with the array populated GPS2: Do ' subroutine start Do While Input$(1, #1) <> "$" : Loop ' wait for the start For i = 0 To max arg$(i) = "" ' clear ready for data Do ' loops until a specific exit x$ = Input$(1, #1) ' get the character If x$ = "," Then Exit ' new data field, increment i If x$ = "*" Then Return ' we have all the data so return arg$(i) = arg$(i) + x$ ' add to the data Loop ' loop back for the next char Next i ' move to the next data field Print "Corrupt data..." ' exceeded max data items Loop ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''' ' data of coordinates of the 9 greens ' Mystic Sands is 9 holes line 19 restores after 9 holes Data 33.7810471,150.8457138,33.779722,150.8444444,33.779444,150.8 452777 Data 33.7808749,150.8465527,33.7810471,150.8457138,33.779722,150. 8444444 Data 33.779444,150.8452777,33.7808749,150.8465527,33.7954276,150. 8457138 ' INIT: ' Initialise the LCD ' For i = 12 To 17 : SetPin i, 9 : Next i ' all open collector _LCD_byte = &B0011 : GoSub LCD3 : Pause 5 ' reset _LCD_byte = &B0011 : GoSub LCD3 : Pause 5 ' reset _LCD_byte = &B0011 : GoSub LCD3 : Pause 5 ' reset _LCD_byte = &B0010 : GoSub LCD3 : Pause 2 ' 4 bit mode _LCD_byte = &B00101100 : GoSub LCD2 ' select 4 bit, 2 lines _LCD_byte = &B00001100 : GoSub LCD2 ' display on, no cursor _LCD_byte = &B00000110 : GoSub LCD2 ' increment on write _LCD_byte = &B00000001 : GoSub LCD2 ' clear the display Return OVER: LCD_line1$ = " HOPE YOU HAD " LCD_line2$ = " A GOOD DAY " GoSub LCD1 GoTo OVER "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 5923 |
From the help file: COS( number ) Returns the cosine of the argument 'number' in radians. for angle = 0 to 90 step 5 print cos(angle);" ";cos(rad(angle)) next angle Jim VK7JH MMedit MMBasic Help |
||||
paceman Guru Joined: 07/10/2011 Location: AustraliaPosts: 1329 |
OK Trevor - thanks. Greg |
||||
Page 1 of 2 |
Print this page |