RIGOL Chapter 4 Programming Instances
4-16 DL3000 Programming Guide
Visual C# Programming Instance
Program used in this instance: Microsoft Visual Studio 2010
Function realized in this example: sending the *IDN? command and reading the instrument
information.
1. Run Microsoft Visual Studio 2010, and create a project. Search for visa32.cs from the VISA installation
directory and add it to the project. Then, visa32.cs appears in the "solution manager", and other
relevant files concerning visa32 are imported.
2. First open the resource manager, and then turn on the device (you need to set the descriptor when
turning on the device).
Const string Cdevice_INSTR=@"USB0::0x1AB1::0x0E11::DL3000A000001::INSTR"
viError=visa32.viOpenDefaultRM(out viDefRm);
viError=visa32.viOpen(viDefRm,cDEVICE_INSTR,0,5000,out viSession);
3. Send requests and read data.
visa32.viPrintf(viSession,"*IND?\n");
byteReadBuf = new byte[128];
visa32.viRead(viSession,byteReadBuf,128,outretCnt);
The data to be read is in byte form, you need to convert it into strings.
StrIdn="";
For(i=0;i<retCnt;i++);
{
strIdn=strIdn+Convert.ToChar(byteReadBuf[i]);
}
4. Turn off the device and the resource manager after finishing the communication.
visa32.viClose(viSession);
visa32.viClose(viDefRm);
5. C# program
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace IDN
{
class Program
{
const string cDEVICE_INSTR = @"USB0::0x1AB1::0x0E11::DL3000A000001::INSTR";
static void Main(string[] args)
{
Int32 viError;
Int32 viDefRm;
Int32 viSession;
Int32 retCnt;
Int32 i;
String strIdn;
byte [] byteReadBuf;