Skip to content

Commit 28a4034

Browse files
Merge pull request #66 from aclary100-bit/main
Detect Service Request on Sweep Done with 2600B or 2600A trigger models
2 parents 21178ee + 959eb92 commit 28a4034

File tree

2 files changed

+104
-0
lines changed

2 files changed

+104
-0
lines changed
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
Option Explicit On
2+
3+
Imports Ivi.Visa
4+
Imports NationalInstruments.Visa
5+
Imports System.Text
6+
7+
Public Class Form1
8+
9+
'Go to Project > Add Reference > Browse
10+
'Locate And add NationalInstruments.Visa.dll
11+
'(usually found in C:\Program Files\IVI Foundation\VISA\Visa.NET Shared Components)
12+
'
13+
'Also include Ivi.Visa.Interop.dll and Ivi.Visa.dll
14+
15+
'Microsoft Visual Studio Community 2022 (64-bit) - Current Version 17.11.4
16+
'NI VISA 2025
17+
'Win11
18+
'Any 2600A or 2600B model but used 2636B, firmware 4.0.5
19+
'
20+
21+
22+
23+
Private rm As ResourceManager
24+
Private mbSession As MessageBasedSession
25+
Dim response As String
26+
27+
Dim Resource As String = "TCPIP0::192.168.0.52::INSTR"
28+
29+
Dim eventOccured As Boolean = False
30+
Dim statusByte As Short
31+
32+
Dim commandList As New List(Of String) From {"reset()",
33+
"errorqueue.clear()",
34+
"status.reset()",
35+
"status.operation.enable = status.operation.SWEEPING",
36+
"status.operation.sweeping.enable = status.operation.sweeping.SMUA",
37+
"status.operation.sweeping.ptr = 0",
38+
"status.operation.sweeping.ntr = status.operation.sweeping.SMUA",
39+
"status.node_enable = status.OSB",
40+
"status.request_enable = status.OSB",
41+
"smua.nvbuffer1.clear()",
42+
"smua.nvbuffer1.appendmode = 1",
43+
"smua.nvbuffer1.collectsourcevalues = 1",
44+
"smua.nvbuffer2.clear()",
45+
"smua.nvbuffer2.appendmode = 1",
46+
"smua.nvbuffer2.collectsourcevalues = 1",
47+
"smua.measure.delay = 0.1", 'slow down the sweep
48+
"smua.trigger.source.action = smua.ENABLE",
49+
"smua.trigger.source.linearv(-1.0, 1.0, 21)",
50+
"smua.trigger.count = 21", ' make tthis same and number of source values
51+
"smua.trigger.measure.action = smua.ENABLE",
52+
"smua.trigger.measure.iv(smua.nvbuffer1, smua.nvbuffer2)",
53+
"smua.source.output = 1",
54+
"smua.trigger.initiate()"}
55+
56+
57+
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
58+
59+
rm = New ResourceManager()
60+
61+
mbSession = rm.Open(Resource)
62+
mbSession.TerminationCharacter = &H10 ' line feed in hex for Byte data type
63+
mbSession.TerminationCharacterEnabled = True ' add LF terminator to each write
64+
65+
mbSession.RawIO.Write("*idn?")
66+
TextBox1.Text = mbSession.RawIO.ReadString()
67+
68+
69+
For Each cmd As String In commandList
70+
mbSession.RawIO.Write(cmd)
71+
Next
72+
73+
' poll until the SRQ is asserted at Sweep completion
74+
statusByte = mbSession.ReadStatusByte()
75+
Debug.Print(statusByte)
76+
Do While ((statusByte And 64) <> 64) ' 64 = 2^6 = MSS bit in status.conditon register = 1
77+
statusByte = mbSession.ReadStatusByte()
78+
Application.DoEvents()
79+
Debug.Print(statusByte)
80+
Threading.Thread.Sleep(100)
81+
Loop
82+
83+
84+
mbSession.RawIO.Write("smua.source.output = 0")
85+
mbSession.RawIO.Write("status.reset()")
86+
87+
mbSession.RawIO.Write("beeper.beep(0.5, 1200)") ' duration and freq of beep
88+
Threading.Thread.Sleep(500)
89+
90+
91+
mbSession.RawIO.Write("printbuffer(1, smua.nvbuffer1.n, smua.nvbuffer1.readings, smua.nvbuffer1.sourcevalues)")
92+
Dim rawData As String = mbSession.RawIO.ReadString()
93+
Debug.Print(rawData)
94+
95+
mbSession.Clear()
96+
97+
mbSession.Dispose()
98+
rm.Dispose()
99+
100+
TextBox1.Text = "All Done"
101+
102+
103+
End Sub
104+
End Class

0 commit comments

Comments
 (0)