|
|
@ -47,7 +47,7 @@ int32_t WaterCoolingTemperatureControlModule::getid(int32_t* id) { |
|
|
|
|
|
|
|
void WaterCoolingTemperatureControlModule::createDefaultConfig(config_t* cfg) { |
|
|
|
cfg->fanlevel = 90; |
|
|
|
cfg->min_fanlevel = 30; |
|
|
|
cfg->min_fanlevel = 10; |
|
|
|
cfg->pumplevel = 100; |
|
|
|
cfg->pid_cfg.kp = 10; |
|
|
|
cfg->pid_cfg.ki = 0.5; |
|
|
@ -112,8 +112,8 @@ int32_t WaterCoolingTemperatureControlModule::temp_controler_start_hearting(int3 |
|
|
|
} |
|
|
|
|
|
|
|
ZLOGI(TAG, "temp_controler_start_hearting %d", targetTemperature); |
|
|
|
m_target_temperature = targetTemperature * 10; |
|
|
|
creg.module_status = 1; |
|
|
|
m_target_temperature = targetTemperature / 10.0; |
|
|
|
creg.module_status = 1; |
|
|
|
|
|
|
|
m_fan_ctrl->clearError(); |
|
|
|
m_pelter_ctrl->clearError(); |
|
|
@ -149,6 +149,7 @@ void WaterCoolingTemperatureControlModule::workloop() { |
|
|
|
fan_start(m_cfg.fanlevel); |
|
|
|
int32_t i = 0; |
|
|
|
uint32_t startticket = zos_get_tick(); |
|
|
|
#if 0
|
|
|
|
while (!m_thread.getExitFlag()) { |
|
|
|
if (zos_haspassedms(startticket) > 1000) { |
|
|
|
if (checkdevice() != 0) { |
|
|
@ -165,19 +166,29 @@ void WaterCoolingTemperatureControlModule::workloop() { |
|
|
|
float out = 0; |
|
|
|
m_pidmodule.compute(error, &out); |
|
|
|
|
|
|
|
if (m_enable_log) { |
|
|
|
ZLOGI(TAG, "temperature: %.2f %.2f integral_err:%.2f out:%d", m_target_temperature, val, m_pidmodule.get_integral_err(), (int32_t)out); |
|
|
|
} |
|
|
|
// if (m_enable_log) {
|
|
|
|
ZLOGI(TAG, "temperature: %.2f %.2f integral_err:%.2f out:%d", m_target_temperature, val, m_pidmodule.get_integral_err(), (int32_t)out); |
|
|
|
// }
|
|
|
|
|
|
|
|
peltier_set_power_level(out); |
|
|
|
i++; |
|
|
|
if (i % 10 == 0) { |
|
|
|
int32_t fanspeed = prvabs(out) * 2; |
|
|
|
int32_t fanspeed = prvabs(out) * 1; |
|
|
|
if (fanspeed > 100) fanspeed = 100; |
|
|
|
if (fanspeed < m_cfg.min_fanlevel) fanspeed = m_cfg.min_fanlevel; |
|
|
|
fan_start(fanspeed); |
|
|
|
} |
|
|
|
} |
|
|
|
#endif
|
|
|
|
while (!m_thread.getExitFlag()) { |
|
|
|
m_thread.sleep(10); |
|
|
|
|
|
|
|
float val = read_pid_temperature(); |
|
|
|
|
|
|
|
ZLOGI(TAG, "temperature %f", val); |
|
|
|
// }
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
pump_stop(); |
|
|
|
fan_stop(); |
|
|
@ -186,27 +197,26 @@ void WaterCoolingTemperatureControlModule::workloop() { |
|
|
|
|
|
|
|
#define BIT(x, n) ((x >> n) & 0x01)
|
|
|
|
|
|
|
|
|
|
|
|
int32_t WaterCoolingTemperatureControlModule::checkdevice() { |
|
|
|
ZITemperatureSensor* sensor = m_temperature_sensor[m_hardwared_config.temp_fb_index]; |
|
|
|
if (m_fan_ctrl->isError()) { |
|
|
|
ZLOGE(TAG, "fan_ctrl is error"); |
|
|
|
creg.module_errorcode = err::kwater_cooling_fan_error; |
|
|
|
creg.module_status = 2; |
|
|
|
creg.module_status = 2; |
|
|
|
return 1; |
|
|
|
} else if (m_pump_ctrl->isError()) { |
|
|
|
ZLOGE(TAG, "pump_ctrl is error"); |
|
|
|
creg.module_errorcode = err::kwater_cooling_pump_is_error; |
|
|
|
creg.module_status = 2; |
|
|
|
creg.module_status = 2; |
|
|
|
return 1; |
|
|
|
} else if (m_pelter_ctrl->isError()) { |
|
|
|
ZLOGE(TAG, "pelter_ctrl is error"); |
|
|
|
creg.module_errorcode = err::kwater_cooling_temperature_sensor_error; |
|
|
|
creg.module_status = 2; |
|
|
|
creg.module_status = 2; |
|
|
|
return 1; |
|
|
|
} else if (sensor->isError()) { |
|
|
|
creg.module_errorcode = err::kwater_cooling_temperature_sensor_error; |
|
|
|
creg.module_status = 2; |
|
|
|
creg.module_status = 2; |
|
|
|
ZLOGE(TAG, "sensor is error"); |
|
|
|
return 1; |
|
|
|
} |
|
|
|