Sie sind auf Seite 1von 5

TITLE:STUDY OF COUNTERS

AIM:To study the application of counters with the help of a few problems.

Apparatus:Logix pro software

Theory :There are two basic counter types: count-up and count-down. When the input to a count-up counter goes true the accumulator value will increase by 1 (no matter how long the input is true.) If the accumulator value reaches the preset value the counter DN bit will be set. A count-down counter will decrease the accumulator value until the preset value is reached. An Allen Bradley count-up (CTU) instruction is shown in fig. The instruction requires memory in the PLC to store values and status, in this case is example. The preset value is 4 and the value in the accumulator is 2. If the input A were to go from false to true the value in the accumulator would increase to 3. If A were to go off, then on again the accumulator value would increase to 4, and the DN bit would go on. The count can continue above the preset value. If input B becomes true the value in the counter accumulator will become zero. Types of counters:

COUNT-UP COUNTER (CTU) COUNT-DOWN COUNTER (CDU)

CTU Counter example Preset 4 Accum. 2 (CU) (DN) X

example.DN

B RES

Older C5:0/DN C5:0/CU C5:0.PRE C5:0.ACC C5:0/CD

Newer c.DN c.CU c.PRE c.ACC c.CD

Count-down counters are very similar to count-up counters. And, they can actually both be used on the same counter memory location. Consider the example in Figure 110, the example input cnt_up drives the count-up instruction for counter example. Input cnt_down drives the count-down instruction for the same counter location. The preset value for a counter is stored in memory location example so both the count-up and count-down instruction must have the same preset. Input reset will reset the counter. Count Up (CTU) The CTU is an instruction that counts false-to-true rung transitions. Rung transitions can be caused by events occurring in the program (from internal logic or by external field devices) such as parts traveling past a detector or actuating a limit switch. When rung conditions for a CTU instruction have made a false-to-true transition, the accumulated value is incremented by one count, provided that the rung containing the CTU instruction is evaluated between these transitions. The ability of the counter to detect false-to-true transitions depends on the speed (frequency) of the incoming signal. The accumulated value is retained when the rung conditions again become false. The accumulated count is retained until cleared by a

reset (RES) instruction that has the same address as the counter reset. The accumulated value is retained after the CTU instruction goes false, or when power is removed from and then restored to the controller. Also, the on or off status of counter done, overflow, and underflow bits is retentive. The accumulated value and control bits are reset when the appropriate RES instruction is enabled. The CU bits are always set prior to entering the REM Run or REM Test modes. Count Down (CTD) The CTD is an instruction that counts false-to-true rung transitions. Rung transitions can be caused by events occurring in the program such as parts traveling past a detector or actuating a limit switch. When rung conditions for a CTD instruction have made a false-to-true transition, the accumulated value is decremented by one count, provided that the rung containing the CTD instruction is evaluated between these transitions. The accumulated counts are retained when the rung conditions again become false. The accumulated count is retained until cleared by a reset (RES) instruction that has the same address as the counter reset. The accumulated value is retained after the CTD instruction goes false, or when power is removed from and then restored to the controller. Also, the on or off status of counter done, overflow, and underflow bits is retentive. The accumulated value and control bits are reset when the appropriate RES instruction is executed. The CD bits are always set prior to entering the REM Run or REM Test modes. Reset (RES) Use a RES instruction to reset a timer or counter. When the RES instruction is enabled, it resets the Timer On Delay (TON), Retentive Timer (RTO), Count Up (CTU), or Count Down (CTD) instruction having the same address as the RES instruction. When resetting a counter, if the RES instruction is enabled and the counter rung is enabled, the CU or CD bit is reset. If the counter preset value is negative, the RES instruction sets the accumulated value to zero. This in turn causes the done bit to be set by a count down or count up instruction.

Das könnte Ihnen auch gefallen