19. Event Based Logic

• These devices will be set based on previous conditions in the PLC.

• Typical events in a PLC include,

first scan of the PLC

time since an input turned on/off

count of events

etc.

19.1 Timers, Counter, Flip-Flops, and Latches

• There are some devices, and concepts that are Temporal. This means that they keep track of events over time, as opposed to conditional logic that decides based on instantaneous conditions.

 

• Controls that have states, or time dependence will require temporal controls (also known as sequential)

• Some devices that are temporal are

Flip-Flops: these can be latched on or off.

Latches: Will stay on until reset (Similar to flip-flops)

Counters: Keeps a count of events

Timers: Allows inputs and outputs to be delayed, or prolonged be a known amount.

19.1.1 Latches

[an error occurred while processing this directive]

 

 

• Assuming that the PLC is much faster than the fastest event (i.e. no aliasing), then we can approximate the timing diagram above with a simpler form.

 

• As an example consider the ladder logic for a SLC-150,

 

• In most PLCs these will keep their last state even when the PLC is turned off, and back on.

Problem 19.1 • Write a short ladder logic program that will alternate between two outputs continuously using latches. ie, each scan one will turn off and the other will turn on.

19.1.2 Flip-Flops

[an error occurred while processing this directive]

• There are many type, but one of the best known is the SR (Set-Reset) Flip-Flop.

 

19.1.3 Timers

[an error occurred while processing this directive]

• We use timers to do some or all of,

Delay turning on

Delay turning off

Accumulate time passed

 

 

 

 

 

• When using timers (especially retentive) we must reset values when done. The (RES) instruction does this.

• The timers also have timer timing bits that indicate when the accumulator value is changing.

• Consider the example below, Write out the values for the accumulator, enable, timer timing and the done bits.

 

• Repeat the last example for the timer below.

 

• Consider the example of the SLC timers given below,

 

 

Problem 19.2 Write a short ladder logic program that will turn a light (LA) on 10 seconds after a button (PB) is pushed. A second light (LB) should be on while the button is pushed and then turn off 10 seconds after it has been released.

• When more than one event should happen in a sequence, timers can be cascaded. This means that the end of the first timer starts the next.

Problem 19.3 Write a short ladder logic program that will turn a light on/off every 10 seconds.

19.1.4 Counters

[an error occurred while processing this directive]

• Count up/count down counters will track input events.

 

• Count down counters are similar but can be used for convenience.

• Consider the example below for a SLC-150,

 

Problem 19.4 Write a simple program that will count 5 button presses and then turn on a light. After ten button pushes the light will be turned off.

19.2 Program Design Methods

• NOTE: these are structured design methods: although many of the design activities are obvious, by following the same steps, others can understand what you have done, and others will get similar results when they solve a similar problem. This is a simple start, and we will advance to significant design techniques later.

19.2.1 Process Sequence Bits

[an error occurred while processing this directive]

• A simple process will typically go through clear steps. Each step should follow the other, and when done the process goes back to the beginning.

• The general steps to this method are,

1. Understand the process

2. Write the steps of operation and give each a number

3. For each step assign a bit

4. Write the ladder logic to turn the bits on/off as the process moves through its states.

Problem 19.5 Design a flag raiser that will go up when an up button is pushed, and down when a down button is pushed, both pushbuttons are momentary. There are limit switches at the top and bottom to stop the flag pole. When turned on at first the flag should be lowered until it is at the bottom of the pole.

19.2.2 Timing Diagrams

[an error occurred while processing this directive]

• By writing a timing diagram, the sequence of steps in a program can be obvious.

• The general steps to this method are,

1. Understand the process

2. Identify the outputs that are time dependent

3. For each step assign a timer

4. Write the ladder logic to turn the outputs on/off as time progresses.

Problem 19.6 A handicap door opener has a button that will open two doors. When the button is pushed (momentarily) the first door will start to open immediately, the second door will start to open 2 seconds later. The first door power will stay open for a total of 10 seconds, and the second door power will stay on for 14 seconds. Use a timing diagram to design the ladder logic.

19.3 Design Cases

19.3.1 Counters And Timers

[an error occurred while processing this directive]

Part A: Develop the ladder logic that will turn on an output light, 15 seconds after switch A has been turned on.

Part B: Develop the ladder logic that will turn on a light, after switch A has been closed 10 times. Push button B will reset the counters.

 

19.3.2 More Timers And Counters

[an error occurred while processing this directive]

Develop a program that will latch on an output ‘B’ 20 seconds after input A has been turned on. After ‘A’ is pushed, there will be a 10 second delay until ‘A’ can have any effect again. After ‘A’ has been pushed 3 times, ‘B’ will be turned off.

 

19.3.3 Oscillator

[an error occurred while processing this directive]

Problem 19.7 Design an oscillator will be designed that will turn on for 1 seconds and off for 1.5 seconds continuously.

19.3.4 More Timers

[an error occurred while processing this directive]

Problem 19.8 Design ladder logic that allows an RTO to behave like a TON.

19.3.5 Cascaded Timers

[an error occurred while processing this directive]

Problem 19.9 Design ladder logic that uses normal timers to measure times of 5.0 days.

19.3.6 Deadman Switch

[an error occurred while processing this directive]

A motor will be controlled by two switches. The Go switch will start the motor and the Stop switch will stop it. If the Stop switch was used to stop the motor, the Go switch must be thrown twice to start the motor. When the motor is active a light should be turned on. The Stop switch will be wired as normally closed.

 

