Project

General

Profile

Example Baseboard I2C Power Monitor

Objective

This example demonstrates how to get data from the Baseboard I2C Power Monitor.

The power is monitored by an Analog LTC2945 part. There is a driver in Linux that makes the information about the monitored current, voltage, and power available to applications.

Note: An early version of the LTC2945 driver assumed a resistor value different from the actual resistor value used on the development kit. This difference resulted in values for the current and power which were 10 times larger than the actual values. A change to the driver was made and committed to Linux to correct this. The formulas shown below assume the newer driver is being used.

Prerequisites

  • A serial port connected to Development Kit.

Steps

  • The values from the LTC2945 part are made available in files located at /sys/class/hwmon/hwmon1/*
  • There are 4 values available:
    Value Description
    curr1 Current
    in1 Input voltage
    in2 Internal voltage
    power1 Power
  • For each value, there are several parameters:
    Parameter Description
    highest highest value seen since power-on
    input The value at the present time
    lowest The lowest value seen since power-on
    max The high-threshold above which should raise a max_alarm
    max_alarm Set to 1 if the input value exceeds the max
    min The low-threshold which should raise a min_alarm if lower values are seen
    min_alarm Set to 1 if the input value is below the min
    reset_history Write-only. Write a 1 to this value to clear the highest and lowest values and to clear the alarms.
  • The values displayed are just integers. To convert them to real values, use the following:
    Value Formula
    Current Current in amps = value_shown / 1,000
    Voltage Voltage in volts = value_shown / 1,000
    Power Power in watts = value_shown / 1,000,000
  • Example of all input values:
    root@mitysom-am57x:~# cd /sys/class/hwmon/hwmon1
    root@mitysom-am57x:/sys/class/hwmon/hwmon1# tail *input
    ==> curr1_input <==
    763
    
    ==> in1_input <==
    4975
    
    ==> in2_input <==
    1013
    
    ==> power1_input <==
    3793438
    root@mitysom-am57x:/sys/class/hwmon/hwmon1#
    
  • Using the formulas listed above, this shows the present values of:
    Value Name Value Shown Formula Present Value
    curr1_input 10600 current = value_shown / 1,000 0.763 amps
    in1_input 4975 voltage = value_shown / 1,000 4.975 volts
    in2_input 1013 voltage = value_shown / 1,000 1.013 volts
    power1_input 52735000 power = value_shown / 1,000,000 3.793 watts
  • * Example of all curr1 values:
    root@mitysom-am57x:/sys/class/hwmon/hwmon1# root@mitysom-am57x:/sys/class/hwmon/hwmon1# tail curr1*
    tail: can't open 'curr1_reset_history': Permission denied
    ==> curr1_highest <==
    1393
    
    ==> curr1_input <==
    773
    
    ==> curr1_lowest <==
    520
    
    ==> curr1_max <==
    10238
    
    ==> curr1_max_alarm <==
    0
    
    ==> curr1_min <==
    0
    
    ==> curr1_min_alarm <==
    0
    root@mitysom-am57x:/sys/class/hwmon/hwmon1#
    
    

If the curr1_max value were to be changed to a value of 10000, then the curr1_input value would be greater than the curr1_max and the max_alarm value would be changed to 1. If the curr1_max value is changed back to 102375, then the max_alarm is not cleared until a 1 is written to curr1_reset_history. Writing a 1 to curr1_reset_history will also reset the curr1_lowest and curr1_highest values and they will initially be set to the curr1_input value and will then record the lowest and highest values.

The *_min_alarm and *_max_alarm files could be monitored in Linux if your application wants to monitor these conditions. Note that the alarm conditions only reset when a 1 is written to the appropriate *_reset_history file and will only stay clear until the alarm condition happens again.

Conclusion

This completes the example for the Baseboard I2C Power Monitor. The location of the driver files has been specified, the meaning of the different files has been described, and the methods for converting from the values shown to amps, volts, and watts have been provided and demonstrated.

Go to top
Add picture from clipboard (Maximum size: 1 GB)