CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PID heater control with phase angle

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
complex72



Joined: 10 May 2014
Posts: 11

View user's profile Send private message

PID heater control with phase angle
PostPosted: Mon Jun 09, 2014 10:46 am     Reply with quote

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: 9246
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Jun 09, 2014 5:01 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group