Skip to content

SWExecStandard

Introduction

The SWExecStandard is a ready RTDB based application with IO-Handlers for some hardware boards.

In this article the IO-Handler is utilize for the K8055 board in StateWORKS Studio 7.2, an older software version still available for download that, when paired with this board, is compatible only with legacy operating systems like Windows XP.

The installation package contains also the monitor SWMon that allows you to display the hardware inputs and change the hardware outputs. In this article we show an Example specification that demonstrates the possibility of the StateWORKS specification tools: to create application without writing a single line of code. If you want to try a creation of your own application, simply download StateWORKS Studio.

Installation

During the installation process, there is an option to change the default installation directory.

C:\Program Files\SWSoftware\StateWORKS Application LE 7.2

In case of StateWORKS Studio 7.2, the file structure looks as shown below.

  • DirectoryProjects
    • DirectoryExamples-Web
      • DirectoryK8055demo
        • DirectoryConf
          • K8055demo.swd
        • K8055demo.prj
  • DirectoryRun-time
    • SWExecStandard.exe
    • K8055D_C.DLL
  • SWMon.exe
  • SWStudio.exe

Starting the application

When starting SWExecStandard.exe, you will be asked to provide the configuration file. In this case, we use K8055demo.swd for our board.

The next time the program is started, it will suggest using the last configuration file. You can accept it or enter a new configuration path.

SWExecStandard.exe
The program should be called with 0-4 arguments:
* -cName: full name (with path) of the configuration file.
If missing the path will be taken from the file .RTDB_Conf.par
in the exe directory.
If the .RTDB_Conf.par is also missing the application will ask
for the path.
* -sService: 0 -> the application does not run as a service (default)
1 -> the application will run as a service
* -tPort: the tcp/ip port number
If missing the default value 59091 will be used.
* -pPassword: a password string.
If missing it is assumed the RTDB can be accessed without a password.
Enter a Configuration file: C:\Program Files\SWSoftware\StateWORKS Application LE 7.2\
Projects\Examples-web\K8055demo\Conf\K8055demo.swd
Started Configuration file = C:\Program Files\SWSoftware\StateWORKS Application LE 7.2\
Projects\Examples-web\K8055demo\Conf\K8055demo.swd
Application created with 33 objects
RTDB variant: LE
RTDB version: 7.2.1
RTDB Server (port 59091) started
TimeBaseTick thread created
Created k8055unit Unit1
Exit program by pressing the key 'q' and Enter.

Monitoring Inputs and Outputs

To display and change hardware signals you have to start SWMon.exe.

On a start accept the default Host and Port values and leave the Password entry empty (assuming that you have not defined the password while starting the SWExecStandard).

With Select → Unit or using the corresponding icon open the “Select Unit” dialog windows where you choose the Unit K8055Unit:001 and confirm it with OK. You should see all inputs and outputs of the board (The screenshot shows all objects of the IO-Handler for the K8055 board). If the board does not exist yet (is not connected) a corresponding alarm will be active.

If you choose VFSM view (Select → VFSM or corresponding icon) you will see all objects that are used in the Example.

The USER view (Select → Objects) displays all objects used in the specification.

If the board is connected its input values (DI, NI) are displayed, and you can set its outputs (DO, NO) using the service (force) mode. If the board is not connected the input values becomes UNKNOWN (DI) or UNDEF (NI) and a corresponding alarm is generated. You can connect / disconnected the board at any time; the system detects the changes and behaves appropriately.

RTDB objects

Actually you see in SWMon RTDB objects that were used while specifying the IO-Unit for the IO-Handler. That means you see not only the inputs and outputs available on the board but also objects that are required for proper functioning and supervision of the IO-Handler. Especially, you see there a few alarms and parameters (see the description of the IO-Units).

Objects_for_K8055_IO-Handler

K8055 IO-Unit

The Unit specifies the interface between the K8055 board signals and RTDB objects. It defines objects shown in the table below:

