PID Loop Update time and external trigger

leitmotif

Member
Join Date
Nov 2004
Location
Seattle Wa. USA
Posts
3,680
In another post
http://www.plctalk.net/qanda/showthread.php?t=2473
post #4
Ron Beaurford said
"And THAT - dear readers - is why I keep harping-harping-harping on maintaining that all important relationship between the PID’s internal “Loop Update Time” setting and the scheduling of the external “trigger” event. If those two settings are not kept in sync, then heaven help you - I can’t."

OK so you have two clocks controlling this - so they must be in synch -
QUESTION why not use only one clock ie loop update time
ANSWER (mine) process may have an interval where the PID must be put on hold to allow process to change ?? For example on AB SLC 5/05 am starting to learn how to use PID to control speed of a hydraulic motor by using VFD to vayr speeed of the hydraulic pump.
When motor reverses (using solenoid actuated 4 way valve)the tach generator output reverses. I have to (choose ?) to multiply this by -1 to correct it back to a positive value. SO I think I will have to use timer to allow for time of motor reversal tand the calculation.

Have I got this right??

Dan Bentler
 
This should be another learning by doing thread.

1. So how fast are you updating the PID? You should do this in an interrupt. Hopefully you can do this at 10 millisecond intervals or faster. Heed Ron's advice. The PID needs to know what the time is between updates so it knows how to calculate some constants that are generated using the integrator and differentiator time constants. If these constants are wrong then the PID will not control correctly.

2. Normally you need to use only the only timer which is the one for the interrupt, but you still need to have the update time in the PID block correct because of the reason stated above.

3. What analog I/O cards are you using? I am just curious.

leitmotif said:
When motor reverses (using solenoid actuated 4 way valve)the tach generator output reverses. I have to (choose ?) to multiply this by -1 to correct it back to a positive value. SO I think I will have to use timer to allow for time of motor reversal tand the calculation.

Have I got this right??

Dan Bentler

Yes, you need to mulitply the output by -1, but it is best to have a tach that will give you direction information when controlling motion in two directions. I would use a tach that generates +/- 10 volts so you don't have to guess which direction the motor is going. This will be a problem when stopped or close to stopped. You will find out soon enough. Hopefully you are not trying to control position.

I would like you to post a RSLogix trend of your results when you get you speed control to go. This will be educational.
 
Peter

DEFINITELY another learning by doing thread. These are just another regular thread are they not?? This is a continuation of the post where I asked the question on cycle hold.

DEFINITELY going to watch and ensure times of timer and PID are same. Still studying on how to do it. 10 ms sounds like a pretty good time for an initial setpoint. ALSO from what you said I am going to have to be careful of other time contants ie integral and derivitive.

USING 1746 NIO41A -- 2 channel input (volt or current) and 2 channel output (current only).

Will definitely send / post the trend graphs
AFTER I figure out the PID
THEN learn the trend graph in RS Lgix - just read manual looks like it will be very helpful at least to keep track of individual changes.
THEN learn how to paste the graph here.
May need some advice on how to do the above.

CAN DEFINITELY use some advice on best sequence (process or steps???) to setup the PID. The manual (1747 RM001D EN P Nov 2003) on p 9 - 5 has table of all the values for PID -- somewhat overwhelming -
BTW is this the best manual??
 
Loop UpdateType in a value representing seconds. (With 5/02 controllers the range is from 0.1 to 25.5. With the 5/03, 5/04, and 5/05 controllers the valid range is 0.01 to 10.23 seconds.)
This is the time interval between PID calculations. The entry is in 0.01 second intervals. Generally enter a loop update time five to ten times faster than the natural period of the load (determined by setting the reset and rate parameters to zero and then increasing the gain until the output begins to oscillate). When in the STI mode, this value must equal the STI time interval value S:30.

Time Mode Select either Timed or STI.
With Timed mode selected, the PID updates its output at the rate specified in the loop update parameter.When using the timed mode, your processor scan time should be at least ten times faster than the loop update time to prevent timing inaccuracies or disturbances.
With STI mode selected, the PID updates its output every time it is scanned. When you select STI, the PID instruction should be programmed in an STI interrupt subroutine, and the STI routine should have a time interval equal to the setting of the PID loop update parameter. Set the STI period in word S:30.

