ESP32 interupt and timers

SimonS
Posts: 2
Joined: Fri Mar 10, 2023 6:04 pm

ESP32 interupt and timers

Postby SimonS » Fri Mar 10, 2023 6:18 pm

Hi
I need to do simple thing, but I got big problem!
My project is to make PID temperature control for water heater.
I need to control (cut) sinusoidal. This is easy job. I have one optocuppler to detect zero cross and then after xx time open SCR
I got one interpret to detect zero cross and start timer. When timer reach value open SCR and wait few uS and
Everything working random and non stable. ESP is crashing. What do I do wrong?

Code: Select all

void IRAM_ATTR vhod1_ISR() {      //interupt zero cross
  timerAlarmEnable(int_timer);  
}

void IRAM_ATTR prozi_SCR(){    // interupt timer
  digitalWrite(grelec,HIGH);
  delayMicroseconds(100);
  digitalWrite(grelec,LOW);
 timerAlarmDisable(int_timer);
}
 

Code: Select all

  attachInterrupt(nula, vhod1_ISR, RISING);   // zero cross interupt
  
  int_timer = timerBegin(0, 80, true);          // timer
  timerAttachInterrupt(int_timer, &prozi_SCR, true);
  timerAlarmWrite(int_timer, 1000000, true);
in ptogram I use timerWrite(int_timer, PID_value); to set new value of timer

noweare
Posts: 74
Joined: Tue Jul 02, 2019 11:35 am

Re: ESP32 interupt and timers

Postby noweare » Mon Mar 13, 2023 2:55 pm

Do you have a snubber network to control emi/spikes that occur when you open and close the scr.
Normally for a resistive load like a heater you do not need them. But it sounds like each time
the scr turns on/off you get emi that disturbs your esp32.

Can you move the scr further away from the esp32 for testing ?

Also they have Zero crossing Triac modules that turn on or off Triac at zero cross.
You will not have phase control but it may work for you. Basically instead of using the phase control
you use pwm to control the temperature. It will still work using PID control except change the output
to a pwm signal. So 50% pwm means the heat is on 50% of the time, etc.

Check out MOC3043M : 6-Pin DIP Zero-Cross Triac Driver Output Optocoupler
It will simplify your circuit quite a bit.

SimonS
Posts: 2
Joined: Fri Mar 10, 2023 6:04 pm

Re: ESP32 interupt and timers

Postby SimonS » Mon Mar 13, 2023 5:43 pm

Hi
Thanks for replay.
No there is nothing connected to board yet, so it cannot be disturbs.
I know PWM with zero-cross optocupler, but I'd like now this method. Like this I have control of direct power of heater. I have filling, that it will work better.

Who is online

Users browsing this forum: Baidu [Spider] and 57 guests