Skip to content

Commit 373e6f4

Browse files
committed
1 parent 01bde48 commit 373e6f4

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/eez/modules/psu/channel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ float Channel::getSwOvpProtectionLevel() {
537537

538538
bool Channel::checkSwOvpCondition() {
539539
float uProtectionLevel = getSwOvpProtectionLevel();
540-
return channel_dispatcher::getUMonLast(*this) + 0.5 > uProtectionLevel || (flags.rprogEnabled && channel_dispatcher::getUMonDacLast(*this) > uProtectionLevel);
540+
return channel_dispatcher::getUMonLast(*this) > uProtectionLevel || (flags.rprogEnabled && channel_dispatcher::getUMonDacLast(*this) > uProtectionLevel);
541541
}
542542

543543
void Channel::protectionCheck(ProtectionValue &cpv) {

src/eez/modules/psu/list_program.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -591,9 +591,12 @@ void tick(uint32_t tick_usec) {
591591

592592
active = true;
593593

594-
uint32_t tickCount = millis();
595-
if (g_execution[i].currentTotalDwellTime <= CONF_COUNTER_THRESHOLD_IN_SECONDS) {
596-
tickCount *= 1000;
594+
uint32_t tickCount;
595+
bool tickCountInMillis = g_execution[i].currentTotalDwellTime > CONF_COUNTER_THRESHOLD_IN_SECONDS;
596+
if (tickCountInMillis) {
597+
tickCount = millis();
598+
} else {
599+
tickCount = millis() * 1000;
597600
}
598601

599602
if (io_pins::isInhibited()) {
@@ -638,9 +641,15 @@ void tick(uint32_t tick_usec) {
638641
if (g_execution[i].currentTotalDwellTime > CONF_COUNTER_THRESHOLD_IN_SECONDS) {
639642
// ... then count in milliseconds
640643
g_execution[i].currentRemainingDwellTime = (uint32_t)round(g_execution[i].currentTotalDwellTime * 1000L);
644+
if (!tickCountInMillis) {
645+
tickCount /= 1000;
646+
}
641647
} else {
642648
// ... else count in microseconds
643649
g_execution[i].currentRemainingDwellTime = (uint32_t)round(g_execution[i].currentTotalDwellTime * 1000000L);
650+
if (tickCountInMillis) {
651+
tickCount *= 1000;
652+
}
644653
}
645654
g_execution[i].nextPointTime = tickCount + g_execution[i].currentRemainingDwellTime;
646655
}

0 commit comments

Comments
 (0)