Simple datalogging

dennis

Member
I am working on a sailboat autopilot using a 28X1 and with a CMPS03 I2C Compass. In Pseudo code my program looks like this :-
' wait for auto button to be pressed
' make set point equal to current compass reading
' ###############
'auto_loop:
'start timer
'get compass reading and turn rate from compass subroutine
'compare with set point and calculate correction
'make correction
'output data to ???
'wait for total loop time
'goto auto loop

I am keen to keep the time through the loop constant and plan to do this with the timer function, simply waiting at the end of the loop until a preset time is reached before intiating the next pass.
To help diagnostics and control I would like to somehow log the key data at each pass through the loop with a view to analysing performance on a PC later. Each pass will generate about 10 bytes and ideally I would like to record at least 20 passes though more would be better. Is it possible to use Hippys Capture.exe program or will that disturb the timer operation ?



 
 

hippy

Technical Support
Staff member
If you put the data logging code after you've waited for your timer to timeout, then restart the timer, providing the data logging code has consistent timing ( do not use # in SERTXD or SEROUT - I cannot off-hand recall exactly what my capture program does ), it should work fine, although your overall loop time will get extended.
 

Jeremy Leach

Senior Member
One of the great things about having a Timer function is that you should be able to time your subroutines now, to get an accurate picture of how much time you've got to play with to off-load data etc - if this helps.
 

dennis

Member
Thanks for the recommendation. Forgive my ignorance but does this mean that use of Sertxd would mess up the timer ? Is the reason to avoid use of # in Sertxd statements to Capture.exe to avoid excessive processing time ? I used Capture.Exe to compare compass and GPS readings when I walked round a football pitch and my program had Sertxd("compass is ", #w3," GPS is ",#w4,13,10). Capture.exe worked perfectly for this with a pretty large file.

I am finding the Timer function very useful for testing subroutine speed but a bit more documentation would help beginners like me.
 

hippy

Technical Support
Staff member
SERTXD and SEROUT are what's called bit-banged where the PICAXE works out the timing itself by executing a known number of instructions, to keep that consistent timers and interrupts are turned off, so the timers, as you put it, get messed up.

The issue with # in SERTXD and SEROUT is that the amount of data sent depends upon the value of what you are sending; it could be anything between a single digit and five, and the time taken can therefore varies.

 

craigcurtin

Senior Member
Why not incorporate a DS1307 RTC - only an 8 pin footprint and easy to implement - alternatively you could put in an EEPROM 24LC256 for additional storage and then perform the dump once per day and take a minute or so to perform it ?

Craig
 
Top