This action might not be possible to undo. Are you sure you want to continue?
- by Jim Rowell - 2004/02/10
Welcome back! Last time, we pretty much ignored ladder diagrams. This time I'm giving you lots of them. We'll look at the ins and outs of turning those pretty pictures into powerful text. You'll gain insight into the block commands and the various structures that can be built using List. You'll leave with full knowledge of the perils and pitfalls. We'll be using numbered as opposed to named I/O for the examples. Don’t get used to it and definitely don't be discouraged by it. Numbers work best for showing you how the code works but they're terrible at showing you what it's actually doing. Your own code (with proper I/O names) will be much easier to follow. Experienced programmers will find the initial stuff a bit on the basic side but please, keep reading. It gets better. The more advanced topics will rely upon terminology and phrases introduced in the basic ones so I suggest you don't skip. I can pretty much guarantee you'll find a knowledge nugget or two somewhere in the following pages (double your money back, void where prohibited). Our focus will be on the Mitsubishi FX series but the concepts apply more or less on all plc's. Before using anything you learn here though, do yourself a favour by checking your manuals and testing your code. Take anything I say (or anyone else says) with several grains of salt. My mistakes don't have to be yours too. The Really Easy Stuff Okay, let's see how List compares with Ladder while writing some code. Feel free to try any of the examples in your editing software. Just be aware that if you switch between List and Ladder views without having an output on each rung (most of the examples don't), you'll receive an error. All you need to do is add an output to the end of the List code. AllRighty then... We'll start at the beginning of a rung (good choice huh?). First we type: LD X0
No surprises there. As you can see, we have begun a new rung with a normally open contact. We always have to start with the LD (or LDI) command.
Now let's add: AND X1
The AND command places a contact in series with all of the preceding logic. So far "all" consists of that single X0 contact we previously placed. You can perform AND as many times as you like and every new contact will be placed in series with all of the preceding logic. That's because when the plc reads a contact, all of the preceding logic has already been reduced to a single result held in the accumulator (remember? Part 1?). The plc is simply going to perform a logical AND with the accumulator and your new contact.
AND X2 AND X3
No mystery there, right? At this point, the accumulator holds the value of the output of X3.
in parallel with your entire rung. X4 -3- X5 . We're back to that accumulator thing again. X0 X4 X1 X2 X3 X3 The accumulator now holds the value of the output of X5.Now try: OR X4 X0 X1 X2 Whoa! What the heck happened there? Unlike a logical AND. The plc performed a logical OR with the accumulator and your new contact. an OR command will place a contact in parallel with all of the preceding logic or in other words. AND X5 . places a contact in series with all of the preceding logic.
They are always in series or parallel with the entire rung up to the current point in the logic. After all. -4- X6 X5 X4 X5 . you're pretty smart. Really Smart PLC Rule #1: AND. are also in series with X0 to X3. ie. you will probably agree that so far it's embarrassingly simple. X0 X1 X2 X3 We could go on forever. Like this: X0 X6 X4 X1 X2 X3 X0 to X3 are in series. as a group. I'm told I do sometimes. I guess it's time to tackle the things that are not so obvious.OR X6 . So Far So Good If you've followed along patiently to this point. one of the most common things you'll encounter is the need to place a few contacts in series with each other followed by some contacts that are in parallel with each other but still in series with the first ones. ANI. places a contact in parallel with all of the preceding logic. OR & ORI commands always operate on all of the preceding logic. First off. X4 to X6 are in parallel with each other and.
Although you have probably drawn exactly such a diagram in Ladder and would be just as likely to build it that way using relays. Like this: X4 X0 X1 X2 X6 X5 -5- X3 . just read a bit further. (the complaints are occasionally followed by rioting in the streets. In Part 1. Such a simple construct in Ladder yet in List we are already having to resort to using 2 separate blocks of code joined by ANB….. Since this is in fact a common logic sequence. as far as the plc is concerned. you've been doing it backwards all along. We'd have to use them here. looting. This is where people start to complain. etc). or what the heck. it's worth letting you in on a little secret.. we talked about using the ORB ("Or Block") and ANB ("And Block") commands.You simply can't do this in List using nothing but your basic AND and OR. Huh? Yup. Something like: LD X0 AND X1 AND X2 AND X3 LD X4 OR X5 OR X6 ANB Note: Do a quick review of Part 1 if you don't understand the use of ANB. Try putting the OR'd contacts first and see what happens. setting of fires.
Before anyone gets upset with me. It now requires less memory to store the program and you made it execute faster. A good controls electrician has this seared into his brain. it's never a bad thing. -6- . You also made it shorter. In a plc. I will quickly add that the efficiency of code is usually not that critical compared to readability. There are times when efficiency is very important. Even more important. add the parallel set last if you want the two sets to be in parallel. you see what the plc sees and you have a better opportunity to write code that is efficient. you learned one of the reasons why List might be a good idea. The following new rule helps us do just that. we need to take advantage of Rule #1 rather than being ruled by it. Really Smart PLC Rule #2: If a string of logic contains a set of series contacts and a set of parallel contacts: add the series set last if you want the two sets to be in series. maintainability and other factors. Note: This is really just an expansion of rule #1. The series-wired stop buttons always came first followed by the parallel-wired start buttons & holding contacts. you tend to think like a human (and that can't be good). Using Ladder. The good old 3-wire start/stop circuit taught in every electrical class is probably to blame. You just made it a lot more readable. But now we are inside the plc.Now write that in List and you get: LD X4 OR X5 OR X6 AND X1 AND X2 AND X3 See? No ANB. On the other hand. If you are using List. Everyone tends to make this AND before OR mistake.
We'll minimize their use by keeping our Really Smart PLC Rule #2 in mind. Exactly what Rule #2 said to do. using the LD command in the middle of a rung suspends the logic you are working on and temporarily begins a new rung at the left rail. You end up with two blocks. First of all. remember that using LD will always begin a new "block" of code (what we called a "series" of statements in Part 1. The reason we want to do this is so that when something applies to "all of the preceding logic" it will only be referring to what's in this new block. the new one can be connected to the old by using ANB or ORB. tech term). the old block will be ignored. For now. In effect. the old unfinished one and a new temporary one. we avoided the ANB by putting the series set last. When you are ready. So let's do some practice with those.start block #1 OR X1 produces this: X6 X5 X4 X3 Block #1 X1 X0 -7- . If we had wanted them in parallel we would have reversed it like this: LD X0 AND X1 AND X2 AND X3 OR X4 OR X5 OR X6 X0 X1 X2 ANB/ORB Sooner or later we will have to resort to ANB/ORB. Pictures! We need pictures! LD X0 . "block" is the official. We had a set of series contacts and a set of parallel contacts and we wanted them in series with each other.In the previous example.
OR X3 X0 Block #1 X2 X1 Block #2 Note that both blocks were left "open" (ie.Now let's add another LD statement (to get a new block) followed by OR. the two blocks will be placed in series like this: X0 X3 ANB X1 X3 -8- X2 . If we add an ANB at the end of our code.start block #1. there are no OUT or other output type commands that would produce a connection to the right hand rail). OR X1 LD X2 . Altogether we have: LD X0 .start block #2.
start block #2. We could have just OR'd all the contacts together in the first place and avoided the use of ORB.If we instead use an ORB. Here's a better example showing the use of ORB: LD X0 .start block #1. we'll parallel them like this: X1 X0 ORB Using ORB in this example was rather pointless. AND X3 X0 X3 X2 X2 X3 X1 -9- . AND X1 LD X2 .
Assuming you are happy with the concept of a spherical planet. let's ride forth… When do you need ANB/ORB? Really Smart PLC Rule #3: Use ANB/ORB when you need to apply logic that only operates on some of the preceding logic. you need an ORB.Now add ORB and you'll get: X0 X1 ORB X2 Common sense might have told you the last drawing could be coded as… LD X0 AND X1 OR X2 AND X3 when in fact. that would have produced this: X0 X1 X3 Just remember that common sense will also insist that the world is flat. this would be a good time to go back and review (starting with Part 1). Identify the logic section of interest and then separate it out by surrounding it with LD & ANB/ORB. If you need to do an AND but only want the contact to be in series with some of the preceding logic.10 - X3 . If you need to do an OR but only want the contact to be in parallel with some of the preceding logic. X2 . So if you're not exactly giving Ptolemy a run for his money. you need an ANB.
marks the start of the "some" stuff. Example of OR needing an ANB: X0 X3 X2 ANB X1 We only want X4 to be in parallel with some of the preceding logic (ie.Example of AND needing an ORB: X0 X1 ORB X2 We only want X3 to be in series with some of the preceding logic (ie.this OR tells us we need an ANB.11 - X4 X3 . Here it is in List: LD X0 AND X1 LD X2 .this AND tells us we need an ORB. but nothing else).places the X3-X4 block in series with the X0-X1 block.marks the start of the "some" stuff. AND X2 . ANB . Here it is in List: LD X0 OR X1 LD X3 . in parallel with X3.places the X2-X3 block in parallel with the X0-X1 block. ORB . but not X0 or X1). OR X4 . in series with X2. AND X3 .
chances are you'll be doing different things tomorrow. you decide it would be a great time to try out the delete key on your new keyboard. You may end up using the opposite approach or perhaps you'll write Boolean in Ladder and switch to List for math and similar functions. names and constants are clearer and more readable. 5) More efficient code. There was nothing extraordinary about it yet there were sections that contained over fifty math functions in a row. Being able to comfortably switch between List and Ladder will allow you to take advantage of the strengths of each. assuming both you and this document still exist… . you'll find that List has the following strengths: 1) It's quicker to type than it is to draw (and in Ladder you still have to fill in names and constants anyway). So why bother with all of this? Well.12 - . Keep the contents of blocks you'll be joining as short and simple as possible. each one ending way over on the right-hand side of the screen in a box full of misarranged numbers. you may have been thinking that for a while now). In Ladder. these appeared as endless horizontal lines. It's also worth pointing out that although the program was over 3000 steps in length. it contained only 15 block joins and a single MPS/MPP pair. I didn't have to really but Rule #2 says I should. if you wish to have List available to you. In more complex code. it was very clear and obvious what was going on. I'll be really ticked if after all the typing I just did. I can almost guarantee your response will soon be "Holy Cow! This just isn't worth it" (actually. until you start to use a lot of advanced functions. 2) Comments. 4) Printouts are more compact and can be edited in any word processor quite easily. I get a second perspective from Ladder that can be invaluable. None of these will make much of an impression (well. 3) You can see more of your program at one time on the screen and have more control over the layout. 7) Women will find you more attractive. maybe the last one). I write everything in List and use Ladder to double-check sections that don't "feel" right. our next example is going to get nasty. In List. That's because it was written in List. You shouldn't judge List by the mess you sometimes see when you auto-convert Ladder into it.Notice I didn't include the 'AND X2' until after the ANB. I recently wrote a program to control a rolling tube bender. Regardless of the type or level of programming you are doing today. Okay. So. Faster execution. 6) Complex functions are more readable. readable code is easier if "Ladder only". once you get used to it. Regardless. Besides. Personally. Let me give you an example. Less memory required . you need an understanding of its features and rules. It looked and read more like proper math. it'll help keep things clearer if you develop this habit. I'll be the first to admit that learning to write clear. I left it until the end as a separate operation.
X1. see J1 (joins the X2-X3 block with the X0-X1 block). ORB . ANB . You are allowed to have several blocks outstanding before you have to perform a join. you have to be careful not to join the wrong blocks together. see J4 (joins the block created by J3 with the one created by J1). see J2 (joins X10-X11 block with the X6-X7 block). . OUT Y0 You'll note that we held off using some of the block commands until the end. The FX series allows a maximum of eight. etc). It's also rather confusing. We had to in order to join blocks in the correct order. LD X4 AND X5 LD X6 AND X7 LD X10 OR X11 ANB .13 - X11 J1 J2 X10 J3 . First we'll translate the ladder diagram shown below exactly as it's drawn. ANB/ORB always operate on the two most recently created blocks. We'll even do it in the order suggested by the contact numbers (X0. X2. see J3 (joins the block created by J2 with the X4-X5 block).Let's try a complex example. J4 X0 X1 X4 X5 Y0 X2 X3 X6 X7 Here's the List: LD X0 AND X1 LD X2 AND X3 ORB . Doing it this way.
The rule tells us that by placing X6 & X7 after X10 & X11 we can eliminate the J2 block command. LD X4 AND X5 ORB . & X11 on the drawing.14 - . Have a close look at X6.By re-arranging things. see J2 (joins X10-X11 block with the X6-X7 block). Look familiar? Remember our Really Smart PLC Rule #2? Oh. we could have kept most of the block commands "inline" and made things a little easier to read (and less error prone). Very nice. you already saw that and were just being polite? I'm impressed. X7. Like this: LD X0 AND X1 LD X2 AND X3 ORB . . see J1 (joins the X2-X3 block with the X0-X1 block) LD X6 AND X7 LD X10 OR X11 ANB . OUT Y0 We still have an area that could be improved. see J3 (joins the X4-X5 block with the one created by #J2). This is a much better technique. ANB . X10. see J4 (joins the block created by #J1 with the one created by J3).
LD X10 OR X11 AND X6 AND X7 . This tells us we've done a good job (according to the next rule).see J3 (joins the X4-X5 block with the X10-X7 block).see J1 (joins the X2-X3 block with the X0-X1 block). You might be using a block join when it's not needed. If we had followed this rule in the first place. Notice the blocks joined by ANB both end in ORB and the blocks joined by ORB all end in AND. Could be a conspiracy. Breaking Rule #4 doesn't make your code illegal. LD X0 AND X1 LD X2 AND X3 ORB .see J4 (joins the block created by J1 with the one created by J3). Notice it says that both of the blocks being joined must qualify.Here's the final version (you don't really believe that do you?). the last version of our example would have appeared automatically without requiring the two revisions. Also note it doesn't recognize LD as a proper block end so you know at least two contacts are needed in each block you are attempting to join. ORI or a block join (ANB/ORB). Rule #4 even insists that you obey rule #2.we no longer need the block join at J2. It just means you haven't written it in the best possible way. GX or whatever and play). Both blocks being joined by ORB should end in AND. Really Smart PLC Rule #4: Both blocks being joined by ANB should end in OR. fire up Medoc. The rule is unforgiving. ANI or a block join (ANB/ORB). That's a key point. ANB .15 - . Interestingly enough. . You could even be including an AND that would be better added after the join is completed. OUT Y0 This version will work the same as the other two but they'll each produce different diagrams in your Ladder editor (go ahead. LD X4 AND X5 ORB .
combine this block with the previous one. There is a purpose here. It's well worth flipping back to the page with the first version and comparing. LD X4 . So. you'll often create divergent ones by mistake. And divergent outputs can lead to horrors such as MPS which should be avoided like prison time or processed cheese. There's a pretty dramatic difference isn't there? Which one would you rather work with five years from now when you've forgotten what this machine even looks like? OUTPUTS We haven't yet dealt with outputs in Part 2.add in the result from way back. Here's a method that is a lot more readable (never believe that "final" version stuff). I heard you). AND X5 LD X10 OR X11 AND X6 AND X7 ORB . I call these Simple. AND M0 . Also.assign an internal relay to record the result so far. A bit confusing isn't it? When quickly scanning the code. Many people. you're saying to yourself "Oh Gawd. You can't give ANB a name at all. It's even harder to use them properly unless you know a few tricks. He's making up terms and definitions now. descriptive name so that when you use it. when writing in List.start over fresh. OUT Y0 In the real world. OUT M0 . It's hard to write a program that does anything without them. . LD X0 AND X1 LD X2 AND X3 ORB . you have no idea what that ANB is referring to. Cascaded and Divergent outputs.There is still the issue of that final ANB in our last version. you'd give M0 a nice. you'll know exactly what it refers to.16 - . don't even realize that cascaded outputs are legal.combine this block with the previous one. if you don't know the difference between cascaded and divergent outputs. Or not… There are three types of output connections that one can make. He just wants this to be complicated" (yeah. I'll now take you to the grand heights of advanced output design.
For a look at why. Note: There are NO contacts at these points LD X0 OUT Y0 AND X1 OUT Y1 AND X2 OUT Y2 X0 Y2 Y1 Y0 X1 X2 X1 extends the logic of Y0. The extension logic added for each new output is built using only AND/ANI.17 - Y1 Y0 .Simple Outputs You have a simple output when you have only one or. etc and. X2 extends the logic of Y1. Nothing mysterious here. if there are several. Note the extension logic leading to each lower coil from the upper coil connects directly to the upper coil. ANB/ORB. see Water Flows Downhill (in the Other Stuff section at the end of this document). The logic leading up to a set of cascading outputs can be built without resorting to anything other than LD/AND/OR. they are directly connected together. (once you place even 1 output. you are no longer allowed to use ANB/ORB). LD X0 OUT Y0 OUT Y1 OUT Y2 X0 Cascaded Outputs You have cascaded outputs when you have more than one output and each uses all of the logic of the preceding output and then extends that logic with more of its own. you should be able to also use OR in the extension logic but the ability has been disabled in the plc. Y2 . if needed. In reality. There are no contacts between that connection point and the upper coil (see arrows). There are no contacts between any of the outputs.
Then it looks at X3 and outputs Y0.Divergent Outputs You have divergent outputs when you have more than one output and each uses only some of the logic of the preceding output. but is not required to. Each output may. The output of the X0 contact is what I call a "point of divergence". In order to build a set of divergent outputs. you can recall that value from storage and use it to modify the accumulator.. . Everything is rosy. This is the only time MPS is used in a program. So what? Well picture the plc merrily processing everything in your program up to and including X0 in the normal manner. plc's don't do that. Really Smart PLC Rule #5: PLC logic never flows backwards.18 - Y2 Y1 Y0 . This result includes the effect of X3. Whenever you see a point of divergence in your code. Hmmm. Y1 totally ignores X3. Rule #6 is all about it). Unfortunately. The logic splits into 2 different routes. you have to use MPS (Memory Point Store) or some other method of saving the value of the accumulator when you come to the place where the multiple output paths separate (the point of divergence). There MUST be contacts here X0 x3 X1 x4 Points of divergence x2 There MAY be contacts here Note that X3 is sitting between the higher coil (Y0) and the connection point leading to a lower coil (Y1). you know you need to stick an MPS there (or similar). when it's time to execute the second branch. at this point (like all points) none of the preceding logic exists anymore. Y1 does not use all of the logic that Y0 does. Sorry. we still have to process the logic leading up to Y1 but that's not supposed to include X3! Basically. Remember. It's like a fork in the road. All we have is the current result in the accumulator. Each half of the fork ends in a coil that is not seen by the other. extend that logic with more of its own (remember this last part.. Later. we now need the plc to back up a bit (to the point of divergence) and then execute the branch to Y1.
All too often. The Point of all of this Simple outputs are obvious. MPS operates on a stack that is 12 storage locations deep (in the FX series). They'll usually take care of themselves. it's an indication that things could have been re-ordered as a cascade. The editor's conversion makes grand use of MPS (especially since unlike you. Your rungs will be shorter and simpler too. Especially when written in Ladder. the plc will store the value of the accumulator at that point in the program. It needs a temporary method like MPS because it's not at liberty to use internal relays (they belong to you) and it would do a lousy job of naming them anyway. You read the topmost value with MRD (Memory Read). When you write in Ladder. Each time you write MPS (Memory Point Store). use the alternate method described below. OUT M0) to that point in the logic instead of using MPS at all. you shove the previous values deeper into the stack. most people don't know about divergent versus cascaded outputs). If you start looking. Now you have to search up through the code to figure out what is being referenced. A better method is to assign an internal relay (eg. you'll be surprised how many times they could have been written as cascades with just a little bit of effort. you shouldn't use MPS except in very obvious circumstances. Divergents are not really devil spawn but we do want to know when we've made them by mistake. If instead you read the stack using MPP (Memory Point Pop). This loads the accumulator with the value read.19 - . you'll see MRD or MPP used many lines below the MPS. Having said that. the editor must convert your code into List because that's what gets sent to the plc. In other words. End the rung right there and start over using a contact from the internal relay. You can have any number of MRD's. You can now give that relay a very descriptive name and refer to it as often as you wish without worrying about matching MPP's with MPS's. don't worry about it. for every MPS there must also be a MPP. Subsequent uses of MRD will read that "next value". If you don't understand it. you load the accumulator with the current value and then bring the next value up to the top. Cascaded outputs are nice. Let's just quickly say this: If you write MPS. . Which brings us to: Really Smart PLC Rule #6: If a divergent output does not have logic between itself and the point of divergence.The Evil MPS I'm not going to go into too much detail on MPS since it's all in the manual. The main reason that MPS exists is for use by the Ladder editing software itself. The code looks good and it executes quickly. You must completely empty the stack before leaving a rung or you'll generate an error.
Proper divergent outputs. Point of divergence X0 X1 X2 It codes as: LD X0 MPS AND X1 OUT Y0 MPP AND X2 OUT Y1 Divergent outputs that should be rewritten as cascaded: Point of divergence X0 X1 It codes as: LD X0 MPS AND X1 OUT Y0 MPP OUT Y1 Note that MPP is followed immediately by OUT.20 - Y1 Y0 Y1 Y0 . This is an indication that it should be rewritten as: .
We could have accomplished the same result like this: LD X0 OUT Y0 AND X1 OUT Y1 AND X2 OUT Y2 Same Logic with Cascaded Outputs You don't have to end a block of code just because you've reached an output. This is NOT a Point of divergence X0 x1 It codes as: LD X0 OUT Y1 AND X1 OUT Y0 Not only can some divergents be re-written as cascades.21 - y0 y1 . . many people are tempted to write code with repetitive logic such as: LD X0 OUT Y0 LD X0 AND X1 OUT Y1 LD X0 AND X1 AND X2 OUT Y2 Simple Outputs with Repetitive Logic They wouldn't have done it like that in Ladder and there's no rule that says they have to do it that way in List. simple outputs need looking at too.Same as above but with cascaded outputs. For instance. when first exposed to List.
OTHER STUFF Reversing Your Logic or "What I really meant was.or x1 is off (full inverse of AND) X2 ." Let's say you've just completed a long.. A full inverse is where you invert both the contact and the operation in one shot. Having to use INV may not be as efficient as .22 - . Before you start a mind-numbing revision (or worse. OUT & INV OUT are the full inverse of each other (we only have an output). start unloading the dishwasher) there is a simple "no thinking required" method for doing it. .. Really Smart PLC Rule #7: If you invert every contact. involved piece of artwork (a masterpiece of logic) that views things from the perspective of "if all things are on then do something". It works like this: LD & LDI are the full inverse of each other (we only have a contact). OR & ANI are the full inverse of each other (both a contact and an operation).if x0 is off (full inverse of LD) X1 . Knowing what your options are is the first step towards writing optimal code. we can mimic it by using INV followed by OUT.and x2 is off (full inverse of OR) .. there are many times when repeating some of the logic (perhaps via an internal relay) will actually be a good idea. Fortunately.then turn on y0. there will be no change in the operation of the outputs. It allows you to break things up into sections and separates ideas. logical operation and output in a logic sequence.or x2 is on OUT Y0 . LDI ORI ANI INV OUT X0 . After looking at it. turn on y0. is the same as. it doesn't explain things in the best possible way.You CAN keep going! Of course. AND & ORI are the full inverse of each other (both a contact and an operation). ANB & ORB are the full inverse of each other (we only have an operation).and x1 is on OR X2 . you realize that although the result is correct.if x0 is on AND X1 . example: LD X0 . Some plc's offer a ready-to-go inverted version of OUT (usually called something similar to OUT_NOT) but it's NOT there in the FX series (pun intended).. Which leads us to.. Note the use of INV ("Invert"). What you really wish you'd written was the same logic but expressed as "if some things are off then don't do anything". It takes the value of the accumulator and inverts it.then don't Y0 ..
LDI would start a new rung. If the first line is true (ie. the statement following the word "then" will execute but the statement following "Else" will not. I don't recommend using it on your next job application. the above is a good example of cascaded outputs. LDI ORI OUT INV OUT BEER . you can quite literally think "else" when using INV in this manner.then get groceries . I prefer INV as it more closely associates the two possible results together. Instead of a cascade. then only the statement following "Else" will execute. If the first line is not true. you'll find it's a lot more difficult especially with complex logic. As you can see. watch TV As a side note.else WATCH_TV . IF/THEN/ELSE If/then/else is a very heavily used feature in almost every computer language ever developed.OUT_NOT but it is very versatile since we can use it for other things anywhere in our code. It works well. . beer & chips really are equal to 0). eg.or no chips GET_GROCERIES . in Pascal one could write this: If (Beer = 0) or (Chips = 0) then GetGroceries Else WatchTV. If you try the same thing in Ladder. An alternative to using INV here would be to replace it with LDI GET_GROCERIES. In fact. I'll refrain from comments such as "Ladders are for changing light bulbs" if you'll admit List is not as bad as you thought.if no beer CHIPS . Notice how easy it is to read the code when you put meaningful names in place of the I/O numbers we've been using. We can do similar on the plc using INV. Nonetheless. this type of logic reversal is quite easy to perform in List. The bad news is it's NOT available on the FXON & FXOS.23 - .
LD X0 OUT Y0 ORI X0 OUT Y1 Under the current rules of engagement. After that.Water Flows Downhill (but Ladder doesn't know that) I mentioned earlier that you are not allowed to use OR (or ORI) with cascaded outputs. This is how you would code it in order to obtain the same behavior: LD X0 ORI X0 OUT Y0 OUT Y1 Now check out this code. It's a set of cascaded outputs where the upper output is extended using ORI. However. Y0 has been handled and forgotten about. All it keeps is the current result in the accumulator. it's only a pitfall for someone who thinks that just because both versions will convert in their head to the same ladder diagram. Remember that once something is executed. it will turn on Y0. this should convert into the same drawing as we have above but its operation is very different from the relay version. If X0 is on. Rather. Guess what? Kaboom! One major pitfall for someone translating a relay diagram into a plc program. I should say. if you let your editor autoconvert this List into Ladder. it will never go back and change Y0.24 - Y1 Y0 . Have a look at the following diagram. the plc forgets about it. . it will either "correct" it for you (Medoc Dos) or get very confused (GX Developer). X0 X0 If this were wired with real relays in the real world. Y0 will only go on if X0 is on. one of the contacts will always power up both coils. we are in effect saying "if the accumulator is on OR if X0 is off then turn on Y1. I'll try and explain that here. in line 3 of the List. he can use either version of List to represent the relays. There is no point to this circuit but it illustrates the idea. Y1 will go on no matter what. It doesn't matter whether X0 is on or off. both Y0 and Y1 would always be on. No matter what it decides to do about Y1.
take note that if you had a different situation and needed to use an ANI instead of the ORI in the cascaded version. I think it's unforgivable that Medoc has the audacity to change this code without so much as a warning. It is correct and might even be a useful bit of logic for you.Medoc will change the cascaded outputs into simple ones as in the first example.25 - . it's good to be aware of the issue. In any event. Written this way. Personally. If you send the cascaded version to the plc without converting it to Ladder. Y1 would never go on in this particular example but you get the point. But it has a different meaning than what we told it we wanted. at least attempt a conversion in GX before deciding that everything is hunky-dory. Did I mention that? While we're on the subject. ************************************* ********** . It really should operate the way we described above (the Kaboom method). the plc or even the Ladder language. Not exactly good behavior. If you don't have access to one. The moral of this is that it's worth having a plc in the shop for testing purposes. It refuses to convert it but doesn't tell you why or what the problem is. before heading out to a client's site. It also illustrates something I've been gently hinting at for some time: PLC logic never flows backwards. This whole cascaded OR thing is not really the fault of List. LD X0 ORI X0 OUT Y0 OUT Y1 This should convert back again into the same drawing as we have above (it does). You can't use them. Mitsubishi simply made it an illegal combination without fully dealing with the situation. it will generate an error that makes no sense ("Number of LD/LDI instructions is more than ANB/ORB instructions"). They could easily have used a downward pointing arrow (or a diode) instead of a solid vertical line. Y0 & Y1 will operate the same as the real relays. Just sort of hangs there in limbo. Current editors have no way to draw it that isn't misleading. you have no choice in the matter. Not something you'll miss anyway. Worse. Medoc users have no recourse other than caution. make you look unprofessional when it fails to convert. On the other hand it could be quite the opposite of what you (or the next guy to read your code) were expecting. viewing it in Ladder will either cause changes that may become permanent or. GX is not much better. you'd avoid all of the problems. The problem lies with the Ladder editing software. Until they figure this out and make cascaded OR's legal. The Ladder editors would be happy and all will work exactly like everyone expects.
Really Smart PLC Rule #7: If you invert every contact. Really Smart PLC Rule #2: If a string of logic contains a set of series contacts and a set of parallel contacts: add the series set last if you want the two sets to be in series. Really Smart PLC Rule #5: PLC logic never flows backwards. logical operation and output in a logic sequence. ************************************* ********** .26 - . Really Smart PLC Rule #4: Both blocks being joined by ANB should end in OR. Really Smart PLC Rule #3: Use ANB/ORB when you need to apply logic that only operates on some of the preceding logic. Really Smart PLC Rule #6: If a divergent output does not have logic between itself and the point of divergence. Both blocks being joined by ORB should end in AND. ANI. ANI or a block join (ANB/ORB).QUICK SUMMARY OF THE RULES Really Smart PLC Rule #1: AND. there will be no change in the operation of the outputs. it's an indication that things could have been re-ordered as a cascade. ORI or a block join (ANB/ORB). add the parallel set last if you want the two sets to be in parallel. OR & ORI commands always operate on all of the preceding logic.
Ask questions. In office software development.RowellElectric. Happy coding! Jim Rowell Rowell Electric Jim. If you have anything to add. right? Some of the people reading this will be beginners so I can't end without making a couple of comments about the need to be very careful. is a whole different animal. Comments and criticism (contract offers. perhaps seeing a different approach has deepened your understanding of plc's and given you some ideas of your own. It's a case of Hero or Zero. That's all for now. The machinery we work on is dangerous and it's your job as a designer to remove as much of that danger as possible. Test.ca . I'd love to hear from you. Maybe you can even see yourself trying it out in your next project instead of automatically using Ladder. It's all worthwhile. Those same problems can rip someone's arm off. And then test some more.27 - . a bad design is an irritant and errors can be expensive.I hope I've managed to provide you with some insight into the Instruction List language. If nothing else. Machinery on the other hand. Think carefully about everything you write. test. Get help. bank drafts.ca www. etc) are all welcome.R@RowellElectric. test. There's not much in between. Worry about the design.
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue listening from where you left off, or restart the preview.