EPC – External program call

Block SymbolLicensing group: ADVANCED
PIC

Function Description
The EPC block executes an external program upon a rising edge (off on) occurring at the EXEC input. The name and options of the program are defined by the cmd parameter. The format is the same as if the program was executed from the command line of the operating system.

It is possible to pass data from the REX Control System to the external program via files. The formatting of the files is defined by the format parameter. All the currently supported formats are textual and simple, which allows straightforward processing of the data in arbitrary program. Use e.g.
values=load(’-ASCII’, ’epc_inputVec1’);
for loading the data in MATLAB or
values=read(’epc_inputVec1’,-1,32);
in SCILAB. The filename and number of columns must be adjusted for the given project. Data exchange in the opposite direction is naturally also supported, the REX Control System can read the files in the same format.

The block works in two modes. In basic mode, the rising edge on the EXEC input triggers reading the data on inputs and storing them in the ifns file. The values of the i-th input vector uVec<i> are stored in the i-th file from the ifns list. In sampling mode, the data from the input vectors are stored in each period of the control algorithm. In both cases the values from one time instant form one line in the file.

Analogically, the data from output files are copied to the outputs of the block (one line from the i-th file in the ofns list to the i-th output vector yVec<i>).

The inputs working in the sampling mode are defined by the sl list (comma-separated numbers). The outputs work always in the sampling mode – the last values are kept when the end of file is reached. The copying of data to input files can be blocked by the DSI input, the same holds for output data and the DSO input.

Use the RTOV block to combine individual signals into a vector one for the uVec input. The RTOV blocks can be chained, therefore it is possible to create a vector of arbitrary dimension. Similarly, use the VTOR block to demultiplex a vector signal to individual signals.

Inputs

uVec1..uVec8

Input vector signal

reference

EXEC

External program is called on rising edge

bool

RESET

Block reset (deletes the input and output files and terminates the external program)

bool

DSI

Disable inputs sampling

bool

DSO

Disable outputs sampling

bool

Outputs

yVec1..yVec8

Output vector signal

reference

DONE

External program finished

bool

BUSY

External program running

bool

ERR

Error flag

bool

errID

Error code

error

i ....

REX general error

res

External program return code

long

icnt

Current input sample

long

ocnt

Current output sample

long

Parameters

cmd

Operating system command to execute

string

ifns

Input filenames (separated by semicolon)  epc_uVec1;epc_uVec2

string

ofns

Output filenames (separated by semicolon)  epc_yVec1;epc_yVec2

string

sl

List of inputs working in the sampling mode. The format of the list is e.g. 1,3..5,8. Third-party programs (Simulink, OPC clients etc.) work with an integer number, which is a binary mask, i.e. 157 (binary 10011101) in the mentioned case.   0  255 85

long

ifm

Maximum number of input samples  10000

long

format

Format of input and output files  1

long

1 ....

Space-delimited values

2 ....

CSV (decimal point and commas)

3 ....

CSV (decimal comma and semicolons)

nmax

Maximum output vectors length  10000

long

Notes