A friend of mine is building a Lapse Pi motorised time-lapse rail and she asked me if I could make the required electronics. A time-lapse rail allows you to take time-lapse sequences during which the camera moves a short distance between each shot for artistic effect.
The electronics is not particularly complicated. A DC/DC converter is needed to convert the battery voltage of 12 V to 5 V for supplying the Raspberry Pi and then a few transistors are required to control the motor and the camera shutter.
DC/DC converter
The most complicated part is the DC/DC converter. Since I was only about to build one unit, I decided to try to minimize work, possibly at the expense of a non-optimal design in other respects, but still with decent power conversion efficiency. A linear regulator was out of the question as the efficiency in going from 12 V to 5 V is at most 5/12 = 42 %, so a more complicated switching DC/DC converter was clearly required.
I decided to buy a cheap car cigarette lighter to USB adapter which does the job of converting a voltage in the range of 12 to 24 V to 5 V to do the job. Good since it did not require any design work on my behalf. Or so I thought.
What I should have done is to check the power requirements of the Raspberry Pi. I somehow had assumed it could be driven by the current nominally available in a single USB port (500 mA), but it turns out that it needs 700 mA according to the schematics and 500 to 1000 mA according to this FAQ. The car-to-USB adapter I had bought unfortunately turned out to be designed with very little margin (not too surprising for a cheap consumer product). It started making an alarming whistling noise when the current exceeded 500 mA and for lower input voltages (like 8 V), the output voltage started dropping even at 400 mA. Ooops. Below is a plot of the output voltage vs output current for three different input voltages.
So, what to do? I took the converter apart to see if it were possible to modify it to make it more powerful. Inside I found a small PCB, see photo below.
The circuitry is based on an MC34063A, which is a rather old and simple DC/DC-converter chip made by e.g. Texas Instruments and ON Semiconductor. The way it was connected in the product was almost exactly like the step-down (buck) converter schematics given in figure 11 of the datasheet. The chip itself has a switch transistor that is able to handle 1.5 A, so this is not what limits the output current. Unfortunately, the transistor is an NPN darlington, so it has a fairly high voltage drop resulting in low efficiency, especially for low input voltages, so heating could be a problem for high output currents.
The component that primarily limits the available output current is however the inductor. It is relatively small and unlabeled (the black cylindrical component right above the text R5 in the picture above). I desoldered it and measured the inductance which turned out to be around 160 µH. This is smaller than the recommended value of 220 µH in figure 11 of the datasheet. I did not have any simple way of measuring how the inductance changed as a result of increased current, but it is very likely that the inductance starts to drop off significantly as the current reaches 500+ mA (there is a ripple current on top of the average output current that the inductor has to handle).
Replacing the inductor with a bigger one with smaller ESR (equivalent series resistance) and suitable for maybe 1.5 to 2 A and perhaps with a somewhat higher inductance seemed like a good modification to the circuit. But the NPN darlington also looked like it was in need of some improvement. Figure 12 of the datasheet shows how an external PNP transistor can be connected to boost the output current. An advantage is that the transistor can saturate and thus have a very small voltage drop (maybe 0.1 to 0.3 V or so) when it is on, which is good for efficiency. Power PNPs are however not know for their high current gains, so efficiency suffers due to all the wasted base current that is needed to reliably saturate the transistor.
It seemed like a modern PMOS transistor would be a better choice as it can have a very low on-resistance and not require any base (gate) current to keep it on. The switching losses should be relatively small since the switching frequency is so low for the MC34063A (well below 100 kHz).
At first my intention was to make the modifications on the original PCB, but with a new and much larger inductor and especially a lot of reconnections required to accommodate the external PMOS transistor, I realized that it was actually more practical to desolder the MC34063A and a few other components and put the modified circuitry on a stripboard.
I bought a new inductor (220 µH, 1.9 A) and used a PMOS power transistor I had at hand. The PMOS was actually half of an NMOS/PMOS pair in an SO8 package (an IRF7343) so I had to solder wires to some pins to adapt it to the stripboard.
I did also replace the electrolytic capacitors at the input and output (47 µF and 330 µF) with ones having higher capacitance (100 µF and 470 µF) and lower ESR. The resulting schematics and the physical board can be seen below.
I measured the output voltage and efficiency to see if the new design was any better than the original one. It turns out that it was. Below are graphs illustrating this.
So the new design is a great step forward both in terms of output current capability and efficiency. In terms of size and cost of components it is far from optimal, but those were not important design parameters. If a smaller and more cost effective design is desired, a more modern switcher with higher switching frequency and a custom board layout could be used.
Motor drive
The motor used is a simple 12 V DC-motor with a gearbox bringing the speed down to 15 RPM. To move the dolly a small distance, the motor is simply turned on for a short period of time (150 ms was used by David Hunt, the man behind the Lapse Pi). For the Raspberry Pi to be able to control the DC motor, we need a transistor that is able to handle the current of the motor. David Hunt used an NPN, but I decided to use an NMOS from the junk bin. Many different transistor models could be used. The main requirements are a low enough threshold voltage for the limited I/O voltages of the Raspberry Pi to turn it on and sufficient drain current capability. I happened to have an old P60N03LDG and this one works fine, although its 60 A maximum current is extreme overkill. The threshold voltage is 2.5 V maximum and the R Pi should have no trouble supplying a voltage higher than this on its 3.3 V I/O lines.
I added a series gate resistor to limit the gate charge/discharge current and a pull-down resistor to make sure the transistor is off if not actively driven. A flywheel diode is also mandatory to take care of the current from the collapsing magnetic field when the motor is switched off. A schematic is shown below.
Camera shutter control
For the shutter release, David Hunt suggests a single transistor that controls the shutter via a remote release cable. That might work for Canon cameras, but here we are dealing with Nikon and in my experience (based on a D300), you first have to ground the focus wire, wait for perhaps 300 ms and then ground the shutter wire. Therefore I used two GPIO pins on the Raspberry Pi, each controlling one signal from the camera. I used the same kind of 2.5 mm stereo jack that fits my existing remote release cable and for transistors I used BS108 NMOS transistors with a threshold voltage of at most 1.5 V. The schematics is shown below.
Raspberry Pi connector
I use the GPIO connector of the Raspberry Pi to both connect to the GPIO signals and to power the board. This eliminates the need for two separate connectors at the R Pi end of the cable. A minor disadvantage of not powering it through the micro USB connector is that the fuse on the R Pi is out of the circuit. A secondary side fuse could be added to the DC/DC converter board, but I think I will stick with just having a fuse on the primary side of the DC/DC.
Below is a photo of the whole thing, including the GPIO connector. The motor connects to the small green screw terminal (partly hidden on top center of the board) and the shutter release cable connects to the black stereo jack at the top left. The green power indicator LED can be removed to save some precious battery power.
David Hunt, the designer of the Lapse Pi, has now linked to this blog post from his article. Thanks David!
Hi Per, thanks for sharing your hard work. I came across your blog through David Hunt’s. I m happy to see that someone on this planet uses a Nikon for timelapses too ;-)
I m setting longterm timelapses devices using various Nikon models and raspberry pi. As some of them are installed in remote locations, I hook the whole set to a 12V battery with DC/DC converters for the Pi, the USB hub and a harddisk. I m facing some issues to power the Nikons from a 12V source. Would you by chance have a solution for this as it looks like Nikon inserted some kind of device or code to recognise when power to the camera is not coming from Nikon supplies (220V converter) so any other power source impairs or damage the camera? Thanks in advance. Laurent
Hi Laurent,
I am sorry, but I have not tried to power my camera from an external source, so I have no proven solutions to offer you, just some ideas.
If you have lots of battery capacity, you could use a DC/AC inverter to power a Nikon AC adapter directly. The efficiency is unlikely to be great and the AC adapter seems rather pricey to me, but no custom electronics is required.
A more efficient method might be to convert 12 V not to 230 V (or 110 V) AC, but to a high (150-320 V) DC-voltage and use that to power the AC adapter. A flyback converter might be suitable, but how to design one is perhaps not common knowledge. Some AC adapters are happy to run on DC as they anyway rectify the voltage before the conversion to a low DC voltage. But I am not sure if the Nikon adapter does that, so this is also a bit risky (in addition to being potentially dangerous due to the high voltages involved).
If your electronics knowledge is adequate and you are willing to risk the cost of a Nikon AC adapter, you could take it apart, salvage the parts that supposedly does the magic ID coding and build a DC/DC converter to provide a suitable DC voltage for the camera from you battery.
All three ideas are rather costly and the two latter ideas are also a bit risky as there is no guarantee for success, especially if you do not have adequate knowledge of electronics and electrical safety…
Sorry for not having any better solution at hand.
Per
Thanks for your feed back Per. You re right to mention that converting 12 V to 220 or 110 then to the Nikon body operating voltage using the Nikon adapter is possible but is not efficient. This is why I look for better options. I ll let you know what I can find. Be well. Laurent
Hello Laurent,
I use Nikon D90 camera and my battery more than 2000 shots. If you need more you can use battery grip which give you 2x more power. If this is still too small you can use cheap but not handy solution. You can connect 12V car battery with car DC/AC adaptor and then connect it to oryginal AC Nikon power adaptor. It will give you a lot of power but it’s very heavy.
Cheers
Hello Per,
I’m very keen to build a timelapse rig similar to David Hunt’s. All things mechanical I can handle, rig and mechanical design is what I do for work, however, electrickery is another matter! I know this is a big ask but is there any chance you could do an idiots guide on how to build your design including the strip board, when I say idiots guide I really mean what I say. Strangely, in a previous job I was a pcb layout designer but I always saw and approached that as a mechanical design so that as I had all the circuit information, this was in the days last century when most components only had legs or pins that went through holes! I plan to use a Canon on the rig, is your design Nikon specific?
Hope you can help
Best regards
Mike
Hi Mike,
I currently have no plans on writing a super-basic guide on how to build the electronics. For one thing it is hard to know how basic to go and it could become veeery long if I am to explain everything. But I think you can figure it all out by using the information in the above blog post in combination with info generally available on the Internet and perhaps a few specific questions in some suitable forum, like the EEV forums: http://www.eevblog.com/forum/ There is a beginners section there that may be suitable.
If you have specific questions about the design you can also ask them here.
Google for stuff you want to know. E.g. “stripboard design for beginners” gives this link that might be useful: http://www.zen22142.zen.co.uk/Prac/vero_circ/vero.htm
The only thing I think might be Nikon specific in the design is that I have two transistors to control both focus (half pressed shutter release) and shutter (fully pressed shutter release). I found that it was necessary on my D300 to first activate focus and then shutter. It seems like David Hunt does not need to do that on his Canon, so perhaps you can skip the transistor that controls the focus button.
Good luck!
Per
A solution for power Nikon cameras from 12v
http://www.instructables.com/id/Portable-DC-power-for-a-Nikon-D40-D40X-D60-D500/all/?lang=es
Hi Jope.
Thanks for the link. That looks like a reasonable way of home brewing a Nikon power adapter that runs on a car battery.
Hi Per,
thanks for sharing your work! It helped me alot.
I tried to build the 12V to 5V DC/DC converter according to your schematics. After failing the first time, I did some research and figured out that you mixed up the positions of GND and Cinv pin of the MC34063. My second attempt, with the switched positions, works great.
Further, (for all other noobs like me) the schematics show the BOTTOM view of the MC34063. And I replaced the IRF7343 with an IRF5305 which seems to do its job pretty well. I don’t know if this is be the best choice since my knowledge in electronics is pretty basic but it works.
Cheers,
Andi
Hi Andi,
Glad you got it to work.
The symbol representing MC34063 in the schematics is not intended to be a physical representation of the component, so the locations of the pins within the symbol are arbitrary. You have to look up the pin numbers corresponding to the pin names when you build the thing. Sorry that this caused confusion.
IRF5305 seems like overkill (it can handle more than 30 A), but it should work.
Per
Can you explain how you got the second GPIO output from the pi to control the focus and how you got the delay before triggering the shutter? I’ve built this rig but it doesn’t work on my D7000 and I found this which I hope will be the final hurdle before it works.
Hi Tim,
If you are using Python (like David Hunt who wrote the original article does), you have to extend his script a little bit. First define which pin to use for focus:
focuspin = 21
Then define how long delay you want between pressing down the shutter to focus and pressing it down to release the shutter:
focus_delay = 0.3
Then make sure to activate focus before the shutter inside the for-loop:
gpio.digitalWrite(focuspin,gpio.HIGH)
sleep(focus_delay)
gpio.digitalWrite(shutterpin,gpio.HIGH)
sleep(shutter_length)
gpio.digitalWrite(shutterpin,gpio.LOW)
gpio.digitalWrite(focuspin,gpio.LOW)
As you probably know, David’s code can be found here:
http://www.davidhunt.ie/motorised-time-lapse-rail-with-raspberry-pi/3/
Per
David’s site appears to be down
I’ve completed the Pi install and screen now shows the GUI works a treat,
But!
Anyone know how to connect the motors to the Pi?
If I use the pins described, these are used by the tft screen so impossible?
Stuck and I’ve got so far
Help appreciated
I was wondering about the transistors you used for the shutter release. I can’t seem to find them anywhere. Will any other transistor work? and how do you know which one?
Hi Damon,
You are right, BS108 seems to no longer be manufactured, but there are many others that will work. The main parameters to look out for are that they should be NMOS transistors in a convenient package with a low enough maximum threshold voltage (you want the output of the Raspberry Pi to be able to fully turn the transistor on). It should be less than 2 V. I searched on Digikey and found the following parts:
http://bit.ly/1GymJGM
ZVNL110A
ZVNL120A
TN0104N3-G
ZVN4424A
TN0702N3-G
TN0620N3-G
VN4012L-G
There are many others as well.
Also, I actually wrote a complete blog post about finding alternative components for the Lapse-Pi:
http://axotron.se/blog/finding-components-to-the-lapse-pi-2/
Hey there,
thanks for the write-up… built my own version so it was pretty useful.
For other people out there with nikons… you can also try just connecting both shutter and focus to the same circuit with camera in manual focus mode (basically the same as having a double circuit but without a delay) worked on my nikon d7000.
And also created controller software to be used over a web app on the phone along with a dumb down guide for the circuits/hardware. http://blog.koivistik.com/pilapserails-raspberrypi-time-lapse-rails/