Originally Posted by
Jerson
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
Bookmarks