PICAXE handling GPS for robot boat

hippy

Technical Support
Staff member
Hemi345 is right; just one program slot on the 08M2.

It probably is worth making the jump to 14M2 or even larger. Sticking with the AXE024 Servo Driver Board may also be imposing unnecessary constraints. Without more I/O you will always be stuck with making a choice of what to have rather than having a wider range of possibilities.

The PICAXE chips aren't that significantly different from each other and it should be pretty easy to move up the chain. In many cases it may only require changing the names of pins in the code.
 

MartinM57

Moderator
Maybe it's about time Snoopy had a midlife PICAXE update - I've always wondered why the infatuation with the 08 series devices [EDIT: for Snoopy], I'd have spent an extra £4 on day 1 and put a 64MHz 28X2 in there and probably had no issues with pins/interfaces/capabilities at all
 
Last edited:

srnet

Senior Member
Maybe it's about time Snoopy had a midlife PICAXE update - I've always wondered why the infatuation with the 08 series devices, I'd have spent an extra £4 on day 1 and put a 64MHz 28X2 in there and probably had no issues with pins/interfaces/capabilities at all
Yep, the cost of the processor is an almost insignificant part of the total project cost, and the time the larger device could have saved ............
 

Hemi345

Senior Member
Maybe it's about time Snoopy had a midlife PICAXE update - I've always wondered why the infatuation with the 08 series devices [EDIT: for Snoopy], I'd have spent an extra £4 on day 1 and put a 64MHz 28X2 in there and probably had no issues with pins/interfaces/capabilities at all
I recall it was because he wanted a ready-made board and didn't want to design a custom PCB. Maybe the AXE022 was initially too big for the design at the time? I think he pretty much has his architecture nailed down and I would be just itching to design custom PCB to cover are all current requirements with a few ports/pins to expand for other capabilities. :)
 

premelec

Senior Member
@Robin... I think your best bet for more memory and even some extra pins if you want them is Hemi345's suggestion to plug in a 14M2 - the power pins are in the same place as the 08M2... one caveat is don't leave any hanging 14M2 unconnected pins as inputs - If I were doing it and wanted to use the same board I'd probably put in a 14 pin socket with long legs if you have space... anyhow it would solve a lot of your concerns and not be a hard fix. I've forgotten how you've protected the circuitry from salt spray - perhaps molded in silicone rubber.... with connection to silicone rudder... :)
 

srnet

Senior Member
I would also add, that for any 'application' that needs to keep running independently long term, use of a PICAXE with a processor reset pin, I would consider essential.

With access to a reset pin, you can add a low voltage supervisor and an independant watchdog device, both of which may rescue the mission if something goes wrong ...............

Matters little how much testing you do, remember the programmers motto;

"There is always one more bug"
 

papaof2

Senior Member
Matters little how much testing you do, remember the programmers motto;

"There is always one more bug"
Even in commercial software. ESET antivirus (Version 6) still has a bug that was in Version 4 - it doesn't play well with Nero (CD/DVD burner) or Malwarebytes on Windows XP. ESEY blocks access to USB drives. You'd think that all these products have been around long enough for the ESET folks to work this bug out. Avira (even the free version) is quite happy in this configuration.
 

JimPerry

Senior Member
Even in commercial software. ESET antivirus (Version 6) still has a bug that was in Version 4 - it doesn't play well with Nero (CD/DVD burner) or Malwarebytes on Windows XP. ESEY blocks access to USB drives. You'd think that all these products have been around long enough for the ESET folks to work this bug out. Avira (even the free version) is quite happy in this configuration.
The "Heartbeat" bug in SSL had been around since 2011 :confused:
 

DDJ2011

Member
I love this thread - it shows just what is (might be) possible.

However, @Robin, could you tidy up your website and blog? Several times now I have tried to find things you refer to without success.
 

Robin Lovelock

Senior Member
Hi Folks. First a humble apology: I've only just got round to checking this forum, and was amazed and delighted to see so many suggestions in answer to my question. Sorry that the reason my web pages are not tidier, and also why I rarely experiment with new stuff, is my time: every hour counts, and there are LOTS of things to do - even when they relate to Snoopy's robot boat "work". Note that no picaxe autopilot software changes have been made, on the boat 9 (and now 10), for 15 months !* But I have still been very busy fixing the reason why Snoopy sailed so poorly on his last attempt. The blog linked from my page www.gpss.co.uk/autop.htm gives the detail: it all came down to the simplest things like mast position, rudder position, gearing - and being properly centred !

Thanks for the suggestions of my switching over from the 8 bit to 16 bit chip - and that's a really interesting idea of trying a 16 bit chip in my 8 bit servo board. The first question in my mind is how software compatible are they ? No problem if it just means changing pin numbers, but are all the other primitives, including SERVOPOS, also the same ? Even if this gets checked out, it will not be for some months yet - after this boat 10 is on it's way and I have time to experiment on the next boat - I have the hull already. Someone asked about I2C - I only use that in the experimental version of the autopilot, that I was working on last year in boat 6, checking out things like a compass chip. The wind direction sensor does not need that, and was working well (for tacking logic) years ago - but I removed it to get two benefits: reduced power consumption and free up memory. It was the memory that is tight. Looking at the move to 16 bit, I'd have to weigh the benefits with moving to two 8 bit processors, to split steering and navigation functions - then no problem with memory.

But, as I say, the picaxe autopilot has not needed to be worked on for literally years* - it does an excellent job if you put it in the right boat :)
Robin
www.gpss.co.uk

