Velocity Control PID in CompatLogix

I was trying to make this a right way vs wrong way to control a simple first order system. I have an update that I will share tomorrow but for right now I want to know if AdvancedHMI could be improved with some simulators. The PLC program would use its PID block to generate an output. The location of the output would be read by AdvancedHMI and generate a PV that would be sent down the PLC. The PLC would use the PV and SP to generate another output. Basically, this would turn AdvancedHMI into a simulator too.


I hate windows programming but I could supply the simulation code for the open loop transfer function for level system, FOPDT, SOPDT, first order velocity, first order position and finally seconder order under damped poles.


Someone would need to write the HMI interface. Also, it would be good to improve the plotting/graphs. There should be a time scale on the horizontal axis and units for the vertical axis. I find it best if the PV and SP scales are on the left and the control output percentage is on the right.
 
This is funny: I am trying to work PeterN's side (model equations) to calculate Kc for critical damping ratio directly; it's slow going as the DiffEq parts of my brain are full of cobwebs, but I'm getting close.



... Basically, this would turn AdvancedHMI into a simulator too. ...


Already done; it's been public for almost a week. Send me your model and I'll implement it. Or you can use the code from Github (cf. below) as a framework and replace the delta_psig_model function with your own model.


I hate windows programming


Me too; editing in anything that is not VI kills me; but then, I have a love/hate relationship with all sorts of operating systems.



TL;DR



The AdvanceHMI app communicates with a physical MicroLogix 1100 PLC; the PID is on the PLC; the PID instruction is not available on MicroLogix 1100, so it's coded up in ladder (.RSS file available here: https://github.com/drbitboy/pressure_control_via_fan_velocity/tree/master/src/MicroLogix1100)


The model equations are available here: https://github.com/drbitboy/pressure_control_via_fan_velocity. The relevant code starts here: https://github.com/drbitboy/pressur...ressure_model/pressure_model/MainForm.vb#L160.


There are three routines that implement the simulation:

  • Subroutine avd_debug_free_running_clock_ValueChanged
    • Event handler
      • called by the AdvancedHMI framework when the PLC cached time variable (N7:2, copied from S:4, IIRC) changes at each run of the PID
        • 1s intervals when controller is in auto
        • 2s intervals when controller is in manual
    • Converts [0%:100%] CV range to [-10%/s:10%/s] ramp slope
    • Uses ramp slope (CV) to calculate a new fan speed
    • Uses integrator function delta_psig_model to get a new PV
    • Updates PV in PLC
  • Function delta_psig_model
    • Uses dpdt_model to get dPressure/dTime values
    • Performs an Implicit Euler integration to calculate next timestep's modeled pressure (PV)
  • Function dpdt_model
    • Calculates dPV/dt
      • dPV/dt = (fanFlowIn - leakageFlowOut) / enclosureVolume
    • fanFlowIn = f(pressure,fanSpeed)
    • leakageFlowOut = f(pressure)
 
Enclosure Pressure Control via Fan Speed Reference Acceleration

From your description of the application I am assuming you want a CompactLogix PLC control the Pressure in an Enclosure by varying the Speed of a Fan that is run by a VFD. Also, you do not have direct control of the VFD Speed Reference but control the Change in Speed Reference (Acceleration or Deceleration of the the Speed Reference).



From my experience with ControLogix / CompactLogix and VFD I will assume that the Fan VFD Speed Reference is controlled by a digital Motor Operated Potentiometer. I will also assume the Fan VFD Speed Reference is Increased or Decreased by two (2) Normally Open Pushbuttons (INC / DEC PB).


One way to do this with in a CompactLogix PLC is to use the Function Block PIDE instruction with the Split Range Time Proportioning (SRTP) instruction. The CV output is 0.0 to 100.0% and the CV Eng Units output of the PIDE instruction is -100.0 to 100.0%. The CV Eng Units output is the input to the SRTP Instruction which controls the CHANGE in the Fan VFD Speed Reference via Pulse Width Modulation of control relay contacts in parallel with the INC & DEC PBs. The SRTP instruction has the following paratmeters:


Max Heat Out Value = 100.0%
Min Heat Out Value = 0.0%
Min Cooling Out Value = 0.0%
Max Cooling Out Value = 100.0%
SRTP Instruction Cycle Time = 4.0 seconds
Max Heat Time = 4.0 seconds
Max Cool Time = 4.0 seconds



The PIDE instruction is set up as follows:


PIDE Action = Reverse (SP-PV)
Timing Mode = Oversample
Update Time = 0.5 seconds
Deadband = User Defined for Enclosure Pressure Common Cause Variation
Proportional = User Defined for Enclosure Pressure Response (Try 2.0 to start)
Integral (1/min) = 0.0
Derivative (minutes) = 0.0
Zero Crossing Off = Checked


I have written a PLC program in CompactLogix Version 20.11 and tested it on a 1768-L45 CompactLogix5345 Controller. The MainTask is Periodic with a 50 msec time period. The MOP position goes from 0.0 to 100.0%. When the HeatOut output is On the MOP position increases 0.5% every 50 msec. When the CoolOut output is on the MOP position decreases every 50 msed. So it takes 10 seconds or the MOP position to go from Min Speed to Max Speed.



