LAB 10 INTRODUCTION TO LADDER LOGIC PROGRAMMING 1 Lab Objective In this lab you will be introduced to programmable logic controllers and the use of relay ladder logic. 2 Lab Equipment 2.1. CLICK Series Micro Programmable Logic Controller (PLC) For this lab we will be working with the CLICK Series Micro PLC (C0-01DD2-D). The main module has 8 DC inputs and 6 source DC outputs (see Figure 1). Each PLC is accompanied by an add-on output module (C0-08TD2) with 8 additional source DC outputs (see Figure 2). Figure 1: CLICK Series PLC CPU Module Figure 2: CLICK Series PLC Output Module The modules have been pre-wired to an input/output control panel to interact with the PLC for each lab activity. The PLC communicates with the PC using a standard serial communication port. The PLC transfers data to and from the PC by sending 38,400 signals per second (38,400 baud). Data is sent 8 bits at a time, with odd parity, and using a stop bit of 1. ce the PLC has been programmed, it can be untethered from the PC. Additionally, since these PLCs have retentive memory, after a power cycle the PLC will resume running the previously loaded program. 2.2. CLICK Software for Relay Ladder Logic (RLL) Programming The CLICK Series PLCs are programed using CLICK Software. The software allows a user to define ladder logic which can control the desired outputs. The logic can be a function of
current inputs, outputs, and internal variables (coils). After the program has been completed, the software will upload the PLC program to the CLICK PLC. While tethered to the PLC, the software has tools with which a user can monitor the real-time value of both internal and external variables (ie. logic states, timer/counter values). If you re interested, the CLICK Software has been made available for free download by the distributor at http://support.automationdirect.com/products/clickplcs.html Step-by-step instructions for starting a new PLC program, writing a program, and uploading a program to a PLC using the CLICK Software can be found in the Appendix. Additionally, a detailed help file for the PLC software can be found at http://www.aboutplcs.com/click/click_help/click_help.htm 3 Ladder Logic Examples 3.1. Oscillating Lamp Program a single output lamp to oscillate ON/OFF on 3 second intervals. 1a. Sequence of Events 1. After 3 seconds turn on Output Lamp and enable Timer 2 2. After 3 seconds turn off Output Lamp 3. Repeats Steps 1-2 indefinitely 1b. Relay Ladder Logic Figure 3: Oscillator - Ladder Logic
1c. Features Timers in RLL Discrete outputs (relay coils and contacts) Internal coils (used only for intermediate logic) 1d. Additional Information No external inputs are required to initiate the oscillator as shown. However, one can add a START switch to initiate the loop or stop it. The program as shown is self-starting. The only physical output is Y1 (connected to a lamp). The control relay C1 is an internal coil in the PLC. 3.2. Real-Time Clock 2a. Sequence of Events: 1. Turn on Seconds indicator every second 2. After 60 ticks of Seconds turn on Minutes indicator 3. After 60 ticks of Minutes reset Minutes Counter and turn on Hours indicator 4. After 24 ticks of Hours reset Hours and turn on Days indicator 5. Reset Days indicator 6. Repeat Steps 1-5 indefinitely
2b. Relay Ladder Logic 2c. Features Counters, Timers, Relay coils and contacts. Figure 4: Real-Time Clock - Ladder Logic 2d. Additional Information The current time on the real time clock is indicated by the output indicators Y2 (hours): Y3 (minutes): Y4 (seconds), and Y1 (days).
3.3. Alternating Red Lights A controller is needed to simulate an intersection where both sides are flashing red lights (the equivalent of a four-way stop). The timing diagram is as shown below. 3a. Timing Diagram Red 1 Red 2 Figure 5: Alternating Red Lights - Timing Diagram For this scenario, the red light on street 1 is one output and the red light on street 2 is the second output. According to the timing diagram, the red lights should alternate on and off at two-second intervals. 3b. Sequence of Events 1. Turn Red 1 on and Red 2 off for 2 seconds 2. Turn Red 1 off and Red 2 on for 2 seconds 3. Repeat steps 1 through 2 indefinitely. 0 2 4 6 8 10 Time (s)
3.4. Traffic Signal A controller is needed to control the traffic lights of an intersection of two streets. Street #1 (Washington Avenue) is a main street whereas Street #2 (Union Street) is a side street (or secondary street). Since Street #1 is a main street, it will be given a longer green light. The timing diagram for each light is shown below. 4a. Timing Diagram Green 1 Yellow 1 Red 1 Green 2 Yellow 2 Red 2 0 10 20 30 40 50 60 Time (s) Figure 6: Traffic Signal - Timing Diagram As seen in the timing diagram, this scenario requires six outputs: Red (2x), Yellow (2x), and Green (2x). e direction of traffic at a time is given a long green light followed by a short yellow light while the other direction maintains a constant red light. This sequence alternates between each direction indefinitely. Here, the cycle time for each light has been decreased for simplicity. 4b. Sequence of Events 1. Turn Green 1 on for 35 seconds and Red 2 on for 40 seconds. 2. Turn Green 1 off and turn Yellow 1 on for 5 seconds. 3. Turn Yellow 1 off, Red 2 off, Green 2 on for 15 seconds and Red 1 on for 20 seconds. 4. Turn Green 2 off and Yellow 2 on for 5 seconds. 5. Turn Red 1 and Yellow 2 off. 6. Repeat steps 1 through 6 indefinitely.
4 Prelab 4.1. Alternating Red Lights Using the outputs given in Table 1, create a ladder logic diagram for the alternating red lights described in Figure 5. Table 1: Alternating Lights - Input/Output Output Address Input Address Red 1 Y001 None Red 2 Y004 Use the appropriate ladder logic representation and naming convention (found in the Appendix) for each element in the diagram. For each timer, be sure to clearly indicate the set point and include the desired units (eg. 4 s). For the CLICK Programming Software, keep in mind that timers are placed at the end of a rung and have their own output memory address (eg. T1). A second rung is required to send this output to a coil. 4.2. Traffic Signal Using the outputs given in Table 2, create a ladder logic diagram for the traffic signal described in Figure 6. Table 2: Traffic Signal - Input/Output Output Address Input Address Red 1 Y001 None Yellow 1 Y002 Green 1 Y003 Red 2 Y004 Yellow 2 Y005 Green 2 Y006 ce again, use the appropriate ladder logic representation and naming convention (found in the Appendix) for each element in the diagram.
5 Lab Procedure 5.1. Alternating Red Lights Implement the alternating red lights from Prelab Exercise 1. Show your working PLC program to the TA. Save or print a copy of the ladder logic diagram for the postlab. 5.2. Traffic Signal Implement the traffic signal from Prelab Exercise 2. Show your working PLC program to the TA. Save or print a copy of the ladder logic diagram for the postlab. 6 Postlab 6.1. Ladder Logic Diagrams Print out the Ladder Logic Diagrams for both exercises. 6.2. Comment Diagrams each diagram write comments for every rung explaining what is happening (logic, counter, finish flag etc.) 6.3. Analyze Ladder Logic Diagram The ladder diagram below uses 1 timer with a time delay of 2 seconds. Analyze the diagram and predict what the signals Y1 and Y2 will look like from 0 to 10 seconds. Assume that the initial values of Y1 and Y2 are zero.
1. Start New Project 1. Open CLICK Programming Software Appendix Start All Programs Local AutomationDirect Click_Programming_Software 2. Select Start a new project 2. Write to PLC 1. Write Project PLC Write Project into PLC Click OK to begin read/write program If PLC is in RUN Mode, click YES to change to STOP Mode Click OK to acknowledge transfer complete Click OK to set PLC mode to RUN 2. Connect to PLC (ly if Write Project fails) PLC Connect Verify settings PC COM Port No.: COM1 Baud Rate: 38400 Address: 1 Parity Bit: Odd Stop Bit: 1 Click OK to connect to PLC 3. Address Naming Convention Each element has an independent name. The following address naming convention is used by the CLICK Software. X001-X008: Input Y001-Y006: Output C1-C2000: Coil T1-T500: Timer CT1-CT250: Counter
4. Ladder Logic Elements The following standard ladder logic elements are available in the CLICK Software. Element Description Ladder Logic Representation Normally Open Contact Is ON when the defined address (eg. X001, Y001, C1, or T1) is ON Normally Closed Contact Is ON when the defined address (eg. X001, Y001, C1, or T1) is OFF Out Coil Turns ON/OFF a given address (eg. Y001 or C1) when the rung is true/false. Timer When enabled, measures the elapsed time. Turns on output address once it reaches the set point. Counter When enabled, counts up or down until it reaches the set point End Instruction Marks the termination point of a program