Simple (really simple!) data logging help needed

Andy1967

New Member
Hi all,

I have been using PICAXE for a while but have not done any data logging. I have looked through the manuals, books and forum but all of it assumes much more understanding than I have!

I want to start with some simple data logging of an LDR.

I am able to send the data with the program code below to my computer and display it using the datalink (although the graph never works?) And I can save that data as a csv as long as the interval is short.

However if I want to log data with large intervals the datalink window tells me there is no data and stops.

I realise this means I have to write the data to the chip and then retrieve it afterwards and that is where the problem is - I don't know how.

I am starting with an 08M with no external datalogging type module and no other software other than the program editor and I want to do something like record the level every 1 minute.

I need someone to explain the code for writing to the chip and then some very specific explanation of how I get that info off into a format that can then be put into excel.

Here is how far I have got

main:
readadc 2, b1
serout 0, N2400, (#b1, 13, 10)
wait 1
goto main

I know how to do a for...next loop so that it records a set number of times.

I know that this is probably stupidly simple stuff for most of you but I would really appreciate your help with this.

Thanks in advance

Andy
 

Andy1967

New Member
Hi Stan,

I had a look at that yesterday, but I will print it off and read it properly today see if I can make sense of it. At the moment I am also struggling hugely with the mailtronics LCD kit as I can't see how to program the chip on the board without removing it and the instruction that come with it don't explain either. All very well telling me the code is serout 7, N2400, ("Hello") but how do I get it on the chip in the first place?!!!!
 

Andy1967

New Member
Ok, so I have got the 08M to record the data over a 20 second period using the data logging part, no problem. Then if I have a short wait time I can then get the saved data to write to the terminal. So far, so good.
But....that only works if both parts of code are in the same downloaded program. If I leave it over night and then come back to it how do I get the data back out? If I split the code into the 2 sections when I download the read/playback part it overwrites the info on the chip doesn't it? And I therefore lose all the data?
Sorry to be such a simpleton.
Andy
 

Andy1967

New Member
Right I have solved that side by including a switch that means the program sits and waits for the switch to be on before uploading the data. I'm wondering if I can then use an interrupt on that, does sleep work with interrupts?
No doubt you are very busy and my idiot questions don't help but any thoughts would be gratefully received.
Andy
 

manuka

Senior Member
Andy- you're doing pretty well without me! However please outline your project & specify how often readings are being taken etc. The 08M uses common storage space for the program & EEPROM data ( Von Neumann architecture),meaning only limited data stashing may be available.

Nice thought re SLEEP, but it can't be interrupted- I guess it's like trying to awaken a teenager! Are you up with RC discharge however? It's possible that a suitably large RC combo may supply a useful hold up voltage, which eventually falls to a level causing PICAXE shutdown & restarting.
 
Last edited:

Andy1967

New Member
Thanks for the replies, it's heartening to know that there are people who can help.
To explain a little
I want to do some data logging with my students (high school) but have not really done any before so want to start with a very simple set up.

08M chip and picaxe editor is all that I want to use to start with.

I want to leave the 08M for say 24 hours and record the light level perhaps every 30 minutes during that time. The actual specs are not important as it is just really proving the concept that I am interested in.

The results need to be stored on the chip and then at some point after the time is up (or even before) I want to be able to upload the stored values to a pc (presumably using the terminal) and save those figures as a .csv file to import to excel.

From there I will obviously move onto using a dedicated data logging kit which I have already bought from mailtronics.

As I say I have the code to save the results but once saved the issue is getting them off. I can add code to the end of the recording part that sends the results to the terminal but you need the pc connect for that to work and I want to leave the picaxe recording then pick it up later.

The code I have used is this

for b0= 0 to 20
pulsout 2,500
readadc 1,b2
write b0,b2
wait x 'time period maybe 30 mins
next b0

Now at this point I want it to wait until I am ready to upload the data but instead it will immediately send the data. A specific wait value is no good because I don't know how long it will be before I am ready to harvest the data.

serout 4,n2400,("Datalog", 13, 10)
for b0= 0 to 20
read b0,b1
serout 4,n2400,(#b1, 13, 10)
next b0

Does that make things any clearer?

Cheers in advance

Andy
 

manuka

Senior Member
Andy- great stuff. Just where are you teaching? What years ? Do you know of the NZ Govt. funded ETITO "Bright Sparks" program & NCET courses? Contact me more directly for insights if you like.

Light levels are a tad vulnerable to shadows,street lights & of course mischievous students with torches/blackouts, so consider instead using a NTC thermistor for temperatures. Better still of course are the esteemed DS18B20s, but they quite costly. Recording temps every 30 mins for a 24 hour day will give 48 readings- easily held in PICAXE EEPROM. See coding in the examples I mentioned a few posts back

PICAXE .csv feedout later to Excel etc is a breeze, & the Editor's nifty F8 terminal often OK (although it times out as you've noted). Many folks use StampPlot => www.selmaware.com/stampplot/index.htm & StampDAQ instead, although they're not so easy to drive. Good luck- Stan
 

hippy

Ex-Staff (retired)
Hi Andy,

With a switch you can have that in two states; record light levels or upload stored data. The code will wait until the switch is in record position before recording, then, once recorded, wait until its in the upload position before sending, for example with that switch on pin 3 ...

MainLoop:
Do : Loop Until pin3 = 0 ' Wait until "Record"
For b0 = 0 To N
Take a sample and store
Next
Do : Loop Until pin3 = 1 ' Wait until "Upload"
For b0 = 0 To N
Upload a sample to PC
Next
Goto MainLoop

You can modify the sampling code so that it terminates prematurely if the switch changes to its upload position rather than take 24 hours worth of samples.
 
Top