Skip to content

Commit

Permalink
Hotfix umwc: send voltage change less often to avoid MCU crash
Browse files Browse the repository at this point in the history
Signed-off-by: Cornelius Claussen <[email protected]>
  • Loading branch information
corneliusclaussen authored and SebaLukas committed Oct 15, 2024
1 parent dce296f commit 6af6a00
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions modules/MicroMegaWattBSP/dc_supply/power_supply_DCImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ void power_supply_DCImpl::init() {
std::thread([this]() {
float low_pass_voltage = 0.;

float last_low_pass_voltage = -1;

while (true) {
std::this_thread::sleep_for(std::chrono::milliseconds(100));
// prevent overshoot
Expand All @@ -48,13 +50,15 @@ void power_supply_DCImpl::init() {
}
}

if (is_on) {
mod->serial.setOutputVoltageCurrent(low_pass_voltage, req_current);

} else {
mod->serial.setOutputVoltageCurrent(0, 0);
if (not is_on) {
low_pass_voltage = 0.;
}

if (last_low_pass_voltage not_eq low_pass_voltage) {
mod->serial.setOutputVoltageCurrent(low_pass_voltage, 0.);
}

last_low_pass_voltage = low_pass_voltage;
}
}).detach();
}
Expand Down

0 comments on commit 6af6a00

Please sign in to comment.