FC 194 - User Defined Data Export

The user defined data export function code outputs user data via an exception report. A batch program, user defined function (UDF), C language program executing in the Harmony controller or a human system interface (HSI) command determines the user defined data output (output block N).

 

For more information refer to the C Utility Program product instruction, the Batch 90 and User Defined Function (UDF) Programming Language Reference instruction.

 

 

 

 

Outputs:

Blk

Type

Description

N

R

Output Value of Function

N+1

R

 

 

 

 

Specifications:

Spec

Tune

Default

Type

Range

Description

S1

N

2

I

Note 1

Block address of input data

S2

N

2

I

Note 1

Block address of input control

S3

N

2

I

Note 1

Block address of input status

S4

N

0

I

0 - 80

Maximum user data length

S5

N

0

I

0 - 255

Engineering units

S6

Y

0

I

0 or 1

Start-up control and force quality control:

0 = block quality on startup is bad

1 = block quality on startup is good

S7

Y

0

R

Full

Return alarm time-out period (secs)

S8

N

0

R

Full

Spare

S9

N

0

I

Full

Spare

S10

Y

0

R

Full

Spare

S11

Y

0

I

Full

Spare

 

NOTES:

1. Maximum values are:9,998 for the BRC-100, IMMFP11/12 and 31,998 for the HAC

 

194.1   Explanation

 

The defined specifications of function code 194 include the input data block, input control block, input status block, maximum data length, engineering units, startup control and return alarm time-out period. The specifications, except for the startup control and return alarm time period, are not tunable.

 

 

194.1.1  Specifications

 

S1

Block address of the input data. The default value of block address two indicates that the block is application program driven. When S1 is set to two, the user defined data export block expects to interface to a C language, UDF or batch program and ignores any block inputs.

 

When S1 is set to any block other than two, the block must be another valid user data block output (e.g., user data import function code 193).

 

S2

Block address of the input control. The input control parameter is formed by setting the corresponding bits of a real block output. This block number must reference the output of a valid real block. Table 194-1 lists the bits of the input control.

 

NOTE: When S1 is set to two, S2 is driven by a C language, UDF or batch program.

 

 

 

 

S3

Block address of the input status. The input status parameter is formed by setting the corresponding bits or a real block output. This block number must reference the output of a valid real block. Table 194-3 lists the bits of the input status.

 

NOTE: When S1 is set to two, S3 is driven by a C language, UDF or batch program.

 

 

S4

Defines the maximum user data length. The maximum user data length is a nontunable integer specification. If an input to the block exceeds this length, truncation occurs and the count fields (included in output block N) are set.

 

S5

Defines the engineering units.

 

S6

Defines the startup control. The startup control can be used to force the block to output good quality on startup.

0 = block quality on startup is bad

1 = block quality on startup is good

 

S7

Defines the return alarm time-out period in seconds. If S7 is set to zero seconds, return alarming is disabled. If S7 is not

zero, return alarming occurs each time that this time period expires. When return alarming occurs, the return alarm status

bit of the block output is toggled and a new exception report is generated.

 

S8 through S11

Spare.

 

 

194.1.2  Outputs

 

N

User data block output with quality. The maximum output data length is 80 bytes plus two count bytes. This output is exception reported when significant change occurs. Significant change is a difference in a memory block comparison function between the current output and the new output or a change in any of the status fields.

 

Output N also includes a sequence number. This sequence number is maintained at the system level by the harmony controller to assist in multiple user data packet management and user data packet identification.

 

N+1

Block status output. The real value can be de-multiplexed to bits using function code 126. Table 194-4 lists the bits.

 

 

 

 

194.2   Exception Report Data

 

Application programs such as C language, UDF or Batch 90 can read various types of data from the user defined data export function code:

 

The userdata_xr_read() function provides the ability to read this data.

Application programs such as C language, UDF or Batch 90 can write various exception report data to the user defined data export function code:

 

The userdata_xr_write() function provides the ability to write this data.

 

 

194.3   Application Programs

 

The input block address and input control block address provide inputs that allow control of the data flow in the user data export function code. The inputs that control this flow include the input block address, auto/manual and data interlock.  Figures 194-1 through 194-5 show five operating modes of the block that can be realized from a combination of these three inputs.

 

The first example (Fig. 194-1) is an application program control. This example allows application programs such as C language or batch to write directly to the user data block output. The application program sets auto mode and enables the data interlock. The module denies HSI write access to this block. The application program is the only process that updates the block. The data of the block is exception reported if the application program changes or updates the block data or any of the write block status fields (e.g., alarm level).

 

 

