PDA

View Full Version : Time Proportional Control Example?



brooksware2000
- 2nd May 2011, 03:45
Hello everyone, this is my first post to the forum.

I've been working on a reflow controller and decided that I wanted to use Time Proportional Control since I am using a SSR to turn ON/OFF the oven. This seems to be a better scheme to me instead of using PWM since the heating elements act relatively slowly. I know that the output from a PID routine can be limited to a time frame say , 0 to 4 seconds. I plan to use DT_INTS to compute the PID output every second.

I was wondering if anyone could provide a little insight on how to convert the output from the PID routine to a ON/OFF time?

I did find an example for the Arduino which uses the Millis() function to keep track of how much time has elapsed since the start of the code.

Thanks,
Curtis

cncmachineguy
- 2nd May 2011, 04:10
I have to admit being somewhat confused. But that won't stop me from trying to help out. I am not clear (maybe due to my own lack of knowledge) how the PID is fitting in to your description. The subject makes it appear you are going to turn the heat on or off based on time. This needs no PID. Time is know, not variable.

If you are going to be reading the temp, and the setpoint is determined by time, then I get it.

Now to try and help:
Idea 1. If you are using DT_INT's just also use DT elasped timer.
Idea 2. If you already have a 1 second time base, just add a counter to the ISR to keep track of seconds. 1 WORD of seconds is over 18 hours. that is clearly enough time to cook the card, or the turkey too. :)

brooksware2000
- 2nd May 2011, 04:34
Time Proportional Control is pretty much a slower version of PWM where the duty cycle is varied by on and off time. For example, if the time span is 10 seconds and I want 90% on time then, that converts to 9 seconds on and 1 second off.

So, the output of the PID routine would span between 0 and 10 seconds for on vs. off time. To accomplish this, I need a way to make a guess as to whether the SSR should be on or off based on the output of the PID loop.

See this link (http://arduino.cc/playground/Code/PIDLibraryRelayOutputExample), this link (http://www.arduino.cc/playground/Code/PIDLibrary), and this link (http://brettbeauregard.com/blog/2011/04/improving-the-beginners-pid-introduction/) for the Arduino example.

Thanks for the help,
Curtis

Jerson
- 2nd May 2011, 05:13
Hello Curtis

Welcome to the forum.

Your problem can be broken down into 2 parts
1 - caluclate the value of output power via your PI routine
2 - convert this power to a time value

From your question, I guess, you have no issues with point 1

Assume you have power going from 0 to 100% corresponding from full off to full on. This can be converted to time thus

If the cycle time Tcyc you specified for your controller is - let us say - 10 seconds

On time will be
Ton = (Tcyc * Power) / 100

With this, you will get a Ton ranging from 0 - 10 seconds

Now, to control the duty cycle of your heater using this value, you can do this
Tvar var word

Tvar is a variable that runs from 0 to 10 seconds.


Tvar = Tvar + 1
if Tvar >= 10 then Tvar = 0 ' roll over

if Tvar < Ton then
gosub HeaterOn
else
gosub HeaterOff
endif

I hope this will help you


Oh, I forgot to add that you need to have the code above run at a fixed 1 second rate to get correct results

brooksware2000
- 2nd May 2011, 12:27
Hello Curtis

Welcome to the forum.

Your problem can be broken down into 2 parts
1 - caluclate the value of output power via your PI routine
2 - convert this power to a time value

From your question, I guess, you have no issues with point 1

Assume you have power going from 0 to 100% corresponding from full off to full on. This can be converted to time thus

If the cycle time Tcyc you specified for your controller is - let us say - 10 seconds

On time will be
Ton = (Tcyc * Power) / 100

With this, you will get a Ton ranging from 0 - 10 seconds

Now, to control the duty cycle of your heater using this value, you can do this
Tvar var word

Tvar is a variable that runs from 0 to 10 seconds.


Tvar = Tvar + 1
if Tvar >= 10 then Tvar = 0 ' roll over

if Tvar < Ton then
gosub HeaterOn
else
gosub HeaterOff
endif

I hope this will help you


Oh, I forgot to add that you need to have the code above run at a fixed 1 second rate to get correct results

Very good! You made it look so simple. I'll be sure to post the code once it is all worked out.

Thanks,
Curtis

cncmachineguy
- 2nd May 2011, 12:54
Yup, as I said, my lack of understanding. Thank you for the links Curtis. It may just be time for me to start playing with PID. Good luck with your project :)