Visual C++ Programming Example - Rigol DG800 Pro Series Programming Manual

Function/arbitrary waveform generator
Hide thumbs Also See for DG800 Pro Series:
Table of Contents

Advertisement

Programming Examples
5. Double-click CH1 to enter the programming environment. Add the following
codes to control CH1-CH2. The codes of CH1 are as shown below; the codes of the
other channel are similar.
Dim defrm As Long
Dim vi As Long
Dim strRes As String * 200
Dim list As Long
Dim nmatches As Long
Dim matches As String * 200 'Reserve the obtained device number
Dim s32Disp As Integer
' Obtain the usb resource of visa
Call viOpenDefaultRM(defrm)
Call viFindRsrc(defrm, "USB?*", list, nmatches, matches)
' Turn on the instrument
Call viOpen(defrm, matches, 0, 0, vi)
' Send a command to query the status of CH1
Call viVPrintf(vi, ":OUTP1:STAT?" + Chr$(10), 0)
' Obtain the status of CH1
Call viVScanf(vi, "%t", strRes)
s32Disp = CInt(strRes)
If (s32Disp = 1) Then
' Send the setting command
Call viVPrintf(vi, ":OUTP1:STAT 0" + Chr$(10), 0)
Label1(0).ForeColor = &H808080 'Gray
Else
Call viVPrintf(vi, ":OUTP1:STAT 1" + Chr$(10), 0)
Label1(0).ForeColor = &HFFFF& 'Yellow
End If
' Close the resource
Call viClose(vi)
Call viClose(defrm)
6. Save and run the project to obtain a single exe program for demo. When the
instrument is correctly connected to the PC, you can control the on/off status of
either channel.
5.4

Visual C++ Programming Example

Program used in this example:Visual C++6.0
Function realized in this example:search for the instrument address, connect to the
instrument, send commands, and read return values.
Enter the Visual C++6.0 programming environment, and perform the following
procedures.
1. Create a MFC project based on a dialog box.
2. Click Project > Settings to open the Project Setting dialog box. In the dialog box,
click the C/C++ tab, select Code Generation from the drop-down list under
Category. Choose Debug Multithreaded DLL from the drop-down list under Use
run-time library. Click OK to close the dialog box.
DG800 Pro/DG900 Pro Programming
Guide
202
Copyright ©RIGOL TECHNOLOGIES CO., LTD. All rights reserved.

Advertisement

Table of Contents
loading

Table of Contents