Archive | November, 2011

Number Crunching

14 Nov

We want to process the electromagnetic field (EMF) data in real time to determine if it’s 60 Hz or maybe in another frequency range. Wow, having different colors to indicate the type of EMF around an appliance, that would be very interesting! But before getting carried away, there is some number crunching to do.

We could do an analog filter so the Arduino would not have any calculations do. That’s elegant but harder to modify later on, and it adds components. Same for adding a DSP (digital signal processing) chip.

Another way to do this is the Fourier transform to tell us what amplitude EMF we have at what frequency. Even the discrete “fast Fourier transform,” designed specifically for computers, involves floating-point multiplication and calculating sines and cosines. The FFT saves some work by keeping results in a lookup table but still. There are plenty of other things the Arduino needs to do, and these calculations will probably slow down the maximum sampling rate.

We could do a variant called the Goertzel algorithm that computes the amplitude at just one frequency. Here’s a good implementation of the Goertzel algorithm:

Goertzel algorithm from mstarlabs

Still a lot of number crunching. Would a result every two seconds be too slow for us? Maybe there is a more continuous way to apply this algorithm.

Alternatively, there’s digitally filtering out everything but the 60 Hz, then finding the amplitude of that filtered signal. Here’s a very good implementation of a digital 60 Hz bandpass filter. The application is getting a robot to locate a power plug by “feeling” the 60 Hz electric field. The best thing is that the algorithm was run on an ATmega 168 and was able to update about 50 times per second!

Robot, Feed Thyself

Here is my version of this bandpass filter:

It was generated using the following MATLAB code…

Continue reading

Advertisements

Tracking EM fields

9 Nov

Since last time, we have been working on visualizing the EMF sensor data. Here’s a video with the Arduino EMF sensor “scanning” a microwave oven:

We analyzed the video using a MATLAB program to track the coordinates of the largest red object, then drew a red square over the LED. This kind of tracing will help us create a still image of the fields surrounding an appliance.

Here is the Matlab m-file used to generate the two videos from an original .avi file that had about 4x higher frame rate than was really necessary to track the led… Continue reading