News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

INA226 any code

Started by John Drew, Sep 17, 2025, 07:41 AM

Previous topic - Next topic

John Drew

I'm starting on a project using the INA226 by TI. It's a power/voltage/current measuring device.
It comes on a tiny board with a load resistor and the necessary parts for a few dollars. It's programmed and accessed by I2C.
Has anyone used this device successfully? If so it would save me a lot of time to get some help. The datasheet is OK but moderately complex.
I reckon I can do the fundamentals such as setting up the I2C. Data comms are 16 bit.
Best wishes
John

RGV250

Hi John,
I wonder how it differs from INA260?

Bob

John Drew

Hi Bob,
I'll check in the morning. I may have it worked out after reading the datasheet three times in between having a piece of chocolate, talking to the next door neighbour and making my wife a cup of coffee :-)
My attention span is becoming a bit short of late.
I'd be very interested in any code you might have for the other device though.
Cheers
John

RGV250


RGV250

Hi John,
I had a quick look at the datasheet and some of the registers are different (probably most) but I think the code I posted should give you a good start.

Bob

John Drew

Thanks Bob,
I'll have a good look, even if the registers are different I can be guided by your code. I've used I2C often enough to make that function work.
Cheers
John

John Drew

A very nice piece of code Bob. I can see what you're doing and it's enough to confirm I'm on the right track.
I'll also compare the data sheets in the next few days.
Thanks again for your support.
John

RGV250

Hi John,
If i am still in hospital today I will have a look and modify the definitions file if that will help.
Otherwise I will probably be bored senseless :)

Bob

top204

Hello Bob

If you do not mind me asking... Why are you in hospital?

Best regards
Les

RGV250

Hi John,
Sleepless night even after reading datasheets :)
From what I can see they are almost identical, the 226 is an earlier model by the looks of it.

The address is the same, note the comment I have not allowed all options but I doubt that would be an issue for you.

Some of the bit names have changed but the bit position doesn't seem to have.
I checked Mode, Conversion times, Average count.

The Die ID is different so in the BAS file you will need to change 2270 for 2260 for the device present test.

The only differences I can see is the Calibration register which I have not read up on as the later one does not need it.
Also the Current register is now 04h and there is a Shunt Register which is 01h (what was the current register in the 260) I think that is the voltage across the shunt resistor but without reading up on it I do not know why you would need it and obviously they agree as it is not present in the 260.

I hope that helps, I have not altered the files as there is so little by the time you download it you could do it.

It is good to know that some companies do not change lots of things for no logical reason, not mentioning any names :)

If I get time I will try to look up what is needed for the Calibration and shunt regs.

Bob

RGV250

Hi Les,
I was walking home Tuesday afternoon and felt like a geriatric, out of breath going up a couple of steps. Tuesday night I had no sleep and could not get out of bed, I lost appetite and the thought of food made me feel sick, even beer :) I thought it was just a bug and would soon pass, a woman from the NHS who is seeing me for other issues said it is not normal so get it sorted.
I called GP and got referred to Chemist, she said out of her scope, you need to go to A&E if you are that short of breath especially with all the other symptoms. At hospital I could barely stand up without falling over while checking in.
They did blood tests and said there is an infection, put me on a drip and other stuff. The nebuliser caused a major issue, quite a while in I got a massive chest pain and pulse rocketed to 140/m resting. The have apparently sorted the high pulse but I want to know what happens when the medication they gave me for that wears off, will it rocket again. Now blood pressure is too low.

Regards,
Bob

John Drew

Hi Bob,
I'm sorry to hear about the health problems. They sound serious enough to warrant close watching.
No health system is perfect and they all like to shove people out the door as soon as possible.
My little project is a tiny blip compared with looking after your health.
Best wishes,
John