Host Engineering Forum

General Category => General Discussion => Topic started by: PLCGuy on October 02, 2018, 07:54:53 PM

Title: PID help
Post by: PLCGuy on October 02, 2018, 07:54:53 PM
I read all the material and can not figure out how to control a output bit. I am using a Watlow Temperature controller and figured I should be able to do the same thing in the D0-More. The watlow controls an discreet output in turn turns my SSR on and off until it the ovcen reaches temperature. I just can not see how the PID in the Do-More controls an output. there is no box to fill out for an output. Somewhere there must be a clear example of having a thermocouple connected to WX0 and the PID controls a bit output. This is such a common thing to do. They talk about a hot air balloon but that is not what I want to do. lol For years I avoided using the PID in plcs and just go with a Watlow controller. Easy pizy.
Title: Re: PID help
Post by: BobO on October 03, 2018, 05:04:37 AM
The output of the PID instruction is the .Output field of the PID structure. It will be a value from 0 to 100. If you want to drive a discrete output, use a TIMEPROP instruction. The .Output field will be your input and the discrete will be your output.
Title: Re: PID help
Post by: PLCGuy on October 03, 2018, 12:14:20 PM
Thank you. I was going to use the TIMEPROP by itself, but now I see how they work together.
Title: Re: PID help
Post by: Controls Guy on October 03, 2018, 03:36:06 PM
Why, when I was young, we didn't have TIMEPROP -- we had a tiny little man with an even tinier knife switch and stop watch.  The PID would have to Telex him the new CV.  Every two hours when he went on break we'd get a process upset.  ;)
Title: Re: PID help
Post by: BobO on October 03, 2018, 04:34:10 PM
Why, when I was young, we didn't have TIMEPROP -- we had a tiny little man with an even tinier knife switch and stop watch.  The PID would have to Telex him the new CV.  Every two hours when he went on break we'd get a process upset.  ;)

Back when we used 'O' for Zeros and sharpened twigs for Ones. Hard times.
Title: Re: PID help
Post by: ADC Product Engineer on October 03, 2018, 04:41:05 PM
Why, when I was young, we didn't have TIMEPROP -- we had a tiny little man with an even tinier knife switch and stop watch.  The PID would have to Telex him the new CV.  Every two hours when he went on break we'd get a process upset.  ;)

Back when we used 'O' for Zeros and sharpened twigs for Ones. Hard times.

Luxury!  When I was a young instrumentation tech we had a rock on a rope for a level control.  When the rock got wet, Johnny would scramble down the ladder and open the valve till he heard it gurgling.  Then back up the ladder he went.  Those were the days...
Title: Re: PID help
Post by: Controls Guy on October 03, 2018, 07:00:31 PM
Back in the day, before v2, all we had to drink was hydroxyl!  Not NEARLY as refreshing as water.
Title: Re: PID help
Post by: Garyhlucas on October 03, 2018, 07:59:34 PM
PLCguy,
If you try autotune you will likely pee yourself with excitement! Tuning a pump for controlling flow, a few seconds at most. Tuning a blower to hold a constant pressure a few seconds. Tuning a pump to hold a tank level, a minute or two. Tuning a pH control loop on a complete system of tanks, about 45 minutes. Haven?t had the need to tweak anything.

Freaking AWESOME!!!
Title: Re: PID help
Post by: PLCGuy on October 04, 2018, 12:16:13 PM
Okay, I will stop by RiteAid to get  a box of Depends before I try the autotune.

Just briefly reading through all the info, but looks like I still use PID with TimePromp to give me the discrete output I need. The setup is a heater with a thermocouple. Actually 8 of them in different zones. I will get one to work then the others are a copy. I need to reach a temp of 350 degrees F. That is my goal.
Title: Re: PID help
Post by: BobO on October 04, 2018, 12:26:40 PM
TIMEPROP is just a slow PWM that uses a 0-100 input to drive what amounts to a dimmer. As long as whatever drives your heater is solid state, you can switch the heater relatively quickly and get a much better control of your temperature. One Hostie built a powder coat oven doing exactly this and was able to control his temp to within a few degrees. If you are driving a relay, you can still use TIMEPROP, but you will need to choose a much longer cycle time to keep from killing your relay as fast. I wouldn't use a relay though.

