A Python-based software-in-the-loop simulation of an industrial conveyor controller. The project models conveyor operating states, safety interlocks, fault handling and emergency-stop behaviour without requiring physical hardware.
The controller is verified using automated tests, a controlled operating sequence, CSV event logging and a graphical state timeline.
- Model an industrial conveyor as a finite-state controller.
- Implement normal start and stop behaviour.
- Simulate conveyor faults and emergency-stop events.
- Prevent unsafe restarts while a fault or emergency stop is active.
- Require a valid reset before operation can resume.
- Verify controller behaviour using automated tests.
- Record and visualise the complete simulation sequence.
| State | Description | Motor |
|---|---|---|
IDLE |
System is ready but not operating | Off |
RUNNING |
Conveyor is operating normally | On |
STOPPED |
Conveyor has been stopped normally | Off |
FAULT |
A simulated equipment fault is active | Off |
E_STOP |
The emergency stop is active | Off |
The controller applies the following safety rules:
- A fault immediately stops the motor.
- An emergency stop immediately stops the motor.
- Start commands are rejected during
FAULTandE_STOP. - A reset is accepted only while a fault or emergency stop is active.
- After a successful reset, the controller returns to
IDLE. - Every accepted and rejected command is recorded in an event log.
The software runs a controlled sequence containing:
- System initialisation.
- Normal conveyor start.
- Fault activation.
- Rejected restart during the fault.
- Fault reset and successful restart.
- Emergency-stop activation.
- Rejected restart during the emergency stop.
- Emergency-stop reset and successful restart.
- Normal conveyor stop.
The upper graph shows the controller state throughout the simulation. Circles represent accepted commands, while cross markers identify rejected restart attempts during unsafe conditions.
The lower graph confirms that the motor is on only while the controller is in the RUNNING state. Both fault and emergency-stop events immediately switch the motor off.
The full sequence is also exported to:
results/simulation_log.csv
python-conveyor-controller/
├── conveyor/
│ ├── __init__.py
│ └── controller.py
├── results/
│ ├── conveyor_simulation_timeline.png
│ └── simulation_log.csv
├── tests/
│ └── test_controller.py
├── plot_results.py
├── simulation.py
├── requirements.txt
├── .gitignore
└── README.md
The project contains ten automated tests covering normal operation, fault handling, emergency-stop behaviour, resets and rejected unsafe commands.
Run the tests from the project folder:
python -m pytest -vCurrent result:
10 passed
Python 3.13 or a compatible recent Python version is required.
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -r requirements.txtRun the simulation:
python simulation.pyGenerate the results graph:
python plot_results.pyRun the automated tests:
python -m pytest -v- Python programming and object-oriented design
- Finite-state control logic
- Industrial safety interlocks
- Software-in-the-loop simulation
- Fault and emergency-stop handling
- Automated verification using pytest
- CSV event logging
- Engineering data visualisation
- Technical documentation
This is a software-only model and does not currently communicate with physical motors, sensors or a PLC. Future work could include sensor timing, object tracking, additional fault conditions, a graphical control panel and hardware or PLC integration.
A detailed technical report will be added in a future repository update.
Zeyad Eldokmak
BEng (Hons) Electronic Engineering
GitHub: zeyadeldokmak
