EasyManuals Logo

Texas Instruments AM335 Series Design Guide

Texas Instruments AM335 Series
39 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #37 background imageLoading...
Page #37 background image
www.ti.com
Example Source Code
37
SPRAC74AFebruary 2017Revised March 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
Additional Information
DIY INA I2C Measurement
#!/bin/bash
#INA226 Registers
CONFIG_REG=0x0
SHUNTV_REG=0x1
BUSV_REG=0x2
#EVM Specific
declare -a INA_ADDRS=(0x41);
declare -a SUPPLIES=('VDD_MPU ');
declare -a RES=(0.001);
#Take shunt voltage measurements #Re-initialize INA226
i2cset -y 1 ${INA_ADDRS[0]} $CONFIG_REG 0x0080 w
i2cset -y 1 ${INA_ADDRS[0]} $CONFIG_REG 0xFF4F w
shuntv=$(i2cget -y 1 ${INA_ADDRS[0]} $SHUNTV_REG w)
let "temp = shuntv >> 8"
let "temp2 = shuntv << 8 | $temp"
let "shuntv = $temp2 & 0xffff"
let "neg_test = $shuntv & 0x8000"
if [ "$neg_test" -gt 0 ]; then #handle negative
shuntv=0
fi
shuntv=$(echo "$shuntv*0.0025" | bc)
#Take bus voltage measurements #Re-initialize INA226
i2cset -y 1 ${INA_ADDRS[0]} $CONFIG_REG 0x0080 w
i2cset -y 1 ${INA_ADDRS[0]} $CONFIG_REG 0xFF4F w
busv=$(i2cget -y 1 ${INA_ADDRS[0]} $BUSV_REG w)
let "temp = $busv >> 8"
let "temp2 = $busv << 8 | $temp"
let "busv = $temp2 & 0xffff"
busv=$(echo "$busv*0.00125" | bc)
#Calculate power
current=$(echo "${shuntv}/${RES[0]}" | bc -l)
power=$(echo "${current}*${busv}" | bc -l)
#Output to console
printf "Supply\t\tRes (ohm)\tShunt (mV)\tBus (V)\t\tCurrent (mA)\tPower (mW)\n"
printf "%s\t%.3f\t\t%f\t%f\t%f\t%f\n" "${SUPPLIES[0]}" "${RES[0]}" "${shuntv}" "${busv}"
"${current}" "${power}"

Other manuals for Texas Instruments AM335 Series

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Texas Instruments AM335 Series and is the answer not in the manual?

Texas Instruments AM335 Series Specifications

General IconGeneral
BrandTexas Instruments
ModelAM335 Series
CategoryComputer Hardware
LanguageEnglish

Related product manuals