usb-6009
This commit is contained in:
105
NI-VISA/Examples/VB6/General/FindRsrc.frm
Normal file
105
NI-VISA/Examples/VB6/General/FindRsrc.frm
Normal file
@ -0,0 +1,105 @@
|
||||
VERSION 5.00
|
||||
Begin VB.Form Form1
|
||||
Caption = "Form1"
|
||||
ClientHeight = 405
|
||||
ClientLeft = 255
|
||||
ClientTop = 10470
|
||||
ClientWidth = 1800
|
||||
LinkTopic = "Form1"
|
||||
PaletteMode = 1 'UseZOrder
|
||||
ScaleHeight = 405
|
||||
ScaleWidth = 1800
|
||||
End
|
||||
Attribute VB_Name = "Form1"
|
||||
Attribute VB_GlobalNameSpace = False
|
||||
Attribute VB_Creatable = False
|
||||
Attribute VB_PredeclaredId = True
|
||||
Attribute VB_Exposed = False
|
||||
|
||||
Private Sub Form_Initialize()
|
||||
MsgBox ("This program finds all of the resources present in the system and displays the instrument descriptor for each resource. The program displays the status of each command in the debug window when run.")
|
||||
End Sub
|
||||
|
||||
Private Sub Form_KeyPress(KeyAscii As Integer)
|
||||
End
|
||||
End Sub
|
||||
|
||||
'
|
||||
' In Visual Basic 5 the VISA library can be referenced by choosing Project >> References
|
||||
' and selecting Visa Library from the list (you may first need to browse for visa32.dll).
|
||||
' This allows the VISA functions and VISA data types to be used in a program.
|
||||
'
|
||||
' This code finds all of the resources in the system and displays
|
||||
' the instrument descriptor for each resource.
|
||||
' This code uses only VISA functions. The status of each VISA function
|
||||
' is displayed in the debugging window along with the data read
|
||||
' by the instrument.
|
||||
'
|
||||
' The general flow of the code is:
|
||||
' Open Resource Manager
|
||||
' Find the first available resource and display its descriptor
|
||||
' Display the descriptors for each additional resource
|
||||
' Close the VISA session
|
||||
' Close the Resource Manager
|
||||
|
||||
Private Sub Form_Load()
|
||||
|
||||
Dim defaultRM As ViSession
|
||||
Dim status As ViStatus
|
||||
Dim response As String * VI_FIND_BUFLEN
|
||||
Dim descriptor As String * VI_FIND_BUFLEN
|
||||
Dim nlist As ViFindList
|
||||
Dim count As ViUInt32
|
||||
Dim x As Long
|
||||
|
||||
' First we must call viOpenDefaultRM to get the manager handle
|
||||
' We will store this handle in defaultRM. The function viStatusDesc
|
||||
' returns a text description of the status code returned by viOpenDefaultRM
|
||||
|
||||
status = viOpenDefaultRM(defaultRM)
|
||||
status = viStatusDesc(defaultRM, status, response)
|
||||
Debug.Print "viOpenDefaultRM", Hex(status), response
|
||||
|
||||
' Next we use the viFindRsrc command to tell VISA to search for all
|
||||
' available resources in the system. The instrument descriptor for the
|
||||
' first resource is returned along with the number of resources found.
|
||||
|
||||
status = viFindRsrc(defaultRM, "?*INSTR", nlist, count, descriptor)
|
||||
status = viStatusDesc(defaultRM, status, response)
|
||||
Debug.Print "viFindRsrc", Hex(status), response
|
||||
Debug.Print "The number of resources found was", count
|
||||
|
||||
If (count = 0) Then
|
||||
Debug.Print "No resources were found"
|
||||
Else
|
||||
Debug.Print "The first resource is", descriptor
|
||||
End If
|
||||
|
||||
' Now we will use the viFindNext command to retrieve each of the
|
||||
' instrument descriptors for the remaining resources.
|
||||
x = 1
|
||||
|
||||
While (x < count)
|
||||
status = viFindNext(nlist, descriptor)
|
||||
status = viStatusDesc(defaultRM, status, response)
|
||||
Debug.Print "viFindNext", Hex(status), response
|
||||
Debug.Print "The next resource is", descriptor
|
||||
x = x + 1
|
||||
Wend
|
||||
|
||||
' Now we will close the VISA Resource Manager and the
|
||||
' list of found resources.
|
||||
|
||||
status = viClose(nlist)
|
||||
status = viStatusDesc(defaultRM, status, response)
|
||||
Debug.Print "viClose", Hex(status), response
|
||||
|
||||
status = viClose(defaultRM)
|
||||
status = viStatusDesc(defaultRM, status, response)
|
||||
Debug.Print "viClose", Hex(status), response
|
||||
|
||||
Debug.Print "Hit any key to quit"
|
||||
|
||||
End Sub
|
||||
|
||||
|
34
NI-VISA/Examples/VB6/General/FindRsrc.vbp
Normal file
34
NI-VISA/Examples/VB6/General/FindRsrc.vbp
Normal file
@ -0,0 +1,34 @@
|
||||
Type=Exe
|
||||
Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#c:\windows\system32\stdole2.tlb#OLE Automation
|
||||
Reference=*\G{39C32428-25DB-11D0-85B4-0020AF33DEAE}#0.0#0#c:\windows\system32\visa32.dll#VISA Library
|
||||
Form=FindRsrc.frm
|
||||
Startup="Form1"
|
||||
HelpFile=""
|
||||
Command32=""
|
||||
Name="Project1"
|
||||
HelpContextID="0"
|
||||
CompatibleMode="0"
|
||||
MajorVer=1
|
||||
MinorVer=0
|
||||
RevisionVer=0
|
||||
AutoIncrementVer=0
|
||||
ServerSupportFiles=0
|
||||
VersionCompanyName="NI"
|
||||
CompilationType=-1
|
||||
OptimizationType=0
|
||||
FavorPentiumPro(tm)=0
|
||||
CodeViewDebugInfo=0
|
||||
NoAliasing=0
|
||||
BoundsCheck=0
|
||||
OverflowCheck=0
|
||||
FlPointCheck=0
|
||||
FDIVCheck=0
|
||||
UnroundedFP=0
|
||||
StartMode=0
|
||||
Unattended=0
|
||||
Retained=0
|
||||
ThreadPerObject=0
|
||||
MaxNumberOfThreads=1
|
||||
|
||||
[MS Transaction Server]
|
||||
AutoRefresh=1
|
135
NI-VISA/Examples/VB6/Vxi-vme/visahigh.frm
Normal file
135
NI-VISA/Examples/VB6/Vxi-vme/visahigh.frm
Normal file
@ -0,0 +1,135 @@
|
||||
VERSION 5.00
|
||||
Begin VB.Form Form1
|
||||
Caption = "Form1"
|
||||
ClientHeight = 285
|
||||
ClientLeft = 1125
|
||||
ClientTop = 10350
|
||||
ClientWidth = 1725
|
||||
LinkTopic = "Form1"
|
||||
PaletteMode = 1 'UseZOrder
|
||||
ScaleHeight = 285
|
||||
ScaleWidth = 1725
|
||||
End
|
||||
Attribute VB_Name = "Form1"
|
||||
Attribute VB_GlobalNameSpace = False
|
||||
Attribute VB_Creatable = False
|
||||
Attribute VB_PredeclaredId = True
|
||||
Attribute VB_Exposed = False
|
||||
Private Sub Form_Initialize()
|
||||
MsgBox ("This program writes to and reads from the configuration registers of a VXI device at logical address zero. It requires the vpptype.bas and visa32.bas modules to be included in the project to run. The program displays the status of each command in the debug window when run.")
|
||||
End Sub
|
||||
|
||||
Private Sub Form_KeyPress(KeyAscii As Integer)
|
||||
End
|
||||
End Sub
|
||||
|
||||
'
|
||||
' For this code to run, the files visa32.bas and vpptype.bas
|
||||
' must be added to the project. These files should have been
|
||||
' installed with VISA.
|
||||
'
|
||||
' This code reads and writes the offset register of the
|
||||
' device at logical address 0. To do this, the code reads
|
||||
' the register at 0xC006 in A16 space, the writes the value
|
||||
' back to the same register. Then it moves the first four
|
||||
' configuation registers into local RAM and displays this
|
||||
' in the Debug.Print window. This code uses only VISA functions.
|
||||
'
|
||||
' The general flow of the code is:
|
||||
' Open Resource Manager
|
||||
' Open VISA session to the instrument at LA 0
|
||||
' Read the offset register
|
||||
' Write the same value back to the offset register
|
||||
' Move in the first 4 configuration registers
|
||||
' Close VISA session
|
||||
'
|
||||
Private Sub Form_Load()
|
||||
|
||||
Dim defaultRM As Long
|
||||
Dim status As Long
|
||||
Dim vinstr As Long
|
||||
Dim response As String * 256
|
||||
Dim offset As Long
|
||||
Dim value As Integer
|
||||
Dim count As Long
|
||||
Dim data(0 To 3) As Integer
|
||||
|
||||
' First we must call viOpenDefaultRM to get the manager handle
|
||||
' We will store this handle in defaultRM
|
||||
|
||||
status = viOpenDefaultRM(defaultRM)
|
||||
status = viStatusDesc(defaultRM, status, response)
|
||||
Debug.Print "viOpenDefaultRM", Hex(status), response
|
||||
|
||||
' To open a session we must use the resource manager handle from
|
||||
' viOpenDefaultRM, and we must use a string which will
|
||||
' indicate which instrument to open. This is called the
|
||||
' instrument descriptor. The format for this string can be
|
||||
' found in the NI-VISA programmers reference manual. After
|
||||
' opening a session to the device, we will get a handle to the
|
||||
' instrument which we will use in later VISA functions. The
|
||||
' two parameters in this function which are 0 are reserved
|
||||
' for future functionality.
|
||||
|
||||
status = viOpen(defaultRM, "VXI0::0::INSTR", 0, 0, vinstr)
|
||||
status = viStatusDesc(defaultRM, status, response)
|
||||
Debug.Print "viOpen", Hex(status), response
|
||||
|
||||
' Now we will read in the offset register and display it on
|
||||
' the screen. We must use the session handle to the instrument
|
||||
' from the viOpen function. We will be reading 16 bits by using
|
||||
' the viIn16 function.
|
||||
|
||||
offset = 6 ' offset in A16 space from the base of device memory
|
||||
|
||||
' Note that the offset is relative to the base of the device's
|
||||
' memory space, not the base of the entire address space.
|
||||
|
||||
status = viIn16(vinstr, VI_A16_SPACE, offset, value)
|
||||
status = viStatusDesc(defaultRM, status, response)
|
||||
Debug.Print "viIn16", Hex(status), response
|
||||
Debug.Print "Register at offset 6", Hex(value)
|
||||
|
||||
' Now we will write out the value just read with the viOut16
|
||||
' function. We will write this to the offset register for the device at
|
||||
' logical address 0 using the instrument handle we acquired
|
||||
' from viOpen.
|
||||
|
||||
status = viOut16(vinstr, VI_A16_SPACE, offset, value)
|
||||
status = viStatusDesc(defaultRM, status, response)
|
||||
Debug.Print "viOut16", Hex(status), response
|
||||
|
||||
' Now we will move the first 4 configuration registers into local
|
||||
' memory. This will be done using viMoveIn16. We will move all
|
||||
' data into memory starting at the base address specified by "data(0)"
|
||||
|
||||
offset = 0 ' we want to get data from 0xC000-0xC007
|
||||
count = 4 ' move 4 16-bit pieces of data
|
||||
|
||||
status = viMoveIn16(vinstr, VI_A16_SPACE, offset, count, data(0))
|
||||
status = viStatusDesc(defaultRM, status, response)
|
||||
Debug.Print "viMoveIn16", Hex(status), response
|
||||
|
||||
Debug.Print "Register at offset 0", Hex(data(0))
|
||||
Debug.Print "Register at offset 2", Hex(data(1))
|
||||
Debug.Print "Register at offset 4", Hex(data(2))
|
||||
Debug.Print "Register at offset 6", Hex(data(3))
|
||||
|
||||
' Now we must close the session to the instrument using
|
||||
' viClose. We must tell VISA what to close by use of the
|
||||
' instrument handle, "vinstr". We will also close the VISA
|
||||
' Resource Manager.
|
||||
|
||||
status = viClose(vinstr)
|
||||
status = viStatusDesc(defaultRM, status, response)
|
||||
Debug.Print "viClose", Hex(status), response
|
||||
|
||||
status = viClose(defaultRM)
|
||||
status = viStatusDesc(defaultRM, status, response)
|
||||
Debug.Print "viClose", Hex(status), response
|
||||
|
||||
Debug.Print "Hit any key to quit."
|
||||
|
||||
End Sub
|
||||
|
||||
|
43
NI-VISA/Examples/VB6/Vxi-vme/visahigh.vbp
Normal file
43
NI-VISA/Examples/VB6/Vxi-vme/visahigh.vbp
Normal file
@ -0,0 +1,43 @@
|
||||
Type=Exe
|
||||
Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\WINDOWS\system32\STDOLE2.TLB#Standard OLE Types
|
||||
Reference=*\G{EE008642-64A8-11CE-920F-08002B369A33}#1.0#0#C:\WINDOWS\system32\MSRDO20.DLL#Microsoft Remote Data Object 1.0
|
||||
Reference=*\G{39C32428-25DB-11D0-85B4-0020AF33DEAE}#3.1#0#C:\WINDOWS\system32\visa32.dll#VISA Library
|
||||
Object={F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0; comdlg32.ocx
|
||||
Object={BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0; TABCTL32.OCX
|
||||
Object={3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0; richtx32.ocx
|
||||
Object={6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0; comctl32.ocx
|
||||
Object={FAEEE763-117E-101B-8933-08002B2F4F5A}#1.1#0; DBLIST32.OCX
|
||||
Object={00028C01-0000-0000-0000-000000000046}#1.0#0; DBGRID32.OCX
|
||||
Object={F6125AB1-8AB1-11CE-A77F-08002B2F4E98}#2.0#0; MSRDC20.OCX
|
||||
Form=visahigh.frm
|
||||
IconForm="Form1"
|
||||
Startup="Form1"
|
||||
HelpFile=""
|
||||
Command32=""
|
||||
Name="Project1"
|
||||
HelpContextID="0"
|
||||
CompatibleMode="0"
|
||||
MajorVer=1
|
||||
MinorVer=0
|
||||
RevisionVer=0
|
||||
AutoIncrementVer=0
|
||||
ServerSupportFiles=0
|
||||
VersionCompanyName="National Instruments"
|
||||
CompilationType=0
|
||||
OptimizationType=0
|
||||
FavorPentiumPro(tm)=0
|
||||
CodeViewDebugInfo=0
|
||||
NoAliasing=0
|
||||
BoundsCheck=0
|
||||
OverflowCheck=0
|
||||
FlPointCheck=0
|
||||
FDIVCheck=0
|
||||
UnroundedFP=0
|
||||
StartMode=0
|
||||
Unattended=0
|
||||
Retained=0
|
||||
ThreadPerObject=0
|
||||
MaxNumberOfThreads=1
|
||||
|
||||
[MS Transaction Server]
|
||||
AutoRefresh=1
|
Reference in New Issue
Block a user