43
Program Example 2:
IBM PC, Microsoft Fortran
v3.3, via RS232
Machine language routines to interface to the
COM1: RS232 port are provided in the file
RS232.OBJ found on the SR575 disk. These
routines allow for simple interfacing to the SR510
at 19.2 kbaud from FORTRAN programs.
To use these routines, the file 'for232.inc' (also on
the SR575 disk) must be 'included' in the
FORTRAN source.
Only two wires between the IBM PC's ASYNC
port and the SR530 are needed (pins #2 & #3 of
the RS232), but pins 5,6,8 and 20 should be
connected together on the connector at the IBM
end.
$storage:2
$include: ′for232.inc′
[ for 232.inc must be included to call subroutines in RS232.OBJ
[ link with RS232.OBJ (on SR565 disk)
[ RS232.OBJ defines:
[ init
[ initializes COM1: to 19.2 kbaud
[ txstr (str) str is a string terminated with ′$′
[ transmits str to COM1:
[ rxstr (str) str must be declared with length of 15 or greater
[ fills str with string received from COM1:
[ if and error occurs, nocom is called.
[ Nocom should be a FORTRAN subroutine in your program.
program test
character *20 str1,str2
[ Example program to read the SR510 outputs and ramp the
[ X6 analog output using Microsoft FORTRAN v3.3 and the
[ COM1: port. Set all switches in SW2 to UP on SR510
[ for 19.2 kbaud.
[ initialize COM1: port to 19.2 kbaud
call init
[ set character wait interval to zero
call txstr(′w0$′)
[ reset X6 to zero
x6=0.0
[ read output into string variable str1
20 call txstr(′q$′)
call rxstr(str1)
[ convert string variable into real variable v1
read (str1,1000) v1
1000 format (bn,f10.0)