View previous topic :: View next topic |
Author |
Message |
complex72
Joined: 10 May 2014 Posts: 11
|
PID heater control with phase angle |
Posted: Mon Jun 09, 2014 10:46 am |
|
|
Hi, I've been working with a heater (resistor) and phase angle control. I can manipulate the triggering of a TRIAC manually with zero crossing detection and loading values to timer1 interrupt.
Now I'm trying to control the triggering with a PID controller. I've read the theory and understand it, and also examined some examples controlling a PWM output with a PID algorithm, which looks fairly easy. But in this case I couldn't figure out how to make the controller load the Timer1 values or how to map the error term into something you control. In this case, am I supposed to map the error term between 0 and 8.3 milliseconds, which represents the phase angle control for 60 Hz power ?
Basic bang.bang pseudocode:
Code: |
BEGIN
DO FOREVER
Measure temperature
IF temperature < Set point -d
Turn ON heater
ELSE IF temperature > Set point +d
Turn OFF heater
END IF
ENDDO
END
|
and PID controller:
Code: |
BEGIN
END
DO FOREVER
Get set point: r(kT)
Get system output: y(kT)
Calculate error: e(kT) = r(kT) - y(kT)
Calculate I term: p(kT) = be(kT) + p(kT-T)
Calculate D term: q(kT) - ce(kT) - ce(kT-T)
Calculate PID output: u(kT) = p(kT) + ae(kT) + q(kT)
Send control to actuator
Save variables: p(kT-T) = p(kT)
e(kT-T) = e(kT)
Wait for next sample
ENDDO |
Thanks! |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Mon Jun 09, 2014 5:01 pm |
|
|
Ok the 'cheat' for this is to use the 'search' feature of the forum and look for PIC controller. You'll find dozens of threads ,some with good code.
Also DL uC apnote 964a. It's rather useful as well......
you should find out that 'heaters' are very slow response systems, probably don't require the D term.
if you have access to MATLAB you can 'reverse engineer' the equations( another 'cheat'...
hth
jay |
|
|
|