DIGITAL INPUT/OUTPUT CARD IOD-144 USER MANUAL
6-5
50 OUT BASEADDR+1,&HFF 'Turn on all Port B bits
60 OUT BASEADDR+2,&HF 'Turn on all bits of Port C Lo
SAMPLE PROGRAMS
The following sample programs are in TURBO-C and TURBO-PASCAL languages.
They cover a security system that allows you to monitor the status of 16 switches and
to automatically trigger four alarms that can be used to turn on lights, activate a siren,
or send a signal to a silent alarm. The alarm system in this demonstration has four
arming stations which toggle the alarm on or off. These programs are also provided
on the diskette that ACCES supplied with your IOD card.
TURBO-PASCAL PROGRAM
CONST BASEADDR = $300; {declare base address for IOD card}
CONST ON = 1; {declare some useful constants}
CONST OFF = 0; { " " " " }
TYPE sensor_array = array[0..15] of integer; {creates a type of variable used for}
{ sensor data}
VAR sensors_at_arm : sensor_array; {bit-by-bit status of sensors when alarm is
{activated. Used to notify user of open windows, etc}
VAR sensors_now : sensor_now; {bit-by-bit status of sensors at current time. When}
{compared against sensors_at_arm, indicates}
{ break-in if there is a change.}
VAR arming_stations : integer; {variables representing all four arming stations}
VAR old_arming_stations: integer; {If value changes toggle alarm on/off}
VAR hour, min., sec., hun. : word; {variables used to retrieve time}
VAR key : char; {useful temporary variable}
VAR i : integer; {useful temporary variable, used in loops}
VAR j : integer; { " " " " " " }
procedure initialize_board; {this procedure sets MODE 0 as active and sets}
{and sets Port A, B, and C LO as input and Port }
{C HI as output}
begin
port[BASEADDR+3] :=$93; {port[X] is Pascal's method of accessing the port}
{memory. This code sets the port memory at}
{address 303 hex, and the control register, to 93}
{hex because the bit pattern to set the desired}
{mode and port designations is 10010011 which}
{equals 93 hex}
end; {procedure initialize_board}
procedure read_sensors(VAR ary:sensor_ary);
VAR tempA : byte; {this procedure fetches data from Ports A }
VAR tempB : byte; {and B and returns a binary representation}