I own one of these small action cameras (SJcam SJ4000). I bought it because it’s small, and easy to take with you wherever you go. To make nice stable videos I mount it on a mini tripod. This got me thinking that it would be fun to have a little motor between the tripod and the camera to slowly pan the camera. That way I can make nice time lapse videos.
I happened to have a couple of 28byj48 stepper motors laying around, these little steppers motors have a gearbox and are 4096 steps for one rotation. They are pretty slow, so it’s ideal for this application. These motors are sold with a driver board that is basically an ULN2003 break out board.
To control the motor I decided to use 2 potentiometers, one to set the speed/time and one to set the angle I want the motor to move. 3 buttons are used to start/stop and set different panning modes. I happened to have a small I2C oled display so I used that to display the settings. For a micro controller I used an ATmega328 with Arduino bootloader.
Programming the device caused me a bit of a headache. The Arduino stepper library is totally unsuited in an application where you want to do more then just drive a stepper motor. So I looked for other smarter stepper libraries. After a lot of searching I found the stepperlab3 library. This library uses a timer interrupt which doesn’t interfere with the other code for the display and buttons. It is written to control a stepper motor with a H-bridge like the L293/L298. I first started modifying the library so I could use it with the ULN2003 chip. Which is just a darlington transistor array. Since the library contained a lot of code that I didn’t need I decided it was better to just copy the code I needed from the library to my Arduino sketch. I also found an interesting bit of code, an internal voltmeter that lets you measure the supply voltage of the ATmega. That way I can show the battery status on the oled. After a bit of programming I ended up with this:
I have programmed 3 modes which I can select with the top button. First mode is the manual mode, with the lower 2 buttons I can move the motor clockwise/counter-clockwise and with the bottom potentiometer I can set the speed. In the second mode the 2 potentiometers are used to set the angle and the time in which the motor will move. With the red button I can select the direction. The green button is used to start the panning. The third mode is similar to the second mode but in this mode the motor will pan the set angle and then return to it’s starting position. You can download my sketch here.
To make the device usable I designed a custom PCB in Eagle. This time I used a lot of SMD components to make it as compact as possible. I don’t have much experience in soldering SMD components so this was a bit of a risk. The board has an ATmega328P-AU and an 8MHz SMD ceramic resonator. I bought an ULN2003 IC in an SMD package from Tayda electronics. To power the device I use a singe cell Li-ion battery. To keep things simple I did not put a voltage regulator on the board. To easily charge the battery I use a TP4056 IC, it comes in a SOP-8 package and only needs very little external components to make it work. The board has a micro USB connector to charge the battery. I use a 3 position switch to select on / off / charging. There are 2 SMD leds on the board to show the status of the charging. I had the PCB’s made by dirty pcbs. The Eagle files of the board: Bajduino time lapse Eagle files
Soldering the ATmega328P-AU, ULN2003 and TP4056 was not to difficult. But I was not successful in soldering the tiny ceramic resonator to the board. After a couple of attempts I soldered a through the hole resonator to the pads. I should have just used the internal 8MHz clock of the ATmega328 and not used a resonator / crystal.
I then started designing a box for my device in Blender. This was a bit harder then I thought. Blender has quite a steep learning curve. It’s not the easiest program to design accurate mechanical parts. I think I’m going to give up on Blender and have since installed Freecad. I then printed my box on my new 3D printer. The print is not the cleanest, I was still learning how my 3D printer worked when I printed it.
I fixed the PCB to the box by using small self tapping screws. In the bottom of the box I glued a big nut that has thread that fits a tripod. On the motor axle I attached a coupling with thread that fits in to a camera. A friend made it for me on a lathe.
I’m quite happy with how this project turned out. But I wished I could have made it a lot smaller, maybe I should design a new version that is halve the size 🙂
5 responses to “Arduino time lapse – camera pan device”
Neat project! Would you be willing to share the circuit diagram?
I’ve just added a link to the Eagle files of the PCB.
That’s even better. Thanks!
[…] For mroe detail: Arduino time lapse – camera pan device […]
[…] For More Details: Arduino time lapse – camera pan device […]