Phonetics Sensaphone ISACC 5000 Manuale Utente

Pagina di 143
97
Chapter 8:  C Programming
OUTPUT
Summary:
int output(n1,n2);
int n1;
Output number
int n2;
Command, 0=turn off;1=turn on;2=return status
Description:
The output function will turn a digital output specified by n1 on or off, or will just
read the present state of the output.  It will also set the value of an analog output.  The
analog outputs, referred to as outputs 11 through 14, are 0 to 10V.  They are specified
by 8 bit data from 0 to 255.  If n1 is from 1 to 8, it refers to the corresponding digital
outputs.  When n1 is 9, it refers to the built in buzzer, and when n1 is 10, it refers to
the built in relay.  This function will not change an output unless that output is
set for automatic control.
  See OUTPUT command, Chapter 7.
Return value:
The output function returns the state of the digital output, 0 for off, 1 for on. IM-
PORTANT:  If the output function is used on an analog output, with n2=2, it will
return status, and set the output to a value of 2. There is no way to query an analog
output without changing  its value.  The C program must remember what it set it to.
The value of n2 is assigned to the analog output.
Example:
This program will turn output 8 on between the hours of 8:00am and 5:00pm.  This
program will also set analog output 1 to full scale if the buzzer is on, and sets analog
output 1 to bottom scale when it is off.
main()
  {
  if ((hours >= 8) && (hours <= 17))
    {
    output(8,1);
    }
  else
    {
    output(8,0);
    }
  if (output(9,2) == 1)
    {
    output(11,255);
    }
  else
    {
    output(11,0);
    }
  }