Skip to main content

3 posts tagged with "CppModel"

A C and C++ library for modeling and simulation of dynamic systems, control algorithms, and optimization problems.

View All Tags

What Level of Simulation Do You Really Need?

· 14 min read
Hristo Hristoskov
Founder @ Control Edge AB

If you're developing control system software today, you have no shortage of ways to simulate and test it. You can write unit tests, build a higher-level engineering model, run an application in a simulated controller environment, model the physics of a machine, place that machine in a virtual environment, emulate an embedded target, connect a real controller to HIL, or test on the machine itself.

All of these approaches can be useful. The more interesting question is not which simulator is the most capable, but:

What are you actually trying to understand?

That question matters because simulation is not only about how much of the system we reproduce. It is also about the abstraction at which we choose to represent the problem. A unit test may be enough to verify a calculation. A higher-level model may be the right place to design a control concept. A physical model may be necessary when hydraulics or mechanics dominate the behavior. And sometimes the production implementation already contains the behavior we need to investigate.

The table below is not a ranking, and the products listed are not necessarily direct competitors. It is a map of different starting points and the kinds of questions they help answer.

ApproachExamplesWhat it helps you understand
Unit testingGoogleTest, Catch2Individual calculations, conditions and module behavior
Code-first control system simulationCppModelHow the production implementation behaves over time
PLC engineering & simulationCODESYS, Beckhoff TwinCAT, Siemens PLCSIMRunning, debugging and observing controller applications in a simulated controller environment
Model-Based DesignSimulink, SCADEControl design and behavior represented at a higher modeling abstraction, including model-based development and code-generation workflows
Physical/system modelingSimscape, OpenModelicaInteraction between control and physical processes
Robotics/environment simulationGazebo, Webots, CoppeliaSimMotion, sensors, physics and interaction with a virtual environment
Embedded platform simulation/emulationRenode, QEMUSoftware behavior in the context of simulated or emulated target hardware
Distributed embedded-system simulation & testVector CANoeSoftware, ECU, communication and distributed-system behavior
Hardware-in-the-loopHIL platformsReal controller hardware interacting with a simulated process
Real-machine testingThe machine itselfActual machine and process behavior

The part of this landscape I want to focus on here is control system software and the behavior it creates in processes, machines and mechanisms.

CppModel starts from a deliberately simple premise: the code is the model. Instead of first creating a separate representation of the control system, it works directly with the production implementation—which in embedded and machine control is often C or C++—and observes its behavior over time. CppModel currently supports this approach for production C and C++ code.

This does not mean that the production implementation is always the only model we need. It means that when the behavior we are interested in is already expressed there, we can start there rather than first rebuilding the same logic at another abstraction level.

Add a simulation CI to your process-based code

· 11 min read
Hristo Hristoskov
Founder @ Control Edge AB

Continuous integration (CI) is a crucial practice in modern software development, helping teams maintain code quality and catch issues early. In the control systems world, concepts like model-in-the-loop (MIL), software-in-the-loop (SIL), and hardware-in-the-loop (HIL) are widely used to validate and verify control algorithms before deploying them to real hardware. In this blog post, we will explore how to integrate simulation-based testing into your CI pipeline for process-based code.

So, how do you fill a glass of water?

· 10 min read
Hristo Hristoskov
Founder @ Control Edge AB

I am starting this blog series with one of the simplest processes I could imagine. We do it every day and rarely stop to think about how it actually happens.

Take a glass, open the tap, and when the water level is high enough, close the tap. It sounds simple. It feels simple. Yet if we try to explain this process precisely enough for a machine to do it automatically, it turns out to have real structure underneath — the same structure engineers use to control much bigger things, like a thermostat keeping a room at the right temperature or a cruise control keeping a car at the right speed.