0
0
FreertosProgramBeginner · 2 min read

Ladder Logic Program for Bottle Filling System in PLC

A simple ladder logic program for a bottle filling system uses Start and Stop push buttons to control a Filling motor coil, with a Level Sensor input to stop filling when the bottle is full, e.g., Start PB --| |----+----( ) Filling Motor and Level Sensor --|/|----|/|--( ) Stop Filling.
📋

Examples

InputStart button pressed, bottle empty
OutputFilling motor turns ON until level sensor detects full bottle, then motor turns OFF
InputStop button pressed during filling
OutputFilling motor immediately turns OFF
InputBottle already full, Start button pressed
OutputFilling motor does NOT turn ON
🧠

How to Think About It

To design a ladder logic program for a bottle filling system, think of controlling a motor that fills the bottle. Use a start button to begin filling and a stop button to stop it anytime. A level sensor input detects when the bottle is full and stops the motor automatically. The motor should only run if the start button is pressed and the bottle is not full.
📐

Algorithm

1
Wait for the Start button to be pressed.
2
Check if the bottle is not full using the Level Sensor.
3
If not full and Start pressed, turn ON the Filling motor.
4
Keep the motor ON until the Level Sensor detects the bottle is full.
5
Turn OFF the motor when the bottle is full or Stop button is pressed.
💻

Code

plc_programming
(* Ladder Logic for Bottle Filling System *)
(* Inputs: StartPB, StopPB, LevelSensor *)
(* Output: FillingMotor *)

(* Start/Stop latch *)
|---[ StartPB ]---+---[ ]---( ) FillingMotor
|                 |
|                 +---[ LevelSensor ]---|

(* Explanation: *)
(* StartPB normally open push button *)
(* StopPB normally closed push button *)
(* LevelSensor normally closed when bottle not full, opens when full *)

(* Ladder logic description: *)
(* FillingMotor coil energizes when StartPB pressed, StopPB not pressed, and LevelSensor not full *)
Output
When StartPB is pressed and LevelSensor indicates bottle not full, FillingMotor turns ON. FillingMotor turns OFF when StopPB is pressed or LevelSensor detects full bottle.
🔍

Dry Run

Let's trace the bottle filling system when Start button is pressed and bottle is empty.

1

Start button pressed

StartPB = ON, StopPB = ON (not pressed), LevelSensor = ON (bottle empty)

2

Check conditions

StartPB ON, StopPB ON, LevelSensor ON means FillingMotor coil energizes

3

Filling motor runs

FillingMotor = ON, bottle starts filling

4

Bottle becomes full

LevelSensor changes to OFF (bottle full)

5

Motor stops

FillingMotor coil de-energizes because LevelSensor is OFF

StepStartPBStopPBLevelSensorFillingMotor
1ONONONOFF
2ONONONON
3ONONONON
4ONONOFFON
5ONONOFFOFF
💡

Why This Works

Step 1: Start and Stop buttons control motor

The StartPB is a normally open button that when pressed allows current to flow, and StopPB is normally closed to allow current unless pressed to stop.

Step 2: Level sensor stops filling

The LevelSensor input is normally closed when the bottle is not full, opening to stop the motor when full.

Step 3: Motor energizes only when conditions met

The motor coil FillingMotor energizes only if StartPB is pressed, StopPB is not pressed, and LevelSensor shows bottle not full.

🔄

Alternative Approaches

Timer-based filling control
plc_programming
(* Use a timer to fill for a fixed time instead of level sensor *)
|---[ StartPB ]---+---[ StopPB ]---( ) FillingMotor
|                 |
|                 +---[ TON Timer ]---|

(* Timer runs when motor ON, stops motor after preset time *)
This method fills for a fixed time, simpler but less precise than level sensor.
Counter-based bottle count control
plc_programming
(* Use a counter to count bottles filled and stop after target count *)
|---[ StartPB ]---+---[ StopPB ]---( ) FillingMotor
|                 |
|                 +---[ Counter ]---|

(* Stops motor after counting set number of bottles *)
Good for batch filling but does not detect bottle fullness.

Complexity: O(1) time, O(1) space

Time Complexity

The ladder logic runs in constant time per scan cycle, checking inputs and setting outputs without loops.

Space Complexity

Uses fixed memory for inputs, outputs, and internal bits; no dynamic memory allocation.

Which Approach is Fastest?

All approaches run in constant time; timer or counter methods add complexity but do not affect scan speed significantly.

ApproachTimeSpaceBest For
Level Sensor ControlO(1)O(1)Precise filling control
Timer ControlO(1)O(1)Simple fixed-time filling
Counter ControlO(1)O(1)Batch filling count
💡
Use normally closed contacts for stop and level sensor inputs to ensure safe fail-stop behavior.
⚠️
Forgetting to include the level sensor input to stop the filling motor causes overflow.