Python · Industrial Automation · SCADA/HMI · PLC-Inspired Monitoring · Fault Diagnostics
An independent controls-engineering work sample demonstrating a Python-based automated ride station simulator. It combines a shared controller state machine, local HTTP/JSON API, interactive browser HMI, automatic scan cycles, read-only ladder and instruction visualization, and latched fault diagnostics.
View the complete technical portfolio (PDF)
Scope: Educational simulation only. No physical PLC or ride hardware is connected. The system is not safety-rated; ladder logic is visualized, not executed.
- Controller states: IDLE, READY, DISPATCHED, AWAY, and FAULT.
- Interactive HMI: Digital inputs, operator controls, controller state, alarms, and scan events.
- Automatic scanning: Optional 500 ms controller scan cycle, with manual scanning available.
- PLC-inspired monitoring: Read-only ladder power flow and XIC, XIO, OTE, OTL, OTU, and TON instruction indications.
- Diagnostics: Simulated communications, sensor, drive, and E-stop faults with latched alarms and reset logic.
- Verification: Python unit tests, recorded scenario traces, and a documented acceptance walkthrough.
| Area | Implementation |
|---|---|
| Controller and CLI | Python (ride_sim.py) |
| API and automatic scan worker | Python standard library (api_server.py) |
| Browser HMI | HTML, CSS, JavaScript (dashboard.html) |
| Communications | Local HTTP/JSON |
| Logic visualization | Read-only PLC-inspired ladder and instruction monitor |
| Tests | Python unittest |
| Development | VS Code, Git, GitHub |
Operator interface showing controller state, digital inputs, dispatch controls, and scan activity.
Read-only ladder monitor showing instruction status and animated power flow based on Python controller state.
Simulated equipment fault detection, alarm register, and operator reset behavior.
dashboard.html communicates over localhost HTTP/JSON with api_server.py. The API owns one shared Python RideStation from ride_sim.py. A background worker can scan every 500 ms; the browser refreshes status approximately every 250 ms. Phase 3/4 ladder displays derive their indications from controller state and do not execute ladder logic.
Eight digital inputs; IDLE/READY/DISPATCHED/AWAY/FAULT states; dispatch permissives; diagnostic fault latching; reset, arrival, and scan event history. The dashboard uses API endpoints rather than an independent JavaScript controller.
Start or stop automatic 500 ms scans; manual scan remains available. Live dashboard refresh, scan counter, recent scan log, active faults, and latched alarm register.
Read-only, RSLogix-inspired rung visualization for diagnostic health, dispatch permissives, dispatch enable, fault, and train-away indications. TRUE/FALSE contact status and animated power flow reflect the current Python state; this is not executable PLC logic.
Instruction indications include XIC (examine TRUE), XIO (examine FALSE), OTE (non-retentive coil-style indication), OTL (latch indication), OTU (unlatch indication), and TON (on-delay timer monitor). A separate instruction-status panel accompanies live visual rung flow.
AWAY_DWELL has a 2,000 ms preset: EN is enabled while AWAY, TT indicates timing, and DN becomes true when accumulated time reaches the preset. The monitoring timer uses elapsed time between scans and resets outside AWAY. Its DN bit does not command ride motion.
The eight modeled digital inputs are:
| Input | Meaning |
|---|---|
train_present |
Train detected at station |
gate_closed |
Station gate closed |
restraints_locked |
Restraints locked |
block_clear |
Downstream block available |
drive_ready |
Drive ready |
estop_healthy |
E-stop circuit healthy |
plc_comms_ok |
Simulated PLC communications healthy |
sensor_consistent |
Sensor readings consistent |
All eight must be TRUE to permit dispatch. FALSE values for estop_healthy, plc_comms_ok, sensor_consistent, or drive_ready generate diagnostic faults. Gate, restraint, or block loss inhibits dispatch without automatically latching a diagnostic fault in this model.
With all inputs TRUE, SCAN moves IDLE to READY. DISPATCH moves READY to DISPATCHED. The next scan moves to AWAY and sets train_present=FALSE and block_clear=FALSE.
To simulate return, set block_clear=TRUE while AWAY, then request ARRIVE; train_present becomes TRUE and the state returns to IDLE. The next scan can restore READY. In AUTO mode, IDLE may be visible only briefly.
For example, set plc_comms_ok=FALSE and scan. The controller enters FAULT and latches PLC_COMMUNICATION_LOSS. Restoring communications alone does not clear the latch. RESET requires no active diagnostic faults and all eight permissives TRUE.
Other modeled diagnostic alarms include SENSOR_DISAGREEMENT, DRIVE_NOT_READY, and E_STOP_CIRCUIT_OPEN.
Open the project folder in VS Code and run the following in PowerShell:
py -m venv .venv
.\.venv\Scripts\Activate.ps1
python api_server.pyOpen http://127.0.0.1:8000/dashboard.html in a browser. Use Ctrl+F5 for a hard refresh and Ctrl+C in the terminal to stop the server. The Phase 4 server does not require third-party Python packages.
| Method | Endpoint | Purpose |
|---|---|---|
| GET | /api/status |
Read controller and monitor status |
| POST | /api/scan |
Execute a manual scan |
| POST | /api/dispatch |
Request dispatch |
| POST | /api/reset |
Reset eligible latched faults |
| POST | /api/arrive |
Simulate arrival |
| POST | /api/input |
Set a simulated input |
| POST | /api/restart |
Restart simulation |
| POST | /api/auto/start |
Start automatic scans |
| POST | /api/auto/stop |
Stop automatic scans |
Example input JSON:
{ "name": "plc_comms_ok", "value": false }Controller access is serialized with a Python lock. Commands can trigger scans while AUTO mode is running.
Run the interactive controller:
python ride_sim.pyAvailable commands include status, scan, dispatch, arrive, reset, set <input> <0|1>, and quit.
Run the included original-controller tests and scenarios:
python -m unittest -v test_ride_sim.py
python ride_sim.py --scenariosThe original work sample reported 10 Python unit tests passed and six scenario traces. These are historical original-controller results, not evidence of automated Phase 4 browser validation.
- Restart, scan to READY, dispatch to DISPATCHED, then scan to AWAY.
- Observe
AWAY_DWELLEN, TT, ACC, and DN at approximately 2 seconds. - Set
block_clear=TRUE, request ARRIVE, and scan to READY. - Set
plc_comms_ok=FALSE, scan to FAULT, restore the input, and reset. - Start AUTO, confirm the scan counter increases, then stop AUTO and confirm it stops.
- At the
station>prompt, enterquitbefore starting the API server. - Do not type the PowerShell prompt itself as part of a command.
- If port 8000 is occupied, stop the prior server using Ctrl+C.
- If the dashboard looks outdated, verify the files and use Ctrl+F5.
- Arrival requires AWAY state and
block_clear=TRUE. - Fault reset requires all permissives TRUE and no active diagnostic faults.
| File | Purpose |
|---|---|
ride_sim.py |
Python RideStation state machine and CLI |
api_server.py |
Local API, automatic scan worker, instruction monitor |
dashboard.html |
Browser HMI and ladder/instruction panels |
test_ride_sim.py |
Original Python unit tests |
scenario_results.json |
Recorded scenario evidence |
test_results.txt |
Recorded test results |
screenshots/ |
HMI, ladder, and fault diagnostics screenshots |
Controls Engineering Technical Work Sample — Automated Ride Station Control & Fault Diagnostics.pdf |
Engineering portfolio report |
This independent portfolio exercise was prepared for a controls-engineering application. Prior manufacturing experience included Wonderware InTouch SCADA/HMI development, Allen-Bradley PLC integration, and limited online RSLogix 500 ladder monitoring; it did not include writing or modifying PLC ladder programs.
The simulator omits real hardware, redundant safety systems, deterministic real-time scheduling, certified block control, braking, and motion dynamics. Phase 5 executable ladder logic is intentionally excluded.


