I am working on a project where I need to measure an oscillating magnetic field that oscillates at a frequency of 100 Hz. For this reason, I am using a Hall sensor. I programmed the Hall sensor to operate in "500 Hz continuous measurement node" and I generate the 100 Hz magnetic field using a linear amplifier with an air coil and a function generator as signal source.
When I compute the DFT (250 samples at 500 Hz, e.g. a measurement of 0.5 s duration), I get the following result:
I do get a peak at 100 Hz, as expected. However, I also see a lot of "sidelobes" that are spaced in multiples of 10 Hz from the main peak. I also observed the following:
- The side peaks also occur when I change the magnetic field frequency to 50 Hz and 75 Hz and they also seems to be spaced at 10 Hz intervals. When I set the magnetic field frequency to 500 Hz, I see a constant signal with a 10 Hz sinusoid superimposed. When I set the number of samples in the frame from 250 to 200 or from 250 to 500 (at 500 Hz sampling again), I also notice the side peaks spaced at 10 Hz.)
- I previously used a different Hall sensor, that sampled at 2 kHz. When I use this sensor to record a 0.5 s frame I can see a single peak in the DFT, so I assume that the magnetic field does not have the side peaks in reality.
Does anyone have an idea on how to debug this?
Edit: Implementation details
I implemented the communication to the sensor in the following way:
- I set up the sensor to "500 Hz continuous measurement mode"
- I have a 500 Hz interrupt on the uC. This interrupt triggers the reading of the sensor magnetic field value. This is done by first writing the address to be read to the sensor and then conducting an I2C read operation. I monitor the timing of this interrupt with a GPIO on an oscilloscope and the interrupt timing is very stable at 500 Hz as shown on the oscilloscope.
- The I2C frequency was set to 200 kHz.
I could also use the "single measurement mode" and see if that improves the situation.
Edit2: Issue now seems resolved
I think I was now able to resolve this issue by using the "single measurement mode" instead of the "500Hz continuous measurement mode" of the sensor. The implementation now does the following:
- Set a 500Hz interrupt on the uC
- uC sends trigger signal to sensor to start measurement when interrupt occurs.
- While sensor measures new value, uC reads old value.
This gives me the following result: