 # INA169 High Side current monitor

Hey peeps! So, I've been a long time reader of this fine forum here and ran into an issue tonight with one of these little INA169's. INA169. I am not using the sparkfun breakout board, I am using a single IC breakout board and building the circuit around that on a bread board.

The lowest resistor I have right now is a 10ohm using that as my shunt and 100kohm as my external resistor R(L). I am also following the generic circuit diagram on page 1 of the datasheet.

I am using this as my code.

``````/*
11-14-2013
SparkFun Electronics 2013
Shawn Hymel

This code is public domain but you buy me a beer if you use this
and we meet someday (Beerware license).

Description:

This sketch shows how to use the SparkFun INA169 Breakout
Board. As current passes through the shunt resistor (Rs), a
voltage is generated at the Vout pin. Use an analog read and
some math to determine the current. The current value is
displayed through the Serial Monitor.

Hardware connections:

Uno Pin    INA169 Board    Function

+5V        VCC             Power supply
GND        GND             Ground
A0         VOUT            Analog voltage measurement

VIN+ and VIN- need to be connected inline with the positive
DC power rail of a load (e.g. an Arduino, an LED, etc.).

*/

// Constants
const int SENSOR_PIN = A0;  // Input pin for measuring Vout
const int RS = 10;          // Shunt resistor value (in ohms)
const int VOLTAGE_REF = 5;  // Reference voltage for analog read

// Global Variables
float sensorValue;   // Variable to store value from analog read
float current;       // Calculated current value

void setup() {

// Initialize serial monitor
Serial.begin(9600);

}

void loop() {

// Read a value from the INA169 board

// Remap the ADC value into a voltage number (5V reference)
sensorValue = (sensorValue * VOLTAGE_REF) / 1023;

// Follow the equation given by the INA169 datasheet to
// determine the current flowing through RS. Assume RL = 100k
// Is = (Vout x 1k) / (RS x RL)
current = sensorValue / (100000 * RS);

// Output value (in amps) to the serial monitor to 3 decimal
// places
Serial.print(current, 3);
Serial.println(" A");

// Delay program for a few milliseconds
delay(500);

}
``````

Which as you can see is the code for the Sparkfun breakout board. I did modify the code to accommodate my minor changes in resistor size.

All I am trying to measure at this point is constant current draw. LED or several LED's. With it all hooked up I get no reading in the serial monitor just 0.000. I modified code to add more decimal places and got some kind of reading. Thing is that when I add LED's current draw drops according to serial monitor. Also the voltage on the external resistor decreases when I add LED's. One LED should at least draw 1mA of current.

So where am I going wrong here. I am at a loss because I do not understand how to calculate shunt resistor size and also not understanding what the external resistor actually does in this case. If anyone is willing to educate me I would be more than appreciative. And so you know I was measuring voltage drop across the resistors with a Fluke DMM, Thanks for any help in advance.

Alrighty so upon some more fooling around I have gotten the thing to output an increase when there is an increase instead of a decrease. Had a wire hooked up wrong. I swear I looked over it 100 times but alas that is fixed now.

The new problem is this. Serial output is showing .000814598. I changed code to allow more decimals. I have the LED connected in series with a 1/4watt 330 ohm 5% resistor. My shunt is also a 5% resistor but it measures 9.9ohms. R(L) measure 1017ohms.

I changed this

``````current = sensorValue / (1000 * RS);
``````

to this

``````current = sensorValue / (10 * RS);
``````

Which datasheet shows a R(L) value of 10k gives you a voltage gain of 10. So I fixed that error. I was thinking the actual resistor value went there.

So with code fixed and circuit connected right why am I still not getting what I am supposed to. I guess I need to calculate current draw based on measured values and go from there but am still confused. My level of proffeciency with electronics especially when it comes to sensors and MCU's is in a toddler stage so to speak. So again any help is greatly appreciated.

Just so you guys know. I have figured this out. It helps when you put the components in the correct holes on your bread board. I had the R(L) resistor in the row right above where it should have been. Everything work as it should now.