Want to take incredible time-lapse video images? This time-lapse slider will enable you to introduce motion into videos, to add genuine WOW factor; and all you need is a basic camera.
We’ve all seen movies that include those amazing time-lapse videos of fast-moving cloud patterns or the depths of the Milky Way. But have you ever wondered how you can create that dynamic, smooth motion in your own videos, making them more reminiscent of Hollywood blockbusters? The dolly is a fundamental piece of film-making equipment; it allows a smooth transition to bring your audience into the action. However, with the advent of digital cameras, we now all have the ability - when coupled with a little bit of tech know-how - to create a sequence of images that can be stitched together to create stunning 4K video renders. Both can be achieved with this project.
THE BROAD OVERVIEW
This project is broken down into three core areas. The unit is controlled by a Raspberry Pi 3, and for this project we are using the Raspberry Pi 7” Touchscreen LCD. We are using Tkinter and Python3 to create a Graphical User Interface (GUI), allowing the user to work in the field without the need for a mouse or keyboard (if you missed it, we explored the Raspberry Pi (RPi) GUI). The RPi is then connected via the GPIO port to a breadboard or Veroboard, to control everything from there.
The control unit uses a form of Pulse Width Modulation (PWM) to get the slider unit to move. When used as a video slider, it just applies the pulse and the gantry moves. When used for time-lapse photography it moves the gantry a predefined amount, fires the shutter, waits the required amount of time, and then moves to the next position where it repeats the process. We have added a 0.5 second rest period before and after the shutter fire, just to make sure the platform is settled, and the motor has stopped.
If required, the camera trigger can be built as a separate unit. It requires a “high” pulse input and will close the loop on the other side. Be mindful that it does need to drive a small load, so proper grounding is essential. The circuit is based around the 4N25 opto-isolator. Most modern cameras have a way to trigger externally, and it is as simple as creating a short-circuit across the ground and shutter pins. Most cameras will also have a third focus pin. If you wished to use that in your circuit it would require another opto-isolator, but it can be connected to the same plug. In this case, we will be using a 3.5mm stereo socket. Depending on your camera, you'll need a trigger cable. This could be a simple 3.5mm cable, or a proprietary plug, but most camera stores will sell them.
The hardware of this project is the slider itself. It consists of a V-Channel frame and a small gantry, which is driven by a long lead screw attached to a NEMA stepper motor. This motor is driven by a stepper motor driver; in this case, a HY-DIV268N-5A. The motor has two coils, and depending on the pulse applied to the controller from the RPi, the stepper motor spins forwards or backwards and drives the gantry along the lead screw. On the gantry is two small magnets that correspond to a hall effect sensor at each end. When the magnet comes close to the hall effect sensor, it is activated and sends a signal to the RPi, indicating that it has reached the end of its safe limits, so the motor stops turning.
HOW IT WORKS
The hall effect sensor consists of a small piece of metal. When it comes near a magnetic field, it begins to conduct current. This is amplified to become logic “high” the RPi looks for this during each loop to drive the stepper pulses. If the hall effect sensor is triggered when the stepper tries to take a step, it breaks the program loop and stops.
OPTP-ISOLATORS / CAMERA TRIGGER
Most modern mid to pro level cameras will include a port to enable triggering of the camera without touching it. The primary function of this is to avoid camera shake from your finger leaving the shutter button (which occurs even when the camera is on a tripod), during long exposures. We have built a circuit around triggering this remote option directly from the RPi (it could be easily used with an Arduino or 5V signal source). The camera input requires a simple short circuit (i.e. a switch). However, this is not so straight forward when using it with a micro controller, as sending a pin high is not the same thing. We need to trigger the flow of energy from one part of the camera to another. This could be achieved with a relay, but they require bulk and power to run. We do not need anything more than a few mA, so the simplest solution is an opto-isolator. The opto-isolator works by applying a voltage to one side of the unit, which is connected internally to an LED. On the other side is a receiver, which switches on a transistor when the load is detected. This allows current to flow on the other two output pins, without contact to the original input signal. This will not work as a switch, and requires there to be some load (which is provided by the camera). However, the major benefit is that it protects the camera from any stray voltages that may be present. This is an important consideration when using stepper motors, as a stepper (just like a standard motor) can act as a generator and create serious power if you move it by hand.
The RPi has several functions, but primarily it drives the stepper via the control module. Two key variables drive the number of steps, and the speed in which the steps are taken. We achieve this by creating a loop that drives the output high, pauses briefly before taking it low, and then repeats the process. The RPi also selects the direction of the motors, and pulls the pin high or low to control it.
The code and GUI are used to control key elements of the project. On boot, the system will “home” itself, and return to the right (stepper) side of the unit. Since all units will vary, the next step is to calibrate the unit (this gives you the option to extend the length beyond what we are using here). The calibration process will count the number of steps from one end to the other, before returning itself back to the “home” position. This is a practical process to complete each time, which helps to minimise any issues. This data could be stored locally to speed up the process in future.
Once calibrated, you just press Home(L) or Home(R) and the unit will traverse the entire distance of the rail. If required, you can use the 1-4 slider to select the speed here. Within the code, you will see some notes relating to the delay time. Depending on the stepper motor chosen, you may be able to slow the unit even further. To use the time-lapse function we need to tell the RPi two things: firstly, how many shots do you want? Secondly, over what time will these shots occur? This breaks the unit’s steps down to the number required for the length/number of shots required.
Next, we tell it the total time of the time-lapse in seconds 100/(60*60). This will give us the delay after each shot (note: there is a built-in pause of 0.5 seconds before and after each camera pulse, to ensure the gantry is stable, since the stepper motor can introduce vibration).
Here is a basic flow chart of the system logic:
This system will use just about any gantry style setup you like, so long as it uses a four-wire stepper motor, and you can attach hall effect switches to each end. It doesn't particularly matter if it's belt-drven, leadscrew-driven, has four wheels or slide-bearings. It can be brand new, or recycled from another project - it really doesn't matter.
For our build we simply purchased a gantry kit from: Maker Store - it comes with everything to make a strong gantry including stepper motor, in barely a coffee break.
We did recycle our stepper motor controller however. Ours was left over from another CNC project. Realistically however, any 4-wire stepper controller with this sort of configuration will work as long as the drive voltage is compatible with your stepper motor.
Perhaps one of the most awesome aspects of this project is that our code is designed to auto-detect the travel of your gantry. It counts and moves in steps, not actual measurements, so it can feasibly work with any hardware configuration, from 30cm to 3m (and beyond!). For this reason, we won’t be describing the gantry build itself in any great detail, as it’s very feasible you’ll be using different hardware, simple follow the instructions that come with your kit.
Note: The Stepper Motor part number in the print addition are incorrect please use the parts listed below.
|1 x Stepper Motor Controller
|1 x Raspberry Pi 3 with NOOBS
|1 x 7" Touchscreen Monitor
|1 x 330Ω Resistor
|1 x Red LED
|1 x 4n25/4n28 Opto-Isolator
|1 x 3.5mm Stereo Socket
|2 x Hall Effect Sensor Modules
|2 x Rare Earth Magnets
|1 x Emergency Stop Switch (Optional)
BUILDING THE CIRCUIT
The build is divided into three parts: the first circuit is used to drive the stepper motor, its controller and the hall effects. The second is the camera trigger; and finally the rail and gantry.
The first part of the circuit connects to the HY-DIV268N-5A. This is a 5A four-wire stepper motor controller. As previously noted, you don’t need to use this particular stepper driver. The stepper driver simply allows you to control the heavy power required to action the signals being sent from the RPi. We need to connect pin 16 to the enable pin, 18 to the direction pin, 23 to the pulse pin, and the remaining to ground. In this case, we have used a 6-pin header to make connecting the driving elements. Next, we have added two 3-pin headers; one for each hall effect sensor. These then connect to the sensor located on each end of the rail. We have laid them out to replicate the pin configuration of the hall effect modules.
Most modern cameras with an electronic trigger simply require a switch or a dead short across the points, to trigger the shutter. However, when we connect this to the micro controller we cannot simply run a “high” 5V signal into this, as it will not work and you risk damaging your (sometimes expensive) equipment. Instead, we need to trigger the camera using a simple switch. The original solution was a relay, but they are big, bulky and can often draw relatively large amounts of power. The solution is an opto-isolator. For this project, we will be using the low-cost 4N25. It is a six-pin package, but we will be using just four pins. The INT side connects to the RPi, and has an LED to indicate that the signal has been received. It also has a 390ohm resistor, which drives the LED we are using, as well as the LED inside the opto-isolator. We then connect our output to pins 4 and 5 of the opto-isolator.
For the camera in use, we have used a 3.5mm stereo socket. This allows you to use a simple 3.5mm cable if your camera supports one, or a 3.5mm adaptor to whatever proprietary plug your camera requires. We recommend researching what is required for your particular camera. An adaptor cable should be readily available from most camera stores to suit your camera. Be mindful that polarity matters here, and you need to make sure that the ground is connected correctly. Reverse the connection if need be.
Regardless of precisely how your gantry works, at each end of the rail needs to be a hall effect sensor. We have used the prebuilt 3-pin 5V modules to make connections easier, but you can use the straight TO-220 packaged version without PCB too. The major benefit of Hall Effect sensors over tactile switches is they're non-contact (so they'll never wear out), and they don't require such precision alignment. We simply mounted ours using a cable tie and a spare bracket. Gaffa tape or just about anything else will work. Just note that the little red LEDs will give you indication of power and activation of the sensor itself - very useful for debugging.
On the gantry itself, we have placed a magnet at each end. When it travels towards the end, the magnetic field triggers the hall effect sensor, which sends pin 24 or 25 high. When this occurs, the stepper motor is shut down (or sent in the opposite direction). Please note: depending on your magnet and hall effect sensor mounting, you may need to flip one to make it work. The LED indicator is dim when not active (ie; the gantry is far away), and bright when active (ie; the gantry is near). You should test this with your magnet visually before activating the stepper motors.
Next, you need to connect the stepper motor coils to your stepper motor driver. A+/A-, B+/B-. Please consult your stepper motor’s documentation. We found that even though we were using a common stepper, the coil wire colours were often different.
Finally, connect the stepper motor to power. Your system should now be ready to use!
While it's not absolutely imperative to operation, we thought it would be useful to note. As mentioned before Tkinter doesn't like to be interrupted, so an on-screen STOP button won't work with the current system configuration. For this reason, a hardware emergency stop button is a good idea. It interrupts the ENABLE pin on the stepper motor controller, shutting off the stepper motor as soon as it's pressed - regardless of what the Raspberry Pi is trying to do.
Using this method provides a safe method in case of any undesired operation. It could be that a wire came loose and your stepper travels the wrong way, a hall effect sensor doesn't work, or worse someone gets a finger caught in a pinch point. While the stepper motor being used is relatively low torque, if could still do some damage. At the very least, it could damage the slider hardware.
Once you have the hardware connected, please open the DIYODE_time_lapse_slider.py (available in the Resources) file and run. You will be greeted by several buttons on a GUI, optimised for the Raspberry Pi 7” Touchscreen.
Before any operation occurs, the system must calibrate itself by travelling the gantry and back. However, if it does not or you do not have the unit powered up, just press the calibrate button.
The GO button will not work until it is calibrated. In order to set the system to run through operation, simply specify the number of frames you require and the total time duration you'll leave the system running for (eg, 10 frames, over 10 minutes). If you are using video and don't require camera triggering, just select the time and set the frames to 1 or 0. You can feasibly also omit any electrical connection between your camera and the slider, simply remember to start and stop recording before and after the slider motion.
The logic here assumes a few things. Firstly, all the circuit does is trigger your camera. The code could easily be modified to control the exposure, but we would question its accuracy at anything under five seconds. It is designed for the exposure to be set on the camera itself, and so simply replicates the triggering the shutter. Be mindful that you need to have the duration of the shutter set to be less than the delay of the slider, otherwise you will end up with significant blurring of your image. More steps or shots does not equal more delay; more delay comes through the total time (delay time). We have given the frame output time in the GUI in seconds. You also need to remember that there is a 0.5-second delay each side of that delay.
Seconds per frame will come up when you are calculating your time-lapse. Please ensure that your calculated exposure is shorter than this (really only a consideration for astrophotography or night landscapes). Once you have your calculations set and your calibration complete, connect your camera and press GO!
COMPILING THE IMAGES
Once you have captured everything you want, you’ll need to use your video editing software to compile the time-lapse photo sequence into a video. When you create your images, you’ll end up with quite large files - well beyond 1080p, so you can easily create ultra-high definition video from it. We have created some 4K video time-lapses, which demonstrate this capability.
Creating a time-lapse movie is dependent on the software you use, and as such we have not included it in this article. However, we would recommend Final Cut Pro or iMovie on a Mac, and Adobe Premiere or Windows Movie Maker on Windows machines. It is beyond the scope of this article to provide a detailed guide on each one. Once you have all of your images, you will need to import them all into your software of choice and commence creating your time-lapse.
WHERE TO FROM HERE?
BELT DRIVE: For this project we used a lead screw, which offers low maintenance and bulletproof consistency; however, we did notice vibrations were occasionally produced which caused our motion video to be shaky at times. Using a belt drive would eliminate this and make rating more smooth. However, it does come with an increase in maintenance costs.
Y or Z AXIS: Why not add in a second or third stepper or servo, or create even more dynamic movement with pan and tilt of the camera on the gantry?
RAMP UP / DOWN: One thing that will make your videos look even more professional is to ramp the movement in and out. This is easily done in the software; however, it does become more complex in the GUI. It is as simple as a start speed and end speed, and incrementing or decrementing the variables as required.
MULTI-THREADING: The GUI has one major limitation. Once the operation has started, you are unable to stop operation due to the way Python and Tkinter handles its events. The alternative would be to start the movement functions as a separate thread to the GUI main loop. This method could result in increased functional control and enable an on screen emergency stop. However, virtually all stepper motors have an “enable” pin, including our test circuit. A hardware method to disrupt the enable pin means everything stops if you hit that emergency button. The software may continue to run, but if provides you with an emergency stop if your hardware is about to do something you don’t want.