SinelaboreRT Header Logo

SinelaboreRT

It's better when it's simple!

User Tools

Site Tools


Sidebar

Tool Landing Pages

Examples

Designers Toolbox

How-To

Integrated state-chart editor with auto-layout

Focus on modeling and not on moving states around to create a nice looking diagram! Syntax aware text fields offer a comfortable way to specify actions, guards etc. When the diagram passed the model checker it can be directly simulated. Connect the diagram to the real hardware to monitor the state machine in action.

There are better ways to model state machines than using spread sheets!

In the past different μC manufacturers have published application notes about the benefit of using state machines for the design of embedded software. An example is the application note SLAA402 from Texas Instruments (TI). It suggests to generate source code based on a spread sheet table. Nowadays several affordable UML modeling tools are available supporting the efficient design of state machines in a graphical way. SinelaboreRT generates production quality source code from state diagrams created with many different UML tools. Give it a try!

Latest Changes

wiki:examples:pump_controller

Sump Controller

This example presents the software necessary to realize a simplified pump controller which might be used in a mining environment. It is based on a case study presented in 1).

The task of the system is to pump water from a sump to the surface. There are two level monitors which start pumping if the sump is full and stop pumping if it is empty again.

Pumping shall only start if the methane level is below a certain threshold. In case the pump is already running it shall stop automatically.

Pumping shall only start if the methane level is below a certain threshold. In case the pump is already running it shall stop automatically.

There is some additional requirements:

  • After starting the pump a pressure monitor must signal pressure within a defined time to ensure the pump does not run dry. Otherwise the pump becomes hot and finally breaks.
  • If stopped the run signal (checkback) from the motor must be absent (i.e. contactor opened)
  • When running the checkback signal must be present.
  • After a fault a manual reset signal is necessary to restart the controller.

The controller behavior can be modelled as a flat state chart. The model below was created using ArgoUML an open source modeling tool. There are two main states PumpStopped and PumpRunning. Changing from run to stopped is only possible via two intermediate states (PumpStarting, PumpStopping) which check that the pump motor checkback signal is present after a switching command. If the checkback from the motor is missing the Error state gets entered.

 Sump Controller State Diagram

In another possible design all states beside the Error state are children of a NoError state.

To create the state machine implementation code export the diagram to an XMI file and then call the state machine generator:

java -jar codegen.jar -S -p ARGOUML -t "sump controller:Controller" -o controller controller.xmi

In this case the C implementation is generated. The -t flag defines the path to the state diagram within the xmi model file.

With the optional -S command line flag the graphical simulation is started (see below). The graphical simulation allows to interactively send events to the machine and observe the new active state and the executed C-code. The diagram below shows the state machine in state PumpRunning. Events that are now accepted from the machine are listed on the left and are shown in blue in the diagram. To send a transition just click on the event in the list. The output window displays a trace of the executed code as provided in the diagram.

 Sump controller simulation

It is also possible to observe a real target which is connected to the graphical simulation. More information on how to connect an embedded target e.g. via a CAN communication link is available in the sinelabore manual. If you are interested in the model file or the generated code just send a mail to info at sinelabore dot com.

1)
Burns and Wellings, Real-Time Systems and Programming Languages, Addison Wesley 2001

Leave your comments

Enter your comment. Wiki syntax is allowed:
137 +1 = ?
 
wiki/examples/pump_controller.txt · Last modified: 2015/11/28 14:53 by pmueller