INA219 Current Sensor , PWM and Mosfets
Moderators: adafruit_support_bill, adafruit

INA219 Current Sensor , PWM and Mosfets

by bitspaz on Sat Jan 12, 2013 12:59 am

Hello,

I'm using an Arduino and Mosfets to modulate LED RGB light strips. The INA219 works fine at full voltage but as it is lowered the mA values get more and more erratic. It works flawlessly when analogWrite is set to 255. However values at 230 and below cause the INA219 to output ranges from 7.05 mA to 6553.40 mA.

Here is a webpage with a photo of the setup and a screenshot of the serial window. The digital scrap on the left is the LED block covered with a DMV post it. I tried panorama mode on my phone to get a close up and moved to quickly at the end.

http://www.ultrafuzz.net/currentQuery.html

Thanks in advance
bitspaz
 
Posts: 12
Joined: Thu Feb 09, 2012 12:26 pm

Re: INA219 Current Sensor , PWM and Mosfets

by adafruit_support_bill on Sat Jan 12, 2013 8:07 am

I'm using an Arduino and Mosfets to modulate LED RGB light strips. The INA219 works fine at full voltage but as it is lowered the mA values get more and more erratic.


That is because the modulation is done with PWM. You are not really lowering the voltage, just sending shorter and shorter pulses of the same voltage. The corresponding current draw will not be a constant value. Depending on how you have things connected, you might be able to smooth the signal a bit with a capacitor. Or you can filter it in software by taking the average of multiple readings.
User avatar
adafruit_support_bill
 
Posts: 31061
Joined: Sat Feb 07, 2009 10:11 am

Re: INA219 Current Sensor , PWM and Mosfets

by bitspaz on Sat Jan 12, 2013 8:41 pm

That makes sense.

Another question if I may.

I connected the Adafruit Motor Shield duplicating the layout in the INA219 tutorial.
I combined the motor test sketch with the getcurrent sketch inserting the "current_mA = ina219.getCurrent_mA();" line with a "Serial.println" in the for loops.
The mA ebbed and flowed in time with the voltage. It did do with an occasional hiccup but overall it worked great.

The motor shield is using PWM. Is it the capacitors on the shield or is there more to it?

Thanks
bitspaz
 
Posts: 12
Joined: Thu Feb 09, 2012 12:26 pm

Re: INA219 Current Sensor , PWM and Mosfets

by adafruit_support_bill on Sun Jan 13, 2013 7:29 am

Yes, the capacitors C7 & C8 are connected between V+ and GND to smooth out the power demand from the H-Bridge chips.
User avatar
adafruit_support_bill
 
Posts: 31061
Joined: Sat Feb 07, 2009 10:11 am

Re: INA219 Current Sensor , PWM and Mosfets

by bitspaz on Sun Jan 13, 2013 8:08 pm

Thanks, I'll give that a try.
bitspaz
 
Posts: 12
Joined: Thu Feb 09, 2012 12:26 pm