4
\$\begingroup\$

I have the following circuit:

schematic

simulate this circuit – Schematic created using CircuitLab

I am using a motor from an electric bike, as a generator and I am rotating it using a drill, to test its regenerative properties. The energy generated is consumed by R1. The current flowing through the circuit is controlled by a low-side N-MOS switch, using the STP55NF06L N-Mosfet. Its gate is driven by a PWM signal (at 500Hz) and an ICL7667 Mosfet driver.

I am using both a multimeter and the attopilot current sensor 90A version.

The output of the current sensor is driven to an AnalogToDigital port of my microcontroller. The problem is that the current readings I get from the sensor, are not steady and are changing rapidly, while the multimeter shows a nice, steady current value.

I decided to check the output of the current sensor using an osciloscope. With the N-MOSFET duty cycle set to 60%, and a current of around 1A (as measured from the multimeter), these were the results:

This picture has a 1V/div scale: enter image description here

This picture has a 500mV/div scale: enter image description here

How can I filter the above noisy signal to get a nice current reading from the sensor, like the one of the multimeter, that seems to be the mean value of the current flowing through the circuit?

\$\endgroup\$
  • 2
    \$\begingroup\$ Have you considered low-pass filtering the output of the current sensor? \$\endgroup\$ – Sven B Jul 5 '18 at 11:27
  • 1
    \$\begingroup\$ A drill near an oscilloscope? That's like trying to hear someone whispering near a waterfall. Low pass filtering, as suggested by Swen, is a possible solution. I wonder if there is a way to shield the RFI by operating the drill inside a thick metal box. Also, how did you probe the circuit? Ground spring or dreadful antenna ground loop? A differential pre-amplifier might be helpful too. \$\endgroup\$ – Sredni Vashtar Jul 5 '18 at 11:47
  • \$\begingroup\$ It looks like you may have some inductive component behavior (the generator). You might try putting a zener diode across the M1 to release energy from any inductive components. \$\endgroup\$ – Jaden Jul 5 '18 at 13:32
  • \$\begingroup\$ Unfortunately, I have little experience in filters. I have tried some simple low pass filters, unsuccessfully. Any detailed advice on how to calculate and choose the correct filter for the above case, will be greatly appreciated. \$\endgroup\$ – NickG Jul 7 '18 at 22:53
0
\$\begingroup\$

Seems like you are trying to filter the digital value as stored on your microcontroller. I would implement a moving average on the value. It's easier than filtering the signal through an analog circuit..

Here is someone who has implemented a moving average in C. Just remember to keep length of the average short enough.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ If ADC has low enough sampling rate, it won't even see those spike. \$\endgroup\$ – Long Pham Jul 5 '18 at 12:59
  • 3
    \$\begingroup\$ ADC might take the sample DURING the spike. \$\endgroup\$ – analogsystemsrf Jul 6 '18 at 3:40
  • \$\begingroup\$ I have tried some "software filters", but as mentioned above, the sampling does often occur during a spike. \$\endgroup\$ – NickG Jul 7 '18 at 22:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.