PID Instruct doesn't execute w/RSEmulate

jfls45

Member
Join Date
Mar 2012
Location
Pennsylvania
Posts
76
I spent several hours late into the night trying to figure out what in the blue-banana-blazes I was doing wrong trying to get the PID instruction in a RSLogix 500 w/Micro1200R PLC to work. Alas, I discovered in a RSLogix Emulate 500 Release Note: The PID, PTO, PWM, SVC, and DLG instructions are allowed in the ladder code but, they don't execute.

I was hoping to be able to set this up on my laptop and test it out. The PLC and hardware haven't been ordered yet so I was using the emulator.

Does anyone have any ideas the next best step, is there any sample PID math calculation logic floating around I could try?

Jeff
 
Last edited:
Jeff,

Calculating the PID equations is not for the faint of heart, involving some pretty tough math. However, calculating the scaling equations for the values that go into the PID is not too difficult.

The best method of testing a PID is to wait until you get the PLC and set up a test on your bench top using an analog output module and a multimeter with a milliampere range.
 
Jeff,

Calculating the PID equations is not for the faint of heart, involving some pretty tough math.

It is easy if you have floating point. After the initialization there are only 3 multiply and adds and then some output limiting and shifting the errors.

Use a COP or two MOV blocks to shift the errors.
e(n-2)=e(n-1);
e(n-1)=e(n);
e(n)=SP-PV;
CO(n)=CO(n-1)+K0*E(n)+K1*E(n-1)+K2*e(n-2);
CO(n)=LIMIT(CO(n),MinCO,MaxCO);

The formulas for K0,K1, and K2 need to be done only when the gains are changed. The formulas for K0, K1 and K2 vary depending on whether the gains are dependent or independent.

I have my temperature simulator almost always on line. That has everything IF your are doing temperature control.

I would NEVER use the built in PIDs as their implementation is inferior because it doesn't handle integrator wind up well after a step change.

I would put the PID code in a subroutine and pass the file number to the PID. The SLC subroutines can take parameters can't it?

I am a little short on time now but the formula's have been posted many times before.

It is best to know what the PID will be controlling.
 
It is easy if you have floating point. After the initialization there are only 3 multiply and adds and then some output limiting and shifting the errors.

Use a COP or two MOV blocks to shift the errors.
e(n-2)=e(n-1);
e(n-1)=e(n);
e(n)=SP-PV;
CO(n)=CO(n-1)+K0*E(n)+K1*E(n-1)+K2*e(n-2);
CO(n)=LIMIT(CO(n),MinCO,MaxCO);

The formulas for K0,K1, and K2 need to be done only when the gains are changed. The formulas for K0, K1 and K2 vary depending on whether the gains are dependent or independent.

I have my temperature simulator almost always on line. That has everything IF your are doing temperature control.

I would NEVER use the built in PIDs as their implementation is inferior because it doesn't handle integrator wind up well after a step change.

I would put the PID code in a subroutine and pass the file number to the PID. The SLC subroutines can take parameters can't it?

I am a little short on time now but the formula's have been posted many times before.

It is best to know what the PID will be controlling.

My particular application is filling hoppers to the exact tenths of a pound. It's not a continuous running process. With analog, I think the problem is going to be stopping right where I need it, for instance... 210.5 Lbs.

Am using strain gauge weighing scales with 4-20mA outputs to the PLC. The PLC will output 4-20mA to a "pinch valve" that controls the amount of material dropping into the hoppers.

I've been studying PID Control the past couple of days and getting a really good handle on the basics. Going to try out some test logic in the emulator because the PID Instruction won't work. I am actually learning alot this way.

Jeff
 
Last edited:
A couple of things that you probably have figured out...

The span of the Load cell divided by 2^12 is about the resolution of the 'system.' So if the load cells are 500x1 the range is 500/2^12, and in that case the resolution of the PLC is better than the resolution of the load cell.

There is an expression in weighing applications called dribble and refers to how much product would continue to load the scale after the valve is shut off. Not sure if this applies to your application, but it's something that needs to be dealt with.

I've done tons of weighing applications, and all of them had the gauges connected to a scale or controller of some form or another. I haven't seen strain gauges with 4-20mA outputs.

The controller will handle things like calibration, zero, tare, and the like. Should the resolution not be enough, you may need a couple of load cells and the controller knows how to treat them as one.

The controller usually has a feature called 'auto tare' which is a great feature if you're trying to get precise weights; the idea is that product tends to build up on the scale platform. Auto tare will tare (ignore) that build up over time.

Hope this helps.
 
A couple of things that you probably have figured out...

The span of the Load cell divided by 2^12 is about the resolution of the 'system.' So if the load cells are 500x1 the range is 500/2^12, and in that case the resolution of the PLC is better than the resolution of the load cell.

There is an expression in weighing applications called dribble and refers to how much product would continue to load the scale after the valve is shut off. Not sure if this applies to your application, but it's something that needs to be dealt with.

I've done tons of weighing applications, and all of them had the gauges connected to a scale or controller of some form or another. I haven't seen strain gauges with 4-20mA outputs.

The controller will handle things like calibration, zero, tare, and the like. Should the resolution not be enough, you may need a couple of load cells and the controller knows how to treat them as one.

The controller usually has a feature called 'auto tare' which is a great feature if you're trying to get precise weights; the idea is that product tends to build up on the scale platform. Auto tare will tare (ignore) that build up over time.

Hope this helps.

I brought my work laptop home with me and right now I am setting up some PID calculation logic. So far I have created the proportional control part of it and testing it out with RS Emulate.

Jeff

I'm actually having fun learning and doing this stuff.
 

Similar Topics

Hi, I would like to assemble a simulator/practice booster pump system that uses PID to maintain steady water pressure under various outlet demands...
Replies
0
Views
65
Hello, I have a motor that we are sending a RPM Speed Output from 0-100% to the VFD. However, the Motor HP needs to be limited to 6000 HP and the...
Replies
3
Views
88
I have S7 1512C controler for controlling 48 PID temperature loop, the output is PWM. Please I need the best, most efficient way to write the...
Replies
13
Views
600
Hi all, I'm having trouble solving a problem I've been working on for several months, and thought you might like a stab at it. The machine runs...
Replies
22
Views
940
How can I connect PID Output to a valve. In ladder logic program is there any logic do I want to add between valve and PID? PV=SP What will be the...
Replies
7
Views
411
Back
Top Bottom