Office 0049-(0)40 - 866 298 75
Mobil 0049-(0)171-28 52 405

PMS State Diagram Editor SD2

Develop Embedded Real-Time Code with the Sate Diagram Editor SD2

How to Start a Program

The entry point of a state diagram program is the upper- and left- most state on the working screen. You can easily remember this rule by thinking of the way you are starting to write text on an empty sheet of paper.

When you will deviate from this rule, you must name the entry point state "Entry<program name>". When your state diagram program for example is named "LiftProg" then the entry point can be named "EntryLiftProg". SD2 differenciates between small and capital letters.

C code and commenting texts can be placed at any place of the state diagram program. But please consider, that SD2 only can transport those texts to the generated C source, which are placed on the leftmost edge the state diagram programming working sheet.

A state diagram program can be written on more than one page. For this task SD2 features connectors. Ingoing or outgoing events can end at such connectors. A connector with the same name then leads the program flow to other places or to another page. Many outgoing events can end at a specific connector, but only one (1) incomming event is allowed to be connected to this connector.

The Sample Program "SDDemo"

The state diagram program "SDDemo" demonstrates a simplified minor road crossing traffic light. You can find this state diagram program in the ZIP file from our internet home page or on the SD2 CD. The system is waiting for a car to enter the crossing. The appearence of a car is sensed by a car sensor, which physically is an electric loop inside the road. When a car or bike moves over the loop the magnetic properties of the loop is altering, which again is meassured by an connected mirocontroller.

The microcontroller generates a low-to-high edge on the event "CarSensor", which starts a red-yellow-green cycle on the traffic light. After a few seconds the traffic light undergoes a green-yellow-red cycle and then falls back to the "Wait" state.

When you don't have an empty state diagram screen, then create one by the the menu or the respective icon "New Program". Use the "Save As" menu to rename the program to "Sample".

Some SD2 Settings

The "Settings" menu offers you all settings for SD2. Here is a short description of a few settings:

In the "Code Generation" dialog box you can choose between a generation of either C or IL code. IL (Instruction List) is a textual programming language for PLCs (Programmable Logic Controllers). To be able to make an online visualization, SD2 needs to know the state variable - the variable in the controller, which holds the state of the state diagram program at runtime.

The "Sticking Objects" dialog box controls if you want all object to sticks to each other, or if you want be able to move all objects freely. Try to experiment in a sample SD2 program to move objects while sticking objects is activated and while this feature is deactivated.

The "Initial Object Sizes" dialog box sets the initial sizes of states and events. In the "Object Colors" dialog box you can set the colors of all SD2 objects.

Entering a State

Enter the first state by the menu "Objects - State" or the "new state" icon. In the appearing dialog box "State Diagram Identifier" you can enter a new identifier in the text field "New Identifier". All used identiers are shown in the field "Used Identifiers". Entering an already used identifier will be denied by SD2 because all state identifiers must be unique.

You can easily move and modify an state. Click once inside the state. The state should change into the inverse color and get a thick border. The state is now "active". Then click inside the state once again, keep the mouse botton pressed and move the mouse. The state is moved this way.

When the state is "active" you can resize the state by clicking on the top, botton, left or right side of the state, keep the mouse botton pressed and move the mouse. Try to experiment a bit by yourself.

A right mouse click inside a state will call ist property dialog box. More about this later on.

Three Kinds of Events

The state diagram program "SDDemo" demonstrates a simplified minor road crossing traffic light. You can find this state diagram program in the ZIP file from our internet home page or on the SD2 CD. The system is waiting for a car to enter the crossing. The appearence of a car is sensed by a car sensor, which physically is an electric loop inside the road. When a car or bike moves over the loop the magnetic properties of the loop is altering, which again is meassured by an connected mirocontroller.

The microcontroller generates a low-to-high edge on the event "CarSensor", which starts a red-yellow-green cycle on the traffic light. After a few seconds the traffic light undergoes a green-yellow-red cycle and then falls back to the "Wait" state.

When you don't have an empty state diagram screen, then create one by the the menu or the respective icon "New Program". Use the "Save As" menu to rename the program to "Sample".

Entering an Event

For the line event first select one of the menu "Objects - Event Straight" or the respective icon. Then click on the working sheet where the event shall start, keep the mouse button pressed and move the mouse to the position where you want the event to end and finally release the mouse botton.

The multi line event is selected by the menu "Objects - Event Multi Line" or the respective icon. Click once on the working sheet where the event shall start, release the mouse button and move the mouse to the position where you want the event either to bend or to end. If you want to create a bending click the mouse botton once and move the mouse button into the new direction. When you want to end the multi line simply press the escape botton.

The self loop event is selected by the menu "Objects - Event Self Loop" or the respective icon. Click on the top, botton, left or right side of a state once to place the event. Eventually improve its appearance by clicking and tearing the event.

Entering C Code and Text

The menu "Objects - C code" and "Objects - Text" and the respective icons are starting the entering of C code and texts. Then simply enter the intended text, whereby you can enter line feeds by pressing the enter key. The C/text entry is finished by pressing the escape key. By clicking with the right mouse button you can later on alter C codes and texts.

Entering Connectors

The entering of a connector is started by the menu "Objects - Connector" or by the respective icon. Enter the intended connector name and finish by pressing the enter key.

Some Edit Possibilities

Try to move objects while the SD2 feature "sticking objects" is activated. When moving states all connected events will then follow. When you move segments of multi lines, then the connected lines will follow and when you move multi line edges the touching lines will follow your mouse movements.

In case you made a wrong entry, the undo/redo feature can be an easy help. SD2 indeed offers unlimited undo/redo steps.

The Reference List

The event object contains C statements and function calls. When you use SD2 to program PLCs you can also use process variables for PLCs. Instead of using C variables or process variables directly, you can use references to these variables. Have a short look at the refrence dialogs and the sorting possibilities. The Cross Reference Feature scans through all SD2 modules to set up a global cross reference list. For this feature you need the IL code generator.

The Property Dialog Boxes

SD2 offers dialog boxes for all state diagram objects. The property dialog boxes are called by clicking on the object with the right mouse botton.

The state property dialog offers the altering of the properties of the state and of the properties of all connected incomming and outcomming events. Mark an event or a procedure with the mouse and then click the modify botton. The error fields show program errors, which are detected, when you generate C or IL code by saving your program.

Each event can be modifies by its event dialog box. Here you can enter the events and functions other than the initial settings "Event" and "Routine".

C code and texts have a common property dialog. This offers you the advantage, that you easily can "comment out C code.

The connector property dialog box shows you if the connector is an input or output.