Sign in to follow this  
Followers 0
Pulsar2003

Add and Substract to change an Analog output value

23 posts in this topic

Hello again. This has to do with my other topic: NIO4I, Channel configuration. Some times I need to make some adjustments on a burner. For that I need to switch the burner to manual to avoid having a command from the PID and to have the potentiometer functional. In a way I would like to eliminate that component because we are in a dusty environment and vibrations which from time to time causes problems. In other words there are glitches and I have to verify the wiring between the PID and all the different components that prevents the signal from reaching the modutrol. This potentiometer would be replaced by a UP and DOWN buttons at the back of the oven (far from the HMI). What I've tried in a simple ladder was to use the ADD and SUB commands. A value of 500 is added or subtracted. I toggled both input to no avail. The destination value remains unchanged. Any ideas? P.S.: Don't bother with the COP and MOV commands in this ladder. Thank you again. TEST_increment_ANALOG_OUTPUT.RSS

Share this post


Link to post
Share on other sites
It should work. The first time input 0 goes true you should see 500 in your dest. When input 1 goes true without input 0 then you should see a -500. Back and forth 500 to -500 as you toggle both inputs one at a time. ( on/off) In practice writing a negative number to an output address will probably not be a good idea. Edited by Mickey

Share this post


Link to post
Share on other sites
When I'll have a value less than 0 I will add the compare command that once N12:1 is lower than 0, the rung will never go true to avoid any mathematical mistakes to set the CPU to fault. Limit test could also work I believe. Have to look into that. Same thing for the ADD. Once the maximum of 21 000 is reached the ADD rung will be false. That way I will limit the possible values between 0 and 21 000.

Share this post


Link to post
Share on other sites
This works. TEST_increment_ANALOG_OUTPUT.RSS

Share this post


Link to post
Share on other sites
That still won't prevent the value from going over or under. What if N12:0 has a value of 400. Or a value of 20600? Consider a limit instruction with a high value of 20500 and a low value of 500.

Share this post


Link to post
Share on other sites
This value will only be in a subroutine. I will probably move a 0 value to the N12:0 when the subroutine is requested to make the adjustments on the burner. That way I'll be certain that it will always start at 0 and once the subroutine is exited it will be set back again at 0 no matter to what it was set previously. The only way this value can be affected is by the up and down button that increments a value of 500. My worry is mostly on how I can get two different values to the same output at different time. The PID (0 to 16383) will be scaled with parameters and stored to another N something file. There will be this seldom used subroutine in a N12:0 file. Depending if the regular cycle is used the N something value will be moved with a condition to the O:2.0 and if ever the adjustment subroutine is used it will be the other move command that will become effective (if requested via the HMI). Hopefully that is not too confusing.

Share this post


Link to post
Share on other sites
Greetings Pulsar2003 ... regardless of how you decide to "ramp" your signal value, you really should consider using something along the lines of the two rungs shown below ... most programmers call this a "clamp" arrangement ... notice that it should be placed just ahead of the MOV instruction ... the basic idea is that WHATEVER happens in the preceding logic, when the processor reaches this "clamping" arrangement, we're (pretty much) guaranteed that the value we're interested in will be forced into an acceptable range before we make use of the value ... (in this example the range is from 0 through 21000) ... I hope this helps ... going further ... if you can, please post your FULL program (.RSS file) whenever possible – even if it's not "finished" ... that cuts down on a LOT of the confusion as we try to help you along ... Edited by Ron Beaufort

Share this post


Link to post
Share on other sites
Along the same lines as has been suggested, consider toggling the .SWM (software manual) bit on the PID instruction and loading/changing the values in the .SO (software manual output) value in the PID file. This value is in percentage (0-100) so scaling is easy. It is not obvious but this is how you turn a PID loop on/off between auto and manual. When it is in auto, the .SO value will automatically track the output value, so when you go to manual, it is automatically set to the correct value. If you turn PV tracking OFF, then when you go back to auto, the set point is the same as it was before. If you set it to ON, the SP follows the output (PID inverts).