Object typeName (K8055 unit)RTDB object
Digital input DIDi_1
Di_2
Di_3
Di_4
K8055:Di:001
K8055:Di:002
K8055:Di:003
K8055:Di:004
Digital output DODo_1
Do_2
Do_3
Do_4
Do_5
Do_6
Do_7
Do_8
K8055:Do:001
K8055:Do:002
K8055:Do:003
K8055:Do:004
K8055:Do:005
K8055:Do:006
K8055:Do:007
K8055:Do:008
Numerical input NINi_1
Ni_2
K8055:Ni:001
K8055:Ni:002
Numerical input NONo_1
No_2
K8055:Ni:001
K8055:Ni:002
Data DATDat_Counter1
Dat_Counter2
K8055:Dat:Counter:001
K8055:Dat:Counter:002
Command CMDCmdK8055:Cmd
Alarm ALAl_CommError
Al_AddressError
K8055:Al:AlaCommError
K8055:Al:AlaAddressError
Parameter PARPar_DebounceTime1
Par_DebounceTime2
Par PollingTime
K8055:Par:DebounceTime1
K8055:Par:DebounceTime2
K8055:Par:PollTime

Several objects are IO-Unit specific ones:

  • Cmd is a command send to the board and could be:
    • AnalogClearAll_Ao 4
    • AnalogSetAll_Ao 3
    • CloseDevice 22
    • CounterResetAll 11
    • CounterReset_1 12
    • CounterReset_2 13
    • CounterSetDebounceTime_1 14
    • CounterSetDebounceTime_2 15
    • DigitalClearAll_Do 2
    • DigitalSetAll_Do 1
    • OpenDevice 21
    • OpenFirstDevice 23
  • AlaCommError is an alarm generated if the communication with the K8055 board is down.
  • Al_AddressError signals an erroneous physical address of the board (must be 0…3).
  • Par_DebounceTime1 and Par_DebounceTime2 are debounce time values for inputs Di_1 and Di_2 that are counted correspondingly by Dat_Counter1 and Dat_Counter2.
  • ParPollTime defines the value of the polling time loop which queries the K8055 input signals. It can be changed at any time in the SWMon.

Example

The Example demonstrates a typical control performed by starting a device and supervision of a controlled value (pressure). We assume that the device is switched on by setting a digital input HIGH and the SetPressureValue is a voltage on an analog (numerical) output (representing the required pressure value). The device supplies a digital signal HIGH to a digital input if switched on and a voltage (proportional to a actual pressure value) to the analog (numerical) input. The use of board inputs and output is shown in the table below.

BoardUnit
Digital input DI
(Start acknowledgement)
Inp1K8055:Di:001
Digital output DO
(Device On/Off)
01K8055:Do:001
Numerical input NI
(Pressure)
A1K8055:Ni:001
Numerical output NO
(SetPressureValue)
DAC1K8055:No:001

There are 3 control phases:

  • The first phase begins with the command Cmd_Start which starts the device. If the device acknowledges its start by setting the digital input to HIGH the state machine passes to the second phase. The first phase is supervised by a timer which timeout value is equal to 3 sec. If the timeout elapses before the device acknowledges its start the state machine should terminate the start-up.
  • In the second phase a ramp of the SetPressureValue (required pressure value) is to be generated. The SetPressureValue should increase in 100 steps from 0 to 4 V. If the SetPressureValue reaches its nominal value we should wait 5 seconds to be sure that the pressure has reached its required value and the third phase should begin.
  • The third phase is a supervision of the pressure value which should stay in between maximum and minimum limits. If the pressure leaves the band an alarm should be generated. If this erroneous situation last more than 3 seconds the state machine should stop the device. On the other hand the number of pressure errors is limited to 4. A non-compliance to this requirement should stop the device. Every pressure error-free minute should reduce the number of errors done by one.

At any time the Cmd_Stop should switch off the device and set the SetPressureValue to 0.

The state transition diagram of the state machine Example that does the control is shown in below. The specification has been done using StateWORKS Studio which is available for download.

Example_state_transition_diagram