p.s. * the picaxe autopilot software in the boat being prepared for an Atlantic attempt, has not been modified since early 2013 - and that was a very minor change. However, I do sometimes work with other, experimental versions of the autopilot software, such as in late 2013, when testing use of an electronic compass. See www.gpss.co.uk/rbcompas.htm

p.p.s. Snoopy's boat 10 is on 24/7 test, and seems ready for this year's 2014 attempt on the Atlantic.
Meanwhile I've just ordered a tilt compensated compass at a sensible price, for experiments on what might go into next year's boat:
http://www.hobbytronics.co.uk/cmps10-tilt-compass?utm_source=google&utm_medium=googleshopping&utm_campaign=googlebase&gclid=CMzQtrrcgL8CFUjlwgod46AAkQ
 
Last edited:

Robin Lovelock

Senior Member
Hi Folks. I took another browse around the picaxe site, and have just ordered the PICAXE 28X2 (AXE201).
http://www.picaxe.com/Hardware/PICAXE-Chips/PICAXE-28X2-Module/
Looks as if little need for my soldering iron for the first tests. e.g. See if existing 08M2 program loads into it - with all that memory spare ! :)
Could not see power consumption in the data sheets, but my meter should show that quickly enough: hopefully not too much more than 1mA of 08M2.
Then the INTERESTING work begins - finding pins that correspond to those used on the 08M2, to drive servo, read GPS serial, drive TTS, etc, etc.
I'm guessing that will need a combination of reading what info is in the documentation, and helpful guys who know :)
I thought I might try this 08M2->28X2 change first, before experimenting with things like the tilt compensated compass.
Meanwhile, Snoopy looks ready to try the Atlantic again soon :)
Robin
www.gpss.co.uk
 
Last edited:

erco

Senior Member
Robin: I for one am very glad to hear you're still at it. Your dedication and persistence is incredible and admirable. After your last boat Snoopy was abducted, have you come up with any new methods to help your new boat to avoid a similar fate? I think that adding some fake dynamite or such to the top in a very visible and obvious location would make people think twice about picking it up. You would want to escort the boat out as far as possible (to avoid someone calling in a threat to the authorities), and provide for releasing/dropping the fake dynamite after a week or two, so that once it crossed the ocean, people would want to retrieve it. Check local laws, of course.

And/or, a LOUD electronic voice from Snoopy that says "self-destruct sequence engaged" and counts down if it is lifted out of the water too soon. :)
 

Robin Lovelock

Senior Member
Hi Erco. Great to see my "subscribe" to this thread now works: that's my lame excuse for going weeks without responding to postings.

What follows is probably very clear if you watch at least the first few minutes of the new video, near top of www.gpss.co.uk/autop.htm ...

Great ideas :) But first you should understand that it was only the 2012 attempt that suffered from "human intervention" and we learnt from it - as we did from other events on Bray Lake, when Snoopy was alone for days. In short - to "watch the boat closely" and have as many others doing the same. If we'd done that ourselves in 2012, we would have organised that "reception committee". In March 2013 we learnt to use "magic seaweed" so not as to choose a launch day with other than FLAT surf conditions. Our last attempt, in October 2013, took months to work out why Snoopy simply drifted with the tide: in brief, it was probably due to lack of locktite on the rudder servo linkage, or poor sailing balance of the boat, or some unknown combination of these things. Main lesson - LOTS OF TESTING NEEDED - as if I didn't already know that.

I see you are on the west coast - so you need not worry about Snoopy reaching you - just yet :)

Robin
www.gpss.co.uk
 

erco

Senior Member
Robin L said:
I see you are on the west coast - so you need not worry about Snoopy reaching you - just yet :)
Unless she sails right through the Panama Canal. You did say westward to either North or South America, so the Panama Canal is right in the middle. If everything averages out, I'd be honored to pluck Snoopy from the water for you here on the far side of the world. :)
 

Robin Lovelock

Senior Member
Taa Folks. Good to see you share my warped sense of humour :) Now the nitty gritty, hoping I can simply start by loading my existing autopilot program, for the 08M2, into that 28X2 module, then connect to the correct pins, for servo, TTS, and GPS. Someone like Hippy might save me a lot of time trying to find the relevant info. Nearly a year ago, I put this up onto my "design" page:
QUOTE
Footnote in July 2013: here are typical statements from the PICAXE AutoPilot program, showing signal/pin numbers used for things like reading GPS data, rudder servo output, and text-to-speech (TTS) output. I've put them here to aid discussion, on the PICAXE forum, of experiments with the HMC6352 compass module. We need to find one or two spare signal pins !
•SERIN 3, N4800_16, ( ",A," ), b22,b23,b24,b25,b26,b26,b27,b5 'typical reading of GPS serial data bytes
•SERVOPOS 1,CENTRE 'move servo to middle position
•READADC 4,w6 'read wind direction sensor or pot 0 to 255 - not currently used.
•SEROUT 2, T9600_16, ( "Target ", #w1," degrees. " ) 'TTS output e.g. "Target 45 degrees" if to North East
UNQUOTE
I found those spare pins for the compass, not important now. Priority is the Servo, TTS, and GPS.

Robin
www.gpss.co.uk
 

Technical

Technical Support
Staff member
Everything there will be fine on the 28X2.
Just remember to change the pin notations (2, 4 etc.) you have at moment to port.pin notations (e.g. C.2, B.4 etc)

And the default setfreq on a 28X2 is m8, so make sure you allow for that when using any 'setfreq m16' commands to change settings such as T9600_16 (ie m16 is 2x default on a 28X2, not 4x default as on 08M2).
 

Robin Lovelock

Senior Member
Great timing Technical: I'd just started preparing the new AUTOPX1.BAS for the 28X2 based on AUTOP2TTS for 08M2 used in boats 9 and 10 (This year's boat).
Thanks for the tips: I've already changed the #picaxe 08M2 to #picaxe 28X2 and see I do have setfreq m16 at start.
I see one of the first things I can try, before getting a soldering iron out, is the sertxd to output text back through the program load lead, to the editor, so I will see this at a different speed than 19200 - no problem.
If we take my SERVO 1, CENTRE as an example, what would this change to ? What physical pin on the 28X2 ? Relevant documents ?
Many Thanks
Robin
www.gpss.co.uk

