Target behavior
Run the belt conveyor, count the workpieces that pass the photoelectric sensor, and show the count with lamps (stop at 3)
What you will learn
This model uses a belt conveyor and a photoelectric sensor.
First, let's explain belt conveyors and photoelectric sensors.
A belt conveyor is a system that carries workpieces on a belt by rotating a motor.
In this simulation, a magnetic contactor is used to control the conveyor motor.
A magnetic contactor is a device that lets the PLC output unit switch the AC200V power for driving the motor ON and OFF.
Try wiring it yourself using the figure as a reference!
A photoelectric sensor uses light to detect whether a workpiece is present.
It consists of two parts, an emitter and a receiver, and there are two types: light-on and dark-on.
With light-on, the PLC input turns ON when light from the emitter reaches the receiver. With dark-on, the PLC input turns ON when light from the emitter does not reach the receiver.
In this model we want to catch the moment a workpiece passes between the emitter and receiver and blocks the light, so dark-on is used.
The motion to reproduce is driving the belt conveyor, counting the workpieces that pass through the photoelectric sensor, and lighting lamps according to the count.
To reproduce this, you need the INC and = (equal) instructions that handle numbers! Take on numeric operations!
DM0, and light lamps according to that value. Stop the conveyor after the third workpiece has completely fallen off.Based on this approach, try writing the ladder yourself first.
In the simulator, you can create the wiring and ladder and actually run the 3D equipment model.
| Device | Comment |
|---|---|
| Inputs | |
X0 | Conveyor start button |
X1 | Photoelectric sensor |
| Outputs | |
Y0 | Conveyor (contactor) |
Y1 | Workpiece 1 lamp |
Y2 | Workpiece 2 lamp |
Y3 | Workpiece 3 lamp |
| Internal relays | |
MR0 | 3rd workpiece passed |
MR1 | Complete |
| Timers | |
T0 | Waiting to stop |
| Data memory | |
DM0 | Number of workpieces passed |
The row numbers in the figures match the row numbers in the simulator's ladder window.
On the rising edge of X0 (start button), SET Y0 (conveyor). While MR1 (complete) is ON, it does not restart.
On the rising edge of X1 (photoelectric sensor), add 1 to DM0.
INC adds 1 every scan while its input is ON. With LD X1 it would keep counting the whole time a workpiece blocks the sensor, so always make it a pulse with LDP.
The compare instruction = is a contact that closes only while the value of DM0 equals the specified value. Y1 lights for the 1st workpiece, Y2 for the 2nd, and Y3 for the 3rd (only while the conveyor is running).
LDF X1 (the falling edge of the sensor = the moment a workpiece leaves the sensor), if DM0 is 3, SET MR0MR0 is ON, wait 1.5 seconds with T0 (time to carry it to the end of the conveyor)T0 turns ON, stop the conveyor (Y0 RES), SET complete MR1, and RES MR0The sample wiring and ladder data can be downloaded fromGitHuband loaded with "Load wiring" and "Load ladder" in the simulator.
Key points
LDP closes for one scan at the moment a signal turns ON, and LDF at the moment it turns OFF. They let you catch "a workpiece has arrived" and "a workpiece has left" respectively.