Using multiple INA260 breakouts

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
afkor
 
Posts: 13
Joined: Tue Mar 14, 2017 7:39 am

Using multiple INA260 breakouts

Post by afkor »

Hi all, I'm trying to use 3 INA260 power sensors in the same circuit and am not getting reasonable and consistent measurements. I have the jumpers soldered so that each sensor has a different I2C address and the sensors initialize and respond to commands correctly. My problem is likely my circuit.

First off: Although I've done several projects and this one is not even the most complex, I am not much of a hardware guy--I'm still trying to figure out most of this stuff!

The project is a simple switch box that controls three different voltages: 12V, 15V, and 24V sources. The 12 and 24 volt circuits are switched through relays. The 15V circuit is always on and provides power to the microcontroller and other devices via a DC buck converter. Expected loads are about 3.5 amps on the 24V, 2 amps on the 15V, and usually 2 to 4 amps on the 12V, but up to 7 amps in certain configurations. The measurements on all three sensors bounce around by almost 2V. The current readings bounce around also by up to about 0.5 amps. The current readings when no load is attached to the 12V and 24V circuits are large: around 5 amps on the 12V and around 10 amps on the 24V. I read the data sheet and have tried adjusting the conversion times and averaging counts since I really only need to read the sensors once every half second or so. This did not make a difference.

I suspect my problem is the circuit itself. I really don't understand high side vs low side for power sensing. I think I am measuring before the load, so I am using the high side configuration. The examples in the tutorial that the negative side of the circuit to be measures should be tied to the microcontroller ground. I suspect that this is where my problem is. I simply tied all of the grounds together at the incoming connector and routed that to the microcontroller's ground. So three separate circuits now share a ground. Is this the correct way to do that? If not, how should that be done--how does one use multiple sensors to measure the voltage and current of independent circuits?

The microcontroller is a Teensy 4.0. Not connected in the Fritzing diagram (attached) are two buttons, a TFT display, and an ESP32 breakout to allow switch control and voltage/current monitoring via WIFI. These do not affect the sensors and trying to get all of their wires where they need to be makes the Fritzing diagram unreadable.

Here is the class for sensor operations. It really is basically the example program encapsulated to make it easy to control 3 sensors.
Sensor.h:

Code: Select all

  
#ifndef __SENSOR__H
#define __SENSOR__H

#include <stdint.h>
#include <Adafruit_INA260.h>
#include <Diag.h>

// Global Constants ************************************************************

//******************************************************************************
class Sensor : public Adafruit_INA260 
{
    public:
                Sensor();
        bool    begin(uint8_t i2c_addr = INA260_I2CADDR_DEFAULT, TwoWire *theWire = &Wire);
        bool    update(void);

        char*   voltageValue(void);
        char*   currentValue(void);
        void    status(float* volts, float_t* amps);

    private:  
        void        _read_sensor(float* volts, float* amps);
        
        bool        _sensor_OK;

        float       _volts;
        float       _amps;

        char        _voltageValue[8];
        char        _currentValue[8];
};

#endif // __SENSOR__H
And Sensor.cpp:

Code: Select all

#include "Sensor.h"

//******************************************************************************
Sensor::Sensor() : Adafruit_INA260()
{
    return;
}

//******************************************************************************
bool Sensor::begin(uint8_t i2c_addr, TwoWire *theWire)
{
    _sensor_OK = Adafruit_INA260::begin(i2c_addr, theWire);

    setCurrentConversionTime(INA260_TIME_1_1_ms);
    setVoltageConversionTime(INA260_TIME_1_1_ms);
    setAveragingCount(INA260_COUNT_4);
    
    if (_sensor_OK)
        _read_sensor(&_volts, &_amps);

    return (_sensor_OK);
}

//******************************************************************************
void Sensor::_read_sensor(float* volts, float* amps)
{
    *volts = readBusVoltage() / 1000.0;
    *amps  = readCurrent() / 1000.0;

    diag(3, "SENSOR::read_sensor() - volts: %8.4f  amps: %8.4f\n", *volts, *amps);
    return;
}

//******************************************************************************
bool Sensor::update(void)
{
    if (_sensor_OK == false)
        return false;

    _read_sensor(&_volts, &_amps);
    return true;
}

