DC/DC: Add some safety functions to test mode

This commit is contained in:
Martin Jäger
2021-07-14 15:40:17 +02:00
parent da04994ae6
commit 3b72694deb
2 changed files with 17 additions and 4 deletions
+16 -3
View File
@@ -286,11 +286,24 @@ __weak void Dcdc::control()
void Dcdc::test()
{
if (half_bridge_enabled()) {
if (half_bridge_get_duty_cycle() > 0.5) {
half_bridge_set_ccr(half_bridge_get_ccr() - 1);
const char *stop_reason = NULL;
if (lvb->voltage > ls_voltage_max || hvb->voltage > hs_voltage_max) {
stop_reason = "emergency (voltage limits exceeded)";
}
else if (enable == false) {
stop_reason = "disabled";
}
else {
half_bridge_set_ccr(half_bridge_get_ccr() + 1);
if (half_bridge_get_duty_cycle() > 0.50) {
half_bridge_set_ccr(half_bridge_get_ccr() - 1);
}
else {
half_bridge_set_ccr(half_bridge_get_ccr() + 1);
}
}
if (stop_reason != NULL) {
stop();
printf("DC/DC Stop: %s.\n", stop_reason);
}
}
else {
+1 -1
View File
@@ -110,7 +110,7 @@ public:
void control();
/**
* Test mode for DC/DC, ramping up to 50% duty cycle
* Test mode for DC/DC, ramping up/down to 50% duty cycle
*/
void test();