Structured Text PLC Programming for Automatic Gate Control

In this post, we will write a logic for controlling the gate of a car passing automatically using structured text language.

Automatic Gate Control

Let us understand the case scenario first. There is an automatic gate which is controlled by a motor. The gate is equipped with open and close sensors for sensing the limit. There is a stop lamp indication to avoid collision of cars and a fault lamp indication in case of any malfunction of the system.

There are two gate sensors, one that gives the command to open the gate and one that gives the command to stop the gate. When the open gate command is sensed, the gate opens till the open limit switch is sensed. Then, the system waits for the second car gate sensor to sense.

Once sensed, the gate closes till the close limit switch is sensed. Till the second gate limit is not sensed, a stop lamp will be indicated to avoid any incoming car from coming again (because the existing car has not crossed the gate yet). If any of the limit switches fail to operate in a given time, the fault lamp indicator will turn on.

Also, once the car has entered but not exited within a given time frame, then too the fault lamp will turn on. The operator needs to attend and reset the system to start the system once again. Remember that we have also installed mechanical hard lock limit switches for breaking the electrical supply of the motor in case the limit switch of PLC fails.

Following are the PLC IO’s in this case:

  • Digital inputs – Motor run feedback, open limit switch, close limit switch, gate-1 sensor, gate-2 sensor, and alarm reset push button.
  • Digital outputs – Motor open, motor close, stop lamp, fault lamp.

Structured Text PLC Programming

Refer to the below image for the PLC program. In the first part, we will open the gate when the gate-1 sensor is sensed and there is no fault condition present in the system. In this case, the stop lamp too will turn on.

Only the gate open output will turn off when the open limit switch is sensed; the stop lamp will remain on (see we have not unlatched it.)

Structured Text PLC Programming for Automatic Gate Control

Next, we will close the gate when the gate-2 sensor is sensed and there is no fault condition present in the system. When the gate close limit switch is sensed, then both the outputs of the gate close, and the stop lamp will turn off.

Now, we will create four timers for checking fault conditions. In the first timer, we check if the open limit switch has failed for 10 seconds by seeing whether the open limit switch has not been received even though the gate is open.

In the second timer, we check if the close limit switch has failed for 10 seconds by seeing whether the close limit switch has not been received even though the gate is closed.

In the third timer, we check if the gate motor run feedback has failed for 5 seconds by seeing whether the feedback has not been received even though the gate motor is on.

In the fourth timer, we check if there is any issue in the car passing for 20 seconds by seeing whether the gate-2 sensor has not been received even though the stop lamp is on.

If any of the above timers go on, then a fault will be generated and it will turn off all the outputs and turn on only the fault lamp.

The operator has to press fault reset PB to reset the faults and start the system again.

In this way, we saw how to write a PLC program for automatic gate control using structured text.

Read Next:

Don't Miss Our Updates
Be the first to get exclusive content straight to your email.
We promise not to spam you. You can unsubscribe at any time.
Invalid email address

Leave a Comment

Share via
Follow us and never miss an update!