I don't know what your existing temp controller uses, but it's converting the analog output from the PID loop into a discrete output in some similar manner, it's just built into the controller.
Title: Re: PID help
Post by: PLCGuy on October 05, 2018, 12:13:50 PM
Yes, the heaters are being turned off/on with a SSR. So if I understand you. I will being using a PID than use that output to the TimeProp controlling my SSR?
 
The watlow controllers  have an autotune feature also which in turn the controller operates my SSR. Interesting to watch. The SSR stays on for long periods and as the set point is getting closer, the SSR slowly turns on and off until it reaches the setpoint.
Title: Re: PID help
Post by: BobO on October 05, 2018, 12:37:49 PM
You understand correctly.

The TIMPROP's interval will control what you see. Since you are driving with 60Hz, I wouldn't go less than 1 second, but if you do go short, it'll be blinking, and not so much on or off. For temperature control you could go longer with good results, but short makes the control much more analog.
Title: Re: PID help
Post by: PLCGuy on October 20, 2018, 07:47:50 AM
I will be doing some reading today. Printed out the PID View and Auto-Tune topics. Auto-Turn did not go so well.
Not understanding why my PV value was so off in the PID view. The memory I am looking is the thermocouple which reads 72. But when I bring up the PID view PV = 55. I have no idea what numbers I am suppose to start with in the gain, etc boxes. I set the SP to 175 thinking that is the temp I want to reach. Running the Auto-tune it went way over 175 according to monitoring the thermocouple. The graph showed it was no where reaching the 175. So I am thinking the numbers are not actually real world numbers? All the boxes stayed greyed out so I cancelled the auto tune. Printed out all the info and see what I come up with. I guess this is one of those things that is not obvious.

Garyhlucus, if you read this what numbers did you start with? My setup is, N0 contains the thermocouple reading. It was reading 72 degrees. PV in the PID view shows 55. I wanted to tune the heater to reach 175 degrees. But that never happened. The graph showed very slow  progress and 175 was way up the scale, but my thermocouple was reading 250 so I canceled.
Title: Re: PID help
Post by: BobO on October 20, 2018, 08:48:03 AM
For your initial condition, you want the SP to be above the PV, and at roughly mid range. Auto tune will drive the output to 100% until the PV crosses above SP, then it will go to 0% until it drops back below. It will do that two more times, for a total of three cycles. Then it will compute the loop parameters and set them. If you are doing temp control and have a slow moving process that can take a while.

On Host's website there is a page of FAQs. One of those describes in detail how to use the simulator to demonstrate auto tuning. It's very quick and will show you exactly what you should be seeing. Can't get the link now, but I'll try to a bit later.
Title: Re: PID help
Post by: Mike Nash on October 20, 2018, 10:13:17 AM
As much as I wanted to use real-world values for SP, PV, etc., there are a few factors that make that less than ideal in the PID. The PID was built with 0-100% being more the range it wants to work with. Scale your real-world values to this range and the PID works so much more betterer.

You CAN use your real-world values instead, but some things will work less than ideally, especially with Autotune. The P, I and D terms have had a limit on decimal places when reading and writing these values from the interface buttons. This may have changed since I reported it, I just don't recall. (It does look like there are more decimal places now, cool.)

See https://forum.hosteng.com/index.php/topic,1787.msg15129.html#msg15129 on the resolution change.
Title: Re: PID help
Post by: BobO on October 20, 2018, 10:40:13 AM
As much as I wanted to use real-world values for SP, PV, etc., there are a few factors that make that less than ideal in the PID. The PID was built with 0-100% being more the range it wants to work with. Scale your real-world values to this range and the PID works so much more betterer.

