@Technical: How about tbe 08M2+?
'COSLAT is used to scale difference in longitudes to similar scale of miles/km as difference in latitude 'ATAN functions used to calculate angle 0 to 45 from the ratio of lat and lon differences. 'The work of interest now (February 2015) is to estimate errors of approxiumations and find better approximation(s) 'in the (cruder) software used within the Picaxe 08M2, that does not have ATAN and COS functions, that are in 28X2. 'Typical code from Picaxe 08M2 autopilot, using crude approximations for ATAN and COS for calculation of direction: coslat: '09Feb15 returns COS(Lat) * 100 in b22. e.g. COS(50)=0.64. b22=64. 'Average Lat between GPS in b0 and Destination waypoint in b14 is used. b22 = b0 + b14: b22 = b22 / 2 'average. b23 = 115: b22 = b23 - b22 'approximation in b22 is 115 - Lat in degrees. e.g. 65 return atana1: '10Feb15 better approximation of ATAN from 0 to 45 degrees w13 = w13 * 45 / w12 if w13 < 15 then w13 = w13 + 5 endif return 'Typical code from Picaxe 28X2 autopilot, able to exploit COS and ATAN functions, working in summer of 2014 on lake: w27 = cos b0 '01Aug14 was b1 use Picaxe COS and ATAN instead of approximations. ' (would be better to use average latitude of GPS positiuon and destination waypoint) ' (following gives flavour of how ATAN function used in core of direction calculation) w13 = w13 * 100 / w12 w13 = atan w13
If you have some eeprom free then you can store the ATAN function as a table lookup. A table of 56 values (0-55) resolves to 1 degree steps.Does anyone have a better crude approximation to the ATAN function
w13 = w13 * 45 / w12
eeprom(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,24,25,26,27,28,29,29,30,31,32,32,33,34,35,35,36,37,37,38,39,39,40,41,41,42,42,43,43,44,44,45) ; b0=w13*55/w12 max 55: read b0, w13
eeprom(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,24,25,26,27,28,29,29,30,31,32,32,33,34,35,35,36,37,37,38,39,39,40,41,41,42,42,43,43,44,44,45) ; main: for b0 = 0 to 55 ; start a loop read b0,b1 ; read value from EEPROM serout C.1,N2400,(#b1,13,10) ; transmit to serial LCD module next b0 ; next character stop
b0 = w13*100/w12 b1 = 377-b0*b0/606
' TEST.BAS Test code for 28X2 #picaxe 28X2 '18Feb15 was 08M2 w13 = 1 b12 = 200 / w13 'e.g. b12=200 for w13 = 1 for Lat difference 51N-50N w26 = 60000 / b12 'e.g. w26=300 for b12=200 b13 = w26 'e.g. b13=300 for b12=200 (but get 44 in b13 ???) sertxd (10,13,"b12=",#b12," w26=",#w26," b13=",#b13, " (in calc)")
In some microcontroller/processors the "Stack Pointer" is simply a pointer into the normal RAM. Also PUSH and POP commands which allow variables also to be put onto the stack. That gives great flexibility, but also the possibility of creating total havok!I was hoping I might get some answers from Hippy on things like reading the stack pointer (e.g. with PEEK ?) or confirmation that GOSUB=CALL.
3.7V is a long way above the threshold for the X2, they will run quite happily down to around 2V, although other stuff may well stop working long before that.running at ~ 3.7v, near the threshold for the picaxe, which means it often restarts. This is partly due to use of the servo causing voltage reduction as it draws current
No need for an external reference, there is an internal one, thus:Thanks Alan and Eggd. I guess what is not yet clear to me, is if I need to provide a reference voltage of some kind, to use Calibadc10 ?
If this is needed, I can imagine it might be provided by a low voltage zenar, on some pin, well below the lowest supply voltage. e.g. ~ 1v to 2v.
Or is there some simpler way ? It would certainly be useful, to know when supply voltage is running low. e.g. below 3.8v.
Right now, and not yet reported in Blog or BlogX, I have two systems running in the house: Boat10, checking out the replaced battery (in the Blog) and - relevant to this - the "tea-tray" autopilot, running at ~ 3.7v, near the threshold for the picaxe, which means it often restarts. This is partly due to use of the servo causing voltage reduction as it draws current. The battery is obviously slowly going flat, so in the morning, I will see if the autopilot has "frozen". Sadly, I expect it will not. i.e. raising the voltage will restart it. But if it has frozen, I've recreated the problem, so there is scope to diagnose and fix it.
Robin,what is not yet clear to me, is if I need to provide a reference voltage of some kind, to use Calibadc10 ?
GO SNOOPY!!! Robin, you have the patience of a saint. Just think where the world would be if the 36 billion man hours spent every year on social networking were spent on solving real problems. My hat is off to you! I can envision self-steering, un-manned, cargo ships crossing the major oceans in my lifetime.
Hi Folks. Another long gap since I last looked at this forum. I'll repeat that stuff earlier: latest news about Snoopy on www.gpss.co.uk/autop.htm with him sat ready for this year's attempt here. Also the recent arrival of a toy boat from USA without an autopilot - just the tracker. I'll also repeat that email address of firstname.lastname@example.org - and add a bit more on that subject. Very wise being cautious about the Net: I knew about GPS and the Internet (Arpanet) when they were secret and I worked as a NATO scientist in the 1970s. All my details, including email address have been public for over 20 years on my www.gpss.co.uk contact page, and I get little more spam than the rest of us. It does not take long to check spam folders for stuff that is mistaken for it. I don't use online banking, the cloud(s), and assume our emails may get parsed for anything useful. But no need to be paranoid about it: I usually don't worry about who is sat near us, when swapping yarns in the pub about our earlier defence career - so long as we are not putting lives at risk You will find a lot about me on my web sites that may surprise you: send me an email direct, with your nearest town and country, what interests you, and I'll send you some links on my site: or - if you have the stamina - you might browse and find what interests you anywayHi Martin, just found all the information you were saying, thanks. Certainly an interesting challenge he has with snoopy and is all well documented and he deserves to achieve his goal.