Step 6Receiver circuit and picaxe code
The transmitter code is as follows:
main:serout 1,N2400,("UUUUUUUUUUUUUTW",b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13)
' T and W = ascii &H54 and &H57 = 0100 and 0111 = equal 1s and 0s
'b0=random number
'b1=random number
'b2=to device
'b3=reverse
'b4=messagetype
'b5=reverse
'b6/b7 = data 1 and reverse
'b8,b9 = data 2
'b10,b11 = data 3
'b12,b13 = data 4
random w0 ' random number used to identify messages when using multiple repeaters
b2=5' to device number...
b3=255-b2
b4=126' random number for testing
b5=255-b4
b6=0' random number for testing
b7=255-b6
b8=1' random number for testing
b9=255-b8
b10=2' random number for testing
b11=255-b10
b12=3' checksum - any value
b13=255-b12
pause 60000' transmit once per minute
goto main
And the receiver code:
main: serin 4,N2400,("TW"),b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13
b13=255-b13' inverse again only need to really test one
if b12=b13 then
for b12=0 to 55
high 2
pause 100' flash led once a second for a minute
low 2
pause 900
next
endif
goto main
The transmitter sends a packet once per minute - once debugged this ought to be decreased to every 15 mins or 30mins to avoid interference to neighbours. The "ÂUUUU"Â at the beginning of the packet is binary for 01010101 which balances the Rx unit. The protocol uses a form of Manchester coding where the number of 1's and 0's is kept as equal as possible, and this is done by sending the inverse of each byte after the byte is sent. Without this the packets sometimes don't get through if they are sending lots of binary zeros. A checksum at the end must be valid before the data is processed. The receiver flashes a led for 55 seconds when a packet is received and once debugged, this could be changed to some other acknowledgement.
| « Previous Step | Download PDFView All Steps | Next Step » |
![]() |
Add Comment
|










































