Sensaphone SCADA 3000 Users manual User Manual

Page 205

Advertising
background image

16-19

Chapter 16: Programming in C

Example #4 Forcing Alarms from the C-Program
To make an alarm occur as the result of a C-program action, you must define a C variable and

then use the same C Variable as the Source Data Point on the Alarms form. On the alarms

form you would select the Alarm Type to match the value of the C variable. For numeric val-

ues, set the Alarm Type to limit, for digital values set the Alarm Type to either bit=0 or bit =1.

For example, suppose you have a C program that computes the average temperature of a liquid

based on readings from several sensors. The average temperature is stored in a program vari-

able called avg_temp. This C Variable would be used as the Source Data Point for an alarm and

you would program high and low alarm limits accordingly.

float avg_temp;

float sensor_A;

float sensor_B;

float sensor_C;

float sensor_D;

main ()

{

sensor_A=read_uaf(Input,0,10);

sensor_B=read_uaf(Input,0,11);

sensor_C=read_uaf(Input,0,12);

sensor_D=read_uaf(Input,0,13);

avg_temp = ((sensor_A + sensor_B + sensor_C + sensor_D)/4);

}


Example #5 Acknowledging Alarms from the C Program
The following lines of code show how to acknowledge an alarm from the C Program. If a

momentary normally open push-button was connected to input zero, depressing the button

would acknowledge the alarm.

Example:

main ()

{

if (read_uaf(input,0,0)==1) /*If input 0 on main

board is closed */

{

reset (0); /* then acknowledge alarm 0 */

}

}

Example #6 Lead-Lag Pump Down Control
This program will perform simple pump down control with alternating lead and lag pumps.

The program controls two relay outputs from the reading of one analog level indicator. The

level input is assumed to be on channel zero of the motherboard, and the relay outputs are

assumed to be on channels zero and one of the motherboard. As long as those I/O points are

acceptable, the only set up is to change the variable set up for ‘lead_on’, ‘lag_on’, and ‘all_off’.

For this example the three set points are preset in the source code. With some minor modifi-

cations you can make these parameters programmable from the C Variables form.

int lag;

int lead;

int state;

float lead_on;

float lag_on;

Advertising