added TPS546 static power offset. Increased delay for power_management_task.c to start

This commit is contained in:
Skot
2024-08-16 22:32:22 -04:00
parent 7a074609b0
commit be1242ec61
4 changed files with 87 additions and 88 deletions

View File

@@ -9,8 +9,8 @@
#define BM1370_INITIAL_DIFFICULTY 256
#define BM1370_SERIALTX_DEBUG true
#define BM1370_SERIALRX_DEBUG true
#define BM1370_SERIALTX_DEBUG false
#define BM1370_SERIALRX_DEBUG false
#define BM1370_DEBUG_WORK false //causes insane amount of debug output
static const uint64_t BM1370_CORE_COUNT = 128;

View File

@@ -62,10 +62,10 @@ float EMC2101_get_external_temp(void)
reading >>= 5;
if (reading == EMC2101_TEMP_FAULT_OPEN_CIRCUIT) {
ESP_LOGE(TAG, "EMC2101 TEMP_FAULT_OPEN_CIRCUIT");
ESP_LOGE(TAG, "EMC2101 TEMP_FAULT_OPEN_CIRCUIT: %04X", reading);
}
if (reading == EMC2101_TEMP_FAULT_SHORT) {
ESP_LOGE(TAG, "EMC2101 TEMP_FAULT_SHORT");
ESP_LOGE(TAG, "EMC2101 TEMP_FAULT_SHORT: %04X", reading);
}
float result = (float) reading / 8.0;

View File

@@ -184,7 +184,6 @@ void app_main(void)
xTaskCreate(USER_INPUT_task, "user input", 8192, (void *) &GLOBAL_STATE, 5, NULL);
if (GLOBAL_STATE.ASIC_functions.init_fn != NULL) {
wifi_softap_off();

View File

@@ -26,6 +26,9 @@
#define TPS546_THROTTLE_TEMP 105.0
#define TPS546_MAX_TEMP 145.0
#define SUPRA_POWER_OFFSET 5
#define GAMMA_POWER_OFFSET 5
static const char * TAG = "power_management";
static float _fbound(float value, float lower_bound, float upper_bound)
@@ -115,7 +118,7 @@ void POWER_MANAGEMENT_task(void * pvParameters)
default:
}
vTaskDelay(3000 / portTICK_PERIOD_MS);
vTaskDelay(4000 / portTICK_PERIOD_MS);
while (1) {
@@ -128,6 +131,8 @@ void POWER_MANAGEMENT_task(void * pvParameters)
power_management->current = TPS546_get_iout() * 1000;
// calculate regulator power (in milliwatts)
power_management->power = (TPS546_get_vout() * power_management->current) / 1000;
// The power reading from the TPS546 is only it's output power. So the rest of the Bitaxe power is not accounted for.
power_management->power += SUPRA_POWER_OFFSET; // Add offset for the rest of the Bitaxe power. TODO: this better.
} else if (INA260_installed() == true) {
power_management->voltage = INA260_read_voltage();
power_management->current = INA260_read_current();
@@ -140,19 +145,16 @@ void POWER_MANAGEMENT_task(void * pvParameters)
power_management->current = TPS546_get_iout() * 1000;
// calculate regulator power (in milliwatts)
power_management->power = (TPS546_get_vout() * power_management->current) / 1000;
// The power reading from the TPS546 is only it's output power. So the rest of the Bitaxe power is not accounted for.
power_management->power += GAMMA_POWER_OFFSET; // Add offset for the rest of the Bitaxe power. TODO: this better.
break;
default:
}
power_management->fan_rpm = EMC2101_get_fan_speed();
if (GLOBAL_STATE->asic_model == ASIC_BM1397) {
switch (GLOBAL_STATE->device_model) {
case DEVICE_MAX:
case DEVICE_ULTRA:
case DEVICE_SUPRA:
case DEVICE_GAMMA:
power_management->chip_temp_avg = EMC2101_get_external_temp();
if ((power_management->chip_temp_avg > THROTTLE_TEMP) &&
@@ -170,12 +172,6 @@ void POWER_MANAGEMENT_task(void * pvParameters)
exit(EXIT_FAILURE);
}
break;
default:
}
} else if (GLOBAL_STATE->asic_model == ASIC_BM1366 || GLOBAL_STATE->asic_model == ASIC_BM1368 || GLOBAL_STATE->asic_model == ASIC_BM1370) {
switch (GLOBAL_STATE->device_model) {
case DEVICE_MAX:
case DEVICE_ULTRA:
case DEVICE_SUPRA:
@@ -192,9 +188,10 @@ void POWER_MANAGEMENT_task(void * pvParameters)
break;
}
//overheat mode if the voltage regulator or ASIC is too hot
if ((power_management->vr_temp > TPS546_THROTTLE_TEMP || power_management->chip_temp_avg > THROTTLE_TEMP) &&
(power_management->frequency_value > 50 || power_management->voltage > 1000)) {
ESP_LOGE(TAG, "OVERHEAT VR: %fC ASIC %fC", power_management->vr_temp, power_management->chip_temp_avg );
ESP_LOGE(TAG, "OVERHEAT! VR: %fC ASIC %fC", power_management->vr_temp, power_management->chip_temp_avg );
EMC2101_set_fan_speed(1);
if (GLOBAL_STATE->board_version == 402) {
@@ -207,6 +204,7 @@ void POWER_MANAGEMENT_task(void * pvParameters)
nvs_config_set_u16(NVS_CONFIG_ASIC_FREQ, 50);
nvs_config_set_u16(NVS_CONFIG_FAN_SPEED, 100);
nvs_config_set_u16(NVS_CONFIG_AUTO_FAN_SPEED, 0);
nvs_config_set_u16(NVS_CONFIG_OVERHEAT_MODE, 1);
exit(EXIT_FAILURE);
}
@@ -220,9 +218,10 @@ void POWER_MANAGEMENT_task(void * pvParameters)
break;
}
//overheat mode if the voltage regulator or ASIC is too hot
if ((power_management->vr_temp > TPS546_THROTTLE_TEMP || power_management->chip_temp_avg > THROTTLE_TEMP) &&
(power_management->frequency_value > 50 || power_management->voltage > 1000)) {
ESP_LOGE(TAG, "OVERHEAT VR: %fC ASIC %fC", power_management->vr_temp, power_management->chip_temp_avg );
ESP_LOGE(TAG, "OVERHEAT! VR: %fC ASIC %fC", power_management->vr_temp, power_management->chip_temp_avg );
EMC2101_set_fan_speed(1);
@@ -233,12 +232,13 @@ void POWER_MANAGEMENT_task(void * pvParameters)
nvs_config_set_u16(NVS_CONFIG_ASIC_FREQ, 50);
nvs_config_set_u16(NVS_CONFIG_FAN_SPEED, 100);
nvs_config_set_u16(NVS_CONFIG_AUTO_FAN_SPEED, 0);
nvs_config_set_u16(NVS_CONFIG_OVERHEAT_MODE, 1);
exit(EXIT_FAILURE);
}
break;
default:
}
}
if (auto_fan_speed == 1) {