'DATDS08M.BAS = temp.datalogger-Picaxe-08M variation Ver 1.00 30/9/04 Stan. SWAN 'NB-this enhances orig. 08 version as the new 08M "sertxd" cmd feeds serial data out '"18X style" via progr. lead @ 4800bps & displays via editors F8/F9 inbuilt terminal. 'Options->Options->auto open serial terminal after download gives instant F8 display 'But-Grr!- F9 5 sec time out prevents live data display.Use StampPlot instead maybe ? '=================================================================================== 'Use with DS18B20 temp sensor IC etc to Picaxe-08M Ch.1. Via=> s.t.swan@massey.ac.nz 'DS18B20 reads -10C to +85C to +/- 0.5C,but wider with less accuracy. Supply 3-5.5V 'N.B.Subzero "bug"-temps <0 C read as ascending from 128. Ex 129 = -1C, 130 = -2C etc 'Fix when >127 by subtracting 128.Thus b1=b1-128 Ex.-3= 131-128. (Ref Cmd HELP P.66) 'Insuffient memory left on 08M to implement ! 18X has much greater RAM so handles OK 'Program inspired by lo res NTC data08M.bas -an upgrade of Sept.'03 SiChip 08 version 'When "08M" powered up,any prior stored EEPROM values sent as SERTXD serial port data '-suit 4800bps display via any terminal program -LCD,F8,StampPlot- or.csv Excel too. 'NB-Gives you 30secs to turn unit OFF before fresh storage begins & thus progressively 'wiping existing values ! For security however this data can't easily be bulk erased '***BUT CARE - BE PROMPT ! REPROGRAMMING/RELOADING "08M" TOTALLY WIPES DATA TOO ****. 'As set up logs direct Celsius temp every 60 secs for ~2 hrs. Alter WAIT value to suit? 'A further tempting enhancement uses DS 1307 clock chip for improved logging times ' -sold as 4 channel Rev.Ed 18X datalogging PCB kit with extra I2C memory in fact. '------------------------------------------------------------------------------------- 'PICAXE08M has hi-res data values 0-255(via "readadc" command),but also READTEMP for 'direct DS18B20 Celsius readings! Values stored in program space (like "08")- care ! '"Data compression" scope that'll maybe give 256 values ? 18X + I2C better if pushed 'If power saving needed use SLEEP instead of WAIT ex. 25x2.3secs ~1min delay (+/- 1% ) 'Alter to suit.Ex.Sleep 391 =128x1/4 hr =32hrs run.Some interpreter o'head/drift noted '128 readings,so @ 1/min ~2 hrs, /5 min ~10 hrs, /30 min ~2.5 days,& /60 min ~5 days 'NB- sensor thermal lag means there's little point sampling faster than every minute ! 'Solderless "PICNIK" breadboard setup pix => www.picaxe.orcon.net.nz/datds08m.jpg 'Sample Excel graph resulting (1 hour runon 18A)=> www.picaxe.orcon.net.nz/datads18.gif 'Program hosted=> www.picaxe.orcon.net.nz/datds08m.bas & circuit=> ... /datds08m.gif '-------------------------------------------------------------------------------------- ' SERTXD DS18B20 pinouts ' & piezo - - - - - - - - - - - - -ve rail (top view) ' Ch.0 _____ Ch. | | ' - | ___ | 2 LED | * * ' ------ | |_______| | * * ' |Picaxe| |_________ DS18B20 * * ' | 08M | Ch.1 |_____________| | * * ' ------ (READTEMP) | | --------- ' + 4.7k | / / / '||| | | / / / 'Usual 3 wire + + + + + + + + + + + +ve supply 0V | V+ 'prog.input (3-5V ~10mA) data '--------------------------------------------------------------------------------------- 'READ/PLAYBACK ROUTINE pause 100 'needed to wake up sertxd & avoid initial junk? sertxd(" PICAXE-08M DS18B20 Temp.Datalogger",13,10) ' Title header for b0=0 to 127 'stored data values readout to terminal or LCD read b0,b1 'polls & reads out stored eeprom values ( .csv) sertxd(#b0,44,#b1,13,10) 'Actual value @ prog.pin,+ comma for Excel .csv next b0 'read next stored EEPROM value & SERTXD out wait 30 '30 secs "reading" delay -modify if too short etc '---------------------------------------------------------------------------------------- 'WRITE/DATA LOGGING ROUTINE for b0= 0 to 127 'begin 128 data readings @ time set by SLEEP/WAIT sound 0,(75,10) 'Beep to alert data logging commencing pulsout 2,500 'brief flash from pin 2 LED indicates datalogging readtemp 1,b1 'direct Celsius reading of DS18B20 temp. returned sertxd(#b0,44,#b1,13,10) 'Now allows data display (via F8 )as gathered too ! write b0,b1 'sequentially write values to EEPROM locations wait 60 'Checks every 60 secs (max 65)-alter to suit etc next b0 'Gathering automatically stops after 128 samples high 2 'Ch.2 green LED on to show data run ended (optional) '----------------------------------------------------------------------------------------