//******************************************************************************
char* Sensor::voltageValue()
{
    if (_sensor_OK == false)
        return (char*) "--.-";

    snprintf(_voltageValue, sizeof(_voltageValue), "%4.1f V", _volts);
    return _voltageValue;    
}

//******************************************************************************
char* Sensor::currentValue()
{
    if (_sensor_OK == false)
        return (char*) "--.-";

    snprintf(_currentValue, sizeof(_currentValue), "%4.1f A", _amps);
    return _currentValue;    
}

//******************************************************************************
void Sensor::status(float* volts, float* amps)
{
    *volts = _volts;
    *amps = _amps;
    return;
}
As I said above, I suspect the issue is the combining of the 3 circuits' grounds. I'd appreciate enlightenment from anyone who can give it!

Thanks - Shane
Attachments
Fritzing Diagram
Fritzing Diagram
M2PB_bb.png (592.44 KiB) Viewed 565 times

User avatar
afkor
 
Posts: 13
Joined: Tue Mar 14, 2017 7:39 am

Re: Using multiple INA260 breakouts

Post by afkor »

I guess monitoring multiple circuits is a weird thing to do and no one has any suggestions.

Can anyone explain the practical difference between high side and low side monitoring and in what situations you would choose one over the other. I have read several articles that tell what they are and details like what type of amplifier is used, but haven't found anything that tells me which would be better for what situations. And my lack of hardware experience impairs my understanding of those articles anyway. If anyone has a "Current Sensing for Dummies" explanation, please send it my way!

Back to the project: I'm going to try adding i2c isolators and individual buck converters for each circuit to separate their grounds. I just ordered parts and will report back if that works.

- Shane

User avatar
adafruit_support_bill
 
Posts: 88089
Joined: Sat Feb 07, 2009 10:11 am

Re: Using multiple INA260 breakouts

Post by adafruit_support_bill »

Your diagram seems to be missing some connections. But the power & ground connections look OK. When the relays are open, the V+ terminal of the sensor will be 'floating', so the values reported will be unpredictable.

High side monitoring is useful for circuits which depend on a stable ground reference. Since the current measurement inserts a shunt resistor into the current path, there will be a voltage drop that is proportional to the current draw. If the shunt resistor is inserted on the 'low side', that means your ground reference will vary with the current.

User avatar
afkor
 
Posts: 13
Joined: Tue Mar 14, 2017 7:39 am

Re: Using multiple INA260 breakouts

Post by afkor »

Thanks for the response, Bill.

By "missing some connections" are you refering to the buttons, display, and ESP32? Or am I missing something else?

I can handle the floating values when the relays are off in the code, since I know when I turn the relays on and off, I ignore the values from the meter because I know that they are 0.

The issues I'm seeing is that the voltage and current float around quit a bit (several volts and 10's of amps) when the realys are on and a load is attached. I also see interplay between loads on separate circuits which I attribute to having all of the negatives tied together and running to the meters' grounds. I don't really _know_ if that is the problem, but I can see that it is probably not the correct thing to do.

That is why I'm going to try isolating the negatives, meter grounds, and I2C connections. If fact, the Adafruit 1540 breakout says in the seconds sentence of its description: "Maybe because one is Earth-grounded, maybe because you've got some funky power monitoring setup, maybe you want to reduce noise." I guess I might have a "funky power monitoring setup"!

Anyway, thanks for the response and I'll post success or failure when I get the parts and have time to add them to an already crowded enclosure.

- Shane

User avatar
adafruit_support_bill
 
Posts: 88089
Joined: Sat Feb 07, 2009 10:11 am

Re: Using multiple INA260 breakouts

Post by adafruit_support_bill »

By "missing some connections" are you refering to the buttons, display, and ESP32? Or am I missing something else?
Two of your sensors have no connections to the processor. And there is also no clear power or ground connection for the processor.
The issues I'm seeing is that the voltage and current float around quit a bit (several volts and 10's of amps) when the realys are on and a load is attached. I also see interplay between loads on separate circuits
What are the loads? Some loads are less well behaved than others.

User avatar
afkor
 
Posts: 13
Joined: Tue Mar 14, 2017 7:39 am

Re: Using multiple INA260 breakouts

Post by afkor »

