added calls to Adafruit_INA219 libs

pull/10/head
alanbjohnston 7 years ago committed by GitHub
parent 3be2f3b5ba
commit 9e0e42617e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -356,11 +356,14 @@ int get_tlm(int tlm[][5]) {
// read i2c current sensors // // read i2c current sensors //
double current = 0, power = 0, y_current = 0, y_power = 0, z_current = 0, z_power = 0; double current = 0, power = 0, y_current = 0, y_power = 0, z_current = 0, z_power = 0;
if (x_fd != -1) { if (x_fd != -1) {
wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue); // wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue);
wiringPiI2CWriteReg16(x_fd, INA219_REG_CONFIG, config); // wiringPiI2CWriteReg16(x_fd, INA219_REG_CONFIG, config);
setCalibration_16V_400mA(x_fd);
int blink; int blink;
for (blink = 1; blink < 20 ;blink++) { for (blink = 1; blink < 20 ;blink++) {
delay(500); /* delay(500);
int shuntVolts = wiringPiI2CReadReg16(x_fd, INA219_REG_SHUNTVOLTAGE); // * 0.01; int shuntVolts = wiringPiI2CReadReg16(x_fd, INA219_REG_SHUNTVOLTAGE); // * 0.01;
delay(500); delay(500);
int busVolts = wiringPiI2CReadReg16(x_fd, INA219_REG_BUSVOLTAGE); // * 0.001; int busVolts = wiringPiI2CReadReg16(x_fd, INA219_REG_BUSVOLTAGE); // * 0.001;
@ -368,11 +371,19 @@ int get_tlm(int tlm[][5]) {
double volts = busVolts * 0.001 + shuntVolts * 0.01; double volts = busVolts * 0.001 + shuntVolts * 0.01;
printf("********** -X 0x40 volts %4.2f busvoltage %d shutVoltage %d\n", volts, busVolts, shuntVolts); printf("********** -X 0x40 volts %4.2f busvoltage %d shutVoltage %d\n", volts, busVolts, shuntVolts);
*/
float shuntVolts = getShuntVoltage_mV(x_fd);
float busVolts = getBusVoltage_V(x_fd);
current = getCurrent_mA(x_fd);
power = getPower_mW(x_fd);
printf("********** -X 0x40 busVolts %4.2f shuntVolts %4.2f current %4.2f power %4.2f \n", busVolts, shuntVolts, current, power);
delay(500); delay(500);
} }
wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue); // wiringPiI2CWriteReg16(x_fd, INA219_REG_CALIBRATION, x_calValue);
current = wiringPiI2CReadReg16(x_fd, INA219_REG_CURRENT) / x_currentDivider; // current = wiringPiI2CReadReg16(x_fd, INA219_REG_CURRENT) / x_currentDivider;
power = wiringPiI2CReadReg16(x_fd, INA219_REG_POWER) * x_powerMultiplier; // power = wiringPiI2CReadReg16(x_fd, INA219_REG_POWER) * x_powerMultiplier;
wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue); wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue);
wiringPiI2CWriteReg16(y_fd, INA219_REG_CONFIG, config); wiringPiI2CWriteReg16(y_fd, INA219_REG_CONFIG, config);
wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue); wiringPiI2CWriteReg16(y_fd, INA219_REG_CALIBRATION, x_calValue);

Loading…
Cancel
Save

Powered by TurnKey Linux.