p.s. just found http://www.picaxe.com/Site_Resources/Media/Site_1/pinout/pinout28x2.jpg with pinouts for 28X2 - WRONG - need to look for "28X2 Module" not "28X2" on http://www.picaxe.com/docs/picaxe_manual1.pdf !
Do I just change SERVO 1 to whatever output pin I wish ? I'm guessing some pins are spoken for.

As most of you will know, all my robot boat autopilots have used the 08M2 within the AXE027 servo driver board.
The AXE027 is on http://www.picaxe.com/docs/axe024.pdf and you will see that the board includes the required additional components such as 330R series resistors for each of the three servos. I guess I must add these components to the 28X2. Similar things apply for the GPS serial input - not just the choice of pin, but addition of the two resistors. So we are not only dealing with software changes here. I look forward to hearing more good advice.

#picaxe 28X2 'was #picaxe 08M2
setfreq M16 'no change from 08M2 to 28X2
sertxd ( "AUTOPX1",10,13 ) 'test output back to PC at 19200 ?
SERVO 1,CENTRE 'start servo control process - middle

p.p.s. I just found a VERY different pinout diagram on http://www.picaxe.com/docs/picaxe_manual1.pdf - that which is under "28X2 Module" rather than just "28X2". The same 28 pin socket, but VERY different connections. Also a very useful page. Good that I found it ! :)

p.p.p.s with a combination of inspired guesswork and "suck it and see", I have the autopilot running in the 28X2 module.
Here are comments from the top of the program:
'AUTOPX1.BAS for 28X2 Module based on AUTOP2TTS for 08M2 Jan2013 in boat 9 (and 10)
'changes needed:
' #picaxe 08M2 change to #picaxe 28X2
' setfreq M16 to ... unchanged
' sertxd ( "AUTOPX1",10,13 ) 'unchanged text output back to PC at 19200
' SERVO 1,CENTRE ... unchanged if use pin B.1
' SEROUT 2, T9600_16, ( "S I am Snoopy.",10 ) 'TTS output ...unchanged use pin B.2
' SERIN 3, N4800_16, ( "$GPRMC," ) 'wait for $GPRMC from GPS ..unchanged use pin B.3

Some new problems popped up, which may be due to the 28X2 needing unused pins to be tied down ???
The sertxd worked immediately, and at the same 19200 rate as on the 08M2
The SERVO also worked immediately that I used pin B.1 via the same 330R as on an 08M2
The SEROUT to Text-To-Speech worked immediately that I used pin B.2
The SERIN from GPS, via the same 22k and 10k resistors on pin B.3 worked immediately,
and the autopilot seems to be running, moving the rudder servo based on GPS input.
BUT, after connecting the GPS, it seems the TTS and sertxd no longer work. Side effects/resistors needed ?

I measured current drawn, and it is not too much: 4.4mA may be 3x that for the 08M2 servo driver, but low enough.
A few problems to solve, but it's looking good: practically no software changes.
Note that my signal pin numbers were written years before the B.1, B.2, etc naming convention, and I've not changed them.

Something seemed unreliable, since I was not able to get the TTS to work, after removing the GPS. Looking at the (correct) documentation above, you see things like need to put a resistor on the reset pin - but then elsewhere, it implies that the 28X2 Module includes this resistor. I suspect this module is not reliable unless wired exactly right. Anyone know where the relevant document is, if not above ?

IT WORKS ! :) I added a series 330R resistor for the TTS, just like the servo, following what was in my 08M2 based autopilot.
Now it all runs, just like as used in the boats - but with 2K spare memory and a few extra pins if needed ! :)

Any suggestions will be gratefully received. e.g. documentation that would have given a similar good result.

Robin
www.gpss.co.uk
 
Last edited:

Robin Lovelock

Senior Member
HELP PLEASE ! :) My long posting above gives the detail, which in brief, says that my Autopilot works, with almost no software changes, including reading GPS data, output of speech, and control of the rudder servo.

BUT - I now see that the servo does NOT do what it should, in terms of WHAT position it moves to. If I plug the same servo in to the 08M2 based autopilot, it starts with a test "waggle" of CENRE-LEFT-CENTRE-RIGHT-CENTRE, moving roughly 50 degrees either side of centre. But if I plug the servo into the 28X2 based autopilot, the same waggle is centred far to the right, and only a few degrees.

So my question is: am I experiencing "features" or "bugs" with the SERVO/SERVOPOS implementation within the 28X2 Module ? How to program around it ?

I'll paste in relevant lines of code below. Remember: they work well on the 08M2 based servo driver board.

Robin
www.gpss.co.uk

#picaxe 28X2 'was #picaxe 08M2
setfreq M16