Figure 194-2 shows an application program control with HSI access example. Application programs write directly to the user data block output. The application program sets auto mode and disables the data interlock. HSI text string data is accepted by the Harmony controller. The received HSI command information can be read by the application program but it will not update to the block output unless it is explicitly written there by the application program. The data of the block are exception reported if the application program changes/updates the block data or any of the writable block status fields.

 

 

 

Figure 194-3 shows an application program control with HSI access and echo example. The application program sets auto mode and disables the data interlock. When auto/manual is manual mode and the Harmony controller receives new user data from the HSI, this information is placed in the block output and is echoed back to the HSI. The exception report designates echoed information by setting an echo field. Application programs can read the information sent from the HSI and write to the block output. The exception report contains the information from the last process, either HSI or application program, which updated the block prior to its execution cycle. The data of the block are exception reported if the application program changes/updates the block data or any of the writable block status fields.

 

 

 

Figure 194-4 shows a block control example. A user defined data import block output is the input. This input indicates to the user defined data export block that it is under block control. HSI write access is not allowed since data interlock is enabled. This block exception reports its information when significant change of its output occurs.

 

 

 

Figure 194-5 shows a block control with HSI access example. Information that is received from the HSI is placed in the block output. The input block address must reference a valid user data output block number. Accomplish this by pointing the block at itself (set S1 to block output N). This block exception reports its information when a significant change of its output occurs.

 

 

 

 

194.4   HSI - Text String Element

 

The text string element allows the operator to interact with an application program running in a module. The user defined data export function code in a module provides an interface between the HSI and the program. At the HSI, a TEXTSTR tag referencing a data export block in the module allows an operator at the HSI to interact with the function block. The data export function block can also be driven by another function block rather than directly by an application program.  The text string functionality provides, for example, a means to prompt or question an operator and have the operator respond to the prompt or question in some manner. The response may be to make some type of selection, acknowledge an event or provide an answer to a question. It can also be used to simply allow the operator, through descriptive text, to monitor and verify the progress of a process routine.

 

The capabilities provided by the text string function are not limited to the uses previously described. A batch program or C language program executing in the module determines the  operations performed through the text string block and text string element.

 

 

 

194.5   C Language Program

 

This example demonstrates how two C language programs, running on two modules, residing in separate HCU modules, can exchange data using function codes 193 and 194. The data that are exchanged are an array of 16 floats (64 bytes in size), which is exported from the module at 1-2-4, block address 200. These data are then imported by the module at 1-3-4, block address 200.
 

The export module contains a function code 194 at block address 200, and its C language program is as follows:

 

#include <xr_bufs.h>

float matrix[4][4];                                 /* array of 16 floats to export */

struct userdata_xr_buf xr;                  /* buffer for FC194 */

void main(void)

{

long int status;

short int row, col;

/* setup array of floats to some arbitrary values */

for(row=0; row<4; row++)

{

for(col=0; col<4; col++)

{

matrix[row][col] = row * col / 50;

}

}

/* setup FC194 buffer */

 

xr.data = (char *) matrix;                         /* point to floats */

xr.mask = DATA | QUALITY;                  /* set data and quality */

xr.quality = GOOD_QUALITY                 /* set quality good */

 

/* call export function at block 200 */

 

status = userdata_xr_write(200, &xr, sizeof(matrix));

 

/* program continues here... */

}

 

 

The import module contains a function code function code 193 at block address 200, and its C program is:

 

#include <xr_bufs.h>

float matrix[4][4];                      /* array of 16 floats to import */

struct userdata_xr_buf xr;       /* buffer for FC193 */

void main(void)

{

long int status;

short int row, col;

 

/* setup FC193 buffer */

 

xr.data = (char *) matrix;                                                     /* point to floats */

xr.mask = READ_FROM_BLOCK_OUTPUT;                /* set to read   FC193 */

 

/* call import function at block 200 */

 

status = userdata_xr_read(200, &xr, sizeof(matrix));

 

/* if return ok (64 bytes read), print values */

 

if (status == 64)

{

for(row=0; row<4; row++)

{

for(col=0; col<4; col++)

{

printf("Value (%d,%d): %f\n",

row, col, matrix[row][col]);

}

}

}

else

{

printf("Import error: %d\n", status);

}

}

 

The Symphony configuration for this example is shown in Figure 194-6.