tweak power management

This commit is contained in:
macphyter 2024-02-11 19:37:46 -07:00
parent b8632fcf2b
commit 44092eff01
3 changed files with 30 additions and 10 deletions

View File

@ -503,8 +503,8 @@ void TPS546_write_entire_config(void)
smb_write_byte(PMBUS_VIN_OV_FAULT_RESPONSE, TPS546_INIT_VIN_OV_FAULT_RESPONSE);
/* vout voltage */
ESP_LOGI(TAG, "Setting VOUT");
smb_write_word(PMBUS_VOUT_SCALE_LOOP, TPS546_INIT_SCALE_LOOP); /* no conversion necessary */
ESP_LOGI(TAG, "Setting VOUT SCALE");
smb_write_word(PMBUS_VOUT_SCALE_LOOP, float_2_slinear11(TPS546_INIT_SCALE_LOOP));
ESP_LOGI(TAG, "VOUT_COMMAND");
smb_write_word(PMBUS_VOUT_COMMAND, float_2_ulinear16(TPS546_INIT_VOUT_COMMAND));
ESP_LOGI(TAG, "VOUT_MAX");
@ -655,7 +655,7 @@ float TPS546_get_vout(void)
void TPS546_set_vout(int millivolts)
{
uint16_t value;
float volts = millivolts / 1000;
float volts = (float)millivolts / 1000;
if (volts == 0) {
/* turn off output */
@ -663,12 +663,12 @@ void TPS546_set_vout(int millivolts)
} else {
/* make sure we're in range */
if ((volts < TPS546_INIT_VOUT_MIN) || (volts > TPS546_INIT_VOUT_MAX)) {
ESP_LOGI(TAG, "ERR- Voltage requested (%f) is out of range", volts);
ESP_LOGI(TAG, "ERR- Voltage requested (%f V) is out of range", volts);
} else {
/* set the output voltage */
value = float_2_ulinear16(volts);
smb_write_word(PMBUS_VOUT_COMMAND, value);
ESP_LOGI(TAG, "Vout changed to %f mV", volts);
ESP_LOGI(TAG, "Vout changed to %1.2f V", volts);
/* turn on output */
smb_write_byte(PMBUS_OPERATION, OPERATION_ON);

View File

@ -24,7 +24,7 @@
#define TPS546_INIT_VIN_OV_FAULT_RESPONSE 0xB7 /* retry 6 times */
/* vout voltage */
#define TPS546_INIT_SCALE_LOOP 0xC808 /* 0.125 */
#define TPS546_INIT_SCALE_LOOP 0.125 /* Voltage Scale factor */
#define TPS546_INIT_VOUT_MAX 4.50 /* V */
#define TPS546_INIT_VOUT_OV_FAULT_LIMIT 1.25 /* %/100 above VOUT_COMMAND */
#define TPS546_INIT_VOUT_OV_WARN_LIMIT 1.1 /* %/100 above VOUT_COMMAND */

View File

@ -230,12 +230,32 @@ void POWER_MANAGEMENT_HEX_task(void * pvParameters)
while (1) {
// use TPS546_get_vin() for input voltage
// power_management members
//uint16_t fan_speed;
//float chip_temp;
//float voltage;
//float frequency_multiplier;
//float frequency_value;
//float power;
//float current;
power_management->voltage = TPS546_get_vout();
// For reference:
// TPS546_get_vin()- board input voltage
// we don't have a way to measure board input current
// TPS546_get_out()- core voltage *3 (across all domains)
// TPS546_get_iout()- Current output of regulator
// we don't have a way to measure power, we have to calculate it
// but we don't have total board current, so calculate regulator power
// TPS546_get_temperature()- gets internal regulator temperature
// TMP1075_read_temperature(index)- gets the values from the two board sensors
// TPS546_get_frequency()- gets the regulator switching frequency (probably no need to display)
power_management->voltage = TPS546_get_vin() * 1000;
power_management->current = TPS546_get_iout();
// calculate ASIC power consumed (in milliwatts)
power_management->power = (power_management->voltage * power_management->current) / 1000;
// calculate regulator power (in milliwatts)
power_management->power = (TPS546_get_vout() * power_management->current) / 1000;
// TODO fix fan driver
//power_management->fan_speed = EMC2101_get_fan_speed();