19.3.7 Conveyor

[an error occurred while processing this directive]

A conveyor is run by switching on or off a motor. We are positioning parts on the conveyor with an optical detector. When the optical sensor goes on, we want to wait 1.5 seconds, and then stop the conveyor. After a delay of 2 seconds the conveyor will start again. We need to use a start and stop button: a light should be on when the system is active.

 

19.3.8 Accept/Reject Sorting

[an error occurred while processing this directive]

For the conveyor in the last case we will add a sorting system. Gages have been attached that indicate good or bad. If the part is good, it continues on. If the part is bad, we do not want to delay for 2 seconds, but instead actuate a pneumatic cylinder.

 

19.3.9 Shear Press

[an error occurred while processing this directive]

The basic requirements are,

1. A toggle start switch (TS1) and a limit switch on a safety gate (LS1) must both be on before a solenoid (SOL1) can be energized to extend a stamping cylinder to the top of a part.

2. While the stamping solenoid is energized, it must remain energized until a limit switch (LS2) is activated. This second limit switch indicates the end of a stroke. At this point the solenoid should be de-energized, thus retracting the cylinder.

3. When the cylinder is fully retracted a limit switch (LS3) is activated. The cycle may not begin again until this limit switch is active.

4. A cycle counter should also be included to allow counts of parts produced. When this value exceeds 5000 the machine should shut down and a light lit up.

5. A safety check should be included. If the cylinder solenoid has been on for more than 5 seconds, it suggests that the cylinder is jammed or the machine has a fault. If this is the case, the machine should be shut down and a maintenance light turned on.

 

19.3.10 Actuator Failure

[an error occurred while processing this directive]

Problem 19.10 We are using a pneumatic cylinder in a process. The cylinder can become stuck, and we need to detect this. Proximity sensors are added to both endpoints of the cylinders travel to indicate when it has reached the end of motion. If the cylinder takes more than 2 seconds to complete a motion this will indicate a problem. When this occurs the machine should be shut down and a light turned on. Develop ladder logic that will cycle the cylinder in and out repeatedly, and watch for failure.

19.3.11 Palm Button Detection

[an error occurred while processing this directive]

Problem 19.11 In dangerous processes it is common to use two palm buttons that require a operator to use both hands to start a process (this keeps hands out of presses, etc.). To develop this there are two inputs that must be turned on within 0.25s of each other before a machine cycle may begin.

19.4 Problems

Problem 19.12 Develop the ladder logic that will turn on an output light (201), 15 seconds after switch A (001) has been turned on.

Answer 19.12

Problem 19.13 Develop the ladder logic that will turn on a light (201), after switch A (001) has been closed 10 times. Push button B (002) will reset the counters.

Answer 19.13

Problem 19.14 Develop a program that will latch on an output B (201), 20 seconds after input A (001) has been turned on. The timer will continue to cycle up to 20 seconds, and reset itself, until input A has been turned off. After the third time the timer has timed to 20 seconds, the output B will be unlatched.

Answer 19.14

Problem 19.15 Using the status memory locations, write a program that will flash a light for the first 15 seconds after it has been turned on. The light should flash once a second.

Answer 19.15

Problem 19.16 A motor will be connected to a PLC and controlled by two switches. The GO switch will start the motor, and the STOP switch will stop it. If the motor is going, and the GO switch is thrown, this will also stop the motor. If the STOP switch was used to stop the motor, the GO switch must be thrown twice to start the motor. When the motor is running, a light should be turned on (a small lamp will be provided).

Problem 19.17 For the ladder diagram below, what does the program do? (Note: the keep is equivalent to an S-R flip-flop, in other words S will latch the value on, and R will unlatch the value). Note that 200 and 210 are lights and 202 is a motor. 100, 102 and 104 are input push buttons.

Answer 19.17 This is a motor controller. 100 is a start button, and 102 is a stop button. Light 200 will indicate when the motor is on. Light 210 will indicate when either start or stop is pushed, or the emergency button is not pushed. The motor 202 will run if the start button has been pushed and the normally closed stop switch is not pushed.

Problem 19.18 Counters are used to count events or occurrences of inputs when a transition from OFF-to-ON occurs, which implies that they are ________________________ triggered.

Answer 19.18 positive edge

Problem 19.19 The address for a memory location that indicates when a PLC has just been turned on is ___________________.

Answer 19.19 868 for SLC-150

Problem 19.20 We are developing a safety system (using a PLC-5) for a large industrial press. The press is activated by turning on the compressor power relay (R, connected to O013/05). After R has been on for 30 seconds the press can be activated to move (P connected to O013/06). The delay is needed for pressure to build up. After the press has been activated (with P) the system must be shut down (R and P off), and then the cycle may begin again. For safety, there is a sensor that detects when a worker is inside the press (S, connected to I011/02), which must be off before the press can be activated. There is also a button that must be pushed 5 times (B, connected to I011/01) before the press cycle can begin. If at any time the worker enters the press (and S becomes active) the press will be shut down (P and R turned off). Develop the state transition diagram, and then ladder logic for the states. State all assumptions, and show all work.

Problem 19.21 Given the following timing diagram, draw the done bits for all four fundamental timer types. Assume all start with an accumulated value of zero, and have a preset of 1.5 seconds.

Answer 19.21

Problem 19.22 Write ladder logic that will give the following timing diagram for ‘B’ after input ‘A’ is pushed. After ‘A’ is pushed any changes in the state of ‘A’ will be ignored.

 

[an error occurred while processing this directive]