You CAN use your real-world values instead, but some things will work less than ideally, especially with Autotune. The P, I and D terms have had a limit on decimal places when reading and writing these values from the interface buttons. This may have changed since I reported it, I just don't recall. (It does look like there are more decimal places now, cool.)

See https://forum.hosteng.com/index.php/topic,1787.msg15129.html#msg15129 on the resolution change.

Strictly speaking, the only part that is actually 0-100% is the output. I guess that leaks back into the other terms, but for auto tune, I would think it works out as part of the tuning process. I'm honestly not a process guy though, so my opinions aren't super relevant.

I guess the alternative would be to force you to define what 0-100% is in real terms. In a sense we are already doing that by putting the scale into the box, so maybe that wouldn't have been a big deal. We could probably look at doing a mode that uses the output scale parameters as the output bounds. I think that would let you use real units throughout. We only care for auto tune and bias freeze/output clamping.

And this is exactly why we spend as much time on the forum as we do.  ;)
Title: Re: PID help
Post by: PLCGuy on October 20, 2018, 11:01:54 AM
going to check it out. Why is the PV value so low compared to my input value. I was thinking the PV is the current value of NO which is 74 degrees.
Title: Re: PID help
Post by: BobO on October 20, 2018, 11:11:05 AM
going to check it out. Why is the PV value so low compared to my input value. I was thinking the PV is the current value of NO which is 74 degrees.

The .PV is a field in the structure, and comes from you directly, or if you have enabled Scale to .PV option in the box, it comes indirectly from the source variable you specified.

You really need to walk through this: http://www.hosteng.com/FAQFiles/Do-more.htm#FAQ0041 (http://www.hosteng.com/FAQFiles/Do-more.htm#FAQ0041)
Title: Re: PID help
Post by: PLCGuy on October 20, 2018, 06:41:08 PM
I walked through the thread, nice. I guess what i am seeing is PV is being calculated by the scaling. In my mind, using a temp controller, the operator enters the temp they want to achieve, ie, 400 degrees. In the other window they see the PV changing as the heater heats up. they see the setpoint and pv the same and the temp controller shuts off. But in DM they enter 400 and see the pv at some funky number. I do not want that. that would be confusing to the programmer if he had to look into the program. So what I did was entered 32 and 1330 for both scales and now pv matches the input by me. I only tried this at home, will try it when I get to work on the actual oven. 32 and 1330 is the range of the thermocouple. Maybe i do not need to scale, by the PID does not allow that. the only way to assign input is to click on the scale so I can enter N0. I do not see a way to tell the PID to use N0 or any memory for input unless clicking on scaling.
Title: Re: PID help
Post by: BobO on October 20, 2018, 06:54:06 PM
The input to the PID function is the .PV member of the PID structure. You can set it anywhere you like.
Title: Re: PID help
Post by: BobO on October 20, 2018, 06:58:55 PM
You can also use the .PV member instead of N0. No need to use another variable.
Title: Re: PID help
Post by: BobO on October 21, 2018, 02:37:36 AM
Maybe this would be a good time to back up and talk about design philosophy. I think users sometimes have a mental image that prevents them from seeing the forest for the trees. Maybe I can help.

We could have built a PID box that had an input parameter for every single value used: PV, SP, Output, Gain, Rate, Reset, etc...and that might actually be easier to grasp, but it isn't super convenient. What we realized though was that since we already needed to allocate some work space for internal loop variables, we could expand the structure to include every input and output variable for the entire loop. So instead of creating 20 different tags, you just create one. And it really becomes self documenting.

Let's say you need a loop to control a tank temperature, so you create a loop tag called TankTemp. So rather than documenting 20 different tags, it's one and done. PV? TankTemp.PV. SP? TankTemp.SP. Gain? TankTemp.Gain. Etc. Those variable can be referenced throughout the program like V10 or N7 or R15...they are no different. There is no real benefit to using N7 to reference the PV and then copy into TankTemp.PV.

Maybe you don't like the name of a field. Let's say that the loop output is actually driving the tank's burner, and you don't like TankTemp.Output. No problem. Individual structure fields can have their own nickname, so you can assign TankBurner as the nickname for TankTemp.Output.