symbol CENTRE = 150 'Servo middle position
symbol THROW = 50
symbol LEFT = CENTRE + THROW 'Servo left
symbol RIGHT = CENTRE - THROW 'Servo right
symbol FOR1SEC = 4000 'pause value at 16MHz for 1 sec
symbol FORP5SEC = 2000 'pause value at 16MHz for 0.5 sec

sertxd ( "AUTOPX1 ",10,13 ) 'test output back to PC at 19200

'waggle servo 1 on startup to show that working - will control rudder
SERVO 1,CENTRE 'start servo control process - middle
PAUSE FOR1SEC
SERVOPOS 1,LEFT 'move servo to position 1
PAUSE FORP5SEC ' 0.5 sec
SERVOPOS 1,CENTRE 'move servo to middle position
PAUSE FOR1SEC
SERVOPOS 1,RIGHT 'move servo to position 2
PAUSE FORP5SEC
SERVOPOS 1,CENTRE 'move servo to middle position
PAUSE FOR1SEC
 
Last edited:

srnet

Senior Member
symbol FOR1SEC = 4000 'pause value at 16MHz for 1 sec
The 28X2 default speed is 8Mhz, so the pause value for 1 second at 16Mhz is 2000.

And from the manual on the Servopos command;

Effect of increased clock speed:
The servo command will function correctly at 4 or 16MHz (M2/X1 parts)
8 or 32Mhz (X2 parts)
 

Robin Lovelock

Senior Member
Many Thanks SRNET - that's saved me a lot of time here. I'm about to shut down this PC for tonight, but I was able to confirm you've found the problem. When I used a setfreq M8, the SERVO/SERVOPOS worked exactly as it should. Before that I'd tried setfreq M32 but it was thrown out. I remember going to the M16 rate to overcome limitations, with the help of Hippy, years ago, related to handling of the serial input from GPS. Thanks, tomorrow I'll look up that quote, which seems to imply what I suspected: restrictions in the SERVO/SERVOPOS implementation for that 28X2. Before I saw your post, I'd tried SERVO B.1 etc, instead of SERVO, 1 - but with the same bad result. Changing the CENTRE,LEFT,RIGHT numbers also gave unexpected results - all pointing to a bug or restriction. Hopefully I can find out how to use SERVO/SERVOPOS on this 28X2 Module, and the higher rate needed for handling serial input. Switching of speed would probably give unwanted side effects on the servo pulse train. Many Thanks again - much appreciated.
Robin
www.gpss.co.uk
 

Robin Lovelock

Senior Member
Hi Folks - and many thanks again SRNET. I'm a very happy bunny this morning, and this posting was delayed a few minutes, while I added a photo to the very bottom of my "compass" page (on www.gpss.co.uk/rbcompas.htm ) showing my first good "walking test" of the 28X2 based autopilot. Sorry it's not a video, showing me walking to a waypoint up the road, seeing the servo move in the correct direction, and hearing the speech saying distance and direction - also neighbours peeking out from behind curtains :)

Below are some comments from the latest version of the autopilot program, which summarise the changes - which did not take so long.

Before going to bed last night I'd decided what I'd try this morning: start by changing to setfreq M8. I did, and everything worked - but as half expected, this speed was not fast enough to reliably catch the GPS data. So then I tried switching to M16 before the SERINs to read data, and switching back to M8 after. It all seems to work perfectly !
So out with my tea-tray of bits, and the walk up and down the road near my house ! :)

I obviously need to check through my code more carefully, to make sure I've not missed any changes, but right now, it's looking very good indeed. Yesterday I ordered another couple of 28X2 Modules, so I can do a neater job of construction, before going on to try things like the tilt-compensated compass. I also see that Snoopy is happily holding 24/7 position at Bray Lake, because the wind did not drop to near zero last night.

Many Thanks again.
Robin (and Snoopy)
www.gpss.co.uk
www.gpss.co.uk/autop.htm - Snoopy's "front page".

'AUTOPX1.BAS for 28X2 Module based on AUTOP2TTS for 08M2 Jan2013 in boat 9 (and 10)
'changes needed:
' #picaxe 08M2 change to #picaxe 28X2
' change to setfreq M8 (SERVO restriction on 28X2)
' change constants for times, such as FOR1SEC from 4000 to 1000
' sertxd ( "AUTOPX1",10,13 ) 'unchanged text output back to PC at 19200 is now at 9600
' SERVO 1,CENTRE ... change to SERVO B.1,CENTRE (not needed) and use pin B.1
' SEROUT 2, T9600_16, change to SEROUT 2, T9600_8 and use pin B.2
' SERIN 3, N4800_16, change to SERIN 3, N4800_8 (but not fast enough?) and use pin B.3
' or switch to setfreq M16 before N4800_16 then setfreq 8 (this seems to work OK)

p.s. thanks again SRNET (posting below). I'll remember to try that if serin problems pop up. Meanwhile, after higher priority tasks, like buying pub grub for Dick, I'm going to add code from my experimental stripped down version, for things like speaking boat speed, GMT time, etc. Not sure what thing takes priority after that, since this is all very much a "background" task, towards next year's boat, but they include things like that tilt-compensated compass, switching on and off the compass and/or GPS to reduce power consumption, etc.

Just a few words to add that I easily added the extra lines to speak things like "time 1030" (in GMT/UT) and "speed is 1.5 knots", and had the pleasure of showing this to Dick, on the tea-tray, while we ate our pub grub. Then we let the autopilot give us verbal guidance to waypoint A on Bray Lake, until we reached the Base, past the Clubhouse, and sure enough it said "Range 100 metres" etc :) Will probably try that tilt-compensated compass in the near future.
 