Hmm, those connections are in the Fritzing file--for some reason they are not exporting to the PNG. Maybe I need to update Fritzing. Anyway, all of the sensor pins (Vcc, GND, SCL, and SDA) are simply daisy chained from the top to middle to bottom sensor. And the Teensy 2 grounds connected to the ground bus on the perma-proto board.

The loads are:
12V: Pegasus Ultimate Power Box that, in turn, powers various astrophotography instruments including a cooled CCD camera (12V, up to 3A, when cooler is at 100%, 2 uncooled CCD cameras (via USB), focus controller and motor (12V, negligible A) and other sensors internal to the UPB.
15V: The Teensy and other switch components and a NUC headless PC (15V, not more than 2.5A).
24V: Telescope mount. Controller and 2 stepper motors. Max current with both motors at full speed is around 3.2A.

Thanks - Shane

User avatar
adafruit_support_bill
 
Posts: 88089
Joined: Sat Feb 07, 2009 10:11 am

Re: Using multiple INA260 breakouts

Post by adafruit_support_bill »

12V: Pegasus Ultimate Power Box that, in turn, powers various astrophotography instruments including a cooled CCD camera (12V, up to 3A, when cooler is at 100%, 2 uncooled CCD cameras (via USB), focus controller and motor (12V, negligible A) and other sensors internal to the UPB.
Most likely Peltier cooling modules with PWM temperature control. These can generate quite a bit of switching noise from the PWM.
24V: Telescope mount. Controller and 2 stepper motors. Max current with both motors at full speed is around 3.2A.
Stepper motors actually draw less current at higher speeds. They also tend to be quite noisy electrically.

User avatar
afkor
 
Posts: 13
Joined: Tue Mar 14, 2017 7:39 am

Re: Using multiple INA260 breakouts

Post by afkor »

Since I said I'd give an update or success/failure, here it is: Success.

I split out the three separate circuits to isolate their gounds from each other. I added 2 I2C isolators (Adafruit part # 4903) and changed the input voltage to 5VDC to use 3 separate buck converters, 2 Adafruit part # 4739 for the 12V and 15V circuits and a 7805TO-220 with a couple of capacitors for the 24V circuit, keeping their grounds isolated from each other, each running straight from the DC-DC converter to the I2C isolator. I also wen ahead and did a custom PCB for it so eliminate the wire tangle.

I didn't update the Fritzing diagram since the changes were pretty easy to do without much planning. I did do a schematic and board in Eagle Cad. I'm attaching the schematic, if anyone is really interested in my final solution.

Anyway, it works great, it's currently in use in the observatory, and I, being a software guy not a hardware guy, learned that you can't just tie a bunch of independent circuits' grounds together and expect reasonable results!

- Shane
Attachments
PB01_schematic.png
PB01_schematic.png (145.72 KiB) Viewed 441 times

User avatar
adafruit_support_bill
 
Posts: 88089
Joined: Sat Feb 07, 2009 10:11 am

Re: Using multiple INA260 breakouts

Post by adafruit_support_bill »

Good to hear things are working for you. Thanks for the update.

User avatar
adaTinker
 
Posts: 10
Joined: Sat Sep 03, 2016 5:01 pm

Re: Using multiple INA260 breakouts

Post by adaTinker »

@afkor I too was getting erratic readings. for example negative current with an LED load!

I set these max settings.

Code: Select all

    setMode(INA260_MODE_CONTINUOUS); 
    setCurrentConversionTime(INA260_TIME_8_244_ms);
    setVoltageConversionTime(INA260_TIME_8_244_ms);
    setAveragingCount(INA260_COUNT_128);
Since I only poll the values every 15 seconds the longer wait time is acceptable.

With this the results are very consistent. (haven't check accuracy though)

User avatar
afkor
 
Posts: 13
Joined: Tue Mar 14, 2017 7:39 am

Re: Using multiple INA260 breakouts

Post by afkor »

Thanks adaTinker,

I am polling once a second so I'm using the values that I posted. I really don't think that was the problem, though. I really think that you shouldn't just tie non-related grounds together! When I turned one circuit on, the other two's sensor values changed significantly. Anyway, now that all of my circuits are isolated, it works fine--another project that, eventually, turned out just like I wanted it to!

- Shane

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”