A Plant Built Like SoftwareDesigning a micro-service power management system for a waste-to-energy microgrid: a tree of small, reusable services behind simple, contract-defined interfaces
- 5
- subsystem services under the PMS
- 12
- device services talking to field equipment
- 9 signals
- in the PMS to steam plant contract
- 2 fieldbuses
- Profinet and Modbus
- 6-step scan
- fixed call order every cycle: power management first, then the five subsystems
- Micro-service tree
- Encapsulation and abstraction
- Reusable device services
- State-table mode logic
- State transition logic
- Interface contracts
- Synchronous scan-cycle execution
- Siemens PLC programming
- Sequence of operation
- SCADA / HMI
- Inverter firmware configuration
- Event-log debugging
- Profinet / Modbus fieldbus
- Cyclic I/O updates
- Per-service data blocks
- Parallel team development
- Independent commissioning
- Vendor and OEM coordination
- Cross-discipline integration
Abstract
A pilot sewage-to-energy plant needed a power management system to coordinate a diesel generator, a 307 kW steam turbine-generator, a utility connection, a grid-forming AC microgrid and a load bank, all paralleled on a common 780 VDC bus. The equipment came from several vendors and spoke two industrial protocols, and a separate team was writing the steam plant software at the same time. The PMS was built as a tree of micro-services: one service per subsystem, child services for each physical device, and a plant-wide safety service and a message logging service alongside. Each service exposed only enables, a few setpoints, statuses and alarms, and the boundary with the steam plant was fixed early as a nine-signal contract. Because the software boundaries matched the mechanical and electrical ones, each branch could be written, tested and commissioned on its own. The finished plant started itself automatically, handed off between sources seamlessly, and rarely needed an operator to look at the PMS HMI screens. The study also compares this design with the asynchronous, message-broker-based micro-services common in IT, and explains why a real-time controller needed the opposite: synchronous services executed in a fixed order every scan, which in practice made the system run like a well-organized monolith.
Key ideas see 2.4
- Hardware built on software principles: the mechanical and electrical systems were designed around abstraction and reusability, just like the code. Every piece of equipment could be isolated mechanically and electrically behind a standard interface, and the service tree mirrored that isolation one-to-one.
- Small interfaces hide the complexity: each service exposed only what its parent needed, so protocols, error checking and control details stayed inside it, and one service could be reused for many devices.
- A contract between teams: the PMS to steam plant interface was agreed early and changed only by mutual agreement, so two software teams could build in parallel and test against one shared script.
- Organized as micro-services, executed like a monolith: unlike IT micro-services, the services ran synchronously in a fixed order every scan, with no message broker, because predictable execution order was what made the system debuggable (see 6).
1Background and problem statement
The plant dries wet human waste into fuel and burns it in a fluidized bed boiler. Its steam feeds both the fuel dryer and a steam turbine-generator, and the turbine, a diesel generator and the local utility all exchange power through a common DC bus. The electrical design is covered in the companion steam turbine case study. This study covers the software that ran it: the power management system that decided which sources ran, in what order, and how much each contributed.
The PMS was one of four control systems in the plant. A dedicated PLC ran the steam plant. The turbine and diesel manufacturers each supplied controls for their own units. The Vacon inverters/converters on the DC bus each ran a firmware application that gave it a role, with no central bus controller. The PMS sat between all of them, monitoring the steam plant to decide when to start and ramp the turbine, choosing between grid-connected and islanded operation, and dispatching the diesel or the utility connection to import or export power.
Constraints
- Many vendors, two protocols. The PMS had to monitor and command Vacon inverters/converters, remote I/O, a diesel engine controller, a turbine OEM controller and power quality meters, over a mix of Profinet and Modbus.
- Fully automatic operation. The plant had to cold-start from either the diesel generator or the utility, bring the turbine online as steam became available, hand load between sources, and island instantly on a grid disturbance, all without operator intervention.
- Two software teams working at once. The steam plant PLC and the PMS PLC were programmed by separate teams on the same schedule, and neither could wait for the other to finish. Each team had to be able to write, test, debug and commission its software on the real hardware independently. The steam plant team needed to bring up the boiler, dryer and condenser without the PMS PLC, and the PMS team needed to bring up most of the electrical system without the steam plant PLC. The steam turbine was the only part of the PMS that depended on the steam plant, because it needed steam to run.
- Equipment arrived and was commissioned in stages. The software had to support bringing up one source at a time, rather than requiring the whole plant to be complete before anything could be tested.
- It had to stay maintainable. A pilot plant changes constantly, so the code had to be easy to read, diagnose and extend long after commissioning.
2System design
2.1 Where the PMS sits
The PMS PLC was the hub of the plant's electrical controls (Figure 1). Upward, it exchanged a small set of handshake signals and one setpoint with the steam plant PLC over Profinet. Downward, it reached every electrical device in the plant over fieldbus: Profinet to the Vacon inverters/converters and to remote I/O bus couplers for the turbine exhaust condenser and the load bank, and Modbus to the diesel generator controller, the steam turbine controller and the power quality meters on the plant and utility connections.
2.2 The micro-service tree
The PMS software was a set of micro-services arranged in a tree under the plant's main controller (Figure 2). The power management service owned a child service for each electrical subsystem: the diesel genset, the steam genset, the plant microgrid, the local utility connection and the load bank. Each subsystem service in turn owned the device services for its physical equipment, such as generators, active front ends (AFEs), meters and bus couplers. Only the device services spoke Profinet or Modbus to field equipment.
Every service presented a simple, well-defined interface to its parent and hid its internal control details. The power management service itself exposed only enables, a small set of setpoints, statuses and alarms to the main steam plant controller, and nothing below it was exposed unnecessarily.
2.3 Control layers and data blocks
The PMS software was organized into three layers, each with a different job and a different level of authority:
- Safety layer. Protective functions that act independently of the control logic and take priority over it, whatever state the control logic is in.
- Control layer. The service tree itself: business logic, sequencing, mode selection and the device services that command the hardware.
- Message logging layer. Records event messages sent by the services, without affecting the timing or behavior of the control or safety layers.
Every micro-service had its own data block, and that block was the only place where information was written to the service or read from it. Access followed the tree strictly: only a service's parent could write to or read from its data block. Siblings never reached into each other, and a device service never reached up into its subsystem. Two services were the only exceptions: the plant-wide safety service and the message logging service. The safety service could read from and write to any service's data block, so it could, for example, trip a service directly. Any micro-service could send a text message directly to the message logging service, but the message logging service could never write to any micro-service. This rule is what kept the structure a true tree rather than a web of dependencies (see section 3).
2.4 Designing the hardware so the software could be modular
The micro-service architecture worked because it started in the mechanical and electrical design, not in the code. The steam turbine, diesel genset, microgrid inverters, utility connection and load bank were laid out so that each could be mechanically and electrically isolated, and therefore operated on its own. Each of those physically independent units became a branch of the tree.
Software principles applied to hardware. The mechanical and electrical systems followed the same basic principles as good software: abstraction and reusability.
- Abstraction. Every source and load connected to the plant through one standard interface, the common DC bus, by way of its own power electronics. Behind that interface, each unit's internal details, such as a generator's speed, frequency or voltage, were hidden from the rest of the plant. Like a well-designed software module, each unit could be started, stopped, isolated or replaced without the others needing to know.
- Reusability. The same Vacon inverter/converter platform was used again and again across the plant, for the diesel genset, the steam genset, the plant microgrid, the utility connection and the load bank. Each unit took on its role through the firmware application loaded into it, much as one class is instantiated many times with different parameters. In software, that hardware reuse was matched by three reusable software components, one for each type of application: a genset component, used for both the diesel genset and the steam genset; a microgrid/utility component, used for the grid-forming plant microgrid and the grid-synchronizing utility connection; and a load bank component. Each component was written once and instantiated wherever that type of unit appeared.
Because hardware and software were built on the same principles, each software boundary landed on a real hardware boundary.
Abstraction that matched reality. Because a micro-service boundary always matched a real equipment boundary, an interface never had to leak details from a neighbor. A subsystem service could be enabled, given setpoints and asked for its status without its parent knowing which protocol, firmware application or error handling sat beneath it.
Reuse through encapsulation. Three reusable software components covered all five Vacon units on the DC bus: one for genset applications, one for grid-forming and grid-synchronizing applications, and one for the load bank. Each instance exposed only the values needed to monitor and control its unit and took care of the Profinet communication and error checking internally. Write and debug a component once, and every unit of that type benefited.
Independent build, test and commissioning. Each micro-service could be written, tested and debugged on its own. Because the mechanical, electrical and software isolation lined up, equipment could also be commissioned independently to the greatest extent possible: the diesel genset and its Vacon AFE were fully commissioned on the DC bus before the steam turbine was brought online.
Self-documenting code. A well-defined tree with well-defined interfaces made the programming and business logic largely self-documenting. Anyone could find where a behavior lived by walking down the tree, which made the system far easier to operate, troubleshoot and maintain.
3Real-time micro-services versus IT micro-services
"Micro-services" usually means something specific in software engineering, and most of its defaults do not fit a real-time controller. Comparing the two explains the design choices in this plant.
3.1 How micro-services are typically built in IT
In a typical web application, such as an online store, each micro-service is a small, independently deployed program that owns one business capability: users, the product catalog, orders, payments, inventory, notifications. Each runs in its own process, usually several copies in containers managed by an orchestrator such as Kubernetes, and each owns a private database that no other service may touch. A service sits idle until work arrives. Some work arrives as a synchronous request through an API gateway (REST or gRPC), when an immediate answer is needed. Most of it arrives asynchronously, as events delivered by a message broker. Each service has its own build pipeline and release schedule, and the system is designed on the assumption that the network and other services can fail at any time.
3.2 The role of the message broker
The message broker (Kafka, RabbitMQ or a cloud queue, for example) is the middleman at the center of an asynchronous micro-service system. When something happens, a service publishes an event to the broker, such as "order 1042 was placed", and immediately moves on. Any service that cares about that kind of event subscribes to it, and the broker delivers each subscriber its own copy. In the store, the Order service publishes OrderPlaced; the Payment service charges the card and publishes PaymentSucceeded; the Inventory service reserves stock; the Notification service sends a confirmation email. The Order service never calls any of them directly.
That indirection delivers most of what makes IT micro-services attractive:
- Decoupling. Publishers do not know who is listening. A new subscriber, such as a fraud check, can be added without changing the publisher.
- Buffering and fault tolerance. The broker stores messages until they are processed. If the Payment service is down or being redeployed, orders are not lost; they wait in the queue until it recovers.
- Fast responses. The publisher can answer the user as soon as its own work is saved, while downstream work happens in the background.
- Load smoothing. A burst of traffic piles up in the queue, and consumers work through it at their own pace, with more copies added if needed.
- Fan-out. One event reaches any number of subscribers without the publisher sending it more than once.
The price is control over timing and order. Once a message is handed to the broker, the publisher no longer decides when it is processed, which subscriber reacts first, or whether it is delivered twice after a retry. The system is only eventually consistent: for a moment, an order can exist before its payment does. Business software accepts that trade in exchange for scalability and resilience.
3.3 Why a broker does not belong in a real-time controller
A power management system controlling generators, inverters and a DC bus needs exactly the guarantees a broker gives up. The PMS therefore had no broker, and for good reasons:
IT micro-services
- Asynchronous and event-driven
- No guaranteed order between services
- A graph of dependencies
- Eventually consistent data
- Separate processes and machines, linked by a network and a broker
- Private database per service
PMS micro-services
- Synchronous, on a fixed scan cycle
- Guaranteed execution order, set in
main() - An inverted tree
- Every value current within each cycle
- One controller, all services called from one
main() - Data block per service, accessible only to its parent
- Timing must be bounded. A control decision has to be made within a known scan time. A queue adds latency that depends on load and backlog, which is acceptable for an email but not for a bus-voltage setpoint or a generator trip.
- Order must be guaranteed. Control logic depends on reading inputs, deciding and writing outputs in a defined sequence. A broker deliberately makes the order of reactions undefined.
- The latest value matters, not the history. A controller needs the current state of the plant. A backlog of queued messages means acting on stale data, and replaying buffered commands to equipment after an outage could be unsafe.
- Duplicate delivery is a hazard. Brokers commonly guarantee "at least once" delivery. A repeated message is harmless when deduplicated in a database, but a repeated start, stop or trip command sent to physical equipment is not.
- Safety cannot wait in line. A trip has to act within the same cycle. In the PMS, the safety service wrote directly into the data block of the service it needed to stop.
- The benefits were not needed. All services ran in one controller, so there was no network between them to decouple across and no traffic spikes to smooth. Passing data through parent and child data blocks was simpler, faster and fully predictable.
Buffering and asynchronous delivery still have a place at the edge of an industrial system, for example when sending historical data off site, where waiting does not affect control. They do not belong inside the business logic of a controller.
3.4 An inverted tree, not a graph
The two approaches also produce different shapes (Figure 3). In the IT example, services form a graph: the Catalog service has two callers, Payment and Inventory both publish and subscribe, and information flows in loops through the broker. In the PMS, services formed an inverted tree. Each service had exactly one parent, commands flowed down and status flowed up, and the data-block access rule (section 2.3) prevented any shortcuts across branches. A tree has no circular dependencies, so the execution order of every service could be set and known, and any behavior could be traced by following a single path from the top.
main() calls them in a fixed order every scan. Numbers show the order in which main() calls each service.3.5 Synchronous, cyclic execution
The PMS ran on a PLC, a real-time platform built around a repeating scan cycle. Within each cycle, the controller reads its inputs, executes the program and writes its outputs, then starts again. The micro-services were implemented as program blocks called from the controller's main routine, main(), in the order they needed to execute. Each service therefore ran once per scan, in a known position in the sequence, with no scheduler deciding at runtime which service went next. Every scan followed the same order:
- Power managementEvaluates the state table, decides the operating mode and runs any transition logic, then sets the enables and setpoints for the subsystems below it.
- Utility connectionGrid-synchronizing inverter, utility meter and utility communications interface.
- Diesel gensetDiesel engine controller and its active front end.
- Steam gensetTurbine controller, its active front end and the exhaust condenser.
- Plant microgridGrid-forming inverter and plant meter.
- Load bankBrake chopper and load bank tank.
Running the power management service first meant that every subsystem acted on decisions made in the same scan, from the same snapshot of plant data.
The interfaces to the hardware were refreshed cyclically as well. When those values are read and written relative to the services is just as important as the order of the services themselves, and is covered in section 3.6.
This is synchronous control of hardware: logic and I/O updates happen in a fixed, predictable order. Asynchronous control, where services and hardware updates run on independent timing or are triggered by events, can respond faster to individual events and scales across machines, but makes behavior harder to predict and to reproduce. For a plant where a wrong sequence could trip a generator, determinism and debuggability came first.
3.6 Reading from and writing to hardware
Applying micro-services to a real-time controller raises a question that IT systems rarely face: when is information read from the hardware, and when are commands sent back to it? How often is the I/O updated? When is a status read, and when does a setpoint or command actually reach the equipment? These questions are critical. If a value can change partway through a scan, two services can act on two different versions of the plant in the same cycle, and the result is the kind of intermittent, hard-to-reproduce behavior that undermines a micro-service design.
The exact mechanics of how and when the I/O was exchanged with the hardware, such as fieldbus update rates and how they were configured, are outside the scope of this case study. The principle behind them, however, shaped how the services were written. Each scan followed a read, hold, compute, write pattern (Figure 4):
- Read inputsAt the start of the scan, statuses from the hardware, along with the existing setpoints and commands, are read into the controller.
- Hold them constantThose values are frozen for the rest of the scan. Every service sees the same snapshot of the plant, regardless of what the hardware does in the meantime.
- Run the servicesThe micro-services execute in their fixed order. The only values they change are the new setpoints and commands they intend to send to the hardware, which are collected into one consistent set of outputs.
- Write outputsOnly at the very end of the scan is that complete set of outputs sent to the hardware, all at once. The cycle then repeats.
This pattern complemented the fixed call order: the call order fixed which service ran when, and the read, hold, compute, write pattern fixed which data each service saw. Every service worked from one consistent view of the plant, and the hardware never received a half-finished set of commands. Anyone applying micro-services to a real-time operating system needs to know exactly when their platform reads inputs and writes outputs, and design the services around it.
4Methods
A standard shape for every service interface
Every service, from the head of the PMS down to a single meter, presented the same four kinds of value to its parent. Keeping the vocabulary this small meant a parent never needed to understand a child's internals.
| Interface element | Purpose | Example in this plant |
|---|---|---|
| Enables | Parent tells the service to run or stop | Enabling a Vacon inverter/converter on the DC bus |
| Setpoints | A small number of values the parent may adjust | DC bus voltage setpoints, such as 780 V for the load bank and 760 V for the utility inverter |
| Statuses | What the service reports upward | TurbineReadyToStart, TurbineReadyToStop |
| Alarms | Warnings and faults, escalated up the tree | Inverter fault codes; TurbineAlarm_EmergencyShutdown |
Three reusable components, five instances
The Vacon inverter/converter units on the DC bus shared hardware and communications but played very different roles, set by the firmware application loaded into each. Rather than writing a separate service for each unit, the software grouped them by application into three reusable components: a genset component, a microgrid/utility component for grid-forming and grid-synchronizing applications, and a load bank component. Each component handled the common work, Profinet communication and error checking, while the subsystem above each instance gave it its role through setpoints:
| Reusable component | Service | Device | Vacon application | Role on the DC bus |
|---|---|---|---|---|
| Genset | DGN.AFE | Diesel DC μgrid | AFE app | Takes energy from the diesel generator |
| Genset | STG.AFE | Turbine DC μgrid | Generator app | Takes energy from the steam turbine-generator |
| Microgrid / utility | UGD.UDG | Plant DC μgrid | Grid-forming app | Forms the plant's AC microgrid |
| Microgrid / utility | CST.UGD | Utility DC μgrid | Grid-sync app | Imports from or exports to the utility |
| Load bank | LDB.BRU | Brake chopper | Load bank app | Caps bus voltage by diverting surplus to resistors |
Mode logic in one state table
The power management state table lived in the head service of the PMS. It defined the conditions that triggered each operating mode, chiefly whether the grid was available and whether steam was available, and for each mode which assets were called to run. Anyone reading it could see at a glance which mode the system was in, what had triggered it, and which assets should be running. The subsystem services then carried out those calls, so the mode logic never had to reach down into device details.
| Grid | Steam | Diesel | Steam turbine | Plant microgrid | Utility |
|---|---|---|---|---|---|
| Unavailable | No | Run | Off | Run | Open |
| Unavailable | Yes | Ramp down, stop | Run | Run | Open |
| Available | No | Off | Off | Run | Import |
| Available | Yes | Off | Run | Run | Import or export |
Simplified for illustration from the PMS's described behavior: with no grid, the PMS black-started the plant on the diesel; with a grid, it connected automatically and started the steam plant; in either case the turbine came online and took load as steam became available.
Transitions between modes
Determining which mode the plant should be in, and setting it, was the easy part. In real-time control of hardware, the transition between states is usually the most difficult piece, because equipment has to be loaded, unloaded, started and stopped in the right order without disturbing the plant. Moving from the diesel genset to the utility, for example, is far more involved than flipping a mode flag. All of this transition logic lived in the power management service, next to the state table, so the subsystem services only had to follow the enables and setpoints it gave them.
The hand-off from diesel to steam while islanded shows how a transition unfolded:
- Starting stateThe diesel genset, steam genset, plant microgrid and load bank are operating; the utility is not connected. The diesel carries the plant.
- Steam takes the loadAs the steam genset comes online, it picks up the bulk of the plant's power and eventually all of it.
- Diesel unloaded but runningThe diesel genset is fully unloaded and idling, still running but contributing nothing to the microgrid.
- Confirm, then stopOnly after the steam genset has been online for a set length of time, delivering steady power, is the diesel turned off.
- New modeWith the diesel stopped, the plant enters a new operating mode, carried by steam alone.
An interface contract between two software teams
The interface between the steam plant PLC and the PMS PLC was deliberately kept simple, clean and well defined, and served as a contract between the two software teams. The steam plant read five status flags from the PMS and wrote three edge-triggered commands and one analog setpoint. Establishing the contract early let both teams program and configure their software in parallel. As long as it held, each team proceeded independently; when it did need to change, neither team moved forward until both had agreed on the revised interface. Every mode in the sequence of operation listed the expected value of each signal, which gave both teams one shared test script.
| Signal | Direction | Meaning |
|---|---|---|
| TurbineReadyToStart | PMS → plant | Turbine pre-heated and waiting for a start request |
| TurbineReadyForElectricalPowerControl | PMS → plant | Spinning, on the bus, following the setpoint |
| TurbineReadyToStop | PMS → plant | Unloaded, disconnected and idling |
| TurbineWarning_ControlledShutdown | PMS → plant | PMS takes the setpoint and ramps 100 % to 0 % over 2 minutes |
| TurbineAlarm_EmergencyShutdown | PMS → plant | Throttle slams shut. Expect a steam disturbance, and loss of 480 VAC if no other source is online |
| TurbineStart | plant → PMS | Rising edge opens the throttle |
| TurbinePrepareToStop | plant → PMS | Rising edge unloads, disconnects and idles the turbine |
| TurbineStop | plant → PMS | Rising edge closes the throttle |
| TurbineElectricalPowerSetpoint_pct | plant → PMS | Generator load, 0 to 100 % of 324 kW |
Data on the network, not on wires
Most of the data that would traditionally travel over hardwired control I/O was passed over Profinet and Modbus instead. That kept field wiring to a minimum and, just as importantly, made the system changeable in software. To expose a new value from a Vacon inverter/converter, no wire had to be run to a PLC input: the value was enabled in the inverter/converter's configuration to be passed over Profinet, and the PLC was configured to receive and present it. New data reached the relevant device service without touching hardware or disturbing the rest of the tree.
Bringing the system up one branch at a time
The tree also set the order of work. Because each branch could stand alone, development and commissioning proceeded from the leaves up:
- Agree the contractFix the PMS to steam plant signals and the expected value of each in every mode, so both teams can start.
- Build and test each service aloneWrite and debug device services against their own equipment, then the subsystem services above them.
- Commission the first sourceBring the diesel genset and its Vacon AFE fully online on the DC bus before the turbine exists on the bus.
- Add branches one by oneCommission the plant microgrid, utility connection, load bank and steam genset, each as an independent subsystem.
- Integrate under the state tableLet the head service call assets by mode, and run the shared test script against the steam plant PLC.
The message logging service
The message logging service was a power management system (PMS) service that ran only on the PMS controller and recorded events, not process data. Every micro-service sent short, plain-language text messages directly to it whenever something significant happened inside the service. When the diesel generator tripped on overvoltage, for example, the diesel genset service logged a message as simple as "Diesel gen tripped off due to overvoltage event."
It was deliberately separate from the data logging found on a SCADA system. It did not record process values for trending or reporting, and its messages were not forwarded to SCADA. Instead, the messages were held in a first-in, first-out (FIFO) buffer that lived on the PMS controller itself. Each new message entered the buffer and, once the buffer was full, the oldest message dropped out. To use it, an engineer logged in to the controller and read the most recent events, for example the last 50, to see exactly what the services had just done and in what order.
Messages flowed one way only. Services wrote messages to the message logging service, and the message logging service never wrote back to any service, so it could not disturb control.
Debugging the integrated system
Once the services were tied together, problems were rarely confined to one service; a fault in one branch would show up as odd behavior in another. The message logging service was the key tool for debugging these real-time interactions between micro-services. Because every service reported its events into one buffer, in the order they occurred, the log gave a single chronological view of the whole system. Reading it showed what each service had done, in what sequence and relative to which other events, so cause and effect could be traced across services, even when the original fault was several services away from the symptom.
The fixed execution order is what made the log trustworthy. Because services always ran in the same sequence every scan, the order of messages in the log reflected the real order of events. Without a guaranteed execution order, the log itself would have been ambiguous.
5Results
The PMS was designed, built, commissioned and operated at the US site, and the plant was then deployed to West Africa. The results below come from operation at the US site.
- Fully automatic start-up. The plant started itself, islanded or in parallel with the utility, without operator intervention. The steam system ramped up, the turbine came online once enough steam was available, took on the entire plant load, and exported the surplus when grid-connected.
- Seamless source transitions. Hand-offs from diesel to turbine at start-up and from turbine back to diesel at shutdown were seamless. Most people knew a transition had happened only because they heard the diesel start or stop.
- Grid disconnection test. With the whole plant running, the microgrid was repeatedly connected to and disconnected from the utility at roughly five-second intervals. No disturbance was observed on any asset, and the only measurable effect was a sub-cycle transient under 2 ms on the grid-forming AC side.
- Minimal operator attention. Operators rarely needed to check the PMS screens on the plant HMI, because the system ran without problems.
- Parallel development held. The steam plant and PMS teams built their software at the same time against the same contract, and the shared mode-by-mode signal table served as the integration test.
- Changes without rewiring. New values could be brought into the PMS through configuration alone, and the self-documenting tree made the system straightforward to troubleshoot and maintain.
6Discussion: micro-services in practice
The micro-services were called from main() in the order in which they needed to execute. Early on, getting that order wrong proved costly. When services ran out of sequence, the order of operations was no longer guaranteed, and the result was intermittent, seemingly random problems that were very difficult to reproduce and debug.
In the final system, the business logic and the hardware interface updates were called in a specific, fixed sequence every scan. At runtime, the PMS therefore behaved much like a monolithic program: one thread of execution, stepping through every service in a known order. That was a requirement, not a compromise. Guaranteeing execution order was the only way to make the plant's behavior deterministic and its faults traceable.
The micro-service structure still delivered what it was chosen for. The code was organized into small, single-purpose services with simple interfaces and hidden internals, each of which could be developed, tested and troubleshot on the hardware on its own, and reused across identical devices. The lesson is that, in real-time control, micro-services are best used as a way to organize code and isolate concerns, while execution stays synchronous and ordered.
7Lessons learned and contributions
Lessons learned
- Apply software principles to the hardware. Services were only as independent as the equipment beneath them. Designing the mechanical and electrical systems for abstraction and reusability, with isolated units behind a standard interface and reusable inverter platforms, is what makes clean software abstraction possible.
- Keep interfaces boringly small. Enables, a few setpoints, statuses and alarms were enough for every service. Anything more would have tied parents to their children's internals.
- Write the contract before the code. An early, explicit interface between teams turned a schedule dependency into parallel work, and the per-mode signal table doubled as the test plan.
- Put mode logic in one readable place. A single state table in the head service made the system's behavior visible to operators, engineers and reviewers alike.
- Move data over the network, not wires. Fieldbus data turned many hardware changes into configuration changes.
- Spend the design effort on transitions. Deciding which mode the plant should be in was simple; moving between modes without disturbing the plant was the hard part, and it deserved its own logic in the power management service.
- Fix the execution order. Calling services in a defined sequence from
main()turned random, hard-to-reproduce faults into deterministic behavior. Order of execution is part of the design, not an implementation detail. - Do not import IT patterns wholesale. Message brokers and asynchronous events solve IT problems that a single real-time controller does not have, and they bring the timing uncertainty a controller cannot tolerate. Keep the organizational ideas; leave the runtime model.
- Make every service narrate its events. A single, ordered log of plain-language event messages from every service was the most valuable tool for debugging the integrated system.
My contributions
- Designed, programmed, commissioned and troubleshot the PMS software micro-service structure, including the subsystem services, device services, state table and the transition logic between operating modes.
- Authored the steam plant to power management interface specification: theory of operation, signal definitions, and the 11-mode sequence of operation with the expected value of each signal.
- Configured the Vacon inverter/converter applications on the DC bus, the diesel genset controller and the steam genset controller to work with the PMS.
- Engineered, constructed, configured, commissioned and troubleshot the Profinet and Modbus fieldbus control network.
- Designed the message logging service used to debug the integrated system.
- Led hands-on commissioning and troubleshooting across the software, power and networking systems.
I built these systems with the help of many people, and I was responsible for their overall design, construction, commissioning, troubleshooting and final delivery.
8Credits
Although I served as the single point of contact for the technical design, construction, commissioning and troubleshooting, this plant was truly a team effort. I'm grateful to the people who made it possible:
- Peter Janicki, mechanical engineer, entrepreneur and business owner
- Boyd Flacker, PhD, mechanical engineer
- John Weller, PhD, mechanical engineer
- Kyle Martin, electrical engineer
- Stephen Bailey, electrical engineer
- Brad Bouchard, mechanical engineer
- Dennis Schmidt, mechanical engineer
- The engineers at Vacon
- The engineers at the steam turbine manufacturer
- The IT network administrators and software developers who helped me build the plant's IT and data systems