headerphoto

Picaxe sensor and controller boards

 

 

Sense inputs. Control devices

This is the generic picaxe board. It can sense whether something is on or off, such as a switch. It can also sense a voltage between 0 and 5V. The board can also control a relay or output a voltage 0 to 5V.

These boards translate a real world value and translate it to a data packet. The packet is sent out via an RS232 connection to another board. You can flick a switch and have a relay change on another board. The other board could be connected directly to this board, or via a router board, or via a wireless link.

Schematic is here

Boards only have some components installed, depending on their function.

An example of picaxe code to sense a value

main:
 rem where M is start (or runs M.COM later), CR=13,rr=random bytes Alpha=8 bytes name source
 rem Beta   =8 bytes destination,t=1, d=data bytes, cc=2 byte checksum of all previous bytes
 random w0 rem order b0 or b1 doesn't really matter
 rem read the switch position
 if pin2=1 then
  b2=1
     else
       b2=0
 endif       
 rem readadc 2,b2 rem get a value
 rem w6 is the checksum msb first so split to b13 then b12
 w6="M"+13+b0+b1
 w6=w6+ "I"+"O"+"T"+"A"+" "+" "+" "+" " rem 4 spaces
 w6=w6+"A"+"L"+"P"+"H"+"A"+" "+" "+" " rem 3 spaces
 w6=w6+1 rem message type
 w6=w6+b2+b3+b4+b5+b6+b7+b8+b9 rem checksum of data bytes
 serout 0,T1200,("M",13,b0,b1,"IOTA    ALPHA   ",1,b2,b3,b4,b5,b6,b7,b8,b9,b13,b12)
 high 4
 pause 100 rem flash led to indicate data transmission
 low 4
 pause 30000
 goto main

And an example of switching a relay

main:
 rem insert the board name below as part of serin. Board doesn't really care where data came from
 rem name is up to 8 bytes with spaces, followed by a 1 for message type 1
 rem then 8 data bytes and w6 is the sum of the 8 bytes
 serin 3,T1200,("ALPHA   ",1),b2,b3,b4,b5,b6,b7,b8,b9,b13,b12
 rem no checksum as checksum is the entire packet and this can't capture the entire packet
 rem can always do a smaller checksum in b2 to b9, eg make all equal if sending one byte
 high 4
 pause 200 rem flash led to indicate a packet arrived for this board
 low 4
 if b2=1 then
  high 1 rem relay on
    else 
       low 1 rem relay off
 endif      
 goto main

Picaxe boards can be programmed via a serial cable using free software from Revolution Education