For the last few years I’ve had a nagging issue with a field of engineering known as rotordynamics. Its a long story, so I’m not going to go into it now. But in any case, I’d like to do some experiments with some spinning shafts. To be able to observe the behavior of said spinning shafts, I need a stroboscope. A quick search found that such a device was well outside of my willingness to spend money to quell a minor intellectual nag (they’re selling for several hundreds). So I decided to make my own.
Basic Requirements: Display of frequency. Control of frequency. Flashing light at frequency. Cheap.
With the requirements set, it was time to order parts and make shit. In about a week I found myself in possession of: a bunch of bright white LEDs, a 4-digit seven segment display (with serial comm), and a few 50 kΩ pots. My arduino would be the brains of the operation.
Step one was getting the frequency control and display working. A 50 kΩ pot provides a 0-5 volt input to an analog input on the arduino. This signal is digitized to an integer value that ranges from 0 to 1023. This value is mapped to a floating point value between the minimum and maximum frequencies that are set within the arduino code. This floating point is then parsed into four digits and a decimal point location that is sent serially (8-N-1) to the display. This floating point frequency value is also inverted to provide the cycle period in milliseconds. The cycle period is used for timing the signal to flash a light. I had some time on my hand thanks to a cross country flight. I got all this up and working somewhere over Colorado.
With the control and display working, all that remained was working on the light. The LED data sheet stated that 20 mA was the absolute maximum diode current with a diode voltage of approximately 3.4 v. I was thinking that with two diodes in series, with a 5 v power supply, would each get about 2.5 v which would be a good compromise between performance and burning them out too quick. So, I picked up a crappy circuit board from the shack, and soldered 20 white LED’s to it (10 parallel branches of 2 diodes in series). The arduino can’t drive nearly enough current (200mA) for this application, so I picked up a 2N4401 switching transistor for that job. Here is a rough sketch of the circuit:
To my dismay, the brightness of the diodes left much to be desired, to the point where it was hard to tell if they were lit. Hmm. Lesson learned: LEDs are highly nonlinear in the relationship between current (light output) and voltage, as illustrated by the following plot from some random internet site:
With this in mind, I decided to power the LED portion of the light with 9 v. This would result in about 4 v across each diode (yes higher than you are supposed to), and something over 20 mA per branch. Why is this ok? Well, I’m assuming that the max voltage is related to a max current, which is in turn based on a max junction temperature and heat dissipation. Given that we are only driving the LEDs on for a fraction of a millisecond, and keeping them off for the remainder of the cycle, and since the period of the cycle will always be >> the on time of the LEDs, its probably fine. Ta Da:
While experimenting with the stroboscope to do certain things, like freeze fan blades, I found that the responsiveness of the controls was too sluggish. Because the arduino takes about 1 millisecond to perform an analog read, I scheduled that operation to occur once per second to avoid tying up the timing of the light signal. But assuming that I’m not looking for flash rates above X hz, this shouldn’t be a problem, so I stepped up the control sample frequency to be synchronous with the flash frequency. Lesson learned: An analog human control interface needs to be fast, with a latency of no more than a handful of milliseconds to feel natural.
So whats next:
Brighter. The commercial strobes that I looked into had an on time of around 10-20 μs. I’m using 100 μs. This is out of necessity to ensure the level of light observed is acceptable. The down side is that observations under the strobe will appear “blurred”. This is analogous to what fast action looks like in a long exposure photo. On time = exposure. A brighter source will mean a shorter on time which will mean crisper observations. I’m considering a sparkfun driver and led array.
Less floats. Tweaking the code to remove as much dependance on floating point operations. Nuff said.
Fine adjustment. I want to add a second pot to provide a better adjustment in the flash frequency.
2x frequency adjust. Adding two push buttons to allow jumping up by 2x or down by 0.5x in frequency. This is a feature I’ve seen in commercial strobes that could be pretty useful in identifying the frequency of some periodic phenomenon.
Interrupt based. I’d like to move to an interrupt based timing system. This would allow the main program loop to focus on the display and user interface while other processes handle the timing for the flash and interrupt as necessary to ensure said flash happens. There are some useful slides here.
That is all. (for now)
Arduino code is here. Full disclosure: the code to break the frequency float value into digits was written by someone else, but I can’t seem to relocate the source to give proper credit.