Ceiling Fan and Spectral Analysis

The Fun

I want to turn the ceiling fan in my room into a display with those RGB LED strips.

For persistence of vision to work, I need to measure the angular position of the LED strip. For that I will need the phase and frequency estimates. Of course I can just use that old magnet + Hall effect sensor combo, but I don't want to miss this perfect opportunity to play with IMU and FFT.

To get some preliminary data I taped a 9-axis IMU, an Arduino and a Bluetooth transceiver onto one fan blade and a battery on another. IMU data are sampled at 20Hz and wirelessly transmitted to my laptop. A python script captures them into text files for MATLAB processing. The top figure shows the DFT of the captured data (one axis of the magnetometer) along with a power spectral density estimate. Both peak at about 3.2Hz (so around 192rpm).


To verify the measurement, I took pictures of the spinning blades at various shutter speed and estimated the angular velocity from the images (with a protractor, a retroreflective marker, a flashlight, and some least square fitting):

blades at rest

spinning blades

The slope gives the rotation rate, which is about 3.5 rotations per second (a bit faster than with the circuit and battery strapped on). I didn't go out of my way to balance the battery, so the whole fan fixture wobbles quite a bit when the circuit and battery are mounted. This explains why it spins slower when measured with the IMU method.

I took a transform theory and a digital signal processing course just for the DFT/FFT/spectral analysis part (ok perhaps the digital filter design part as well), would be a shame not to use the new tool.


  • to compare this against the gyro's readings
  • to integrate the gyro's readings
  • play with Kalman filters (Estimation Theory... I wish I had the time to learn it.)
  • to perform real-time estimate of the phase and frequency
  • integrate with the LED strip