Program samples standard basic, Visual basic – Bowers Group Sylvac Opto Instruments User Manual
Page 15

14
The instrument sends the preset value of the active reference
Enter preset. Numeric values must always be preceded by a sign.
Refer to the user’s manual of the specific instrument for special applications.
Program samples
Standard Basic
Simplex cable
Serial port opening and parameters
OPEN "COM1:4800,E, 7, 2, PE"
Power supply setting
(RTS=ON, DTR = ON)
&H3FC register addresse (COM2: &H2FC)
OUT &H3FC,&H0B
Set DTR line OFF
(RTS=ON, DTR = OFF)
OUT &H3FC,&H0A
Data reading
Line input #1,a$
Duplex cable
Serial port opening and parameters
OPEN "COM1:4800, E, 7, 2, PE"
Power supply setting
(RTS=OFF, DTR = ON)
&H3FC register addresse (COM2: &H2FC)
OUT &H3FC,&H09
Data request (
command)
PRINT #1, "?"
Data reading
LINE INPUT #1,a$
Visual Basic
The communication control (MsComm) of VisualBasic must be applied :
Port opening
' Use COM1.
Comm1.CommPort = 1
' 4800 baud, even parity, 7 data, and 2 stop bit.
Comm1.Settings = "4800,E,7,2"
' Open the port.
Comm1.PortOpen = True
P
ower supply setting
' Simplex Cable'
Form1.MSComm1.DTREnable = True
Form1.MSComm1.RTSEnable = True
' Duplex Cable'
Form1.MSComm1.DTREnable = True
Form1.MSComm1.RTSEnable = False
Data request
' Simplex Cable'
MSComm1.DTREnable = False
Timer1.Interval = 150
Timer1.Enabled = True
'Duplex cable + duplex instrument'
MSComm1.Output = "?" + Chr$(13)
'Duplex cable + simplex instrument'
MSComm1.Break = True
'Incremente Timer1.Interval in case of no transmission'
Timer1.Interval = 10
Timer1.Enabled = True
MSComm1.Break = False
Data reading
InString$ = Comm1.Input
For more information, refer to the help menu of MSComm in Visual Basic. Program available on www.sylvac.ch
web site.