0

Using multiple INA260 breakouts
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Using multiple INA260 breakouts

by afkor on Sun May 09, 2021 9:06 pm

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 | TOGGLE FULL SIZE
 
#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 | TOGGLE FULL SIZE
#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
M2PB_bb.png
Fritzing Diagram
M2PB_bb.png (592.44 KiB) Viewed 113 times

afkor
 
Posts: 8
Joined: Tue Mar 14, 2017 7:39 am

Re: Using multiple INA260 breakouts

by afkor on Tue May 11, 2021 10:00 am

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

afkor
 
Posts: 8
Joined: Tue Mar 14, 2017 7:39 am

Re: Using multiple INA260 breakouts

by adafruit_support_bill on Tue May 11, 2021 10:29 am

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.

adafruit_support_bill
 
Posts: 81297
Joined: Sat Feb 07, 2009 10:11 am

Re: Using multiple INA260 breakouts

by afkor on Wed May 12, 2021 8:09 pm

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

afkor
 
Posts: 8
Joined: Tue Mar 14, 2017 7:39 am

Re: Using multiple INA260 breakouts

by adafruit_support_bill on Wed May 12, 2021 8:41 pm

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.

adafruit_support_bill
 
Posts: 81297
Joined: Sat Feb 07, 2009 10:11 am

Re: Using multiple INA260 breakouts

by afkor on Thu May 13, 2021 8:55 am

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

afkor
 
Posts: 8
Joined: Tue Mar 14, 2017 7:39 am

Re: Using multiple INA260 breakouts

by adafruit_support_bill on Thu May 13, 2021 10:19 am

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.

adafruit_support_bill
 
Posts: 81297
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.