Controllers Tutorial
Tutorial - Defining a new controller model
The following process will demonstrate how to create a new
controller model using these interface definitions. This tutorial
will guide you through building a simple idle speed controller
for an engine.
- Create a new model that extends
VehicleInterfaces.Controllers.Interfaces.Base, it
should look like this:
- You can now define your controller model as required
Creating a simple idle speed controller example
The following steps demonstrate how to create a simple idle
speed controller model. The controller model will sense the engine
speed, coolant temperature and accelerator pedal position and
adjust the throttle signal to the engine to attempt to maintain the
correct idle speed.
Starting from step 2 above.
- Add the following blocks and connections to the diagram.
- The controller model is built on the assumption that
a corresponding engine model will be developed that outputs
the required signals to the control signal bus. We need to add
connections to the control signal bus and will assume the following
names for the additional signals required that are not part of the
minimal set defined as part of the VehicleInterfaces:
- engineBus.coolantTemperature
- engineBus.acceleratorPedalPosition
- engineControlBus.throttlePosition
- To add these control signals we first need to add the
engineBus and engineControlBus
connectors and connect them to the controlBus.
These connectors are
VehicleInterfaces.Interfaces.EngineBus and
VehicleInterfaces.Interfaces.EngineControlBus.
When connecting these to the controlBus the following dialog will
be produced and should be completed as following substituting
engineControlBus for engineBus as
appropriate.
- We can then complete the model by connecting the blocks to the
control bus connectors and using the appropriate signal names. The
finished model should look like:
- The model is now complete and should check successfully and can
be used in any model compatible with the VehicleInterfaces library
assuming the selected engine model puts the required signals on to
the control signal bus
Generated at 2026-04-14T18:18:34Z by OpenModelicaOpenModelica 1.26.3 using
GenerateDoc.mos