Home > electrical-training-simulator > PLC programming lessons > lesson 6
PLC Programming Lesson 6: Scrap Bottle Grinder
Track damaged bottles with a BSR shift register, divert scrap, count bottles, and control the grinder
Lesson objective: Create a bottle-line scrap handling routine that identifies damaged bottles, tracks each damaged-bottle status as it moves toward the scrap diverter, removes scrap from the main line, grinds damaged bottles, and replaces the collection box after 10 bottles have been processed.
I/O and Application Requirements
Lesson 6: In this lesson we will create a bottle-line scrap handling routine. Scrap must be identified, processed, and removed from the bottle-line application. Damaged bottles are sent to a grinder, and the ground glass is collected and removed by conveyor as needed.
| Address | Name | Device / Function |
|---|---|---|
| I:1/0 | Stop_PB | N.C. push button |
| I:1/1 | Start_PB | N.O. push button |
| I:1/8 | Bottle Defect Detector | Optical sensor |
| I:3/2 | Box Position Detector | Optical sensor |
| I:3/3 | Bottle Detector (Grinder) | Optical sensor |
| O:2/0 | Main Conveyor | Motor control |
| O:2/10 | Run Indicator | Red bulb |
| O:4/1 | Rear Scrap Conveyor | Motor control |
| O:4/2 | Exit Conveyor | Motor control |
| O:4/3 | Round Box Conveyor | Motor control |
| O:4/4 | Main Scrap Diverter | Solenoid |
| O:4/7 | Box Feeder | Solenoid |
| O:4/8 | Grinder Motor | Motor control |
| Address Range | File | Purpose |
|---|---|---|
| N7:0/0-N7:0/5 | N7 Integer File | Damaged-bottle tracking |
Example Requirements:
- The Start/Stop station starts the bottle line.
- The state of a bottle — damaged or not damaged — is shifted into a register as the bottle passes the damage detector. The bottle status moves down the line with the bottle toward the scrap diverter.
- When a damaged bottle reaches the main scrap diverter, it is pushed off the main bottle line to be scrapped.
- The damaged bottle drops onto the rear scrap conveyor leading to the grinder.
- An optical sensor detects an arriving bottle at the grinder and turns the grinder on for 3 seconds.
- The ground glass falls into a box on a round box-removal conveyor. The box is replaced after 10 bottles have passed through the grinder.
- While the scrap-glass box is being replaced, a diverter gate and rear exit conveyor divert bottles until a box is back in position. The bottle count is reset and then increments as additional bottles pass through the grinder.
Step 1: Start/Stop and Conveyor Control
The first task is to control the main bottle line and scrap conveyors using the Start and Stop pushbuttons in the 3D environment.
Rung 0: Create a standard Stop/Start rung with a virtual control relay used to seal in the rung. Use the I:1/0 and I:1/1 addresses from the table with the N.C. and N.O. pushbutton switches (1). Control the O:2/10 Run Indicator (2) from this rung as well.
Rung 1: Use the virtual control relay to turn the main conveyor motor (3) and scrap conveyor motor (4) on and off.
Step 2: Track Damaged Bottles with a BSR Shift Register
Create a BSR (Bit Shift Right) register to track a bottle as it moves down the line. The arrival of a bottle at the bottle detector (1) triggers the shift action. The bottle defect detector (2) provides a high, or “1,” at I:1/8 when a damaged bottle is detected. Use that address as the source-bit location for the shift-right register.
The distance between the defect detector and the O:4/4 main scrap diverter (3) is five bottle positions (4), so the register must be five bits wide to track bottle status as it moves toward the diverter.
Rung 2: Use the I:1/6 bottle detector (1) to trigger the BSR instruction. Configure the instruction to use N7:0/4 through N7:0/0 as the five-bit register. Shift the source bit into the register from the I:1/8 bottle damage detector (2) input.
Rung 3: When a “1” representing a damaged bottle reaches N7:0/0, the normally open contact on this rung energizes the main scrap diverter (3) and pushes the damaged bottle off the line. Use the R6:0/DN bit so this action occurs only after the current bottle information has shifted into N7:0/0. The R6:0/DN bit goes high immediately after a shift occurs in the BSR instruction.
Step 3: Bring a Scrap Box into Position
After a damaged bottle is removed from the main conveyor, it must be processed. Begin by ensuring a box is in position on the round box conveyor (1). Add a rung that brings a new box into position whenever no box is present at the grinder (2). Use the box feeder (3) and round conveyor (1) outputs together with the box position detector (4) input.
Rung 4: Use a normally closed contact with the I:3/2 box position detector (4) input to energize the O:4/7 box feeder (3) and O:4/3 round box conveyor (1) motor outputs. A box is brought to the grinder at startup when the virtual control relay closes.
Steps 4 and 5: Box Replacement, Bottle Counter, and Grinder
Step 4: Modify the box-control rung so a new box is brought in after 10 bottles have been sent through the grinder. Add a counter that counts bottles each time one is ground. Use the counter's Done bit to bypass the I:3/2 box position detector contact on rung 4.
Also prevent bottles from reaching the grinder while the box is being changed. The rear exit conveyor (1) and exit diverter (2) are energized whenever there is no box at the grinder.
Rung 4 (updated): Add two branches: one for the input conditions and one for the additional outputs. Add the box-full flag, using the counter DN Done bit, in a branch around the box-position detector. This provides continuity when the box is full and initiates the box-change sequence.
Rung 5: Use the grinder motor timer Done bit to increment the bottle counter. Set the counter preset to 10. The counter must be reset each time the box is changed. At this stage of the source lesson, use the T4:0/DN address to increment the counter; the grinder timer is added in the next step.
Rung 6: Reset the scrap-bottle counter when the box is changed — when the box is not in position.
Step 5: Add the grinder and grinder-timing rungs so the grinder turns on when a bottle reaches the grinder bottle detector (1) and runs for 3 seconds.
Rung 7: Add a timer for the grinder. Because the grinder bottle detector is only on briefly, use a branch with the timer's TT (Timer Timing) bit to keep the timer running until it times out.
Rung 8: Energize the grinder motor for the timed period determined by the T4:0 timer on rung 7.
Save the file. The application is now ready for testing.
Testing the Scrap Routine
- Open the N7 Integer file so you can watch the shift-register action while the simulation runs. Position the 3D world and N7 table window so you can see both, along with the counter on rung 5.
- Press Start PB and watch the bottles move down the line. When a damaged bottle reaches the I:1/8 damaged bottle detector, verify that a “1” is loaded into N7:0/4. Watch the “1” shift with the bottle toward the diverter. When it reaches N7:0/0, the diverter should energize and push the scrap bottle off the main conveyor.
- Watch as 10 bottles are sent to the grinder. Observe the behavior of the exit conveyor and diverter while the collection box is being changed.
Need access to the required simulator? PLCLogix 500 Simulator | PLCLogix 5000 Simulator