# Measure current through H-bridge using shunt

I am trying to measure the current through the H-bridge and brushed DC motor and shut it off if it exceeds a pre-set limit. This is how I have it currently set up:

simulate this circuit – Schematic created using CircuitLab

OA1 acts as a non-inverting amplifier to amplify the signal that can then be compared by OA2 to a pre-set limit. And if it equals or bigger it outputs 5V signal to microconctroller, which then disables the H-bridge.

The problem is that the output from OA1 saturates at 5V. Which according to my calculations shouldn't be. If I disconnect the wire from OA1 and connects it to oscilloscope I can see a thick sine-like wave from -50mV to +200mV on the shunt resistor. Which is rather weird... The measured current only through the motor with no load is around 2A. So $U=R\times I=0.01\times 2=20mV$.

Whats going on?

• Are you PWMing your H-bridge to adjust your motor speed or just using it for simple on/off/direction control? Feb 4, 2015 at 20:14
• What does "maxed out" mean, specifically? Feb 4, 2015 at 20:39
• @brhans Just for simple direction control. Feb 4, 2015 at 21:00
• @PhilFrost I meant it saturates. Feb 4, 2015 at 21:02
• Yeah, I figured that much. Saturates how? Which node? What voltage? Feb 5, 2015 at 2:12

Your measurement is a classic manifestation of the difficulties involved in measuring high currents. It has two parts. The negative portion of the curve arises from the flow of current through the ground traces of your system. The apparently high amplitude comes from the inclusion of extra PC board traces in the current path which you're measuring. What you need to do is make a differential amplifier with gain

simulate this circuit – Schematic created using CircuitLab

There are a few things to consider.

The most obvious is that you need to monitor both sides of the bridge. In your original circuit, you could have a short in M3, and the MCU would never know it. Unless you've duplicated your sense circuit to provide a second MCU input, that is, but there's no need for the duplication. Apparently you just want to sense an overcurrent in the motor, so a single measurement will do.

Note that the op amp input resistors connect directly to the shunt terminals. While there can be appreciable trace lengths from the shunt to the resistors, the tie point has to be at the shunt itself, not some distance away. That specifically means that, if you're using an SMD shunt, you must connect the op amp resistor traces directly to the shunt pads, not to a via. Take a look at the resistance of pc traces, and figure how much length it takes to get parasitic resistances on the order of your shunt value.

The other change is the considerable reduction in op amp resistor values. For an op amp this fast, you need to keep resistances low to reduce the effect of parasitic capacitances. Although, as Spehro has pointed out, you also need to change op amps.

• I am thinking of getting this one: farnell.com/datasheets/1830959.pdf Do you think it will be suitable? Feb 4, 2015 at 21:36
• I wouldn't recommend it. It's pretty slow. You want a unity-gain bandwidth of well over 1 MHz. It depends on your PWM frequency, of course. It will work if you're using the bridge simply to reverse a motor which is otherwise driven at full voltage. Feb 4, 2015 at 22:14
• I think the comments specify that there's no PWM going on. Feb 5, 2015 at 11:07
• @Golaž - Sorry, missed your comment. Then I reverse my recommendation, and you should be OK with that op amp. Feb 5, 2015 at 11:33
• @WhatRoughBeast Yes, Phil Frost is right, sorry for the misunderstanding. Feb 5, 2015 at 12:12

The TL972 is not a very appropriate op-amp for this purpose. It requires a negative supply since the input common-mode range only gets to within 1.15V of the negative (or positive) rail (despite the output being rail-to-rail). You show the supply grounded, which isn't going to work (assuming the current is less than 115A!).

It also can have as much as +/-6mV Vos which would represent an error of about +/-6% in your trip point- maybe that's okay for your purposes.

Suggest you substitute a single-supply op-amp with a relatively low input offset voltage. Since the TL972 has a standard pinout for a dual op-amp that should not be difficult.

• There are a lot of them out there and I am not that good at finding the right one... Do you have any recommendation on which to use? Feb 4, 2015 at 21:01
• What are you doing with the other op-amp?? Feb 4, 2015 at 21:02
• I dont understand what are you saying. Aren't you suggesting I should find a different op-amp that will suit the job more? Feb 4, 2015 at 21:04
• There are two op-amps in the single package (it's a dual). If you change the part number, the other one will also be different. If the other one is used in a circuit with incompatible requirements then it will cause other problems. Feb 4, 2015 at 21:08