FC 143 - Invoke 'C'

Function code 143 invokes the C program. Specifically, the invoke C block calls a function within the C program designated as a segment entry point.

 

The C program can have as many as eight segment entry points. Each entry point has a function block segment (segment entry point zero with function block segment zero, etc.). A function name (i.e., the name of the functions that compose the C program) connects with each entry point. The same function name may connect with more than one entry point. During function block execution, an encounter with an invoke C block transfers control to the C program at the associated entry point (i.e., calls the appropriate function). When that program returns, function block execution continues normally at the next block. The entry point program function may call other functions of the C program before returning. Besides the normal utilization constraints, there are no further restrictions on the configuring of invoke C blocks.  Specifically, invoke C blocks may appear in any or all function block segments. Since each function block segment is a separate task, more than one task may execute the C program. When the C program is subject to multitasking, all shared functions among tasks must be coded so as to be reentrant.

 

 

Outputs:

Blk

Type

Description

N

R

Value may be set by C program using the putargs function

 

 

 

Specifications:

Spec

Tune

Default

Type

Range

Description

S1

Y

0

I

0, 1 or 2

Program operating mode:

0 = C program will execute normally

1 = C program execution is inhibited, blocks will run

2 = C program is in debug mode for use with the EWS C debugger

S2

N

0

I

0, 1 or 2

Block address of inhibit execution flag

S3

Y

0

I

Note 1

Program readable parameter

S4

Y

0

I

Full

Program readable parameter

S5

Y

0

I

Full

Program readable parameter

S6

Y

0

I

Full

Program readable parameter

S7

Y

0.000

R

Full

Program readable parameter

S8

Y

0.000

R

Full

Program readable parameter

S9

Y

0

I

Full

Spare

S10

Y

0

I

Full

Spare

S11

Y

0.000

R

Full

Spare

 

NOTES:

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

 

 

143.1   Applications

 

Figure 143-1 shows a configuration of a timer used to monitor and provide alarm capability. Figure 143-2 shows the entry in the C utility program for this example. There are numerous ways to use the invoke C command block and several ways to configure a timer. This is just one example.

 

 

 

The example in Figure 143-1 shows a C program called main being executed in segment zero of the module. The invoke C function code is placed in numerical order after the segment control block.

The C program has an output to the invoke C specification which triggers a time delay command (function code 58) in the succeeding configuration.

 

This timer configuration starts with a time delay command (function code 58). The input comes from the invoke C command block. The delay is equal to the longest inference cycle time period anticipated, and the number of intervals set to one. A 2- input summer (function code 15) is next. The summer's inputs come from the invoke C command block (gain equals one) and the time delay block output (gain equals -1). Specification <S2> of the summer block subtracts from <S1> and the value goes to the high/low compare (function code 12).

 

The high/low compare block compares the input with the high and low limits specified. The high limit equals +0.5 and the low limit equals -0.5. If the input is equal to or greater than the high limit, the high output is logic 1 and the low output a logic 0. If the input is equal to or less than the low limit, the low output is logic 1 and the high output a logic 0. If the input value is between the high and low limits, both outputs are logic 0.

 

Both of the high/low compare outputs go to the 2-input OR block (function code 39). If either or both inputs to the OR block equal logic 1, the output equals logic 1. When both inputs equal logic 0, the output is logic 0.

 

The output of the OR block goes to the NOT block which reverses the signal (i.e., logic 0 input equals logic 1 output). The NOT output signal goes to the reset input of the elapsed timer block (function code 86). A constant logic 1 signal goes to the hold input. The elapsed timer block sets the alarm output to a logic 1 when the reset input drops to a logic 0 for the time specified.

 

This configuration compares the present vital sign with the previous cycles vital sign. If there is no significant change (plus or minus 0.5), the elapsed timer starts timing. When the specified time elapses, the alarm output goes to logic 1. Upon a significant change, the configuration continues comparing vital signs.