Building a Gas Turbine Hardware-in-the-Loop Test Bench with an STM32 and a BeagleBone
I have spent six years around turbine control systems, including GE Mark VIe & Bently Nevada(Asset monitoring system) projects in Italy and Singapore. The most expensive lesson in that work never changes: a control program is only as good as the testing you could do before the turbine was spinning. You cannot casually trip a real machine to see if your logic works.
Hardware-in-the-loop (HIL) testing solves this. You replace the machine with a simulation that behaves like it, wire the real controller to that simulation, and then break things on purpose. I wanted to understand every layer of that idea, so I built a small one from scratch. This post is the overview. Later posts go deep on each part.
The idea in one picture
Two boards, three wires, one protocol. The BeagleBone Black plays the gas turbine. The STM32 plays the control system. They talk Modbus RTU over a serial link, the same way a real controller would talk to field devices.
Why a plant model needs real physics
A lookup table that says “fuel up, speed up” is not enough. Controllers behave badly when the plant has the wrong dynamics, so the model has to push back the way a real machine does. I used a simplified Brayton cycle with five dynamic states:
| Piece | What it does |
|---|---|
| Rotor | Speed changes from the balance of gas power, friction and load, with a starter assisting at low speed |
| Compressor | Pressure ratio and discharge temperature depend on speed |
| Combustor | Turbine inlet temperature follows fuel flow and flame state |
| Turbine | Exhaust temperature follows from the expansion across the turbine |
| Actuators and sensors | Valve (0.2 s), fuel flow (0.3 s) and thermocouple (3 s) lags |
Those lags matter more than they look. A 3-second thermocouple means the controller sees a temperature spike seconds after it happened. Any limiter that ignores that will overshoot, and a HIL bench shows you exactly how far.
The rated point is 22.72 MW at 3500 RPM. The model steps every 10 ms using plain Euler integration, which is accurate enough here because the fastest lag is 0.2 s.
The controller: three jobs
The STM32 runs the logic you would expect in a turbine control system, kept deliberately small and readable.
1. Min-select fuel control
Several limiters each ask for a fuel command, and the lowest one wins. The governor wants speed, the acceleration schedule protects against surge, and the temperature limiter protects the hot section. Whichever is most restrictive controls the valve.
/* illustrative pseudocode, not the exact source */
fuel_cmd = min( governor_demand,
accel_limit,
temperature_limit );
2. Protection that latches
A trip is not a suggestion. Once overspeed or over-temperature trips, it stays tripped until an operator resets it, and the controller records which condition came first. That “first-out” record is the first thing an investigator reads after a real event.
3. Voting on bad sensors
Speed uses a 2-out-of-3 vote, so one failed probe cannot cause a trip or hide a real overspeed. Exhaust temperature takes the median of four thermocouples, which throws out a single wild reading without a special case.
The wire is part of the test
I chose Modbus RTU because it is what real equipment speaks, and because bugs in framing and timing show up on a real wire in ways they never do in a function call. The controller polls every 50 ms. A full request and response is roughly 85 bytes on the wire, which is about 8 ms at 115200 baud, or around 16 percent of the cycle. That leaves room, but not unlimited room.
Both sides run a watchdog. If the plant stops hearing from the controller, it assumes the controller has died. If the controller stops hearing from the plant, it trips. Pull the cable and both ends react, which is exactly what you want to be able to test.
Scenarios, not manual poking
Tests are small JSON files that describe a sequence: start, ramp to rated, apply load, inject a fault at a given time. A runner replays them against the bench and records the result. That means every change to the control logic can be checked against the same set of events, the habit that separates a bench from a demo.
What I would do differently
- Settle the network early. Half of my bring-up time went to SSH drops and a misrouted default gateway on the BeagleBone. That is its own post.
- Write down the register map first. Everything else depends on it, and changing it later breaks both boards at once.
- Test the failure paths before the happy path. Starting up is easy. Watching a trip latch correctly is the point.
Next in the series
The next posts go one layer down at a time: the plant physics, the min-select governor, the protection and voting logic, Modbus from scratch, and the real-time details on both boards. The full code is on GitHub: github.com/jdram82/gt-hil.
