Model 2306-LAN Communications and Firmware Upgrade Instructions
8
071377001
April
2022
VXI-11 protocol C# example
When you use the VXI-11 protocol to communicate with a 2306-LAN instrument, use the C# (C-sharp)
programming language using the following example (in the order indicated) to program your instrument.
1. Open resource.
2. Configure resource.
3. Send a command or READ data.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Ivi.Visa;
namespace Idn
{
class Program
{
static void Main(string[] args)
{
var system_dmm
=(Ivi.Visa.IMessageBasedSession)
Ivi.Visa.GlobalResourceManager.
Open ("TCPIP0::192.168.0.2::inst0::INSTR");
// Set timeout value to 60 seconds
system_dmm.TimeoutMilliseconds = 60000;
system_dmm.SendEndEnabled = true;
system_dmm.TerminationCharacterEnabled = true;
//return character
system_dmm.TerminationCharacter = 0xa;
//system_dmm.FormattedIO.WriteLine("*rst");
//system_dmm.FormattedIO.WriteLine("*cls");
system_dmm.FormattedIO.WriteLine("*IDN?");
Console.WriteLine("\nInstrumnet ID: {0}\n",
system_dmm.FormattedIO.ReadLine());
Console.WriteLine("\nSet and output Sour1 volt to 1V ,and Sour2 volt to 2V\n");
system_dmm.FormattedIO.WriteLine(":sour:volt 1;:output on;:sour2:volt 2;
:output2 on");
system_dmm.FormattedIO.WriteLine("read?;");
Console.WriteLine("\nSour1 volt value: {0} ", system_dmm.FormattedIO.ReadLine());
system_dmm.FormattedIO.WriteLine("read2?;");
Console.WriteLine("Sour2 volt value: {0}\n", system_dmm.FormattedIO.ReadLine());
System.Threading.Thread.Sleep(4000);
system_dmm.FormattedIO.WriteLine(":output off;:output2 off");
// Close the session
system_dmm.Dispose();
}
}
}