Micro based PIR to IR remote
converter. After the third attack on my car in 6 weeks, loosing 35 litres
of fuel and generally having my day stuffed up - I got really
pissed off and embarked on the EKM-1 surveillance camera system. Next time I
want to get the act on video. My first thought was to keep it
simple and use a PIR (passive Infra-red) motion detector to set
off an alarm in my bedroom - then I would manually start my VCR
and record video from a low-light
camera. I got carried away and built an automatic system which
starts the VCR recording and stops four minutes after the last PIR
event. The only practical way to do this is via the IR (infrared )
remote control sensor. There was a kit available which used a
dedicated "learning" remote control to send the record
and stop code but this seemed a bit crude and expensive. Mike
pointed me to the www.hut.fi/Misc/Electronics/opto.html
web page. Here I found lots of interesting stuff includingfalcon.arts.cornell.edu/~dnegro/IR/REMOTES/PANASONI.HTML
which had the control codes, modulation and encoding protocols for
panasonic VCRs - which is what I have. I was half way through
another micro project - a pump controller when IR remote
control gained priority. The pump controller schematic looks
something like this. It's a multi-purpose PCB which also works as
a loo-fan controller. For the
pump controller a couple of zener diodes in the switch scanning
inferface (top left) have been replaced with 1uF caps and the
inductor and catch diode (bottom right) are left off. Now the software - | ||
; IR pulsing routines Tpulse: ; a series of 13 cycles with 16
uSec on and 15 uSec off. |
||
Timing the spaces between the pulses is even easier using a
simple delay loop. Then you have enough code to send ones and
zeros to the VCR. | ||
ldi
counter3,48 ; 1 cycle = setup for 48 bit code ; |
||
The subroutine "ttime" is just a 400 microsecond delay. Note the the data stream ends with a terminate bit otherswise the last data bit couldn't be decoded. Before the data is sent the remote sends a longer burst (nom 10T) of carrier followed by a space (nom 4T). This is partly to allow the receiver AGC (auto gain control) to adjust. Anyway my first attempt failed. My CRO was at a friends so I was working blind. I'm still not sure what the bug was as the bug I later found wasn't in this version. A blown LED perhaps. I used the frequency function in my multimeter to check loop timing and found the RC oscillator in the micro was running about 5 percent slow. To be on the safe side I added a 12mHz ceramic resonator and recoded for a 12 meg clock. Still no luck and still no CRO. There were too many unknowns. I wasn't even sure the data I had was for my model VCR! Next day I made a simple circuit to detected IR pulses. I used a 555 timer as a schmitt trigger with an IR photodiode detecting the IR. A cmos gate, opamp or comparitor would have served equally well. I had a visible led at the output and also fed the signal into my soundblaster card. I used wave-studio which came with the SB card to capture the data stream @ 48kHz. The wave file is here - pana-remote.wav. The carrier is supressed by the SB input filters but the data stream is clearly visible.
A problem with the system is there is no way I know of to place the VCR in a know state. In normal use you can see what it's doing. But there is no easy way for the micro to detect what the VCR is up to. There is also no way to put the VCR in totally know state. The problem stems from the many controls which toggle a function - for example sending the "input select" code just changes the input from tuner to aux or visa versa but leave you none the wiser as to which input is selected. So to be triggered by the intruder the VCR has to be ON, not recording and not in timer-record mode. It's quite possible other control codes exist that we don't know about. The input select problem can be gotten around because sending the VCR a channel code (as in TV channel) puts the VCR into a TV/tuner mode. So my record sequence consists of CHAN1,INPUT-SELECT and RECORD codes. Originally I sent each code once with a delay between codes and found it the be unreliable. The real remote doesn't just send a code once, it keeps sending the code as long as the button is pressed. Repeating each code 4 times worked well, repeating 10 times didn't work well as the input select would often toggle more than once - I'm not sure why. Anyhow I'm back to 4 repeats and it hasn't missed a beat since. Now I have lots of video of Eddie driving the car in and out or walking past with firewood - riveting stuff. There are even some shots in the dark to add that spooky X-files feel to it :) The pump controller scanned a 2 by 3 switch matrix (6 switches) . I modified to code to only read 2 switches and freed up 2 port lines in the process. One of these (probably both next version) goes high when recording. This is optionally to turn the IR light source on. It could also be used to sound a buzzer. The PIR unit has a simple switch contact which interfaced easily to the modified pump switch scanning routine. Details about the switch interface and software will be available when I finish the pump project and its web page. I'm fairly happy with my controller but the camera is another matter. Download the program source here Ir1meg.asm |