Code: Select all
'file: HP1_rs232.bas 16 dec 09 modified 22aug19
'XP, null modem cable, HP34401A
'baud on meter set to 9600
'working code thks to Phishguy & Nobozoz
'linux code thks to Phishguy
'read two consecutive voltages from HP meter set to 10V full scale
Dim as string resp, scom
Dim V as Single
dim j as Integer
'9600 baud,even parity, 7 bits,2 stop bits
'rs = supress detection of request to send(RTS) signal
'CDn' Set the Data Carrier Datect(DCD line) duration (in ms) (n>=0), 0 = turn off
'LF = Communicate in ASCII mode (add LF to every CR) - Win32 doesn't support this one
'PE = enable parity check
'CSn' Set the CTS duration (in ms) (n>=0), 0 = turn off, default = 1000
'DSn' Set the DSR duration (in ms) (n>=0), 0 = turn off, default = 1000
'TBn' Set the 'Transmit Buffer' size (n>=0), 0 = default, depends on platform
'RBn' Set the 'Receive Buffer' size (n>=0), 0 = default, depends on platform
'BIN' The opposite of LF and it'll always work
'scom = "com1:9600,7,2,cs0,ds0,cd0,rs,LF" 'Windows cs0 ds0->req'd' 'TB8192,RB8192"
scom = "/dev/ttyS0:9600,e,7,2,cs0,ds0,cd0,rs" 'Linux
Open Com scom AS 1
Print #1, "*CLS"
Print #1, ":SYST:REM" 'System:Remote Sleep absolutely necessary w >1Ghz CPU
Print #1,":CONF:VOLT:DC 10,.001"
sleep 500 'Sleep absolutely necessary w >1Ghz CPU, 30 intermittent
'use > 30 to be safe
for j = 1 to 2
Print #1, ":READ?"
Print Using "##.####";V