Share this post


Link to post
Share on other sites
I hope this helps ... Hello Monssieur Beaufort and Monssieur Paul, First I don't have a full program. What I'm currently doing is getting familiar with some things I never done before: PID and analog outputs! I simply crate short ladders that helps me to understand how to "make it happen" the way I want it to be. That way once in the real program I don't have to figure out what's going wrong or not going right. I want to add some details here. There is a reason why I do not want to us the: ".SWM (software manual) bit on the PID instruction and loading/changing the values in the .SO (software manual output) value in the PID file." But maybe that's what I need. When I said that there is a manual and automatic on the burner it's not done by the PLC nor the PID command. There is a simple double pole double throw switch directly on the burner. On automatic it is the Omron PID that drives the Modutrol according to the desired oven temperature needed, on the other hand the manual allows us to drive the opening of the mudutrol via a simple trim pot. We seldom use the manual mode. This only occurs when we make adjustments on the flame. We can have access to the combustion chamber and look at the appearance of the flame, from there we can adjust the flow of air ratio with the intake of natural gas. The flame has to be perfect at it's maximum, middle and minimum range. This setup only happens once or twice a year. I want to replace the trim pot by the up and down buttons that will increase or decrease the output; therefore the angle of opening of the modutrol (0 to 90). Because of the vibrations on the motors, the dusty environment, verdigris, loose wires, etc. I want to eliminate the components that can be a problem. I want I short cut to from the analog output module directly to the modutrol's terminals. As I wright these line I remember that there will also be a situation where the modutol will need to be open to a full 90 degrees. That will be when a mold gets stuck in the oven during the cooking cycle. This happens when a mold's iron support breaks or any other mecanical faillure. This also happens only once or twice a year. The problem is that in this situation the mold or molds can end up just above the combustion chamber where the temperature is at about 1200 ( I don't know if this is F or C). An aluminium mold doesn't survive long over such heat. We now have a sound signal that warns us. When this happens we all run like crazy to stop the burner and open the oven's doors. The current PLC had no inputs left. For the replacement I have the freedom of deciding so the PLC will know that I mold got stuck. This means that the burner will be shot off, the doors on both sides will be opened AND the burner's ventilation will be turned on again. Only in this situation the modutrol remains shut. I will need to open it to let the cool air flow in the oven to cool down the combustion chamber and oven. Gas wont go in because the burner controller is not in cycle. In conclusion: there are two potential situations. One where we need to adjust the flame (+ or -) and the other where cool air has to get in the oven to cool it down quickly. In the latter situation a 21 000 need to be sent to the output to open up the modutrol to a full 90 degrees. I don't know if it can be done in the manual situation in the PID command (temperature is not needed but an angle on the modutrol). From the ladder provided by Mr. Beaufort, line 5, 6 and 7. What I understand is that the previous line 5 has been moved down to line 7. What has been added are the two conditions that's been added up. I'm not certain that it is correct. I want to limit a range of 0 to 21 000. What I want to do is to increment the output signal manually with two buttons (one will add 500 and the other will sub 500). I use the LEQ command to prevent going bellow 0. Once 0 is attain the user cannot subtract 500 to 0 to prevent getting a -500 and so on. Same goes for the adding, once 21 000 is reached, one can press forever the + button and it will not add another 500. I do not want to have a math overflow and get the processor in fault. Is it recommended to add a clear overflow at that point? Remember, this happens only once or twice a year and the function is only available to the mechanics to adjust the flame and by the PLC in case there should be a mold stuck. This command will also only available when not in a cooking cycle (for the users). It will be an emergency one that will override the cooking cycle and done by a subroutine. Confusing?

Share this post


Link to post
Share on other sites
I stand corrected by Ron Beaufort. The Logix 5000 ladder PID and PLC/5 PID are virtually identical in every way. The Logix 5000 PIDE has more features, and the SLC-500 PID has fewer features. To enable manual mode, toggle the "AM" bit (auto/manual) and directly set the value on the CV (control variable) output which is spanned from 0-16383, not 0-100. See pages 9-9 and 9-29 of the SLC programming manual (available on literature.rockwellautomation.com).