Since we realized that in some cases, your PV and Output would be directly tied to their respective analog channels, we added the scale options to simplify the hookup. They aren't required, just there for convenience.

The decision to use 0-100% for the output was also intended to simplify. We don't know what your physical output is: bang bang, PWM, 12 bit analog, 16 bit analog, scaled engineering units...we don't care, it's all 0-100%. And in reality, it is. Somewhere between fully off and fully on. By using a normalized output, we didn't need the loop to have more knowledge when auto tuning. One less thing to get wrong.

While it may be different than other products, our intention was to simplify. Sadly, I think we did the opposite, at least at first. But once you understand, you can create a brand new loop, wire it to the associated I/O, and auto-tune it in a couple of minutes. With other implementations you'd still be creating tags.
Title: Re: PID help
Post by: Controls Guy on October 21, 2018, 05:46:36 AM
Nice explanation. And I think, also the right direction to go philosophically.
Title: Re: PID help
Post by: PLCGuy on October 21, 2018, 07:42:39 AM
Wow, the forest doesn't seem so scary now. That all makes sense. I never thought about accessing .pv directly.  Actually mine would be called Zone1_PID.PV. That makes more sense if someone gets into the program to read it. Turns out I might not need the scaling. At least that works in the SIM. I will check it out Monday in the real oven we are building.

Sometimes brainiacs create things, thinking okay, that is easy. But not so obvious to a person other then me. It is all clear in my head but to a novice , it is not. What i generally do after building a machine is get a couple operators and say, okay go for it. Amazing what I thought was quite obvious  easy, is not. I have to make changes to the hidden gems. Which is not bad, heck i created it, I know what it means.

I really like the view Host takes on these matters. AB would never do that.
Title: Re: PID help
Post by: Mike Nash on October 21, 2018, 10:40:33 AM
...

Since we realized that in some cases, your PV and Output would be directly tied to their respective analog channels, we added the scale options to simplify the hookup. They aren't required, just there for convenience.

The decision to use 0-100% for the output was also intended to simplify. We don't know what your physical output is: bang bang, PWM, 12 bit analog, 16 bit analog, scaled engineering units...we don't care, it's all 0-100%. And in reality, it is. Somewhere between fully off and fully on. By using a normalized output, we didn't need the loop to have more knowledge when auto tuning. One less thing to get wrong.

...

There is one area that would be nice to have covered within the PID instruction for the case where a bipolar output is required. We can modify or scale the PID.Output either outside the instruction or scale it and stuff it elsewhere from within the instruction and these options are fine. The bipolar-ness is only lacking in having the output reset to that bipolarised zero when the instruction input is false.

It works fine to scale the output to -whatever to +whatever, but it does require a MOVE or MATH or something to force the PID.Output to that "imaginary" zero point if the instruction needs to be reset (off). The Invert Powerflow and a MOVE works well, but I would like to see the PID instruction be truly bipolar where zero is output if the PID input leg is false. This would allow non-symmetric scaling when needed.
Title: Re: PID help
Post by: PLCGuy on October 22, 2018, 12:31:37 PM
Success! Just giving an update to using the PID. I take my thermocouple reading, no decimals, load into PID_O1Z1.PV and load the setpoint into PID_O1Z1.SP.  In my PID box, no scaling. Press Auto-Tune and off it goes. Takes awhile doing heaters because of such a swing, but when done, I loaded the calculated to the plc. Guys are amazed how the PID hold the temp within a couple degrees plus and minus. I take the PID_O1Z1.OUTPUT and feed that into the TIMEPROP to control the SSR. I did find I needed to bumb up the time to 2 seconds in the TIMEPROP box.

Bobo that explanation you gave did the trick.  The operator sees real live numbers. PV being the thermocouple temp. They just enter from the HMI the temperature they want to achieve and off it goes. Very nice. You can watch the PV rise as it reaches the SetPoint temp. No fudging required.