Rockwell Software 2000
Ron B.'s admonition applies more particularly to the PLC-5. The above quote is from the RSLogix 500 help file. In the SLC, if you use "Timed Mode" then the PID instruction takes care of the timing based on what you enter for "Update Time" and the instruction can be in an unconditional rung. In "STI Mode", follow the rules above.
 
Greetings Dan,



as Gerry has correctly pointed out, the correlation between the PID’s “external trigger” and the PID’s “loop update time” setting becomes most critical when setting up a PLC-5 system ... with the SLC-500 systems, the PID setup window is quite different - and usually easier to work with ... I’ve got a hunch that the material that I posted earlier for a PLC-5 system is causing some confusion when you try to apply it directly to an SLC-500 system ...



just for starters, the “payroll accountant” analogy in this post might help you understand things a little bit better ...



going further ... with the SLC-500 PID instruction, there are two ways to “trigger” the PID into executing:



(1) “TIMED” mode (most commonly used) ... and

(2) “STI” mode (most often required when the processor’s scan cycle is long in relation to the desired PID “loop update” time) ... unless you are trying to control a relatively fast process, then you will probably not require the “STI” mode ...



here’s a little more detail on the “book” material that Gerry posted ...



if you set the “Time Mode” setting for “TIMED” operation, then the PID will take care of the triggering for you ... specifically, the PID should be placed on an unconditioned rung (in other words, on a rung all by itself) and the rung should be scanned by the SLC processor during each and every scan cycle ... the best way to insure that this happens is to put the PID rung in Ladder File #2 ... suppose that you’ve decided to use this arrangement ... and let’s further suppose that you’ve got the PID “Loop Update” setting entered as “0.50” for a one-half second interval between PID executions ...



with this setup, the SLC processor will “check” the rung on each and every pass through the scan cycle ... BUT ... the PID will only be executed (“triggered”) once each one-half second ... that’s because of the PID’s handy built-in clock which automatically “triggers” the PID into execution once each time the “Loop Update” time elapses ...



I suggest that you start with this timing arrangement and then let us know if things don’t seem to be working out for you ...



note: the PLC-5’s PID instruction does NOT have a handy built-in clock ... so with the PLC-5, we always have to take care of the “trigger timing” issue for ourselves ...