Last edited:

srnet

Senior Member
Remember the X2s can use background receive, so the GPS output can go into a circular buffer, which you can then search at the programs leisure.
 

Robin Lovelock

Senior Member
For those interested, here are my thoughts and plans for "work" that may start tomorrow:
1) assemble one or two more 28X2 Module based boards, and test with GPS, TTS and Servo using AUTOPX1.BAS used above.
2) connect the Tilt Compensated Compass, probably using serial rather than I2C comms.
Details of the Compass module are on http://www.hobbytronics.co.uk/cmps10-tilt-compass?utm_source=google&utm_medium=googleshopping&utm_campaign=googlebase&gclid=CMzQtrrcgL8CFUjlwgod46AAkQ
3) investigate use of spare 28X2 pins to switch on and off the compass, and then the GPS.
This is all about developing an autopilot that consumes even less power than the old 08M2 version (typically 50mA from 5v of which majority is the GPS)
I'll obviously need to check maximum current that can be supplied by a 28X2 pin. The GPS needs about 35mA and the compass about 20mA.
The GPS will probably need tens of seconds, if not minutes, after switching back on, after maybe a minute or more of being off.
The Compass may deliver good data within a fraction of a second of being switched on, so this might be a good strategy to reduce it's 20mA to a much lower drain.
i.e. the program will switch the compass on, just before reading the magnetic heading, then switch it off, spending most of the time in the servo steering control loop.
In the Atlantic, with big distances to the next waypoint, the GPS could be switched off for long periods - maybe based on range to waypoint.
But the same software needs to be tested thoroughly on Bray Lake, so this will influence the details in the software, such as switch off times.
Any ideas are welcome. As always, they can save me time and effort ;-)
Robin
www.gpss.co.uk

p.s. Thanks Jim (below): that tells me I can start with a direct pin to power the compass, taking less than 20mA, after I get the compass working.
Thanks srnet (below) - could you point me to any suitable GPS product with simple NMEA output, with a fast startup, AND low power consumption, including any required trickle charging of it's backup battery ? Obviously no point in switching the GPS on and off if the backup battery consumes as much as leaving the GPS on all the time. Most of the GPS that I am familiar with consume in the ballpark of 30mA+ although Globalsat were helpful in bringing this lower by putting their (SiRF based) products into power saving mode.
I'm using the Globalsat BR-355 (see "design" page on www.gpss.co.uk/rbdesign.htm) although I've used others over the years.
See "8. the Autopilot sub-system, including GPS, PICAXE, and Rudder Servo ..." on the "design" page link above.
 
Last edited:

srnet

Senior Member
The GPS needs about 35mA and the compass about 20mA.
The GPS will probably need tens of seconds, if not minutes, after switching back on, after maybe a minute or more of being off.
That a poor GPS then, which one are you using ?

With a battery backup supply for the GPS, even the cheap ones should re-aquire a fix within 5 seconds or so of being powered up.
 

Robin Lovelock

Senior Member
Hi Folks. Just an update here to say that things went even easier than I expected in getting that tilt-compensated compass to work with the Picaxe 28x2 Module, and so I've updated my "compass" page on www.gpss.co.uk/rbcompas.htm . I expect to start looking at using a pin to power off and on the compass soon, to see if it still works and I can reduce power drain significantly. I'll be interested if SRNET or anyone knows of a better GPS than the one I'm using. Details of that are at the end of my edited earlier posting.
Robin
www.gpss.co.uk

p.s. Great News Folks ! It's the breakthrough I was hoping for. These words now added to my "compass" page above ...

Not long after, I was able to drastically reduce the power consumption of the compass, from less than 20mA to an average
of less than 1mA, by using the Picaxe program to switch on the compass just before it is read, then switch it off again.
If it is only switched on for 0.1 seconds, in a rudder servo control loop of say two seconds, that only 5% of 20mA.
i.e. 1mA - not worth worrying about ! :)

... and here is the code used to test it:

'compass test loop - Compass only switched on for 0.1 sec in 4.1 sec loop
sertxd ( "Compass Test ",10,13 ) 'output back to PC
SEROUT B.2, T9600_8, ( "N1",10,"V10",10,"W200", 10 ) 'N1=Deep Male, loud, fast was _16
PAUSE FOR1SEC
SEROUT B.2, T9600_8, ( "S Compass test starting. ",10 ) 'test TTS output was _16
lab1:
HIGH B.6 'switch ON the compass
PAUSE FORP1SEC 'give Compass 0.1 sec to start
SEROUT B.4, T9600_8, ( 19 ) '19 = 1x13 = get angle as two bytes 0-3590
SERIN B.5, T9600_8, b5,b4 'get w2 0-3590 from two bytes
LOW B.6 'switch off compass
w2 = w2 / 10 'w2=heading 0-359
sertxd ( " H=",#w2,10,13 ) 'output heading value back to PC
SEROUT B.2, T9600_8, ( "S heading ",#w2,10 ) 'speak heading value
pause for4sec
goto lab1

Now the important step: switching the GPS off and on, and using the compass for steering - which we've done before. I can do this for the GPS I've been using all these years, which is the best one I've found, but it will need a bit more current than 20mA - so that earlier tip could be useful. But if anyone knows of a lower power GPS, that would be much more significant.

p.p.s. Many Thanks SRNET (Posting below) for suggesting the Mediatek 3329 - I googled this name and found a datasheet on
https://www.sparkfun.com/datasheets/GPS/Modules/LS20030~3_datasheet_v1.2.pdf
which I guess is the same product. I see it is also in the ballpark of 30mA power consumption, as are most GPS chipsets. But the mention of a backup battery raises the possibility of my raising this subject with people like Globalsat who use the SiRF chipsets (don't know if Locosys in Taiwan also use SiRF - my Globalsat 355s come from Taiwan, where they manufacture). Maybe there is scope to speed up acquisition this way, and reduce average power consumption. Many Thanks again.
 
Last edited:

srnet

Senior Member
I have been looking at GPSs recently for this project;

http://www.picaxeforum.co.uk/showthread.php?25864-HABAXE-High-Altitude-Balloon-Tracker-for-PICAXE

Here weight is paramount, so the Mediatek 3329 I have used in the past is just way too heavy (with ceramic patch antenna).

But the Mediatek 3329, despite being supposadly old technology, will re-aquire lock from power down a lot faster than the Ublox Neo 6, and it uses less current when its running too.

So since weight is not so much of a problem for you, try the Mediatek, and setup your program to tell you how long it takes to re-aquires lock, and do some tests.
With a backup battery on the Mediatek, I was getting a lock from power down in a couple of seconds or so.

Its the time taken to re-aquire lock from power down, that has the greatest effect on power used, not the running current of the GPS itself, in this sort of application.

How often would you need to take GPS fixes ?
 
Last edited:

Robin Lovelock

Senior Member
Many Thanks Folks. Today it did not take long to import my compass-based steering logic from last year's stripped down 08M2 based program, to the full 28X2 based autopilot. Lots of minor changes were needed, but I just had time to do the tea-tray test outside, before the rain sent me back indoors ! :)

I've been getting good advice on what low power/fast startup GPS to try, from several sources, including direct email, the Picaxe Forum, and the Microtransat list. Good if I'd asked for this advice earlier, but it seems I've not (yet) wasted my scarce pocket money.

e.g. back on 17th June, before getting your advice, I ordered two of the Skylab SKM53, which will not be delivered until late July. However, looking at their datasheet on
http://www.nooelec.com/files/SKM53_Datasheet.pdf I see they say the SKM53 is based on the Mediatek 3329, reccomended by SRNET on the Picaxe forum. Another friend has suggested that I try the Mediatek MTK3339, which he has used himself, and I've just ordered one today from Proto-Pic in UK, so I should have this early next week.

Thanks for those other suggestions, including the Telit Jupiter JN3 from my local friend John, and the Ublox from Yariv. It's much easier to find relevant specs and sources by searching for these product names or brands, rather than simply "gps module". Please keep the suggestions coming, particularly if you can include a link to a supplier and the relevant data sheets.

Meanwhile, Snoopy is keeping to his 24/7 position on Bray Lake, after 11 days of continuous sailing. Good to see that I should not need to go out in the rain, to push him away from the bank ! I've pinched a sheet of my wife's kitchen cling wrap, to protect the chips, if I go outside with an umbrella. I expect to put this new experimental stuff into boat 6 soon, and give it a try on Bray Lake. Watch Snoopy's "front paage" to see when he next travels down to the coast to make his 2014 attempt in boat 10 - maybe next month, if we get the required "weather window".

Robin
www.gpss.co.uk
www.gpss.co.uk/autop.htm Snoopy's "front page".
www.gpss.co.uk/rbcompas.htm "compass page".
 

Robin Lovelock

Senior Member
Hi Folks. Mostly rain here today, and wife more interested in watching the tennis on TV, so I was able to do things not normally done at the weekend :)

Mr Postman delivered some bits, including two of the Skylab GPS based on the Mediatek 3329 suggested by SRNET. I've made some good progress, reported here, since you may point out things. First I put a working Picaxe 28X2-Compass-BR355 in my boat 6, all ready to try on Bray Lake this coming week.

Then, using bits delivered today, I made up a second system and checked it worked - and it did.
Then I soldered one of the two Skylab GPS in, to replace the BR355 and that practically works.
i.e. I'm getting the $GPRMC sentence from it, and the good news is that current has dropped from about 60mA to about 35mA.
That's encouraging enough, and makes this GPS well worth pursuing - BUT, there are some problems to overcome...

It did not take long to find changes needed, such as the SERIN changing from SERIN B.3, N4800_16, to SERIN B.3, T9600_16,
but the comments in the code below flag up peculiarities. At this stage, I'm not sure how much is due to the detailed
behaviour of the Skylab GPS, or if it relates to the Picaxe struggling to catch data at 9600 instead of 4800.
It will not be the first GPS from Taiwan/China that I've seen, over the years, that does NOT sent out ,V,
in the $GPRMC sentence to say it is not tracking yet, and only gives ,A, when data follows.
But there are all sorts of things that may be going on here.

I need to find a work-around, if there is one. e.g. change the speed of the GPS from it's default 9600 down to 4800.
e.g. find sufficiently complete documentation for the Skylab implementation of the NMEA $GPRMC sentence.

Here is an extract of code from my test program:

'e.g. $GPRMC,114801.123,A,5129.8944,N,00041.0771,W,3.53,358.23,280608,,*18
waittrack:
setfreq M16 'wait for the Skylab GPS to start tracking
SERIN B.3, T9600_16, ( "$GPRMC," ) 'wait for $GPRMC sentence
SERIN B.3, T9600_16, ( ",A," ),b22,b23,b24,b25,b26,b27,b5 'wait for tracking to start
setfreq M8 'b22 etc should hold 5129.89 the decimal should be in b26
sertxd ( "waiting ",b22,b23,b24,b25,b26,b27,b5,10,13 ) 'output back to PC
if b26 <> "." then goto waittrack
'the Skylab GPS sometimes gives A,3,16,18 - due to GPS or Picaxe speed limitation ?

setfreq M8
sertxd ( "GPS now tracking.",10,13 ) 'output heading value back to PC

SEROUT B.2, T9600_8, ( "S The G P S is now tracking.",10 ) 'test TTS output was _16
PAUSE FOR4SEC
setfreq M16

I've updated the section "New Picaxe computer and Compass working" at bottom of the "Compass" page on www.gpss.co.uk/rbcompas.htm

Any suggestions or info will be appreciated.
Robin
www.gpss.co.uk

p.s. Thanks SRNET (Posting below). I'm using the 28X2 Module, so would your approach work on it ? Right now, I'm thinking the simplest thing to try next, will be to wire another Picaxe pin, via a 220R, into the Rx line of the Skylab GPS, so I can switch it's speed to 4800 at the start. I found what seems the correct command for that : $PMTK251,4800*14<CR><LF> which looks simple enough. If that works, maybe I can find similar proprietary sentences, to switch off NMEA sentences other than $GPRMC - the only one I use. Looks like weather will be better tomorrow, so this may wait another day or two :)

p.p.s. Still curious to know if SRNET's approach would work on the 28X2 Module, but I prefer the idea of switching the Skylab GPS from it's default 9600 to 4800. It would seem simple, and the addition of a wire from pin B.7, via 220R, to the GPS RXD pin is simple - I did it today. I like use of the RXD into the GPS, because it opens the door to setting up other GPS for lower power use, and/or suppression of unused NMEA sentences, to reduce load on the PICAXE. e.g. Trickle mode on Globalsat BR355. I wired up this RXD pin today, but have not made much progress: I corrected the *17 checksum to *14 in the SPMTK251 sentence above, after seeing that it must be a mistake in the forum I found it mentioned. I googled and found what might be a more reliable document for the Skylab SKM53 (and Mediatek MTK3329?). I suspect the Skylab GPS may be doing things not expected, rather than speed limitations of the Picaxe. My attempts to switch speed to 4800 don't work. Many reasons possible, including my use of the wrong code, and/or the Skylab recommending different interfacing. e.g. "Pull up 10k" on
serial input and output, compared with Picaxe "Pull down 10k" for input, and serial 330R for output.

If I go back to code I used yesterday (above), waiting for the decimal point after the ",A," it works - but I notice this strange behaviour, particularly when the GPS has poor signals (near the Window, connected to my desktop PC): it may spend several minutes, waiting for the decimal, indicating good lat/lon data (e.g. 5129.89 ), but the rest of the time, it repeatedly sees the same string repeated, for tens of seconds, or minutes, such as "3,24,12" or "3,2412," or "3,12,25" or "3,1225,". I'm sure this is a clue. I can see me wiring up the other Skylab GPS
to a 7 pin D serial connector, so I can do some tests with HyperTerminal on my Laptop PC.
 
Last edited:

srnet

Senior Member
The approach you are taking, is OK for the M2 Picaxes, its all you can do after all.

However the X2s have far better ways of dealing with things like GPSs.

The X2s have a scratch pad, and the HSERIN command (uses the PICAXE hardware UART) will allow you to wait for a qualifier and then dump n bytes into the scratchpad. The advantage of this approach is that you can then print the scratchpad out to terminal to see what was actually recieved from the GPS.

Or you can run the background recieve for a period and search the scratchpad buffer for the appropriate sentances, or print it out.

I have run the Mediatek GPS at 38400baud, using HSERIN into the X2 scratchpad, never had a problem with missed or corrupted characters, its one of those things that just works.
 

Robin Lovelock

Senior Member
p.s.Hi Folks. After my updates at the bottom of my earlier posting, edited after SRNET's above, today I decided to try the Skylab GPS with Hyperterminal.

My normal "67 year old grumplyness" was increased a little, and not helped by the hand-writing on the package from Hong Kong:
"Gift, of no commercial value" - hopefully just there to evade import duty, and not because the Skylab GPS came out of a skip :)

That was after my earlier experiences this morning: No COM1 serial port on my Laptop - no problem, I guess I must have used this Win7 Desktop last time I did this. So I wired up the Skylab GPS 4 pins to a lead, connected to a 9 way D Female, to plug into the COM1 port on my PC.
Thought I'd fire up HyperTerminal - it had expired - no problem, I paid 60USD and installed a copy from Hilgraeve. Remember the days, from early 1990s and Windows 3.1, to not long ago, and XP, When Windows Terminal was bundled in to Windows ? Win7 changed all that :)

Progress when I plugged in the 9 pin D to the PC and powered up the GPS - at least I get some garbage data.
So it looks as if I didn't blow up the chip - as might happen if RS232 levels were flying around.

But I've not managed to find a HyperTerminal setting (e.g. other speeds) where I get the expected $GP sentences.
I also find that Hyperterminal seems very limited on what settings I can configure - or maybe I need to look in the right place ?
Maybe this GPS uses serial levels the other way round ?
e.g. those changes in the Picaxe SERIN needed to make it work ?

I tried the Skylab reccomended 10k pull up resistor, from TXD into the PC up to +5v VCC - same result.

Any ideas appreciated.

Robin
www.gpss.co.uk

Received at 9600,N,1 from Hyperterminal when Skylab SKM53 GPS powered up:

&#376;&#8250;£&#376;&#8250;&#8212;§§§§§&#376;§§§§e§§e§§«&#8212;yåë·q_qY}§}§§§§§§§§§§§§§§§§«uåë·q_qYS§&#8482;§§&#376;§&#8250;&#8212;§&#8250;§
&#376;&#8482;§&#8482;&#8220;§&#8250;§&#8220;&#376;§&#8250;&#8250;&#8212;§§&#8226;§&#8482;&#376;§&#8220;§§&#8216;§&#8250;§&#376;&#8226;§«&#8216;åë·q_qYS§&#8482;§&#8250;§&#376;§&#8212;§&#8250;&#8216;§&#8482;§§&#8250;&#8226;§&#8250;&#8482;§&#8250;&#8482;&#8482;§§
&#8250;&#8250;§&#8250;&#376;§&#8250;§§§&#8226;§&#8250;&#8212;&#8482;§«&#8216;såë·q_qYS§&#8482;§&#8482;§&#376;§&#376;§&#376;&#8250;§&#376;&#376;&#8226;§§&#376;&#8212;§&#376;§&#376;&#8226;§«&#8216;&#8220;åë·q_[ey§&#376;&#376;&#8250;£

p.s. Thanks Martin (Posting below) - I think you've saved me some time, but I think it's not as you say because of TTL RS232 levels - because the many GPS I have tested like this, including the BU355, also have the same TTL levels and work with COM1 on the PC. But I'm sure it may be - as you imply with the possible solution - because the Skylab signal is inverted. That's what I suspected, because of the changes needed to the Picaxe test program above.

Maybe someone can confirm:
'change SERIN B.3, N4800_16, to SERIN B.3, T9600_16 for default 9600 speed.
Maybe the change of N before 4800 to T before 9600 is to reverse the input signal ?

Before your posting, I did try swapping the signal and ov wires, into COM1 D pins 2 and 5, around - but without a good result.
Not worth me mucking about with invertor transistors, if it can't be done more simply.
I can continue with tests on the Picaxe - there may be enough clues in my earlier posting for a diagnosis.

Robin
www.gpss.co.uk
 
Last edited:

MartinM57

Moderator
Unfortunately you can't connect the Skylab GPS straight to the PC - it will have a "TTL RS232" electrical interface which will not work plugged straight into a PC serial port

You will probably get success by just inverting the Skylab signal - a logic chip inverter gate or a simple circuit with a npn transistor and 2x resistors...ask if you need more detail.

..you may also get success by sending the Skylab signal to the PC via the AXE027 cable if you have one (no explicit inverting being required)
 

Robin Lovelock

Senior Member
Thanks Martin (reply at bottom of my earlier posting) and Jim: thanks Jim - was very quick to download and run putty.exe and it also gives garbage when I open COM1 for serial input. Lots of options, but I didn't see one to invert the signal. See my reply to Martin earlier - I'm sure this is the problem. I would have thought HyperTerminal or Putty would have an option for this - unless it's deeper in the PC Bios or UART. Interesting if a Picaxe has more capability than a (Microsoft) PC :)
Robin
www.gpss.co.uk

p.s. Thanks SRNET (three postings below) - than confirms it. I'll give up on using the PC for this - other than in the Picaxe Editor. Please take a look at my earlier posting. e.g. that I'm doing this experimental work on a 28X2 not a 08M2, and those symptoms - may give a clue why the SERIN is not working reliably. I suspect the Picaxe can't cope with the 9600 - ref discussion and solutions from Hippy near the very start of this thread, years ago, when getting COMS working at only 4800 with the 08M2 - that's why we went to the faster 08M2.

p.p.s Thanks SRNET - please read that earlier posting of mine. We are reading the Skylab GPS at 9600 - it's not the baud rate in question. When seeing garbage on the PC, it does not take a moment to change baud rate on the PC Terminal, just to confirm that's not the reason.
 
Last edited:

srnet

Senior Member
I would have thought HyperTerminal or Putty would have an option for this
Those programs are designed for talking to hardware based UARTs.

A lot of UARTs support inverted\noninverted operation, such at that in the AXE027 program lead or those in the UART in the PICAXE.

But there is no universal way of using the invert capability, it depends on the particular UART.
 

srnet

Senior Member
For 28X2 one project, realising that GPSs come (or may have been set to) an unknown baud rate, I wrote a program that went through the range of normal baud rates, true and inverted, captured a bit of the output in the scratchpad, and printed it to the terminal.

It did not take long before you saw consistent text, and thus what the GPS baud rate was.
 

Robin Lovelock

Senior Member
Hi Folks. Quite a bit more progress to report: the most interesting being the 10 minute youtube video uploaded today, and linked from my updated "compass" page on www.gpss.co.uk/rbcompas.htm I'd put the 28X2 Module + CMPS10 Compass into experimental boat 6, and it did a lovely job of completing the "Bray Lake Test". Earlier, I'd made more progress with the Skylab GPS, using the proprietary $PMTK251 sentence to switch it to 4800 baud: very easily done. What I do next depends on the flow of bits and information - and the weather :) My replies to your postings above are in my earlier posting. Thanks again.
Robin
www.gpss.co.uk

p.s. Thanks SRNET (posting below): I just found an interesting post #8 on this thread by Hippy, three years ago. He was suggesting the 28X2 then. I remember he got me to switch to the 08M2, which was an easy change. I'd like to know more about what you've been suggesting recently, also mentioned by Hippy then, I think - HSERIN background receive. If needed, I can repeat the SERIN statements that have been used with success in recent years.
 
Last edited:
Top