Skip to content

Commit

Permalink
fix: stop timer when turning off all the thyristors at the end of the…
Browse files Browse the repository at this point in the history
… semi-period
  • Loading branch information
fabianoriccardi committed Nov 5, 2023
1 parent 218b312 commit d8a9455
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/thyristor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static uint16_t semiPeriodLength = 0;
// Tune this parameters accordingly to your setup (electrical network, MCU, and ZC circuitry).
// Values are expressed in microseconds.
static const uint16_t startMargin = 200;
static const uint16_t endMargin = 600;
static const uint16_t endMargin = 500;

// This parameter represents the time span in which 2 (or more) very near delays are merged (the
// higher ones are merged in the smaller one). This could be necessary for 2 main reasons:
Expand Down Expand Up @@ -144,6 +144,10 @@ void turn_off_gates_int() {
for (int i = alwaysOnCounter; i < Thyristor::nThyristors; i++) {
digitalWrite(pinDelay[i].pin, LOW);
}

#if defined(ARDUINO_ARCH_AVR)
timerStop();
#endif
}

/**
Expand Down

0 comments on commit d8a9455

Please sign in to comment.