Tutorials
Each tutorial takes a small but realistic piece of control software, runs it in a simulation, states its requirements as verification rules, and uses the result to find something wrong with it. All the code is on the page, complete, and every graph comes from a run of that code exactly as shown.
They build on each other, so if you are new to CppModel, take them in order.
| Tutorial | The code under test | What you learn |
|---|---|---|
| 1. Excavator Boom Control | Joystick to hydraulic valve coils, with signal monitoring | A simulation's structure, a scripted scenario, parameters, Always and Response rules. Finds a broken-wire fault that drives the boom down. |
| 2. Temperature Control | A P and PI room temperature controller | A plant model and a closed loop, the Settle rule, controller variants from --inputs files without rebuilding, comparing runs. Shows steady-state error and integrator windup. |
| 3. Garage Door Controller | A state machine with a button, a photo-eye and limit switches | Test sequences with steps and reusable input profiles, Mode rules, requirement IDs and coverage. Finds a motor reversal without a rest. |
Before you start
- Install the CppModel library and a C compiler with CMake (see Installation). Each tutorial expects the library in a
dependenciesfolder next to itsCMakeLists.txt. - The first run of a simulation prints a login link to your workspace. After that, each run prints a link to its results.
- Each tutorial's complete project is on GitHub, linked at the end of the tutorial: excavator-boom-control, temperature-control and garage-door-controller.
How to read the graphs
The graphs show the same things the workspace draws for a run:
- Lines are the inputs and outputs the simulation recorded, held between changes.
- Lanes under the graph show each verification rule: green where it passed, red where it failed. A mode strip shows the state of a
Moderule. - Grey windows are the time a rule allows, such as a deadline after a trigger.
- Bands are the range a rule allows, and the checked signal turns red where it failed.
- Diamonds mark events, such as a response time or a settling point, green when within the rule and red when not.
See Rules on the graph for the full list.
More examples
- Steps and Input Profiles and Verification Rules use a tank level controller throughout.
- Structured Text (VirtualPLC) tests a PLC program in IEC 61131-3 Structured Text against a plant model.
- Python and Node.js writes simulations in Python or JavaScript.
- So, how do you fill a glass of water? explains a closed-loop simulation from scratch.
- GitHub Examples has more algorithms ready to build.