Share this post


Link to post
Share on other sites
Lets see if I got it all wrapped up.... Don't slap my wrist if I confused some details. The chapter 9 is in the publication: 1747-RM001G-en-P. On page 9-9 The word 0 bit 1. When off (0), it specifies automatic operation and when on (1) it it specifies manual. So when the oven is not in use and I need to adjust the burner I simply can go to the HMI and set this bit to 1. Next I can use the + or - button to transfer a value to the Control Variable (CV). Once the tune up finished it's back to the HMI and have the bit back to 0 or automatic. The rage is from 0 to 16 383 so it will need to be scaled to have 0=0 and 16 383=21 000. The other situation where a manual overrun is when an emergency situation where I need to cool down the combustion chamber as quickly as possible. This subroutine would set the Word 0 bit 1 to on and have a 16 383 value move to the CV word. If I was to use the N7:0 to N7:22 (only an example) as the set up files. N7:0 bit 1 is the A/M. All I need to do is LATCH or UNLATCH this bit (N7:0/1)??? For the Control Variable (CV) it's I who decide. Lets say it is N7:23. I would simply move the maximum value that I need to get the modutrol fully opened. There is something else...In a publication for a Micrologix (1766-RM001A-EN-P) page 332 there is an example to stop or restart the PID instruction. I want to repeat some information: the oven has two bogeys where they take their turns to go in the oven, there are times when only one side is needed, and finally there is a time where both are in the cooling station. This means that the oven is not in use. I need to shut off the burner. Is it best to have a condition to get the PID instruction true or could I simply go manual and move "0" to N7:23? I recall that I read something about the PID instruction getting halted. The CV remains unchanged as the "I" in the algorithm doesn't get updated. I could be confusing things as I read allot of topics that related to PID as well as many RS's publications. Another detail: Because I don't know exaclty how the burner controller works when it purges (gets the modutrol fully open by making a short between the RED and BLUE) I will have a solid state relay to protect the analog output. Suggested by this forum's experts. This means that I don't need to worry about the CV value. Now I await more suggestions or appraises. Thanks.

Share this post


