Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

GPS Functions
Goto page Previous  1, 2
 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here
View previous topic :: View next topic  
Author Message
nicofer

Bascom Member



Joined: 01 May 2013
Posts: 90
Location: GRJ

southafrica.gif
PostPosted: Sun Feb 22, 2015 9:19 am    Post subject: Reply with quote

Hi
Regarding the pcb that was mentioned early January - well at last a few photos to show what is happening .

Still need a lot of work on the display and layout during use .

The green led is a 1pps indication , if no 2d/3d fix it will flash red - led on other side is red for charging and green for user .

Vib motor , 4 buttons , power on/off "( Power on/off auto standby with buttons )but gps rtc get direct feed from batt , li charger , micro sd card with power control , 3 axis acceleration sensor , 14 pin programming / serial output port ,
5x5 mm beeper , 0,96 " oled , ( 1.3" will also fit ) micro usb for charge , G-Top 16 x 16 gps module , 1.2 mm pcb with "ears " for wrist strap .

Pcb size 42 x 32 mm (without ears , can be cut off if not required , can be worn in landscape or portrait mode )

At the moment I have an external gps antenna hooked up to the module - on the ext ant input- for testing since some functions will only work with valid fix .



Cheers
Back to top
View user's profile
snipsnip

Bascom Member



Joined: 10 Feb 2014
Posts: 74
Location: Melbourne

australia.gif
PostPosted: Mon Feb 23, 2015 1:45 am    Post subject: Reply with quote

Hi nicofer,
nice work

Are you going to be selling these? put me down for a couple. Cool

Also
what speed are you running the gtop comms at? I'm using same module but
I cant get it to work at 115200, only 38k is working for me.

Cheers
Back to top
View user's profile
nicofer

Bascom Member



Joined: 01 May 2013
Posts: 90
Location: GRJ

southafrica.gif
PostPosted: Mon Feb 23, 2015 10:19 pm    Post subject: Reply with quote

Hi
Thanks - yes , there will be a few pcb's for those who would like to experiment , maybe with a few odd parts until my stock dries up .

My GPS data rate is still 9600 - default , have not tried any other .

I want to make one or 2 changes to the pcb before I set them free.

The main idea is the logging of the track for GPX file upload to Strava or similar application (working fine ) - the on screen info during use is second in line but still very important .

There are 2 fields of further exploring - the gps data filter / calculation ( metrics ) - and then the display .

The last is the hardware and enclosure - way off topic ....


So I hope that this project will set the creative minds free and we can share a bit of code.

The big problem with AVR compared to ARM is the internal RAM - 4k is quite limited once you have a sd flash disk and a graphics screen . One way to solve it is to use a AT90USB1287 with 8kb RAM - and the USB - I have not used any of the AVR USB devices so it will be uncharted waters .

At the moment firmware upload is via ISP , want to add usb-uart converter so that the firmware can be uploaded via usb/serial bootloader - ( only one external connector required )

I still need to decide on std mega128 (4k ) with an external usb bridge or a USB1287 cpu with more memory ( 8 k ) and internal USB - any feedback ?

Best might be to just add the usb/uart bridge chip ( PL2303 SA ) , mainly for serial debugging and maybe bootload later , do not want to create more problems .

Will advise when rev 2 pcb's are ready .

Cheers
Back to top
View user's profile
snipsnip

Bascom Member



Joined: 10 Feb 2014
Posts: 74
Location: Melbourne

australia.gif
PostPosted: Tue Feb 24, 2015 12:10 am    Post subject: Reply with quote

Quote:



I still need to decide on std mega128 (4k ) with an external usb bridge or a USB1287 cpu with more memory ( 8 k ) and internal USB - any feedback ?


Yeah, but what about the 2561 and an external 16u2? If you keep it Arduino compatable there would be a much bigger market, Tindie, adafruit, sparkfun resellers etc.
Back to top
View user's profile
snipsnip

Bascom Member



Joined: 10 Feb 2014
Posts: 74
Location: Melbourne

australia.gif
PostPosted: Tue Feb 24, 2015 12:32 am    Post subject: Reply with quote

Day, Time and date stamp.

Code:

Function Timestamp(timezone As Word , Plusneg As Byte)as String
Local X As Byte
Local Timez As String * 8 : Local Datez As String * 8 : Local Dayz As String * 4
Local Tmp As String * 2 : Local Tmp1 As String * 2 : Local Tmp2 As String * 2
Local Sissec As Long

 Timez = Commapos(1 , "GPRMC")
 Timez = Left(timez , 6)
  Tmp = Left(timez , 2)
  Tmp1 = Mid(timez , 3 , 2)
  Tmp2 = Right(timez , 2)
  Timez = Tmp + ":" + Tmp1 + ":" + Tmp2

 Datez = Commapos(9 , "GPRMC")
  Datez = Left(datez , 6)
  Tmp = Left(datez , 2)
  Tmp1 = Mid(datez , 3 , 2)
  Tmp2 = Right(datez , 2)
 Datez = Tmp + "/" + Tmp1 + "/" + Tmp2

 Sissec = Syssec(timez , Datez)
 Timezone = Timezone * 3600
 If Plusneg = 0 Then Sissec = Sissec - Timezone
 If Plusneg = 1 Then Sissec = Sissec + Timezone

   Datez = Date(sissec)
   Timez = Time(sissec)