Three Important Points:
1) In Timing Mode = Oversampling the Program Controls when the PIDE instruction is executed. Execution time must be consistent and equal to the PIDE Update Time.
2) Integral and Derivative are not needed because when the CV Eng Units output / SRTP instruction input = 0.0 the HeatOut / INC PB and CoolOut / DEC PB output are OFF so the MOP position does not change.
3) In over 33 years of Process Control using PID controllers and PLCs with PID instructions I have never needed to change the PID Control Action (Direct or Revers) "On the Fly" so this is definitely NOT recommended.
 
Both drbitboy and OldChemEng seemed to favor a rate of change mode but that isn't close to optimal. Basically your gain is an integrator gain because the output is integrated.
The problem is that this method results in a slow response. In the case of drbitboy's example the closed loop time constant is 2 times the open loop time constant. That isn't good. Secondly, by adding, what is effectively an integrator gain, you have introduced two poles. This means it takes 6.64 time constants to get with 1% of the set point instead of 5 time constants. So in drbitboy's example it takes 13.28 seconds for the response to settle within 1%.

Increase the gain does not result in a faster settling time. It does result on more overshoot.

The is a general rules for choosing gains or if to choose a gain. There should be one controller gain for every open loop pole. The integrator does not count because it has its own pole. So in this example a true proportional gain is required.


I used a standard PI controller. My closed loop time constant is 0.1. There are two poles but my method of placing poles puts a zero on top of one of the poles so effectively there is only one closed loop pole with a time constant of 0.1 second so it takes only 0.5 seconds to settle within 1% of the set point.

A controller should make the response faster not slower.

On page 5/13 of
https://deltamotion.com/peter/Mathcad/Mathcad - t0p1 pi tc direct synthesis drbitboy.pdf
You can see that the pole closest to the origin is cancelled out by a zero. This is one reason response of the PI controller much faster.

On page 6/13 I implement a controller like drbitboy's. I get the same response using the same numbers.
I also calculate the integrator gain Ki, what drbitboy calls Kc, that results in a crtically damped response. It is simple finding the roots of a quadratic equation.

On page 7/13 I calculate the symbolic formulas for the integrator gain and closed loop time constant that results in a critically damped response. I then use the invlaplace function to find the response in the time domain just to check the results. You can see it takes about 13.28 seconds for the response to get within 1% of the setpoint.

On page 8/13 I calculate the symbolic formulas for the underdamped case where the integrator gain is greater than 2.5. I also compute the response as a function of time using the invlaplace function. Unfortunately the equation is long and continued on page 12/13. Notice that the exponential term is exp(-1/(2*Tp)). This shows that the decay is independent of the integrator gain. Increasing the integrator gain only increases the amplitude of the overshoot.

On page 9/13 I do a similar calculation for the over damped response when the integrator gain is below 2.5.

On page 10/13 I plot the response using formulas from previous pages as a function of time and the integrator gain. As drbitboy rightly noticed, the setting time is contant. Now you know why and have seen the proof.

On page 11/13 I plot the close loop pole locations as a function of the integrator gain. At first the pole locations start at -0.1 and 0 and move toward 0.05 as the integrator gain is increased from 0 to 2.5. Integrating the integrator gain above 2.5 only moves the poles in the plus and minus imaginary directions resulting in high frequencies and magnitudes of oscillation.

The short story is there is a right way and wrong way to do closed loop control.

I can understand cases where one may want to integrate the output but in drbitboy's example there should be a derivative gain that gets integrated into an effect proportional gain.
 
Both drbitboy and OldChemEng seemed to favor a rate of change mode


Sorry, but I can assure you that is absolutely not true. We saw it as an interesting application, but, as can be seen from several of my posts, PI with CV direct to the fan speed, is of course better.


Where integral-only control is a useful tool, it will be used, but those applications are few an far between, and the selection of I-only is most likely not by choice but of necessity.


gain is an integrator gain because the output is integrated.


... which is what I have been saying since post #2 of this thread.
 
I agree with drbitboy that it was never stated that the proposed method was the way to go. It was all based on the original post which stated:

The output of the PID is used for the change in velocity. So with the output at 100% the fan will ramp at max accel at an output of zero the speed will stay the same.

The original question was does this make sense. The rest was a discussion proving it isn't the way to go. Likedrbitboy said, it FELT like it was a bad idea but he had no direct data stating that it was. Now he has that.

Keith
 

Similar Topics

The is the first system that uses complex or imaginary poles. Complex poles oscillate. RLC circuits, masses on springs, pendulums, masses on...
Replies
19
Views
16,998
So you thought you would take the weekend off! No way. The link below is saying download me! Give me a try! The link is to a spreadsheet that...
Replies
15
Views
23,438
A query for the motion control experts: I have an app where I measure the position (encoder ∝ K * angle) of a rotating device, and use that along...
Replies
15
Views
3,728
A bit of background here: We use an incremental encoder with a counting module in our PLC configuration. Using dual phase / quadrature counting...
Replies
26
Views
8,874
I have a 1746-QV. I just replaced one that had gone bad. I am looking for an electrical schematic for it so I can attempt to repair it just for...
Replies
0
Views
1,605
Back
Top Bottom