EEVblog Electronics Community Forum

Electronics => Beginners => Topic started by: JJalling on February 04, 2021, 02:55:49 pm

Title: Simple current detection
Post by: JJalling on February 04, 2021, 02:55:49 pm
Hello,

I have a stm32 running at 3V3. I want to monitor a USB VBUS (5V) line and detect if the current draw is higher than say 50-100mA (the number doesn't need to be exact - just ball park).

How would you do this with as few external components as possible? A sense resistor and a voltage divider on the VBUS line, to the ADC of the STM32?

Thanks in advance.

BR Jonas
Title: Re: Simple current detection
Post by: Terry Bites on February 04, 2021, 04:15:12 pm
Use a current monitor amp and connect its output to your ADC input. You can tie the ADC ref in as well.... FAB
eg https://www.onsemi.com/products/amplifiers-comparators/current-sense-amplifiers/ncs199a3rsqt2g (https://www.onsemi.com/products/amplifiers-comparators/current-sense-amplifiers/ncs199a3rsqt2g)
Cheaper than an Aussie Dollar. Happy days!
Title: Re: Simple current detection
Post by: mvs on February 04, 2021, 04:27:18 pm
How would you do this with as few external components as possible?
current shunt + integrated high side CSA.
If you are space constrained, there is quite small CSA in sot23-3 package with current output - ZXCT1009.
https://www.diodes.com/assets/Datasheets/ZXCT1009.pdf (https://www.diodes.com/assets/Datasheets/ZXCT1009.pdf)

Quote
A sense resistor and a voltage divider on the VBUS line, to the ADC of the STM32?
VBUS line is not exact 5V, so you would need to measure VBUS before and after current shunt and then substract values. shunt + 2 divider = 5 parts

If the rest of your circuit is also 3.3V, you may monitor current after LDO.   

Title: Re: Simple current detection
Post by: JJalling on February 04, 2021, 05:10:06 pm
Thank you, both of you.

I'll use a CSA, but I have one question; won't I have problems, since my circuit is 3.3v and I want to measure on the 5V circuit?
Or should I just supply the CSA from the 3.3v line, and use the voltage reference in the STM32 to supply the CSA reference?

If the rest of your circuit is also 3.3V, you may monitor current after LDO.   
It's not the 3.3v circuit I want to measure, but whatever is connected to the VBUS, but thanks.

BR Jonas
Title: Re: Simple current detection
Post by: JJalling on February 04, 2021, 05:24:46 pm
Thank you, both of you.

I'll use a CSA, but I have one question; won't I have problems, since my circuit is 3.3v and I want to measure on the 5V circuit?
Or should I just supply the CSA from the 3.3v line, and use the voltage reference in the STM32 to supply the CSA reference?

If the rest of your circuit is also 3.3V, you may monitor current after LDO.   
It's not the 3.3v circuit I want to measure, but whatever is connected to the VBUS, but thanks.

BR Jonas

Well, reading the datasheet answers my question :palm:

BR Jonas
Title: Re: Simple current detection
Post by: Terry Bites on February 05, 2021, 09:36:15 am
isn't that part discontinued?
Title: Re: Simple current detection
Post by: JJalling on February 05, 2021, 09:39:03 am
Hello Terry,

I have picked INA180 - it does what I need :)

Thanks again,

BR Jonas