X = Dayofweek(sissec)
Select Case X
   Case 0 : Dayz = "MON "
   Case 1 : Dayz = "TUE "
   Case 2 : Dayz = "WED "
   Case 3 : Dayz = "THU "
   Case 4 : Dayz = "FRI "
   Case 5 : Dayz = "SAT "
   Case 6 : Dayz = "SUN "
End Select

Timestamp = Dayz + Timez + " " + Datez + " " + Valid

 End Function



 


Last edited by snipsnip on Sat Feb 28, 2015 1:50 am; edited 1 time in total
Back to top
View user's profile
snipsnip

Bascom Member



Joined: 10 Feb 2014
Posts: 74
Location: Melbourne

australia.gif
PostPosted: Tue Feb 24, 2015 12:47 am    Post subject: Reply with quote

odometer
pretty much working - matches car odo (+/-) 200m over a 32k drive

Code:

 Function Odo(startlat As Single , Startlon As Single , Startalt As String ) As String
 Local Tempstring As String * 10 : Local Y As Byte
 Dim Temp As Single : Dim Total As Single
 Dim Alti As Single
 Dim Store(6) As Single
 Dim Initflag As Byte
 Dim Togglebit As Bit
Alti = Val(startalt)


if Initflag < 3 then
Store(1) = Startlat
Store(2) = Startlon
Store(3) = Startlat
Store(4) = Startlon
Store(5) = Alti
Store(6) = Alti
incr Initflag
endif

If Togglebit = 0 Then
   Store(1) = Startlat
   Store(2) = Startlon
   Store(5) = Alti
End If
If Togglebit = 1 Then
   Store(3) = Startlat
   Store(4) = Startlon
   Store(6) = Alti
End If

Temp = 3ddistance(store(1) , Store(2) , Store(3) , Store(4) , Store(5) , Store(6))
Total = Total + Temp
Toggle Togglebit
Tempstring = Str(total)
Y = Charpos(tempstring , "." )
Y = Y + 3
Tempstring = Left(tempstring , Y)
Tempstring = Tempstring + " ODO"
Odo = Tempstring
End Function


Last edited by snipsnip on Sun Mar 01, 2015 11:06 am; edited 3 times in total
Back to top
View user's profile
nicofer

Bascom Member



Joined: 01 May 2013
Posts: 90
Location: GRJ

southafrica.gif
PostPosted: Tue Feb 24, 2015 5:52 am    Post subject: Reply with quote

Hi

I have not thought about the "other " market , but not a bad idea . I used the cpu that I had but the 1280 or 2561 is a good improvement and the 16u2 will help even more. Will have to see what will still fit on the pcb .

Cheers
Back to top
View user's profile
snipsnip

Bascom Member



Joined: 10 Feb 2014
Posts: 74
Location: Melbourne

australia.gif
PostPosted: Wed Mar 04, 2015 2:54 pm    Post subject: Reply with quote

another basic one - returns the difference between the last and current headings.
doesn't give a direction (WIP) just returns the angle.

Code:

 Function Deviation(starthead As String)as String * 7
 Local Tmp As Integer : Local Stmp As String * 6
 Tmp = Val(starthead)

 ''togglebit is global - toggled on each gps read.
 If Togglebit = 0 Then Tmp3(1) = Val(starthead)
 If Togglebit = 1 Then Tmp3(2) = Val(starthead)

Tmp = Tmp3(1) - Tmp3(2)
Tmp = Abs(tmp)

'this is to get rid of the 360 - 0 degree crossover / rollover.
If Tmp => 180 Then
Tmp = 360 - Tmp
 End If

Stmp = Str(tmp)
Deviation = Stmp + "  "
 
End Function

 
Back to top
View user's profile
max

Bascom Member



Joined: 29 Jun 2005
Posts: 131

australia.gif
PostPosted: Tue Apr 14, 2015 12:54 pm    Post subject: Reply with quote

snipsnip wrote:
anchor / proximity alarm, not tested yet

Code:

'anchor / proximity alarm returns "anchor" in meters from target when setdistance is exceded
'lat,lon in decimal                                       meters,
'to_from.. 0=to 1=from ie 1=anchor and 0=proximity alarm conviguration
Function Anchor(anchlat , Anchlon , Curlat , Curlon , Setdistance , To_from) As Single
Local Tmp As Single
Setdistance = Setdistance / 1000
   'couldnt be stuffed rewiting the dist function here. if stack / portability is an issue rewrite it Smile
   Tmp = 3ddistance(anchlat , Anchlon , Curlat , Curlon , 1 , 1)

   If To_from = 1 And Tmp > Setdistance Then
     Tmp = -tmp
     Elseif To_from = 0 And Tmp < Setdistance Then
     Tmp = -tmp

      End If

