Hello all.
I have started playing around with a remote switch plug kit I got. I've seen on the internet that there are a couple of DIY projects controlling those plugs through a uC and an RF transmitter and I though that this could make a nice Picaxe project.
After reading about the protocol and especially looking at the code at this site I had a better understanding about what I needed to implement and the correct timing I had to use. I used a 20X2 chip running at 32MHz and I was able to turn on and off the plug.
This is the code I used to switch on a plug:
I'm trying to make the code run at 16MHz speed by altering the pulse length (waitShort). My target is to run this code on a 08M2 chip overclocked. Any ideas about what I could do to save me a few CPU cycles on the chip and run the code a bit faster at 16MHz speed?
I have started playing around with a remote switch plug kit I got. I've seen on the internet that there are a couple of DIY projects controlling those plugs through a uC and an RF transmitter and I though that this could make a nice Picaxe project.
After reading about the protocol and especially looking at the code at this site I had a better understanding about what I needed to implement and the correct timing I had to use. I used a 20X2 chip running at 32MHz and I was able to turn on and off the plug.
This is the code I used to switch on a plug:
Code:
'
' PicAxe remote switch controller
' Emulates the output from a PT2262 encoder chip.
'
' ver 0.1(Proof-Of-Concept), by Steliosm (steliosm@gmail.com)
' based on project rc-switch (http://code.google.com/p/rc-switch/)
'
'
' Overclock the chip
setfreq m32
' Define the timings - each pulse should be about 300-500uS depending on the receiver.
' The following timing value seem to work OK.
symbol waitShort = 150
symbol waitLong = 3 * waitShort
symbol waitSync = 31 * waitShort
'
' Bit-bang the RF Nexa protocol
'
main:
'
' This should be done in a better way :-)
'
for b0 = 1 to 3
' Group address (dip switches set at 10001)
gosub send0
gosub sendF
gosub sendF
gosub sendF
gosub send0
' Plug address (dip switches set at 01000)
gosub sendF
gosub send0
gosub sendF
gosub sendF
gosub sendF
' SendCommand (FF-on/F0-off)
gosub sendF
gosub sendF
' Send Sync
gosub sendSync
next
' End
end
send1:
' Send tri-State 1
for b1 = 1 to 2
high 4
pauseus waitLong
low 4
pauseus waitShort
next
return
send0:
' Send tri-State 0
for b1 = 1 to 2
high 4
pauseus waitShort
low 4
pauseus waitLong
next
return
sendF:
' Send tri-State F
high 4
pauseus waitShort
low 4
pauseus waitLong
high 4
pauseus waitLong
low 4
pauseus waitShort
return
sendSync:
' Send sync sequence
high 4
pauseus waitShort
low 4
pauseus waitSync
return
I'm trying to make the code run at 16MHz speed by altering the pulse length (waitShort). My target is to run this code on a 08M2 chip overclocked. Any ideas about what I could do to save me a few CPU cycles on the chip and run the code a bit faster at 16MHz speed?