{"id":99,"date":"2014-01-05T16:06:14","date_gmt":"2014-01-05T15:06:14","guid":{"rendered":"http:\/\/axotron.se\/blog\/?p=99"},"modified":"2014-01-05T16:06:14","modified_gmt":"2014-01-05T15:06:14","slug":"electronics-for-the-lapse-pi-motorised-time-lapse-rail","status":"publish","type":"post","link":"https:\/\/axotron.se\/blog\/electronics-for-the-lapse-pi-motorised-time-lapse-rail\/","title":{"rendered":"Electronics for the Lapse Pi Motorised Time-Lapse Rail"},"content":{"rendered":"<p>A friend of mine is building a <a title=\"Lapse Pi\" href=\"http:\/\/www.davidhunt.ie\/?p=2822&amp;page=1\" target=\"_blank\">Lapse Pi motorised time-lapse rail <\/a>and she asked me if I could make the required electronics. A <a href=\"http:\/\/en.wikipedia.org\/wiki\/Time-lapse_photography\" target=\"_blank\">time-lapse<\/a> rail allows you to take time-lapse sequences during which the camera moves a short distance between each shot for artistic effect.<\/p>\n<p>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.<\/p>\n<h3>DC\/DC converter<\/h3>\n<p>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.<\/p>\n<p>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.<\/p>\n<figure id=\"attachment_117\" aria-describedby=\"caption-attachment-117\" style=\"width: 1000px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/USB-charger.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-117\" alt=\"Cigarette lighter to USB adapter\" src=\"http:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/USB-charger.jpg\" width=\"1000\" height=\"667\" srcset=\"https:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/USB-charger.jpg 1000w, https:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/USB-charger-300x200.jpg 300w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/a><figcaption id=\"caption-attachment-117\" class=\"wp-caption-text\">Cigarette lighter to USB adapter<\/figcaption><\/figure>\n<p>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 <a href=\"http:\/\/www.raspberrypi.org\/wp-content\/uploads\/2012\/04\/Raspberry-Pi-Schematics-R1.0.pdf\" target=\"_blank\">schematics<\/a> and <a href=\"http:\/\/www.raspberrypi.org\/faqs#powerReqs\" target=\"_blank\">500 to 1000 mA according to this FAQ<\/a>. 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.<\/p>\n<figure id=\"attachment_129\" aria-describedby=\"caption-attachment-129\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/output_voltage_original.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-129\" alt=\"Output voltage plot\" src=\"http:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/output_voltage_original.png\" width=\"600\" height=\"450\" srcset=\"https:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/output_voltage_original.png 600w, https:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/output_voltage_original-300x225.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><figcaption id=\"caption-attachment-129\" class=\"wp-caption-text\">Output voltage vs output current for a few different input voltages.<\/figcaption><\/figure>\n<p>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.<\/p>\n<figure id=\"attachment_118\" aria-describedby=\"caption-attachment-118\" style=\"width: 1000px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/USB-charger_open.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-118\" alt=\"Innards of 12 V to USB adapter\" src=\"http:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/USB-charger_open.jpg\" width=\"1000\" height=\"402\" srcset=\"https:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/USB-charger_open.jpg 1000w, https:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/USB-charger_open-300x120.jpg 300w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/a><figcaption id=\"caption-attachment-118\" class=\"wp-caption-text\">Innards of 12 V to USB adapter<\/figcaption><\/figure>\n<p>The circuitry is based on an <a href=\"http:\/\/www.onsemi.com\/PowerSolutions\/product.do?id=MC34063A\" target=\"_blank\">MC34063A<\/a>, 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 <a href=\"http:\/\/www.onsemi.com\/pub\/Collateral\/MC34063A-D.PDF\" target=\"_blank\">datasheet<\/a>. 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.<\/p>\n<p>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 \u00b5H. This is smaller than the recommended value of 220 \u00b5H 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).<\/p>\n<p>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.<\/p>\n<p>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).<\/p>\n<p>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.<\/p>\n<figure id=\"attachment_122\" aria-describedby=\"caption-attachment-122\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/PCB-remains.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-122 \" alt=\"PCB-remains\" src=\"http:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/PCB-remains.jpg\" width=\"600\" height=\"400\" srcset=\"https:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/PCB-remains.jpg 1000w, https:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/PCB-remains-300x199.jpg 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><figcaption id=\"caption-attachment-122\" class=\"wp-caption-text\">The remains of the original DC\/DC converter board with the useful components removed. Original inductor (L1) at lower right.<\/figcaption><\/figure>\n<p>I bought a new inductor (220 \u00b5H, 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.<\/p>\n<p>I did also replace the electrolytic capacitors at the input and output (47 \u00b5F and 330 \u00b5F) with ones having higher capacitance (100 \u00b5F and 470 \u00b5F) and lower ESR. The resulting schematics and the physical board can be seen below.<\/p>\n<figure id=\"attachment_125\" aria-describedby=\"caption-attachment-125\" style=\"width: 1000px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/DCDC_sch1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-125\" alt=\"Schematics of DC\/DC converter\" src=\"http:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/DCDC_sch1.png\" width=\"1000\" height=\"440\" srcset=\"https:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/DCDC_sch1.png 1000w, https:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/DCDC_sch1-300x132.png 300w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/a><figcaption id=\"caption-attachment-125\" class=\"wp-caption-text\">Schematics of DC\/DC converter<\/figcaption><\/figure>\n<figure id=\"attachment_121\" aria-describedby=\"caption-attachment-121\" style=\"width: 1000px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/DCDC_stripboard.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-121\" alt=\"DC\/DC converter built on stripboard\" src=\"http:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/DCDC_stripboard.jpg\" width=\"1000\" height=\"667\" srcset=\"https:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/DCDC_stripboard.jpg 1000w, https:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/DCDC_stripboard-300x200.jpg 300w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/a><figcaption id=\"caption-attachment-121\" class=\"wp-caption-text\">DC\/DC converter built on stripboard<\/figcaption><\/figure>\n<p>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.<\/p>\n<figure id=\"attachment_130\" aria-describedby=\"caption-attachment-130\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/output_voltage.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-130\" alt=\"Output voltage plot\" src=\"http:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/output_voltage.png\" width=\"600\" height=\"450\" srcset=\"https:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/output_voltage.png 600w, https:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/output_voltage-300x225.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><figcaption id=\"caption-attachment-130\" class=\"wp-caption-text\">Output voltage vs output current for a few different input voltages. The new design works fine up to at least 1.2 A.<\/figcaption><\/figure>\n<figure id=\"attachment_141\" aria-describedby=\"caption-attachment-141\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/efficiency.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-141\" alt=\"Efficiency plot\" src=\"http:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/efficiency.png\" width=\"600\" height=\"450\" srcset=\"https:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/efficiency.png 600w, https:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/efficiency-300x225.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><figcaption id=\"caption-attachment-141\" class=\"wp-caption-text\">Efficiency vs output current for a few different input voltages for the original and new DC\/DC converter designs. The efficiency of the new design is well over 80% for currents between 400 and 1000 mA, whereas the original design never reached 80% efficiency and was unable to supply more than 600 mA.<\/figcaption><\/figure>\n<p>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.<\/p>\n<h3>Motor drive<\/h3>\n<p>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.<\/p>\n<p>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.<\/p>\n<figure id=\"attachment_131\" aria-describedby=\"caption-attachment-131\" style=\"width: 537px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/Motor_NMOS.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-131\" alt=\"Schematics of motor drive transistor\" src=\"http:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/Motor_NMOS.png\" width=\"537\" height=\"419\" srcset=\"https:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/Motor_NMOS.png 537w, https:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/Motor_NMOS-300x234.png 300w\" sizes=\"auto, (max-width: 537px) 100vw, 537px\" \/><\/a><figcaption id=\"caption-attachment-131\" class=\"wp-caption-text\">Schematics of motor drive (a much wimpier transistor can be used).<\/figcaption><\/figure>\n<h3>Camera shutter control<\/h3>\n<p>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.<\/p>\n<figure id=\"attachment_133\" aria-describedby=\"caption-attachment-133\" style=\"width: 833px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/Shutter_NMOS.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-133\" alt=\"Schematics of focus and shutter control.\" src=\"http:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/Shutter_NMOS.png\" width=\"833\" height=\"344\" srcset=\"https:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/Shutter_NMOS.png 833w, https:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/Shutter_NMOS-300x123.png 300w\" sizes=\"auto, (max-width: 833px) 100vw, 833px\" \/><\/a><figcaption id=\"caption-attachment-133\" class=\"wp-caption-text\">Schematics of focus and shutter control<\/figcaption><\/figure>\n<h3>Raspberry Pi connector<\/h3>\n<p>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.<\/p>\n<p>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.<\/p>\n<figure id=\"attachment_134\" aria-describedby=\"caption-attachment-134\" style=\"width: 1000px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/Lapse_Pi_electronics.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-134\" alt=\"The finished board with all the electronics.\" src=\"http:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/Lapse_Pi_electronics.jpg\" width=\"1000\" height=\"666\" srcset=\"https:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/Lapse_Pi_electronics.jpg 1000w, https:\/\/axotron.se\/blog\/wp-content\/uploads\/2014\/01\/Lapse_Pi_electronics-300x199.jpg 300w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/a><figcaption id=\"caption-attachment-134\" class=\"wp-caption-text\">The finished board with all the electronics.<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 &hellip; <a href=\"https:\/\/axotron.se\/blog\/electronics-for-the-lapse-pi-motorised-time-lapse-rail\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Electronics for the Lapse Pi Motorised Time-Lapse Rail<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,11],"tags":[],"class_list":["post-99","post","type-post","status-publish","format-standard","hentry","category-electronics","category-photography"],"_links":{"self":[{"href":"https:\/\/axotron.se\/blog\/wp-json\/wp\/v2\/posts\/99","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/axotron.se\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/axotron.se\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/axotron.se\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/axotron.se\/blog\/wp-json\/wp\/v2\/comments?post=99"}],"version-history":[{"count":14,"href":"https:\/\/axotron.se\/blog\/wp-json\/wp\/v2\/posts\/99\/revisions"}],"predecessor-version":[{"id":288,"href":"https:\/\/axotron.se\/blog\/wp-json\/wp\/v2\/posts\/99\/revisions\/288"}],"wp:attachment":[{"href":"https:\/\/axotron.se\/blog\/wp-json\/wp\/v2\/media?parent=99"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/axotron.se\/blog\/wp-json\/wp\/v2\/categories?post=99"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/axotron.se\/blog\/wp-json\/wp\/v2\/tags?post=99"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}