12.07.2015 Views

PICAXE Manual Section 1 - TechnoPujades - Free

PICAXE Manual Section 1 - TechnoPujades - Free

PICAXE Manual Section 1 - TechnoPujades - Free

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

www.picaxe.co.uk<strong>Section</strong> 1 66GETTING STARTEDTutorial 7 - Using DebugWhen using analogue sensors it is often necessary to calculate the ‘threshold’value necessary for the program (ie the values 70 and 120 in the tutorial 6program). The debug command provides an easy way to see the ‘real-time’ valueof a sensor, so that the threshold value can be calculated by experimentation.main:readadc 1,b0debug b0pause 500goto main‘ make a label called main‘ read channel 1 into variable b0‘ transmit value to computer screen‘ short delay‘ jump back to the startAfter this program is run a ‘debug’ window showing thevalue of variable b0 will appear on the computer screen.As the Light falling on the LDR sensor is altered, thevariable value will show the current sensor reading.The debug window opens automatically after adownload, but can also be opened manually at any timevia the <strong>PICAXE</strong>>Debug menu.Tutorial 8 - Using Serial Terminal with SertxdAll <strong>PICAXE</strong> variants support the debug command.However the M and X parts also support more complex serial debug messages byuse of the sertxd command, which sends a user defined serial string to thecomputer (at baud rate 4800). This can be displayed by the included SerialTerminal function (<strong>PICAXE</strong>>Terminal menu). The Serial Terminal can also beautomatically opened every time a download takes place by theView>Options>Options menu.main:‘ make a label called mainreadtemp 1,b0 ‘ read channel 1 into variable b0sertxd (“The value is “,#b0,cr,lf)pause 500‘ short delaygoto main‘ jump back to the startThe sertxd command transmits the string “The value is”followed by the ASCII string of the current5Vvalue of the variable b1 (the # prefix to thevariable indicates an ASCII stringrepresenting the correct value is to betransmitted). The CR and LF constants are temperaturesensorpre-defined values (13 and 10) that causethe serial terminal to display a newline foreach value so that the display updatescorrectly.0VThis program uses the readtempcommand to read the temperature from a DS18B20 digital temperature sensorconnected to input 1.revolutionDS18B20V+data0V(c) Revolution Education Ltd. Email: info@rev-ed.co.uk Web: www.rev-ed.co.ukVersion 6.9 07/2009All rights reserved.4k7inputpinV+0V<strong>PICAXE</strong>NB: most project boardsare pre-fitted with a pulldownresistor on the inputpin. This must be removedto use the temp. sensor.66

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!