Try our online PLC Simulator- FREE. Click here now to try it. |
Learn quickly with our PLC Training DVD Series: on sale
Click here now for details! Counters A counter is a simple device intended to do one simple thing - count. Using them, however, can sometimes be a challenge because every manufacturer (for whatever reason) seems to use them a different way. Rest assured that the following information will let you simply and easily program anybody's counters. What kinds of counters are there? Well, there are up-counters (they only count up 1,2,3...). These are called CTU,(count up) CNT,C, or CTR. There are down counters (they only count down 9,8,7,...). These are typically called CTD (count down) when they are a separate instruction. There are also up-down counters (they count up and/or down 1,2,3,4,3,2,3,4,5,...) These are typically called UDC(up-down counter) when they are separate instructions. Many manufacturers have only one or two types of counters but they can be used to count up, down or both. Confused yet? Can you say "no standardization"? Don't worry, the theory is all the same regardless of what the manufacturers call them. A counter is a counter is a counter... To
further confuse the issue, most manufacturers also include a limited
number of high-speed counters. These are commonly
called HSC (high-speed counter), CTH (CounTer High-speed?) or whatever.
To use them we must know 3 things:
When the program is running on the plc the program typically displays the current or "accumulated" value for us so we can see the current count value. Typically counters can count from 0 to 9999, -32,768 to +32,767 or 0 to 65535. Why the weird numbers? Because most PLCs have 16-bit counters. We'll get into what this means in a later chapter but for now suffice it to say that 0-9999 is 16-bit BCD (binary coded decimal) and that -32,768 to 32767 and 0 to 65535 is 16-bit binary. Here are some of the instruction symbols we will encounter (depending on which manufacturer we choose) and how to use them. Remember that while they may look different they are all used basically the same way. If we can setup one we can setup any of them. In
this counter we need 2 inputs. For example, if we are counting how many widgets pass in front of the sensor that is physically connected to input 0001 then we would put normally open contacts with the address 0001 in front of the pulse line. Cxxx is the name of the counter. If we want to call it counter 000 then we would put "C000" here. yyyyy is the number of pulses we want to count before doing something. If we want to count 5 widgets before turning on a physical output to box them we would put 5 here. If we wanted to count 100 widgets then we would put 100 here, etc. When the counter is finished (i.e we counted yyyyy widgets) it will turn on a separate set of contacts that we also label Cxxx. Note that the counter accumulated value ONLY changes at the off to on transition of the pulse input. Here's the symbol on a ladder showing how we set up a counter (we'll name it counter 000) to count 100 widgets from input 0001 before turning on output 500. Sensor 0002 resets the counter. Below is one symbol we may encounter for an up-down counter. We'll use the same abbreviation as we did for the example above.(i.e. UDCxxx and yyyyy) In this up-down counter we need to assign 3 inputs. The reset input has the same function as above. However, instead of having only one input for the pulse counting we now have 2. One is for counting up and the other is for counting down. In this example we will call the counter UDC000 and we will give it a preset value of 1000. (we'll count 1000 total pulses) For inputs we'll use a sensor which will turn on input 0001 when it sees a target and another sensor at input 0003 will also turn on when it sees a target. When input 0001 turns on we count up and when input 0003 turns on we count down. When we reach 1000 pulses we will turn on output 500. Again note that the counter accumulated value ONLY changes at the off to on transition of the pulse input. The ladder diagram is shown below. Click here and view the animation to really learn! One important thing to note is that counters and timers can't have the same name (in most PLCs). This is because they typically use the same registers. We haven't learned about timers yet but you might make a note of this for future reference because it's pretty important. Well, the counters above might seem difficult to understand but they're actually quite easy once we get used to using them. They certainly are an essential tool. They are also one of the least "standardized" basic instructions that we will see. However, always remember that the theory is the same from manufacturer to manufacturer! Learn quickly with our PLC Training DVD Series: on saleClick here now for details! |
||
copyright © 1996-2011 by Phil Melore.
All rights reserved. |