0
\$\begingroup\$

I'm trying to figurate out how to measure current in circuit. I have idea to use shunt resistor but after connecting op amp on shunt I have some unpredicted measurements on output of op amp. I want to measure amps of leds. Is this good idea to measure current? I can control led intensity with pwm that works fine and I can measure small voltage on shunt and after using Omh law I got current in circuit and I want to amplify that voltage because MCU need to read voltage. Is voltage on shunt dc or we have there some ripples which can look likes sin(pwm) signals? Here is schematic:

enter image description here

Any idea and comment is welcomed

\$\endgroup\$
2
  • \$\begingroup\$ What current range are you trying to measure and what op-amp are you using? \$\endgroup\$
    – Andy aka
    Mar 17, 2021 at 9:56
  • \$\begingroup\$ Current range is 0.2-1.4 Amp and LM358 \$\endgroup\$
    – subavet995
    Mar 17, 2021 at 10:03

1 Answer 1

3
\$\begingroup\$

Is this good idea to measure current?

It's an acceptable way to measure current but remember that the current will be pulsed (due to the PWM) and some form of filtering may be required if you want to measure average current. If you want to measure peak current then that requires some form of synchronous measurement but, the basic front end op-amp circuit remains the same. However, I would suggest a couple of things as per this modified diagram: -

enter image description here

The filter capacitor should be used if you want the average current taken by the load: \$C = \frac{1}{2\pi R F_C}\$ where Fc is the cut-off frequency required and R is the red resistor value.

  • Add an op-amp protection resistor in case your MOSFET went short circuit or the peak voltage exceeded 3.3 volts (shunt going open). It should be in the realm of 10 kΩ.
  • Make sure your measurement connections to the shunt resistor are very short (blue wires above).
  • Make sure your op-amp is capable of working with input voltages at 0 volts and that the output from your op-amp can reach close to the 0 volt rail.

Current range is 0.2-1.4 Amp and LM358

With 0.2 amps and an 85 mΩ shunt, the voltage is 17 mV and the expected voltage on the op-amp output is 34 mV - this should be OK with the LM358.

\$\endgroup\$
4
  • \$\begingroup\$ Thank you for this very very good and extensive answer. But I have still couple a questions. You said "some form of filtering may be required if you want to measure average current", can you add answer how to do that? How to get average voltage when there is some ripples? Second question is next: you said "With 0.2 amps and an 85 mΩ shunt, the voltage is 17 mV and the expected voltage on the op-amp output is 34 mV" but I want higher gain, for example 10, I put right resistors right? \$\endgroup\$
    – subavet995
    Mar 17, 2021 at 11:26
  • \$\begingroup\$ @subavet995 oops yes, you have a gain of 11 and not 2. I read the feedback resistor as 4k7 mistakenly. As for filtering, if you add the resistor I have shown in red, you could put a capacitor to ground from the non-inverting input to filter the signal into the op-amp. If your PWM is 10 kHz for instance, then you might want to reduce ripple by enacting a 100 Hz filter where the capacitance value would be 159 nF. \$\endgroup\$
    – Andy aka
    Mar 17, 2021 at 11:48
  • \$\begingroup\$ Thanks again for answer which is very helpful. Where I need to put capacitor? One side of capacitor is going between op amp non-invert input and resistor and another go to gnd, right? I have 20kHz pwm, do you use some formula to calculate which capacitor is right one? You can easily add this in your answer because this will be very helpful \$\endgroup\$
    – subavet995
    Mar 17, 2021 at 12:19
  • \$\begingroup\$ @subavet995 yes, that's where the capacitor is fitted between non-inverting input and ground. \$C = \dfrac{1}{2\pi R F_c}\$ where Fc is the cut-off frequency of the filter (100 Hz in my example above). \$\endgroup\$
    – Andy aka
    Mar 17, 2021 at 12:21

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.