' ----------------- IWATSU SG-4115 -----------------------------
Dim BaseColor As Long
Dim talker As Long, stbyte As Long
Dim AdrComp As Integer, Adr4115 As Integer
Dim Pstb(31) As Long ' 返送されたステータスバイト配列
Dim Cmd(31) As Long, CmdR(31) As Long
Dim Amp As String * 8, Vol As Single
Dim Freq As String * 10, Hz As Single
Dim Wave_mode As String * 4, Wave_old As String * 2, Power_Status As String * 1
Dim L As Integer
Private Sub Form_Load()
Form1.Show
Form2.Show
AdrComp = 0 'Computer Address
Adr4115 = 4 'SG-4115 Address
'--------------------------------------------------------------------------------------------
e1 = GpIni(): 'GPIB 初期化
e2 = GpIfc(1): 'インターフェイスクリア (1×100μsec)
e3 = GpRen(): 'GPIB remote enable
Cmd(0) = 1 ' トーカ数
Cmd(1) = Adr4115 ' トーカアドレス
e7 = GpPoll(Cmd(0), Pstb(0)) ' ポーリング
talker = Cmd(Pstb(0)) '
stbyte = Pstb(Pstb(0)) '
e4 = GpDelim(1, 1) 'Delimiter [1: CR+LF / 1: EOI valid]
e5 = GpTimeout(2000) 'Timeout (2000×1msec)
e6 = GpSdc(Adr4115) 'SDC (Select Device Clear)
'----- Frequency -------------------------------------------------------------------------------------
Cmd(0) = 2 'talker + listener
Cmd(1) = AdrComp 'talker address (GPIB)
Cmd(2) = Adr4115 'listener address(SG-4115)
e = GpTalk(Cmd(0), 11, ":OUT1:FREQ?") 'Frequency
For I = 1 To 100000: y = Sin(1#): Next I 'waiting time
CmdR(0) = 2 'talker + listener
CmdR(1) = Adr4115 'talker address (SG-4115)
CmdR(2) = AdrComp 'listener address (GPIB)
e = GpListen(CmdR(0), 10, Freq)
Hz = Val(Freq)
Text9.Text = Hz
'----- Voltage -------------------------------------------------------------------------------
For I = 1 To 100000: y = Sin(1#): Next I 'waiting time
Cmd(0) = 2 'talker + listener
Cmd(1) = AdrComp 'talker address (GPIB)
Cmd(2) = Adr4115 'listener address(SG-4115)
e = GpTalk(Cmd(0), 11, ":OUT1:AMPL?") 'Amplitude
For I = 1 To 100000: y = Sin(1#): Next I 'waiting time
CmdR(0) = 2 ' talker + listener
CmdR(1) = Adr4115 'talker address (SG-4115)
CmdR(2) = AdrComp 'listener address (GPIB)
e = GpListen(CmdR(0), 8, Amp)
Vol = Val(Amp)
Text8.Text = Vol
'----- Wave Mode --------------------------------------------------------------------------------
For I = 1 To 100000: y = Sin(1#): Next I 'waiting time
Cmd(0) = 2 'talker + listener
Cmd(1) = AdrComp 'talker address (GPIB)
Cmd(2) = Adr4115 'listener address(SG-4115)
e = GpTalk(Cmd(0), 11, ":OUT1:FUNC?") 'Generator Wave function
For I = 1 To 100000: y = Sin(1#): Next I 'waiting time
CmdR(0) = 2 ' talker + listener
CmdR(1) = Adr4115 'talker address (SG-4115)
CmdR(2) = AdrComp 'listener address (GPIB)
e = GpListen(CmdR(0), 4, Wave_mode)
a$ = Left$(Wave_mode, 2)
If a$ = "SI" Then
Command5.BackColor = vbGreen
Command5.Enabled = False
ElseIf a$ = "PU" Then
Command6.BackColor = vbGreen
Command6.Enabled = False
ElseIf a$ = "SQ" Then
Command7.BackColor = vbGreen
Command7.Enabled = False
ElseIf a$ = "DC" Then
Command8.BackColor = vbGreen
Command8.Enabled = False
End If
'-------- Output status ------------------------------------------------
For I = 1 To 100000: y = Sin(1#): Next I 'waiting time
Cmd(0) = 2 'talker + listener
Cmd(1) = AdrComp 'talker address (GPIB)
Cmd(2) = Adr4115 'listener address(SG-4115)
e = GpTalk(Cmd(0), 11, ":OUT1:OUTP?") ' 1: on / 2: off
For I = 1 To 100000: y = Sin(1#): Next I 'waiting time
CmdR(0) = 2 ' talker + listener
CmdR(1) = Adr4115 'talker address (SG-4115)
CmdR(2) = AdrComp 'listener address (GPIB)
e = GpListen(CmdR(0), 1, Power_Status)
BaseColor = Command1.BackColor
If Power_Status = "1" Then
Command1.BackColor = vbGreen
Command2.BackColor = BaseColor
Command1.Enabled = False
Else
Command1.BackColor = BaseColor
Command2.BackColor = vbRed
Command2.Enabled = False
End If
'-----------------------------------------------------------------------------------------------------
If e1 <> 0 Then Text1.Text = "GP-IB intialization Failed"
Else Text1.Text = "GP-IB intialization OK"
If e2 <> 0 Then Text2.Text = "Interface Clear Failed"
Else Text2.Text = "Interface Clear OK"
If e3 <> 0 Then Text3.Text = "GP-IB Remote Enable Failed" Else Text3.Text = "GP-IB Remote Enable OK"
If e4 <> 0 Then Text4.Text = "Delimiter Failed" Else
Text4.Text = "Delimiter OK"
If e5 <> 0 Then Text5.Text = "Timeout (2sec) Failed"
Else Text5.Text = "Timeout (2msec) OK"
If e6 <> 0 Then Text6.Text = "Select Device Clear Failed" Else Text6.Text = "Select Device Clear OK"
If e7 <> 0 Then Text7.Text = "Polling Failed => "
& e7 Else Text7.Text = "Polling OK"
'-----------------------------------------------------------------------------------------------------
End Sub
Private Sub Command1_Click()
Command1.Enabled = False
Command1.BackColor = vbGreen
Command2.BackColor = BaseColor
Hz = Text9.Text
Freq = Str$(Hz)
Cmd(0) = 2 'talker + listener
Cmd(1) = AdrComp 'talker address (GPIB)
Cmd(2) = Adr4115 'listener address(SG-4115)
L = Len(Wave_mode)
e = GpTalk(Cmd(0), 11 + L, ":OUT1:FUNC " + Wave_mode) 'Frequency
For I = 1 To 30000: y = Sin(1#): Next I 'waiting time
L = Len(Amp)
e = GpTalk(Cmd(0), 11 + L, ":OUT1:AMPL " + Amp) 'Amplitude
For I = 1 To 30000: y = Sin(1#): Next I 'waiting time
L = Len(Freq)
e = GpTalk(Cmd(0), 11 + L, ":OUT1:FREQ " + Freq) 'Frequency
For I = 1 To 30000: y = Sin(1#): Next I 'waiting time
e = GpTalk(Cmd(0), 13, ":OUT1:OUTP ON")
a$ = Left$(Wave_mode, 2)
If a$ = "SI" Then Command5.BackColor = vbGreen
If a$ = "PU" Then Command6.BackColor = vbGreen
If a$ = "SQ" Then Command7.BackColor = vbGreen
If a$ = "DC" Then Command8.BackColor = vbGreen
If Wave_old = "SI" Then Command5.BackColor = BaseColor
If Wave_old = "PU" Then Command6.BackColor = BaseColor
If Wave_old = "SQ" Then Command7.BackColor = BaseColor
If Wave_old = "DC" Then Command8.BackColor = BaseColor
Command2.Enabled = True
End Sub
Private Sub Command9_Click()
If Command1.Enabled = False Then
Hz = Text9.Text
Freq = Str$(Hz)
Cmd(0) = 2 'talker + listener
Cmd(1) = AdrComp 'talker address (GPIB)
Cmd(2) = Adr4115 'listener address(SG-4115)
L = Len(Wave_mode)
e = GpTalk(Cmd(0), 11 + L, ":OUT1:FUNC " + Wave_mode) 'Frequency
For I = 1 To 30000: y = Sin(1#): Next I 'waiting time
L = Len(Amp)
e = GpTalk(Cmd(0), 11 + L, ":OUT1:AMPL " + Amp) 'Amplitude
For I = 1 To 30000: y = Sin(1#): Next I 'waiting time
L = Len(Freq)
e = GpTalk(Cmd(0), 11 + L, ":OUT1:FREQ " + Freq) 'Frequency
a$ = Left$(Wave_mode, 2)
If a$ = "SI" Then Command5.BackColor = vbGreen
If a$ = "PU" Then Command6.BackColor = vbGreen
If a$ = "SQ" Then Command7.BackColor = vbGreen
If a$ = "DC" Then Command8.BackColor = vbGreen
If Wave_old = "SI" Then Command5.BackColor = BaseColor
If Wave_old = "PU" Then Command6.BackColor = BaseColor
If Wave_old = "SQ" Then Command7.BackColor = BaseColor
If Wave_old = "DC" Then Command8.BackColor = BaseColor
End If
End Sub
Private Sub Command2_Click()
Command2.Enabled = False
Command2.BackColor = vbRed
Command1.BackColor = BaseColor
Cmd(0) = 2 'talker + listener
Cmd(1) = AdrComp 'talker address (GPIB)
Cmd(2) = Adr4115 'listener address(SG-4115)
e = GpTalk(Cmd(0), 14, ":OUT1:OUTP OFF")
Command1.Enabled = True
End Sub
Private Sub Command3_Click()
If Vol > 0 Then
Vol = Vol - 0.1
Vol = Int(Vol * 1000 + 0.5) / 1000
Text8.Text = Vol
Amp = Str$(Vol)
End If
End Sub
Private Sub Command4_Click()
If Vol < 4 Then
Vol = Vol + 0.1
Vol = Int(Vol * 1000 + 0.5) / 1000
Text8.Text = Vol
Amp = Str$(Vol)
End If
End Sub
Private Sub Command5_Click()
a$ = Left$(Wave_mode, 2)
Wave_old = a$
If a$ <> "SI" Then
Command5.BackColor = vbYellow
Command5.Enabled = False
Wave_mode = "SIN"
Command6.BackColor = BaseColor ' PU
Command7.BackColor = BaseColor ' SQ
Command8.BackColor = BaseColor ' DC
Command6.Enabled = True
Command7.Enabled = True
Command8.Enabled = True
If Wave_old = "PU" Then Command6.BackColor = vbGreen
If Wave_old = "SQ" Then Command7.BackColor = vbGreen
If Wave_old = "DC" Then Command8.BackColor = vbGreen
End If
End Sub
Private Sub Command6_Click()
a$ = Left$(Wave_mode, 2)
Wave_old = a$
If a$ <> "PU" Then
Command6.BackColor = vbYellow
Command6.Enabled = False
Wave_mode = "PULS"
Command5.BackColor = BaseColor
Command7.BackColor = BaseColor
Command8.BackColor = BaseColor
Command5.Enabled = True
Command7.Enabled = True
Command8.Enabled = True
If Wave_old = "SI" Then Command5.BackColor = vbGreen
If Wave_old = "SQ" Then Command7.BackColor = vbGreen
If Wave_old = "DC" Then Command8.BackColor = vbGreen
End If
End Sub
Private Sub Command7_Click()
a$ = Left$(Wave_mode, 2)
Wave_old = a$
If a$ <> "SQ" Then
Command7.BackColor = vbYellow
Command7.Enabled = False
Wave_mode = "SQU"
Command5.BackColor = BaseColor
Command6.BackColor = BaseColor
Command8.BackColor = BaseColor
Command5.Enabled = True
Command6.Enabled = True
Command8.Enabled = True
If Wave_old = "SI" Then Command5.BackColor = vbGreen
If Wave_old = "PU" Then Command6.BackColor = vbGreen
If Wave_old = "DC" Then Command8.BackColor = vbGreen
End If
End Sub
Private Sub Command8_Click()
a$ = Left$(Wave_mode, 2)
Wave_old = a$
If a$ <> "DC" Then
Command8.BackColor = vbYellow
Command8.Enabled = False
Wave_mode = "DC"
Command5.BackColor = BaseColor
Command6.BackColor = BaseColor
Command7.BackColor = BaseColor
Command5.Enabled = True
Command6.Enabled = True
Command7.Enabled = True
If Wave_old = "SI" Then Command5.BackColor = vbGreen
If Wave_old = "PU" Then Command6.BackColor = vbGreen
If Wave_old = "SQ" Then Command7.BackColor = vbGreen
End If
End Sub
Private Sub form_unload(cancel As Integer)
Unload Form1
Unload Form2
Call Command2_Click
e = GpResetren()
e = GpExit()
End Sub