I recently got a Lego Power Functions set and noticed that it uses an IR communications protocol for the remote control, and this got me thinking that it would be good to create my own remote control with a view to adding some automation.
To ensure correct detection of IR messages six 38 kHz cycles are transmitted as mark. Low bit consists of 6 cycles of IR and 10 “cycles” of pause, high bit of 6 cycles IR and 21 “cycles” of pause and start bit of 6 cycles IR and 39 “cycles” of pause.
Now I'm more used to dealing with serial protocols that talk about bits per second and the like, so my question is this: Can a PICAXE 08M running at 4MHz generate this 38kHz signal? What commands would I use, or would it literally be bit-banging on the output pin?
If the 08M isn't fast enough, what cheap hobby micros will be?
Thanks for that info. I have read the Picaxe manual and the IR commands appear to use the Sony SIRC protocol. The good news is that this also uses 38KHz, however the other parts of the protocol doesn’t seem to match up to what Lego uses, e.g:
"The SIRC protocol uses a 38KHz modulated infra-red signal consisting of a start bit (2.4ms) followed by 12 data bits (7 data bits and 5 device ID bits). Logic level 1 is transmitted as a 1.2 ms pulse, logic 0 as a 0.6ms pulse. Each bit is separated by a 0.6ms silence period."
Where as the Lego Power functions uses 16 data bits with timings of:
"Low bit range 316 - 526 us High bit range 526 – 947 us Start/stop bit range 947 – 1579 us"
So it appears that a 4MHz 08m would be fast enough, but I would need to do some bit-banging and implement the protocol myself? That might be a bit tricky without an oscilloscope or something…
Page 165 of Picaxe Manual 2 gives details of the PWMOUT command.
There is a wizard for calculating period and duty cycle given desired frequency and duty cycle as percentage. Assuming a duty cycle of 50% (which the diagrams in the Lego manual seem to indicate), this then generates a command of:
pwmout 2, 25, 53
So the question now is, can I get this to run for just 6 cycles?
I’ve got an oscilloscope now so I’m going to have a play… !