Link to post
Share on other sites
There are two problems that having a manual override as it exists (simply ignoring the PID loop) can cause, and a third when you "stop" the PID instruction. These three problems are: bumpless transfer, integrator windup, and timing related variable gain issues. I'll explain each in turn. First, timing related variable gain. A PID loop instruction operates incrementally. That is, each time it gets executed, it makes adjustments to the output value and some internal values as well. The gains (Kp, Ki, Kd) control the RATE that these changes occur. There is also a time constant that you set on the loop that indicates how often the loop is executed. The loop executes every time that the input conditions are true (or on every scan of the ladder if there are no input conditions). If you execute the loop at a different rate from your gain settings, then the rate of change will change. And if you fatally execute it on every SCAN, then the response from your loop will be a somewhat random variable that is completely dependent on scan time. And as you make changes to your program over time, even if things are working reasonably well, your loop speeds will seem to be changing as well, even without editting the loop code! The correct way to execute a PID loop is to execute it with the timing that you set in the loop time constant. The easiest way to do this is to set up a ladder to be executed by an STI. Put all your PID loops in that ladder and run the ladder via the STI. This gives you exact timing with very little effort (no special timers) on your part. This is part of the warning about "starting/stopping" PID loop instructions. The second issue is integrator windup. The integrator part of a PID loop instruction will integrate the error in the loop continuously. If for instance something blocks the actuator from achieving the set point or some external manual override does this, then the integrator will saturate (go to maximum negative or positive value). Whenever the PID loop finally does get control, it first has to deplete the integrated value which may take some time. Then it will "take off" out of control trying to achieve the set point. All PID instructions contain some type of integrator anti-windup feature. It is able to suppress the "delay" part of integrator windup but not the "take off" part by simply clearing the integrator when the CV reaches the clamping limit (effectively 0% or 100%) or setting it to a relatively low value. You don't have to do anything about this except to turn it on if it's an option in your particular PID loop algorithm. The third issue is bumpless transfer. This is related to integrator windup. When you go from manual to automatic control unless the loop is inverted and perfectly tracks the CV and PV during manual mode, there will be a "bump" as the loop engages. During manual mode, the CV from the loop was attempting to control the loop and the loop was responding to the PV readings but got nowhere. You can simply stop executing the loop during manual control but this only solves part of the problem and still results in a bump because the loop goes back to operating in it's last known state (hopefully when things were very stable). The better method is to zero the integrator and derivative, and to set the set point based on what the proportional calculation says it should be if the loop was inverted (run backwards). Still, there are tweaks to the PID algorithm that can definitely be done even without using PV tracking to avoid severe bumps in manual/auto transfers. A third approach that completely avoids the "bump" issue is to use a differential PID loop algorithm rather than an absolute one. There are several different ways to write the PID loop algorithm itself, each with various advantages and disadvantages. However, it is pointless to argue about the relative merits of the different PID algorithms because unless you are writing your own and ignoring the built-in AB supplied PID instruction, you are stuck with whichever one AB actually used. You may want to read through this book for more details on control loops in general: http://caltechbook.library.caltech.edu/226/1/Feedback08.pdf Warning...the book is fairly math intensive. It appears to be written for a senior-level electrical engineering program. This is one of those books that you have to either read in depth and take days or weeks going through it, or skim the material for the highlights and try to understand the basics of what it is saying. I don't normally do most of the calculations suggested in the book very often. If you are dealing with a pure electromechanical system (mechatronics), you can usually actually model your system mathematically very accurately. Then you can use this material to the fullest. The loop constants (Kp, Ki, Kd) are known values and can be calculated ahead of time. With most process systems, it is almost impossible to do this. At best, you can roughly model your system but I tend to get the same values with hand tuning after a few hours. It is more important with process systems to understand the basic concept of what is going on and to get an intuitive understanding than to get hung up in the details in most cases. The mathematical approach is reserved for truly "tough" complicated control situations, such as inherently unstable (integrating) systems.

Share this post


Link to post
Share on other sites
Wow. That's allot of details to digest. I'll have to read it a few times to understand it all. Back to my business. To begin with I have to elaborate my whole program. Determine my ladder where the PID loop will be and setup the STI parameters. The ladder 9 is called Burner, that is where the PID loop will be with the manual and automatic commands, the output. Basically what has been discussed in this topic from the start. I'll make sure to incorporate all the suggestions to have a smooth program. In RSLogix500 I double click on the Processor Status to open up the popup screen. I go the the STI tab. For the set point I've decided to go at 2 seconds so that will be 200 in S:30. My ladder is 9 (any ladder between 3 to 255) so in the file number I put 9. Next is to go back to the setup screen in the PID instruction command. The loop time is 2. The time mode is STI. (I try te remember if both time have to match or if the loop time has to be a fraction....???) From what I understand is that no matter how "heavy" my program is the file 9 will always get updated every 2 seconds. I deliberately decide to go with 2 seconds, I'll see if it is agreed. The reason is that on all my ovens there is an overshoot of about 15 to 25 degrees and then the temperature fluctuated of +/- 1C (299-300-301C). Not bad. Once hooked up I'll see how it behaves and will reduce the update time of the file. My problems is not with the PIDs but with all the useless components between their outputs and the modutrol. If all is virtual in the PLC I don't have to worry about loose wires or failing relays. Quite certainly I will make a ladder with the different commands that I need in the whole project (A/M, emergency, manual output level...what has been discussed here basically). Thank you Mr. Paul.

Share this post


Link to post
Share on other sites
Edited by Mickey

Share this post


