Getting started and example I/O needed for OpenTRV.
DHD20130117: getting the AXE091 kit up and running (using mains power supply).
PICAXE AXE027 USB plugged into Window 7 laptop running the PICAXE Programming Editor, all W7 drivers for AXE027 installed. Under options select the right COM port and tell the editor that an 18M2 chip is being used.
Wired L1 (LED 1 via 330R to 0V) to PICAXE 18M2 pin 7 (B.1), see 18M2 pinout.
Using following sample program to flash the LED from the PICAXE tutorial:
do high B.1 ; switch on output B.1 pause 1000 ; wait 1 second low B.1 ; switch off output B.1 pause 1000 ; wait 1 second loop ; loop back to start
Firstly running it in the simulator, I can see the B.1 pin toggling.
Then PICAXE --> Program and the LED on the board is flashing! Wooooo!
Similarly, for the Mac, with AXEPAD, tell it that an 18M2 is being used, tell it to find the AXE027 USB connection, and a new program can be sent down the wire.
(If you don't specify the right PICAXE chip in Options, the program download silently fails.)
And by inserting the following line into the loop I have the core of sending debug information back up the wire to the editor's terminal (at 4800 baud):
sertxd("Hello",13,10)
Note that unplugging the USB seemsto case the sertxd to block for a little while, but not totally; the LED still flashes.
This shows multi-bit output and the internal PRNG.
In addition to wiring B.1 (pin 7) to LED1, wire B.2 (pin 8) to LED 2 and B.3 (pin 8) to LED3.
Ahoy flickering LEDs:
let dirsB = %00001110 ; B.1/.2/.3 outputs. let w0 = 42 ; start seed do random w0 let pinsB = w0 pause 100 loop
In place of the "pause 100" the "debug" command can be used, and on the Windows Editor the word/byte values, as well as ports and 'time' are shown live.
Connect the TMP (DS18B20 output) to C.7 (18M2 pin 16) and use the following code to sample and show the temperature rounded to whole degrees C every couple of seconds or so, and nominally in power-save mode between samples:
do readtemp C.7, w0 sertxd("T=",#w0,"C",13,10) sleep 1 loop
and I see lines such as:
T=18C T=18C T=18C
with the temperature rising when I touch my finger on the DS18B20.
The slightly more advanced code shows raw temperature in 16ths of a degree C too:
do readtemp12 C.7, w1 let w0 = w1 / 16; sertxd("T=",#w0,"C, raw=",#w1,13,10) sleep 1 loop
and that produces output such as:
T=19C, raw=308 T=19C, raw=308 T=19C, raw=309
Adding a connection from C.1 (18M2 pin 18) to POT (the centre tap of a potentiometer / variable resistor from 0V to V+), which could be a thumbwheel in a grown-up implementation, and upgrading the code a little to:
do readtemp12 C.7, w1 let w0 = w1 / 16; readadc C.1,b4 sertxd("T=",#w0,"C, raw=",#w1,", pot=",#b4,13,10) sleep 1 loop
shows 'pot=' values ranging from 0 to 255 as I adjust the potentiometer, and this could clearly be scaled and compared with the temperature output to decide whether to call for heat or not for example, or light status LEDs.