Specifications
SR400 with the RS-232 Interface
51
PROGRAM EXAMPLE 2:
IBM PC, MICROSOFT FORTRAN V4.0, VIA RS-232
Machine language routines to interface to the COM1: RS-232 port are provided in the file RS-232.OBJ found
on the SR400 demo disk. These routines allow for simple interfacing to the SR400 at 19.2 kbaud from
FORTRAN programs.
To use these routines, the file 'for232.inc' (also on the demo disk) must be 'included' in the FORTRAN source.
Only two wires between the IBM PC's COM1: port and the SR400 are needed (pins #2 & #3 of the 25 pin RS-
232 connector), but pins 5,6,8, and 20 should be connected together on the connector at the IBM end.
$include:'for232.inc'
c for232.inc must be included to call subroutines in RS-232.OBJ
link with RS-232.OBJ (on demo disk)
c RS-232.OBJ defines:
c init
c initializes COM1: to 19.2 kbaud
c txstr (str)
c transmits string str to COM1:
c str is a string terminated with '$'
c rxstr (str)
c fills str with string received from COM1:
c str must be declared with length of 15 or greater
c If an error occurs, nocom is called.
c Nocom should be a FORTRAN subroutine in your program.
program ex5
character*20 str1,str2
c Example program to read the SR400 counter data and ramp the PORT1
c analog output using Microsoft FORTRAN v4.0 and the COM1: port.
c Set the SR400 to 19200 baud, RS-232 ECHO=OFF,RS-232 BITS=8,PARITY=NONE
c initialize COM1: port to 19.2 kbaud
call init
c reset the SR400
call txstr('RC0$')
c set character wait interval to zero and counter A to 10 MHz
call txstr('CI0,0;SW0$')