'convert to meters
Tmp = Tmp * 1000
Anchor = Tmp

End Function

End Function
 



I live on my boat now and was looking to make one of these. Any more work done on this?
Thanks
Back to top
View user's profile
snipsnip

Bascom Member



Joined: 10 Feb 2014
Posts: 74
Location: Melbourne

australia.gif
PostPosted: Wed Apr 15, 2015 6:08 pm    Post subject: Reply with quote

max wrote:

I live on my boat now and was looking to make one of these. Any more work done on this?
Thanks


Hi mate, not much at the moment - working on the hardware side of things.

So you getting nervous when the wind picks up? Rum helps Very Happy Very Happy
Back to top
View user's profile
max

Bascom Member



Joined: 29 Jun 2005
Posts: 131

australia.gif
PostPosted: Fri Apr 17, 2015 7:16 am    Post subject: archor drag Reply with quote

Just for info, why am I wanting to make my own anchor drag when they are available on the commercial chart plotters etc..
They false alarm a lot due to the way they work.
Imagine if you will a 20 meter circle based on where the anchor it sitting. Then imagine a 20 metre circle where the chart plotter etc is after the chain/rope is paid out. if the wind is from the north when you set the anchor point and it changes to the south, with the rope paid out you will swing way over 20 metres.
I need to make a unit which takes a reading from the GPS as it is let go, that way the 20 metre arc is relative to the anchor and not the boat. This will mean the anchor drag is a circle from the point of anchor and not the boat GPS location. With 15 ton of yacht, I want to be able to sleep better.
Smile Rather than average, I will take the most common ten samples and ignore anything out side of those. Always comparing the latest 10 samples.
Back to top
View user's profile
snipsnip

Bascom Member



Joined: 10 Feb 2014
Posts: 74
Location: Melbourne

australia.gif
PostPosted: Fri Apr 17, 2015 8:26 am    Post subject: Reply with quote

Can you tap into the NMEA data bus? If you could integrate wind speed and direction info it would be a lot easier to eliminate false alarms.

IE a false gps reading to the west whilst a westerly blowing would obviously be rubbish.

Another thought would be to look for consecutive readings that lie in a straight line and trigger the alarm on this (once its outside the set radius)

Don't know wether averaging out the gps is any good.

You could use the deviation function to check logged readings and say if 70% of readings deviate by less that a set amount (drifting in straight line) you could be heading for the rocks Crying or Very sad This would remove GPS errors whilst still detecting drift accurately (maybe Smile )

Code:

Function Deviation(starthead As String)as String * 7
  Local Tmp As Integer : Local Stmp As String * 6
  Tmp = Val(starthead)

  ''togglebit is global - toggled on each gps read.
  If Togglebit = 0 Then Tmp3(1) = Val(starthead)
  If Togglebit = 1 Then Tmp3(2) = Val(starthead)

 Tmp = Tmp3(1) - Tmp3(2)
 Tmp = Abs(tmp)

'this is to get rid of the 360 - 0 degree crossover / rollover.
If Tmp => 180 Then
 Tmp = 360 - Tmp
  End If

 Stmp = Str(tmp)
 Deviation = Stmp + "  "
   
End Function
 
Back to top
View user's profile
snipsnip

Bascom Member



Joined: 10 Feb 2014
Posts: 74
Location: Melbourne

australia.gif
PostPosted: Sun Nov 10, 2019 12:05 pm    Post subject: Reply with quote

a few years later and just wrote this for spitting out basic kml info for google earth
just does pins, but enough for testing.

Code:
Sub genKML()
   local  a as byte

   print  "<?xml version=";chr(34);"1.0";chr(34);" encoding=";chr(34);"UTF-8";chr(34);"?>"
   print  "<kml xmlns=";chr(34);"http://www.opengis.net/kml/2.2";chr(34);
   print " xmlns:gx=";chr(34);"http://www.google.com/kml/ext/2.2";chr(34);">"
   print  "<Document>"
   print  "<LookAt> <longitude>";
   print fencelon(1);
   print  "</longitude> <latitude>";
   print fencelatt(1);
   print  "</latitude> <range>1300.000000</range> </LookAt>"
   print  "<Folder>"

   for a = 1 to index
      print  "<Placemark>"
      print "<name>";a;"</name>"
      print"<Point> <coordinates>"
      print fencelon(a);
      print ",";
      print fencelatt(a);
      print  "</coordinates></Point></Placemark>  "
   next a
   print  "</Folder>  </Document></kml>"

   wait 10     'just for testing

end sub
 


Cheers
Simon
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here All times are GMT + 1 Hour
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum