Hi all,
As with Ferroto, I am a software guy trying to learn a bit about hardware and more specifically PIC micros.
My project is a device to let my SLR camera take time-lapse video by generating IR pulses on a variable timer.
The IR pulse-generating routine is in assembler as I needed very fine control over timings. The signal needed is 4 seperate timed pulses, each pulse turning the LED on/off at just over 38Khz. I got the timing specifics from
http://www.bigmike.it/ircontrol/ but haven't looked at his code or schematics. I used the MPLab simulator to test my timing code and to my surprise I haven't had to touch that code at all since moving to a real PIC as the pulse triggers the shutter every time. C is used to to control the overall program outside of the IR pulse and has needed some debugging though.
The main 2 debugging problems have been -
* PIC was constantly resetting several times per second. I eventually realised that this was because I had a couple of pins that were floating and not tied to anything. I linked them all to ground and it was stable.
* Sleep mode. As this is running off 2xAA batteries I want to make it use as little power as possible. So I was trying to get it to sleep for a second with the WDT, then wake up to see if it was time to carry on or just go back to sleep again. In the simulator it worked perfectly but not on my breadboard. After hours of trying different things I found it was because you have to manually disable the oscillator and tell it to use idle mode before calling sleep. Seems a bit of a messy way to do things, I would expect the 'sleep' opcode to do that itself. I get some drift on the interval as well. Partly this is because the WDT can't wake up after exactly 1 second, it is slightly over at 1.024s. And partly because the oscillator takes a short time to come back up to speed before carrying on with code. So if I set an interval of 60 seconds it actually waits about 65. It is accurate enough for my purposes though.
I was interested in estimating the battery life but I'm not sure if the voltage drop on batteries is linear? From the EEV video on rechargeables I wouldn't be surprised if they weren't as the charging wasn't linear. I left it running for 2 hours with a 2 second interval (the most power consuming as there is no sleep for 1 second of each cycle while a status LED is on) and my (cheap) multimeter shows that it went from 3.22v and 9.0ma down to 3.16v and 8.9ma over that time. I read it a few times in the middle and it seemed consistent with it dropping slowly. I'm happy that it will last a few tens of hours anyway so will easily last for my 2 week holiday which is a few days away.
I've now got it on a home-made PCB and just got a few code tweaks to do to have this version done. It uses a 8-pin DIP switch to set the interval (seconds) in binary but I need to remap this in software. I was trying to get it directly connect so pin 0 of the DIP was pin B0 on the PIC and so on. But it made the routing terrible so I just linked up which ever pin on port B was closest to the next DIP pin and will make my code translate the bits to the right order. It is housed in an old DVD remote just for the sake of having an integrated battery holder right now.
For a final version I want to use a more appropriate PIC, currently using the PIC18F1320 which is a bit beefy for what I need it for. I also want to do away with the DIP switches and use a few buttons and a display to change the duration. And make a PCB with solder pads big enough to actually heat them properly with my soldering iron(and a better tip), looks a mess atm
![Smiley :)](https://www.eevblog.com/forum/Smileys/default/smiley.gif)
.
I'll see if I can take some pics later and attach them, I've also got the first test video on youtube but I can't look up the link atm as it is blocked from work (name is 'time lapse test', usename 'mrstratofish' if you care to search for it before then).