This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

  • TI Thinks Resolved

Linux/INA223: Linux kernel driver & application for INA223

Part Number: INA223

Tool/software: Linux

Hi Sir,

We are using the INA223 for voltage/current monitoring on one of our arm boards.

It is interfaced on I2C BUS and the board is up with linux kernel v4.1.15

I am wondering whether there is any linux driver and user space application available to spped up our development on using this device ?

your help is greatly appreciated. Looking forward for your response.

Please do let me know if you need more information.

Thanks,

Siva

  • In reply to siva prasad15:

    Hey Siva,

    The configuration register address is 0x00. This is because this is the only register in the device. You will write to this register (0x00) in order to set gains for shunt and bus voltage measurements and to set the output mode settings (Table 1 in datasheet). Since there is only one register in the device, once the pointer is set a 0x00, then you can obtain measurements with 3-byte read commands as shown with Figure 40.

    The i2c-tools library in Linux provides a basic library to communicate with devices over the command line. The Linux driver is there to provide device-specific functions in the memory of whatever your system may be. This will make the writing firmware easier.

    Sincerely,
    Peter Iliya
    Current Sensing Applications
  • In reply to siva prasad15:

    Hi Peter,

    Now I am able to see the ina223 device under

    # cat /sys/class/hwmon/hwmon0/name

    ina223
    # cat /sys/class/hwmon/hwmon0/curr1_input
    352
    # cat /sys/class/hwmon/hwmon0/in0_input
    0
    # cat /sys/class/hwmon/hwmon0/name
    ina223
    ~# cat /sys/class/hwmon/hwmon0/power1_input
    0

    in the dmesg, I can see the 

    ~# dmesg | grep ina223
    [ 0.246615] i2c i2c-3: of_i2c: register /soc/aips-bus@30800000/i2c@30a50000/ina223@41
    [ 0.246772] i2c i2c-3: client [ina223] registered with bus id 3-0041
    [ 1.871869] ina223 3-0041: probe
    [ 1.872693] ina223 3-0041: power monitor ina223 (Rshunt = 10000 uOhm)
    [ 1.877880] i2c-core: driver [ina223] registered
    [ 4.551582] ina223 3-0041: uevent
    [ 4.635567] ina223 3-0041: uevent
    [ 4.635820] ina223 3-0041: uevent
    [ 4.636053] ina223 3-0041: uevent

    Now at this stage, I am not sure how to read the current & voltage readings from the driver populated sys filesystem. Could you please assist.

    How can i change the configuration register value from the sysfs using the ina223 driver.

    Please provide me your inputs on this topic. Looking forward for your response

    Best Regards,

    Siva

  • In reply to siva prasad15:

    You cannot read the current or voltage from the INA223 over I2C, it is an analog output only device, not I2C. The I2C interface is only used to select which signal is sent out of the analog output pin, you have to then sample that signal yourself.

    If you are wanting to read these values over I2C then please select one of the devices in this series that does have an internal ADC. If you would also like Linux support I would recommend one of the devices listed in the Linux driver, as these are already supported.

    Andrew

  • In reply to Andrew Davis:

    Hi Andrew,

    Thanks for the inputs. I am using the linux driver and lmsensor application to read the values. Below is the output

    # sensors

    ina223-i2c-0-41
    Adapter: 30a20000.i2c
    in0: +0.00 V
    in1: +0.00 V
    power1: 0.00 W
    curr1: +1.21 A

    The linux driver is for ina226. But the device on the board is ina223 . I am not sure whether i need to do any modifications in the driver to get the correct values.

    The shunt resistor value is 50000 microohms

    From the above output. It shows 0 values for in0, in1 & power1. Could you please provide your inputs where I am missing. 

    Thanking you in advance for your quick response.

    Best Regards,

    Siva

  • In reply to Andrew Davis:

    I am not using the i2ctools to access the device rather I am using the linux driver which takes cares of the samples.
  • In reply to siva prasad15:

    The INA223 is not compatible with the INA226 driver. The INA223 cannot output the voltage or current over I2C as, unlike the INA226, it has no internal ADC. It does not matter what driver or tools you use the device will not give you the current or voltage over I2C. If you need to read the current or voltage over I2C use the INA226.

    Andrew

  • In reply to Andrew Davis:

    Hi Andrew,

    From the earlier posts of this thread its suggested that we can read this device through simple i2c tools and also with the linux driver. 

    But from the latest posts from you gives that we are not in right direction to access this device.

    At this stage if i want to progress with INA223 device to measure the current & Voltage readings. Do I need to connect the analog output to any ADC ?

    If so could you please point to some application note specific to INA223 device. 

    Thanking you in advance for your help. 

    Best Regards,

    Siva

  • In reply to siva prasad15:

    Hi Siva,

    Yes is does look like there was some confusion in the early thread in regards to the driver compatibility.

    You are correct in that you will need to connect the analog output to an ADC. Which one you chose is depedent on your application, for instance if a lot of application processors and micro-controllers have one built in that you can attach to and read from there. If you do not have an ADC available then using an external dedicated one is probably more trouble that it is worth and you should just use the INA226 which has one built in, they are only a couple cents more.

    Thanks,
    Andrew

This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.