The document provides information on timer and counter instructions used in programmable logic controllers (PLCs). It describes the different types of timer instructions including on-delay, off-delay, and retentive timers. It discusses timer parameters, addressing, and memory usage. The document also covers counter instructions and comparison instructions. It includes examples of programming timers and counters to control motors and count parts on a conveyor.
The document provides information on timer and counter instructions used in programmable logic controllers (PLCs). It describes the different types of timer instructions including on-delay, off-delay, and retentive timers. It discusses timer parameters, addressing, and memory usage. The document also covers counter instructions and comparison instructions. It includes examples of programming timers and counters to control motors and count parts on a conveyor.
The document provides information on timer and counter instructions used in programmable logic controllers (PLCs). It describes the different types of timer instructions including on-delay, off-delay, and retentive timers. It discusses timer parameters, addressing, and memory usage. The document also covers counter instructions and comparison instructions. It includes examples of programming timers and counters to control motors and count parts on a conveyor.
Dept. of E&IE, BEC, Bagalkot Introduction • Major enhancement to original PLC – Timing and counting capabilities • Earlier PLCs – Timer cards • Modern PLCs – Timers and counters included in the instruction set • PLC timers are output instructions. They provide the same function as electromechanical and solid state timers Allen Bradley Timer Instructions • Allen Bradley SLC-500’s, ControlLogix and LogixPro have three timers available: TON – Timer On-Delay TOF – Timer Off-Delay RTO – Retentive TON Timer Parameters • Timer The address of the timer. Timers are stored in data file #4 and use a file designator of ‘T’. Valid range of timers is: 0 to 255. • Time Base The number of “ticks” on the clock. The SLC-500 series can be set to 1.0, 0.1, or 0.01seconds • Preset Value (PRE) The preset value is the length of time the timer should time before its contacts change state. The valid range is: 0 to 32,767. The total time of the timer is determined by: Total_Time = Preset_Value * Time_Base • Accumulator Value (ACC) Stores the current time of the timer. Timer Memory • Each timer, of any type, requires three, 16-bit words in timer memory. Word 0 – Stores the status bits of the timer Word 1 – Stores the preset value Word 2 – Stores the accumulator value • Timers have three status bits that are stored in word 0: Bit 13 or Bit (DN) – Done Bit Bit 14 or Bit (TT) – Timer Timing Bit Bit 15 or Bit (EN) – Timer Enable Bit Timer Memory Map Timer Addressing • Timers, by default, are stored in data file #4 and has a file designator of ‘T’. Therefore, timer number zero is addressed as T4:0 • There are two main forms of addressing in AB; Bit level and Word level. To address the status bits of a timer use bit level addressing as follows: T4:0/13 or T4:0/DN = Done Bit T4:0/14 or T4:0/TT = Timer Timing Bit T4:0/15 or T4:0/EN = Enable Bit Timer Addressing • Word level addresses are used to address the value of a 16-bit word. Therefore, to read the value of the timer accumulator or preset use a word level address as follows: T4:0.1 or T4:0.PRE = Value of timer zero’s preset T4:0.2 or T4:0.ACC = Value of timer zero’s accumulator • Almost any word in the AB memory structure can be addressed to bit level, here is an example: T4:0.ACC/8 This is a bit level address that is referencing bit-8 in the accumulator word of timer zero. Timer On Delay Timer On Delay Timer On Delay Timer Off Delay Timer Off Delay Timer Off Delay Timer Off Delay Retentive Timer On Delay Retentive Timer On Delay Retentive Timer On Delay Maximum Amount of Time a Timer can Time To • What is the maximum amount of time that a SLC500 can time to? SLC500 Timers 1.0 Second * [(215 – 1) or 32,767] = 32,767 Seconds Which is: 9-hours 6-minutes 7-seconds Cascading Timers Self Resetting The Timers Programming Examples • Develop a PLC program to control two motors M1 and M2 using two push buttons S1 and S2. The motor M1 should start immediately when push button S1 is activated. Motor M2 should start after a delay of 10 Sec. When push button S2 is activated both motors should turn off immediately Programming Examples • Develop a PLC program to control two motors M1 and M2 using two push buttons S1 and S2. The motor M1 and M2 should start immediately when push button S1 is activated. When push button S2 is activated motor M1 should go to off status immediately, whereas motor M2 should go to off status after a delay of 10 sec. Programming Examples Counter Instructions Counter Instructions Counter Instructions Counter Instructions Counter Instructions Counter Instructions Counter Instructions Counter Instructions Counter Instructions Counter Instructions Counter Instructions Counter Instructions Counter Instructions Counter Instructions Counter Instructions Counter Instructions Counter Instructions Counter Instructions Counter Instructions Counter Instructions • High speed counter Used when the transitions are happening at a rate faster than scan time Works in a way similar to CTU Counter Instructions Counter Instructions • Only one HSC is allowed per program • Address is fixed – C5:0 • Works in a way similar to CTU • Does not count the rung transitions, but transitions are counted directly from the input • A separate hardware accumulator is used in conjunction with HSC – image accumlator • Setting UA bit will cause the counters image accumulator to update the processor accumulator Counter Instructions Counter Instructions Comparison Instructions • EQU • NEQ • LES • LEQ • GRT • GEQ Comparison Instructions • EQU – checks for equality of two values Comparison Instructions • NEQ – Checks for inequality of two values Comparison Instructions • LES – checks whether one value is less than other value or not Comparison Instructions • LEQ – checks whether one value is less than or equal to other value or not Comparison Instructions • GRT – checks whether one value is greater than other or not Comparison Instructions • GEQ – checks whether one value is greater than or equal to other or not Data Handling Instructions • MOV • MVM • FRD • TOD • COP • Logical instructions • LIM • SCP Data Handling Instructions Data Handling Instructions Data Handling Instructions • Status bits – MOV instruction Carry bit – not affected Overflow bit – not affected Zero bit – set if the result is zero Sign bit – set if the result is negative Data Handling Instructions Data Handling Instructions Data Handling Instructions • Status bits – MVM instruction Carry bit – not affected Overflow bit – not affected Zero bit – set if the result is zero Sign bit – set if the result is negative Data Handling Instructions Data Handling Instructions Data Handling Instructions Data Handling Instructions • Carry bit is not affected by the TOD instruction • The overflow bit is set at 1 if the result value is larger than 9999 • The zero bit is set, if the result is zero • The sign bit is set if the source word is negative Data Handling Instructions Data Handling Instructions • Carry bit is not affected by the FRD instruction • The overflow bit is set at 1 if the value contained in the source is not a BCD value • The zero bit is set, if the result is zero • The sign bit is not affected by FRD instruction Data Handling Instructions Data Handling Instructions Data Handling Instructions • Logical Instructions AND Operation Data Handling Instructions OR Operation Data Handling Instructions XOR Operation Data Handling Instructions NOT Operation Data Handling Instructions • Limit Test Instruction Programming Examples • A classroom has a capacity of maximum 120 students. There are two doors, one for Entry and the other for Exit. When number of students in the classroom is less than 120, Entry door has a Green light on it which remains ON. When number of students in the classroom is 120 or more than that, Red light goes ON turning OFF the Green light which indicates that the classroom has reached its maximum capacity and is full. Programming Examples • Considering the availability of two separate doors for Entry and Exit, two separate Proximity Switches can be used to detect entry and exit of students. • One proximity switch is mounted at the Entry door and the other at the Exit door. • Both the switches will generate two different outputs which can be then fed to PLC to operate the lights according to the Ladder Logic Program written in its memory. • Counter must be used to count the number of students entering and exiting. • Comparator must also be used to compare the count value with the given maximum capacity of 120. Programming Examples Programming Examples • Material A and Material B are collected in a tank. These materials are mixed for a while. Mixed product is then drained out through Outlet valve. Implement this in PLC using Ladder Logic programming language. Programming Examples • To detect level of Material A and Material B, two separate level switches are used. • And to detect low level, one more level switch is used at the bottom of the tank. • These give output in digital terms that is when corresponding levels are detected. • To control level of this system, Single Acting Piston valve can be used which has two states, either fully open or fully close. • To control mixing, agitator is used which is connected with Motor shaft. • Particular time delay is generate to mix the materials for a definite time. • Control inlet valves on the basis of Level Material switches A and B. • Outlet valve is then operated to drain the mixed product. Programming Examples Programming Examples • Parts are moved on the conveyor. Count the number of parts collected at the end of the conveyor and display it on the display in PLC using Ladder Diagram programming language. Programming Examples Programming Examples • There are total four number of outputs which should be run one by one with a particular time delay. Implement this in PLC using Ladder Diagram programming language. Programming Examples • Generate Master Start and Stop buttons to activate the sequence and define four outputs. • Use TON timer to generate a particular time delay, same or different. • Use Done bit of first timer to energize other output and activate second timer. • Repeat this process until the final output is energized and last timer is activated. • Reset timers after the completion of first cycle if necessary. • Use LEDs as output to test the program. Programming Examples • Display the time taken to move an object from one end to another on a conveyor Programming Examples • Two different sized particles are being moved on the conveyor belt. To pack these particles, two different boxes are used separately. These products must not be packed in the same box. Separation of these particles is to be controlled. Implement automation to perform this operation in PLC using Ladder Diagram programming language. Data Handling Instructions • Scale with parameter instruction Analog input needs to be scaled before it can be processed Input data from a field device needs to be scaled Analog outputs need to be scaled before it can be sent to analog output module Data Handling Instructions Data Handling Instructions Data Handling Instructions Data Handling Instructions • Input: Input value to be scaled. It is address where input value to be scaled is stored • Input Min: The input minimum is the minimum input value • Input Max: The input maximum is the maximum input value • Scaled Min: This represents the scaled minimum value • Scaled Max: This represents the scaled maximum value • Output: Address where the scaled data is to be stored Sequencer Instructions • Controls a predetermined sequence of events • Three sequencer instructions available in Allen Bradley: Sequencer output Sequencer compare Sequencer load Sequencer Instructions Sequencer Instructions • Sequencer output (SQO) Programmed as an output on a ladder rung Each false to true rung transition causes the sequencer output instruction to increment to the next sequence step Each step of the sequence is stored in a sequencer file Sequencer file: user defined file Length of file determines number of sequence steps Sequencer Instructions Sequencer Instructions • Example: Four step process Four outputs are to be energized on one 16-point output module for each of the four steps All the output points must be on a single output module Sequence Step 1: Outputs 0,1,2,3 will be energized Step 2: Outputs 4,5,6,7 will be energized Step 3: Outputs 8,9,10,11 will be energized Step 4: Outputs 12,13,14,15 will be energized Sequencer Instructions Sequencer Instructions Sequencer Instructions Programming Example • Develop a PLC ladder program to control a stepper motor using sequencer output instructions. How the speed can be controlled Programming Example • There are total 3 tanks of which level is being controlled. Display level of these tanks for 5secs of one by one. Implement this in PLC using Ladder Diagram programming language.