Introduction: Portable Precision Stroboscope
The flashing lights of a stroboscope can give amazing hallucinating effects. But precise repetitive flashes of light also allow to visualize motion that is too fast to be seen by eye or by a regular camera. The great video and instructable by GreatScott inspired me to make a portable battery-operated stroboscope with precise frequency control. It turns out that the Arduino is quite capable of doing so, and more so, implementing settable duration of the flashes was quite straightforward too.
Precise frequency settings means that a stroboscope can actually be used to make precision measurements of the rotation frequency of a motor, or precision measurements of speed using stroboscopic photography. A simple potentiometer dial is not sufficient to reach permille precision in the frequency setting. Instead, here the flashing frequency is related to the 16MHz clock of the Arduino, and the desired frequency can be given in 4 decimals.
Repetitive signals can be generated in many ways with an Arduino. Extremely accurate frequency control can be achieved with a phase increment in a fast loop, as for this waveform generator. However, the Arduino has three built-in timers, and the 16-bit TIMER1 together with its clock prescales turned out to be sufficient to cover the range of frequencies 0.3-999.9 Hz that I was interested in. The use of a timer leaves the CPU free for other tasks so that a compact 4-segment LED display can be used to display the frequency. Moreover, the 4-segment display can be soldered right on an Arduino Nano (as also done for this timer ) giving a very compact and easy-to-buid setup, leaving free pin D10 which is the B-output of TIMER1.
Getting bright flashes with a battery-powered device is a challenge, and the scheme shown here is definitely insufficient for lighting up a dance floor. However, by clever use of capacitors and somewhat overdriving the LEDs, fairly bright flashes can be generated, while being powered with only 2 AA batteries.
Last but not least I should emphasize the feature to set the flash duration: ultra-short flashes result in very ‘static’ images, but the average light-output is low. Longer flashes give more light but are less able to ‘freeze’ the image. Thus I put in the ability to change the flash duration between 64 and 960 microseconds, always staying below a duty cycle of 10%. This extra feature greatly enhances the number of applications that this stroboscope can be used for.
The video above illustrates the functionality. Note that it's been taken with 30fps, so when the the stroboscope is at that frequency, or at a multiple of that, it doesn't seem to be flashing at all, since each picture being taken receives a flash.
If you like this project please consider giving it your vote for the 'make it glow' contest!
Step 1: The Code
Attached is an Arduino sketch. Beware, depending on your display version (common cathode or common anode) and how it is connected (UNO with breadboard or soldered to Nano), you do have to adapt some settings by commenting and/or uncommenting the relevant lines.
Note that the flashing of the stroboscope is done completely with timer1, so that all of the CPU is available run the 7-segment display and to check the buttons. Most of the obscure settings of the timer are hidden in the setfreq routine. The prescale is chosen to be the lowest one compatible with the chosen frequency, such that the best resolution is obtained.
Step 2: Breadboard Version (single 5mm LED Version)
I recommend to make a breadboard version first, to test the components and try out the software. Modifications to the software or to the LED driver to suit your purpose are best done here. The following components were used:
* An Arduino UNO R3 with a prototype shield for compact connections
* A 0.56” 4-digit 7-segment display with decimal dots. Either common anode or common cathode.
* A white 5mm LED plus a 100Ohm current-limiting resistor
* Two push-buttons
* Some hookup wire
The 7-segment display has 6 pins on the top and 6 on the bottom. The connections to the segments and digits seem arbitrary, but they are the same for all displays I’ve seen. Through software we can choose which to fire when, so there is no need to connect them in any particular way. Here the wiring is chosen to match the wiring when the display is soldered directly to an Arduino Nano: A0-A5 and D4-D9.
Connect the LED with the Anode (long lead) to D10 and to ground with a 100Ohm current-limiting resistor. The voltage drop over a white LED is ~3V, so the current will be (5V-3V)/100Ohm=20mA.
Connect the two push-buttons between ground and D11, D12. The software will activate the internal pull-up resistors on D11 and D12, so this minimal wiring will work fine.
Now upload the Arduino sketch (from the ‘Code’ step) through the regular Arduino IDE and if all is well the display shows the number 20.0 and the LED flashes faintly at a rate of 20.0Hz. If the display shows segments in a seemingly random order, it may be that you have a common-anode display. Try commenting and uncommenting the relevant lines in the code. If the display is still messed up you may have a different pin-layout then mine, and you should probably check the datasheet.
To raise the frequency, push one button, to lower push the other. A single push will change in steps of 0.1Hz, keeping it pushed longer will make the changes go progressively faster. The minimal frequency is 0.3Hz, the maximum 999.9Hz.
The pulse length can be changed by pushing both buttons simultaneously and keeping them pushed until the desired pulse length is displayed. It will go in steps of 64 microseconds until it reaches either 960 microseconds or the largest number that corresponds to a duty-cycle of 10%.
Step 3: Increasing the Light Output
The setup from the previous section will flash a single LED, which is just fine for testing the software but not exactly stellar. However, the current (20mA) is close to the maximum that a single Arduino pin can handle (40mA). To get stronger light, we need a driver, power-LEDs and a power source.
Power-MOSFETs are the components of choice for switching high currents, it’s the first time I use them but they work straightforwardly and can handle large currents with little voltage drop. I use the IRLZ44N. The ‘L’ is essential: it means that it can fully switch with ‘logic’ levels : 5V. In my experience, the Arduino can directly drive the MOSFET without need for a MOSFET driver. However, it is better to tie the gate to ground with a 10kOhm resistor to make sure the MOSFET is off when not explicitly switched on.
The MOSFET can easily handle voltages up to 50V, which may be needed if you want to switch the super-high-power (>10W, even 100W) LED COB chips. However, for a battery-operated device, I decided to stick to using the same 5V of the Arduino also for the LEDs. Two AA batteries with a boost module set to 5V can deliver a continuous current of 200mA to the LEDs plus 50mA to the Arduino. 200mA continuous at a maximum duty cycle of 10% means that the LEDs can be chosen to consume an instantaneous current of 2A.
I've done that by using 10 LEDs of 0.5W, the surface-mount 5730 ones, each in series with a 10Ohm resistor. That should give an instantaneous current of 200mA per LED, which is slightly in overdrive, but since they are pulsed at maximum 10%, that is very conservative. See here how to solder these SMD LEDS.
Capacitors are needed to deliver the high instantaneous current for a flash. The time in between flashes is then used to recharge the capacitors. The charged Q stored on a capacitor is the product of the voltage V and the capacity C. However, as soon as the capacitor starts to discharge, its voltage drops, so only a small fraction of the total charge is available to produce the flash. A 1000muF capacitor at 5V would not be able to flash the LEDs strongly for 1ms since it loses 2V if it delivers 2A for 1ms. Thus I use two 1000muF capacitors in parallel. The scope trace shown above demonstrates that the voltage on the capacitors decrease by only 0.5V after being discharged for 1ms.
Step 4: Final Portable Version
To make the stroboscope into a permanent instrument, it needs to be put into a sturdy box. I managed to make it fit inside a standard 100x60x25mm enclosure. Power is provided by 2 AA recharcheable NiMH batteries that are stepped up to 5V. An on/off switch is introduced to prevent the batteries to drain. The nice pushbuttons that I had were too large to fit in the box so I used 12x12mm pushbuttons that are really meant for PCBs, but they are very compact and actually work very well.
First I drew with a pencil the approximate places to cut the 4 holes in the enclosure. With a rotary tool, I cut them out crudely and with a hand file cut the holes to precision. The lamp is connected externally, so it’s sufficient to make 2 small protruding holes on the ‘lid’ of the enclosure.
The Nano is soldered to the 7-segment display as shown in the picture. The 10kOhm resistor nicely fits on the back of the MOSFET to connect the gate to the source.
The step-up module I used has a fixed 5V output, they are slightly smaller than the regulated modules, and there is no danger to accidentally fry the Arduino. The wires that carry signal (such as those to and from the push-buttons) can be thin, but the wires to the LED should have low resistance.
Note how in the schematic the 12 connections from the Arduino to the 7-segment display have been left out to avoid a cluttering of lines. I hope the connections are clear from the pictures and from the description!
Step 5: The Stroboscopic Effect
Finally, a video to show how the stroboscopic effect can be used to measure the frequency of a fast-rotating object, in this case a cappuccino-maker.
First, the frequency is set to 157 Hz, and it is seen that the wheel appears perfectly still. This means that the rotation frequency is 157 Hz, or an integer multiple of that. To check that the actual frequency is not 314 or 471Hz, we also try out doubling and tripling the original frequency. At 314Hz, we clearly see that the wheel has rotated half a turn at every flash and at 471 Hz one third of a turn, so it’s confirmed that the rotation frequency is 157rotations per second, or 9420RPM.
Participated in the
Make it Glow Contest 2018
3 years ago
Hi. Im building a time-fountain but in 5 segments. Is it possible to make a device like this but with 5 channels so i Can make the drops go in different speeds/directions in every segment.
Reply 3 years ago
The 3 timers of the Arduino can each steer 2 outputs, so up to 6 channels, but they can't be controlled completely independently, and the pin number is fixed.
Port manipulation is more flexible, see e.g. https://www.instructables.com/id/Arduino-Waveform-Generator-1/. That's a 1-channel analog wave generator, but it actually produces patterns of 8 digital signals, so if you leave out the R2R DAC, and buffer the output with motor drivers, something like that can easily drive up to 8 (or also 16) motorised output with very well timed patterns.
4 years ago
This is a very impressive miniaturisation! I love Ardiuno, but squeezing the result is always hard. Also, great work with the drivers for the flash. Thank you for sharing your experience and the product :-)
4 years ago
I made a simple LED strobe light not as complex but with a 555 timer.