Visual C# Sample Program
Sample program of settings and queries
// Create VISA ResourceManager object
VisaComLib.ResourceManager rm = new VisaComLib.ResourceManager();
VisaComLib.AccessMode accessMode = VisaComLib.AccessMode.NO_LOCK;
// Serial number of the programmable AC/DC power source
string serial = "0123456";
int timeOut = 0;
string optionString = "";
// Connect with the device
VisaComLib.IMessage msg = (VisaComLib.IMessage)rm.Open(
"USB0::0x0D4A::12::" + serial + "::INSTR",
accessMode,
timeOut,
optionString);
// Set the frequency as 50.0Hz, and ask the value
msg.WriteString(":FREQ 50.0;:FREQ?\n");
Console.WriteLine(msg.ReadString(256));
// Close the device
msg.Close();
Sample program of transferring ARB data
// Create VISA ResourceManager object
VisaComLib.ResourceManager rm = new VisaComLib.ResourceManager();
VisaComLib.AccessMode accessMode = VisaComLib.AccessMode.NO_LOCK;
// Serial number of the programmable AC/DC power source
string serial = "0123456";
int timeOut = 0;
string optionString = "";
// Connect with the device
VisaComLib.IMessage msg = (VisaComLib.IMessage)rm.Open(
"USB0::0x0D4A::12::" + serial + "::INSTR",
accessMode,
timeOut,
optionString);
// Create the waveform data
int[] buff = new int[4096];
double p = 2 * Math.PI / 4096;
for (int i = 0; i < 4096; ++i)
{
buff[i] = (int)(Math.Sin(p * i) * 16383);
}
// Convert the message and the waveform data into byte data
Array data = new byte[9000];
string message = ":TRACe ARB1,#48192";
int j;
for (j = 0; j < message.Length; j++)
{
byte b = (byte)message[j];
data.SetValue(b, j);
}
for (int i = 0; i < 4096; ++i)
{
byte b = (byte)((buff[i] >> 8) & 0x00FF);
data.SetValue(b, j++);
b = (byte)(buff[i] & 0x00FF);
data.SetValue(b, j++);
}
// Transfer the data
msg.Write(ref data, message.Length + 8192);
// Close the device
msg.Close();