Introduction: Programming a PLC to Control a Stop Light.
PLCs are used in everything we encounter on a daily basis. From the machines canning or bottling of items such as beer, soda, soup and many other packaged goods to the conveyor belts at Walmart and the Stop Lights at some intersections, PLCs touch almost everyone’s life in one way or another, so it is important for someone in the robotics field to know how a PLC works, and how to program it.
The following guide will show how to create a functioning stop light with a PLC. These steps will show how to connect the PLC to the inputs and outputs to begin programming. They will also show how to program the PLC to output the correct lights at the correct intervals.
Step 1: Gathering Materials
To complete this project, the following materials are needed.
1 – Allen Bradley MicroLogix 1400 PLC
1 – Computer with RSLogix 500 installed
1 – Red 24v DC Light
1 – Green 24v DC Light
1 – Yellow 24v DC Light
1 – 120V Circuit breaker
1 – 120v AC to 24v DC power supply
1 – Ethernet Cord
1 – Power Cord
Wire to the length required for connecting lights.
Optional: Ferrules to protect the ends of the wire from fraying.
Step 2: Wiring the PLC
CAUTION: Never work on a live circuit, the AC line of the power is connected directly to the wall outlet and 110V, enough to kill a human or cause severe electrical burns including damage to internal organs. Always unplug the circuit, disable the circuit breaker and verify that the circuit has been de-energized.
For this application, the full wiring shown in the picture above is not required, only the wiring described below. All ports are clearly marked on the PLC.
To begin, start by connecting the PLC to power with L1, the white wire coming out of the power cord into the “VAC L1” port, and to the “L” Port on the power supply. Then the black wire coming from the power cord is connected to “VAC L2” and “VAC DC5” on the PLC and “N” on the Power Supply.
From the Power supply the positive, red, wire is connected to the “VAC DC0, 1, 2, 3, and 4” ports on the PLC. The negative, black wire is connected to the PLC “COM 0 and 1” ports and connected to one side of each light. The other side of each light is then connected to the PLC ports “OUT 0, 1, and 2”.
Step 3: Attaching the PLC to the Computer
To connect to the PLC, attach the ethernet cord ends to the PLC and the PC with RSLogix installed. Open RSLogix, and in the upper left corner in the drop-down menu that says "Offline" select "Upload" to import the PLC's settings into the program.
Step 4: Understanding RSLogix
RSLogix uses "Drag and Drop" for placement of its commands and addresses, meaning to insert the command or address, simply click and drag it from the menu to the desired location, then drop it.
The top picture shows the basic commands, the only ones used from this set are the first five. In order from left to right, they are:
Insert new rung.
Insert Examine if Closed
Insert Examine if Open
Insert Output Energize
The second command set, directly below the first picture is the timer set, the only command used from this set in this program will be the "TON" or Timer On.
The bottom three pictures show the Timer, Output and Binary tables, and where they can be located in the menu on the left side of the screen.
In the timer table, TT refers to "Timer Timing," meaning the bit will be enabled when the timer is timing. DN will be enabled when the timer reaches its preset time.
The Binary and Output bit addresses for this program are all in the top line of the table, starting at 0 on the right side.
Step 5: Understanding the PLC
To begin, there are many ways to go about programming any given rung of a PLC to achieve the same result, some are more efficient for the processor, others are easier to troubleshoot when issues arise down the road.
Inputs are connected to switches, which can be anything that can be switched between an on or off state when the desired outcome occurs from the switch being actuated. They can range from an ultrasonic sensor to a touch sensor to a push button.
Outputs are connected to items that need to be turned on or off, such as relays, motor starting contacts, or lights.
Timers and Binary are internal bits that are counted within the program and do not have any external connections.
For the stop light program, only the outputs, timer and binary portions of the PLC will be used.
Step 6: Designing the Program
To Program the PLC, begin by creating 7 “rungs” or lines within the program.
Assigning the addresses can be done with the same drag and drop method. O addresses correspond to outputs, B addresses to Binary, and T addresses to Timer. Their menus can be opened by double-clicking the name in the drop-down menu on the left side of the screen.
On the bottom three rungs, insert one “Examine if Closed” switch on the left side and one “Output Energize” on the right side of each of the rungs. In descending order, designate the “Output Energizes” to O:0/0, O:0/1, and O:0/2, and the “Examine if Closed” switches to T4:0/TT, T4:1/TT and T4:2/TT.
On the second rung from the top, insert one “Output Energize” to the right side of the rung and designate it to B3:0/0.
On the three remaining rungs, insert a “Timer On” timer on the right side of each and assign them in descending order as T4:0, T4:1, and T4:2.
On the first rung, insert two “branches” to the left side of the rung, and insert one “Examine if Open”, assigned to B3:0/0 into one of those branches. In the other two lines created by the branches, insert one “Examine if Closed” switch onto each, and assign one to T4:1/DN and the other to T4:0/TT.
On the third and fourth rungs, insert one “branch” onto the input of each, with one “Examine if Closed” switches on each line created by them. On the third rung, assign the switches to T4:2/DN and T4:1/TT. On the fourth rung, assign the switches to T4:0/DN and T4:2/TT.
The first timer is the time duration that the red light will remain on, the second timer corresponds to the yellow light and the third to the green light. For this example, time increments of 10 seconds, 2 seconds and 8 seconds were used.
To start the program, click the drop-down box that says “OFFLINE” in the upper left corner of the program and select “Download.” Click through the warnings, accepting them and the PLC will begin running the program.
Step 7: Understanding the Program
As a technician, understanding what logic someone used when designing their program is important to understand how to troubleshoot the program when issues arise.
The PLC reads from the top rung down, and without a command to start the program, which is generally achieved by actuating an input, the timer will not start.
Instead, the program was designed that the binary address B3:0/0 is naturally in the off state. The first rung is read, and because the Examine if Open is addressed to B3:0/0, The red light timer, T4:0, will begin timing. On the second rung, B3:0/0 is switched to its on state and will remain there for the duration of the program so that timer T4:0 is not always active.
Timer T4:0 remains timing for 10 seconds because of the Examine if Closed switch addressed T4:0/TT is closed when the timer is timing. When the timer reaches 10 seconds and is done timing, the T4:0/DN bit is activated, starting timer T4:2, and because the timer 4:0 is done timing, the T4:0/TT bit is no longer active, causing the timer to reset its accumulated value to 0. Timer T4:2 completes this same cycle, starting timer T4:1 upon completion of its timer and resetting, and timer T4:1 re-starting the cycle at timer T4:0.
The final three rungs are simply telling the PLC to turn on the lights when their corresponding timer is timing.