4

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?

NickG
  • 391
  • 2
  • 15
  • 2
    Have you considered low-pass filtering the output of the current sensor? – Sven B Jul 05 '18 at 11:27
  • 1
    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. – Sredni Vashtar Jul 05 '18 at 11:47
  • 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. – Jaden Jul 05 '18 at 13:32
  • 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. – NickG Jul 07 '18 at 22:53
  • 1
    if you found a solution to this, it's always okay to post an informative answer to your own question in Stack Exchange, and in a day or two to click "accept" as well. This informs future readers that a solution was found and encourages them to click on it and read further. – uhoh Feb 21 '21 at 21:59

1 Answers1

1

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.

Hein Wessels
  • 312
  • 1
  • 8