just for completeness ... let’s briefly discuss the SLC-500’s “STI” entry for “Time Mode” setting ... with this arrangement, the PID should also be placed on an unconditioned rung (in other words, on a rung all by itself) ... BUT now the rung should NOT be scanned by the SLC processor during each and every scan cycle ... the best way to insure that this happens is to put the PID rung in a new ladder file (NOT in Ladder File #2) and then set up that file to execute as an STI (Selectable Time Interrupt) ... suppose that you’ve decided to use this arrangement ... and let’s further suppose that you’ve got the PID “Loop Update” setting entered as “0.50” for one-half second between PID executions ... now you should also set the STI interval to match the PID’s internal 0.50 Loop Update setting ... if the STI setting and the PID’s Loop Update setting do NOT match, then the Integral and the Derivative settings that you eventually enter will be skewed ... you CAN still tune the system, but the numbers that you’ll have to enter for the Integral and the Derivative settings will be “weird” when compared to a “properly” timed system ...



one more note ... with the SLC-500 system’s PID instruction, regardless of the “Time Mode” setting, if the PID rung is ever scanned as “false”, then the PID will do unkind things to the Integral action ... that’s why the PID should ALWAYS be placed on an unconditioned rung when working with the SLC-500 platform ... this is very different from the setup for a PLC-5 system ... there the PID rungs are usually conditioned by something like a timer’s Done bit which provides an external “trigger” ...



sorry if this seems to simply repeat the advice that Peter and Gerry have already offered ... but sometimes just a different method of describing something can make everything come together ...
 
Ron

Thanks for help. Class tonite, should be able to get a start on things w/ PID and I have to reread and absorb more of what you posted. Will ask again when learn more

Dan
 
UPDATE to Learning by Doing # 2

OK just got back from school. Got the PID sort of working. I know this because:
1. PLC and VFD did not go up in smoke.
2. THe hydraulic motor speeds up when I crank up the speed setpoint pot
3. The hydraulic pump motor (controlled by PLC and VFD) speeds up when I load down and slow the hydraulic motor shaft.

Things I don't understand YET
1. Why I have to multiply the PID %output by nearly 500 to get the hydraulic motor to run. It will not run at a bit level corresponding to 100.
2. Why at higher speeds the system faults when I hit reverse on the hydraulic motor.

WHAT I GOTTA DO NEXT
1. Learn how to record data and make a graph. I need to see when and at what value of gain (was it??) I start the oscilations and I need it to find the period to set the update time.
2. I need to get better at looking up fault codes.
3. Change the paramters where I can to engineering units. For instance hydraulic motor RPM -- Hydraulic pump motor in cycles (I think) -- Speed input pot (setpoint) to volts or % (not sure which I like volts since it is 0 to 10) After this I think the scaling problems will decrease -- we will see

Off to bed job interview in the morning gotta get that beauty rest.

Thanks for help

Dan Bentler
 
Things I don't understand YET
1. Why I have to multiply the PID %output by nearly 500 to get the hydraulic motor to run. It will not run at a bit level corresponding to 100.

You need to scale the output from the pid to match your analog output card, If the output card was a 4-20ma card, then using the SCP instruction, scale the pid output, which will be 0-16383
to 3277-16384, the destination would be your output register. If your output card is not 4-20, you would use the correct numbers for that card.




Ken
 
Last edited:
Greetings Dan,



first things first ... my distinguished colleague, Ken Moore, is on the right track with the output scaling issue ... unfortunately he’s listed the wrong numbers ... note that the 1746-NIO4I module that you’re using has both inputs and outputs ...



disclaimer: what follows is for TYPICAL configurations ... yours might be different - but not likely ...



I’ll assume (gosh I hate that word) that you’re using a 4 to 20mA input for your module ... then the numbers which Ken listed (3277 to 16384) are correct ... but only for the INput section ... secret handshake: they are DIFFERENT for the inputs and the outputs ...



if you’re using a 4 to 20mA output from your module then the numbers that you need are 6242 to 31208 ...



now that we’ve taken care of that minor issue, here’s what I suggest that you do next ... delete the PID ... that’s right ... yank it out by the roots ... the questions that you are asking indicate that your system is not quite ready for the PID yet ...



as for your input ... I’ll assume (there’s that word again) that SOMETHING (a speed transmitter, etc.) is giving you a 4 to 20mA signal from the field ... suppose that the signal lands at I:2.0 (just so that we’ll have a specific address to use for our example) ... and let’s assume that the field transmitter is presently giving you a signal of 11.11mA ...



as for your output ... I’ll assume that your VFD takes a 4 to 20mA signal as a speed command ... suppose that you have that wired up to your module at address O:2.0 (another randomly chosen address for discussion) ... and let’s assume that you have manually typed the value 18433 into O:2.0 ...



then so far we have something like this:



cut1.JPG





notice that the 11.11mA signal from the field will look like 9101 when it reaches the data table at I:2.0 ...



notice that the data table entry of 18433 at O:2.0 will result in a signal of 11.81mA to the field ... if the assumption (that word is killing me) that your drive accepts a 4 to 20mA signal for a 0 to 100% speed control is correct, then the drive should now be running at 48.8% of full speed ...



I’d strongly suggest that you hook up something like this and test it out ... all of these signals should be confirmed (with meters, etc.) before you proceed with the next step ...



once the field signals have been hooked up and are working correctly, then you need to scale those signals for the PID ...



cut2.JPG



here we’re using an SCP instruction to scale the raw input from the field into an acceptable input to the PID ... I’ve chosen N7:54 as a location for my PV signal ... this is the address that you should enter for the PV when setting up the PID (NOT I:2.0 since the scaling there is not correct for a PID input) ...



and we’re using another SCP instruction to scale the raw data reading from the (soon to be) PID into an acceptable signal for the field output ... I’ve chosen N7:75 as a location for my CV signal ... this is the address that you should enter for the CV when setting up the PID (NOT O:2.0 since the scaling there is not correct for a PID output) ...



once these steps have been done, then the 11.11mA signal from the field will produce a data reading of 7280 at N7:54 ... properly scaled for the PID ... and if you type in a data value of 8000 at N7:75, then the field output signal should go back to 11.81mA ... and the drive should run at 48.8% again ... you should be able to manually type in values between 0 and 16383 (you get to “be-the-PID” for awhile) and make the drive speed change from 0 to 100% ...



and as the field input ranges from 4 to 20mA, then the reading at N7:54 should range from 0 to 16383 ... suitable input stuff for a PID ...



and NOW (finally) you’re ready to reinstall the PID and move on from there ...



or at least that’s how I’d go about it ...
 
Ken and Ron

Inputs to NIO41 are
Potentiometer (the setpoint) is 0 to 10 VDC.

Tach gen on hydraulic motor is 0 to 3 VDC (maybe little more ??). This is the control (whoops process) variable.

OUTPUT from NIO41 to the VFD is 4 20 mA. Now lessee this is the control variable.

I KNOW I am in over my head and am confused
BUT then I am learning this so that is OK.

The instructor is in over his head and is also confused. I am somewhat disappointed in this but that is life.

I also talked and showed the setup with a guy who is in the controls business and showed he was very familiar with PID. He had some doubts that this learning platform is the best choice. We have him available for backup.

Anyway I chose to seee if the PID would work or not. IF NOT why not -- which is an experience / learning evolution by itself and a good thing. I think it is going to work (it speeds up the hydraulic pump motor when the hydraulic motor is loaded down and slowed).

I got some more studying to do from your last posts -- that is for sure. Have until Tue which is the next class.

RON I still need to verify that the graphs on What is I and D in PID are not in the posts. Have not had time to do that on computer at work to ensure the problem is not just on my home computer. Will of course let you know what I find.

Many thanks for help.

Dan Bentler
 
Follow Ron's suggestion, and get you inputs and outputs set up correctly, then add the PID instruction

also:
Tach gen on hydraulic motor is 0 to 3 VDC (maybe little more ??). This is the control (whoops process) variable.
You may have to "tinker" with the scaling on you process varible,
Assuming you have the input card setup for 0-10vdc, when you do the SCP instead of 0-32767, you may want to try 0-9820 as the input min and max. It all depends on your specific setup.

Post your code and perhaps someone else will see something we're over looking.

Ken
 
leitmotif said:
The instructor is in over his head and is also confused. I am somewhat disappointed in this but that is life.

That is a shame. What "school" are you going too?

leitmotif said:
I also talked and showed the setup with a guy who is in the controls business and showed he was very familiar with PID. He had some doubts that this learning platform is the best choice. We have him available for backup.

The 'guy' is right. I have never seen a customer with a design like the one you describe. It is a kludge.

leitmotif said:
Anyway I chose to seee if the PID would work or not. IF NOT why not -- which is an experience / learning evolution by itself and a good thing.

That is the right attitude. Sometimes you can learn more from projects that don't work out so well. In this case you will not lose any money if the system doesn't perform well. Schools can't always afford the best equipment. What "school" are you going to?
 

Similar Topics

Hi all, splitting out from this thread because it's a somewhat different question to the original. I have to migrate some code from a Micrologix...
Replies
17
Views
4,068
Hi all, I've been tasked with migrating a standalone control box with a Micrologix 1100 into an existing 5380 Compact Logix controller. It has a...
Replies
9
Views
2,414
Today I upgraded an L55 processor with an L82, which ended up being the 2nd unsuccessful attempt but thats a different story. After starting the...
Replies
15
Views
4,475
Just tuned a heating application where my natural period was 250 seconds. Everything I've read says that the loop update time should be 5-10 times...
Replies
1
Views
1,627
May be my question is too childish, but can i get all the answers please? For PID of ML1400, if I right loop update as 0.02 & time mode as STI...
Replies
4
Views
4,755
Back
Top Bottom