Category Archives: Photography

Electronics for the Lapse Pi Motorised Time-Lapse Rail

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.

Cigarette lighter to USB adapter
Cigarette lighter to USB adapter

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.

Output voltage plot
Output voltage vs output current for a few 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.

Innards of 12 V to USB adapter
Innards of 12 V to USB adapter

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.

PCB-remains
The remains of the original DC/DC converter board with the useful components removed. Original inductor (L1) at lower right.

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.

Schematics of DC/DC converter
Schematics of DC/DC converter
DC/DC converter built on stripboard
DC/DC converter built on stripboard

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.

Output voltage plot
Output voltage vs output current for a few different input voltages. The new design works fine up to at least 1.2 A.
Efficiency plot
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.

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.

Schematics of motor drive transistor
Schematics of motor drive (a much wimpier transistor can be used).

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.

Schematics of focus and shutter control.
Schematics of focus and shutter control

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.

The finished board with all the electronics.
The finished board with all the electronics.

 

Successful Sensor Cleaning

For a rather long time – months if not years – I have been plagued by a a few pieces of dust on the sensor of my DSLR camera. On a previous camera I had, I cleaned the sensor a couple of times using a special (rather expensive) liquid called Eclipse and equally special (and also rather expensive) lint-free cloth. My experience was that this wet method gave mixed results and often resulted in frustrating new patterns of dirt (streaks or new dust) on the sensor, requiring try after try before an acceptable result was perhaps achieved.

My current camera is a Nikon D300 and it has a built in sensor cleaning function that vibrates the sensor (or rather the filter in front of it). Executing this function removes some dust, but not all, so something more had to be done on this camera as well.

To see the dust in detail I took a several second exposure of a white surface while having the camera much out of focus and moving it around to get as little structure as possible from the photo subject so that just the dust would produce a pattern. Then I did “auto contrast” in Photoshop to bring out the details of the dust. The below picture is the result. A very annoying dust squiggle that had disturbed many pictures is very conspicuous along with many small dots.

Dust photo before cleaning.
Dust photo before cleaning.

The squiggle was the most important to get  rid of, and since I did not like the cumbersome wet method very much I decided to try something different.

So I went and bought a can of “Air Duster”. Apparently this product does not contain air, but rather propane and butane, but that is probably not particularly important for the end result (as long as the ventilation is appropriate).

After a series of short blows to the sensor I put the lens on and took a new photo of the dust in the same way as before. The result is shown below.

Dust photo after sensor cleaning using compressed "air".
Dust photo after sensor cleaning using compressed “air”.

As can be seen, the squiggle is gone and so are many of the small dots as well. A few dots seem to have moved. The dots that remain are not ideal, but I have not had much issue with this kind of dust in real pictures, so for the moment I stopped at this stage. More air-dusting is otherwise likely to remove more of the dust.

So all in all I think this was rather successful and much simpler than the wet method.

Much more thorough information on sensor cleaning can be found on Thom Hogan’s site. I just wanted to put this post out there to maybe encourage other people to try this relatively effortless and inexpensive method instead of putting it off like I did for such a long time.

More time-lapse photography

I wanted to make more time-lapse videos of the magnetic putty doing other tricks. For this I decided to also add some new features to the time-lapse controller, namely the ability to dynamically increase and decrease the rate at which the pictures were taken.

The reason I wanted this functionality is that sometimes things happen more quickly and sometimes more slowly, so being able to adjust the shutter rate seemed like it would allow more interesting videos to be created. It was not particularly difficult to implement this and the resulting code can be found here:

Version 0.2 of the Arduino time-lapse controller sketch.

With these new features I am firmly beyond the abilities of the built in time-lapse function of the D300 camera, so now there is at last a good motive to build an external time-lapse controller (in addition to the fun of it).

I made use of the new functionality while recording three new videos of strands of magnetic putty being pulled up towards a magnet. The result can be seen below.

I still am not sure what causes the flickering in the videos as I supply the LED light from a lab power supply set up to function as a constant current source. The only other light source in the room is my computer monitor which is aimed away from the scene.