INA213 current sensing - Page 1
Forum section: electronics / projects

author: OM222O
author_rank: Frequent Contributor
timestamp: August 09, 2018, 04:45:32 pm
content: I am trying to making a current sensing circuit for a motor driver (brushed DC motor) using the INA213 chip.My stall current would be 20 amps but a nominal load would be around 5 amps so I went with a 0.01ohm resistor as my shunt resistor. The micro controller that is used is a ESP32 so it has 3.3V logic. I am using a 3S lipo pack (12.6 to 9.0v) for driving the motors, so I used it directly for powering the chip too.The stall current can be an issue (output of 10 volts which will definitely damage the ESP32 if it doesn't react in time to shut the motor down) so I was wondering if I could use a 1k resistor to limit the current, so even at 10v the micro controller isn't damaged?I also don't know what the Vref pin does. Is it just a DC offset? some pages of the data sheet suggest it can be simply connected to ground, but they have used VS/2 for this pin in all their testing. what should I connect it to?Edit: here are some pictures of my design so farCurrent sensing resistor position:INA213 and it's connections:The CS1 line is fed back to the micro controller to be read.

author: archnemesis
author_rank: Contributor
timestamp: August 09, 2018, 05:02:07 pm
content: The REF pin sets the level at which the output sits when there is 0 current. If you want bi-directional current sensing, setting this to half of your ADC reference voltage will put the output right in the middle when there's no current, allowing it to move positive and negative. If you don't care about bi-directional current, setting it to ground will allow you the full range from 0-VCC for your ADC or whatever.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: August 09, 2018, 05:09:17 pm
content: Why not low side sensing?Tim

author: SiliconWizard
author_rank: Super Contributor
timestamp: August 09, 2018, 06:03:19 pm
content: No matter what the expected output voltage range is in the nominal working condition, it's rarely a good idea to directly connect the output of an opamp powered at a voltage much larger than what can take the input it's connected to. The output voltage swing during power-up or in fault conditions may (and in fact most likely will) reach its power rail (with some drop-out). The max output current of the INA213 may not be enough to cause a big damage to the ESP32 but I wouldn't leave it like that.In your case, the simplest approach is probably to put a resistive voltage divider between the INA213 and the ESP32 input. It will reduce the effective resolution, but you probably don't need much resolution to monitor a motor current.A simple series resistor may be enough to protect the input pin but the input clamp diode will still conduct every time the output of the INA213 goes above 3.3V+a diode threshold. A 10k resistor should limit the max current to under 1 mA which should be safe (but I still don't like to make the input diodes clamp during normal operation).Another option would be to switch to something like the INA226 which has an I2C interface (and additionally gets you the supply voltage, which could be a nice addition given that you're using batteries).

author: Siwastaja
author_rank: Super Contributor
timestamp: August 09, 2018, 06:22:42 pm
content: 10k resistor is probably not a great idea, because the impedance is too high for the ADC to handle, then (caveat: might be acceptable if you have configurable sampling time; refer to actual ADC data). You'd at least need a capacitor to provide the low impedance, creating an RC filter which slows the response down, and it's no longer an effective cycle-by-cycle current limit.Smaller resistor such as 100, maybe 200 ohms could provide enough protection for your case.Any reason you are powering the INA216 from such a high voltage? You see, it has common mode input range over the supply. You can well measure the higher voltage bus while powering the amplifier from 5V, or even 3.3V - this limits the output range. Note that the maximum output high level is, in worst case, Vdd-0.2, and the frequency response may be worse near the rails, so if you need to accurately and quickly measure up to 3.3V equivalent current, you need to power the device with a bit more voltage headroom - say at least 4V.Note that TI recommend operating the part at Vdd=5V.It sounds like, in your case, running the INA216 from 3.3V directly would be acceptable and an extremely simple solution - no extra parts needed.Note that while REF is just an offset you can utilize to enable bidirectional sensing, you can't drive the REF pin from a resistor divider directly - so if you want bidirectional sensing, you need an opamp unity amp following your resistor divider.With brushed DC motors, bidirectional sensing could be valuable to control regenerative braking.You don't need to set it halfway your ADC range even though that's typical; you can use any setpoint - for example, if regenerative braking happens only at relatively low currents, compared to larger driving currents.The datasheet has good application information. Read it carefully, and it answers many of your questions.

author: OM222O
author_rank: Frequent Contributor
timestamp: August 10, 2018, 10:03:16 am
content: I am trying to avoid using the micro controller to power up the INA213 because it's already being used to power other parts of the project, so I don't want to overload it's voltage regulator output, the measurement is not critical because there is a huge difference between running conditions (5A) and going into stall current (20A) so even 1 amp difference in the measured value is acceptable! are there any downsides to power the chip from the battery rather than the micro controller?I'm also going the add the entire circuit diagram if it helps (note that the NPN inverters also use the battery line rather than micro controller).https://cdn.discordapp.com/attachments/469851844819156993/477397792608878593/Dual_H_bridge_Schematic.pdf

author: Siwastaja
author_rank: Super Contributor
timestamp: August 10, 2018, 10:22:44 am
content: Well, the most obvious issue with driving them on your battery DC bus is the problem you are having - you need external circuitry to limit their output range to suit the ADC's input range. And as you need to also satisfy the ADC's input impedance requirement, this circuit is non-trivial. It would be a resistor divider followed by an opamp. But you have the opamp already - your INA213's output stage - and it would be waste not to use it in its intended way.Now, if you powered it all from the same regulator, it would be a direct connection, which is the intended operation mode of these amplifiers - they have low-impedance outputs exactly to drive ADCs directly!Another issue might be PSRR, or noise coupling through the supply, but check the actual graphs to see if this is an issue. Probably a non-issue.