Link to post
Share on other sites
They aren't useless. They're just less reliable than your proposed solution. Relays have failure rates roughly 3-7 orders of magnitude lower than PLC's themselves. If you completely eliminate the component (your solution), then the failure rate becomes the same as the PLC (better since there are fewer parts) for THAT component. Your analog I/O's are going to have the same rate of failure as you started with. The only way this would change is that if you are using more modern I/O, much of it is being built to higher standards to get better TUV ratings for instance to sell it to the process safety market. In the end, when I've done these types of analysis before, the weakest component is always the actuators. Replacing all those actuators and such just keeps the electrical department from getting the calls. The system failure rate won't change all that significantly because all the moving parts are always the limiting factor. So you will very slightly decrease downtime and you will probably see your failure modes change but you won't see that dramatic of a decrease in downtime unless those "useless" parts were engineered poorly.

Share this post


Link to post
Share on other sites
I haven't been on the Forum for a few days. Sorry Mr. Mickey and Mr. Paul. Mr. Mickey, if you read Mr. Paul's last post you will probably understand why I went STI. I choose a low rate because I had no idea what would be a good time for the STI loop. I will decrees it drastically. I had no intention of over doing it to avoid overloading the processor. "As far as how to set it up, you got it. Remember NOT to JSR this particular ladder within your program because otherwise you'll screw up the timing. As a "bread crumb trail" to help myself and anyone else looking at the program, STI's usually confuse electricians because they don't know to look for them and can't figure out "where the routine is called from". So in my list of JSR's for all the various subprograms, I always include this: AFI JSR 9 0 0 This is a JSR to the STI'd routine but it's also AFI'd out. Then I put a rung comment on the line explaining that this ladder is called from an STI and instructions to NOT JSR it." I'm not certain that I understand the AFI JSR 9 0 0..... As for my STI routine it's the LAD9 with only the PID instruction there and that is it. LAD15 is reserved for all the instructions for the burner either in manual or automatic etc. I won't comment further on the added details to avoid saturating this topic. Thank you both.

Share this post


Link to post
Share on other sites
Everything in Logix 5/500/5000 is really command line. Just start typing. It's a series of commands. For instance, try hitting ENTER or INSERT to start a new rung. Then type in "XIC B3/0 CLR N7:0" and press enter. Watch the instructions just appear. AFI -- always fail instruction, available on most AB PLC's. It's an instruction that always evaluates to a false condition, gauranteeing that the next instruction won't execute. JSR 9 0 0 -- JSR to ladder 9, and the extra 0's are because several AB processors are looking for a parameter count so you have to give it zeroes to make it have no parameters.

Share this post


Link to post
Share on other sites
I'm aware that I can type in the instructions directly into the line. XIC B3:0.0 CLR N7:0 means Examine if close bit3:0.0 Clear integer file N7:0. So if B3:0/0 is true it will clear N7:0. I double click on the left margin side and it changes the series of icons, questions marks, branches etc into a written text. I often use that when lines are similar, I'll I need to do in change the bits, timer, etc identifications and details. Makes it much faster. There are easy ways to remember them is that once in the ladder 3 letter identified them: MOV, COP, GEQ, EQU, TON, RTO, RES, CLR etc. RS's software are expensive but they are user friendly. I did try this "AFI" in my Lad2. I get this message: "Unknown instruction type encountered in string: AFI". More details: I have a new rung and double clicked to get the box (could have type directly), next I type the exact command then ENTER. The message pups up. For this project I use RSLogix500.

Share this post


Link to post
Share on other sites
That's because RSLogix500 does not support the "AFI" ( Always False Input/Instruction) instruction. RSLogix5 and RSLogix5000 do. Edited by Mickey

Share this post


Link to post
Share on other sites
If you don't have AFI, use this: XIC B3/0 XIO B3/0 ...or pick some other appropriate bit. The bit absolutely doesn't matter because if the two instructions "examine if 1" and "examine if 0" in series will always result in a false result. Others insert a single instruction at the very top of the program like this: OTU B3/0 Or if you are concerned about using latch instructions, something like this: XIC B3/0 XIO B3/0 OTE B3/0 Either way, these all result in putting a zero into the bit, which is then used anywhere in your program where you need to gaurantee a false result XIC B3/0 Any bit can be used. I just used B3/0 as an example.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0