Specifications

12
4.3 Communicating with an instrument using the VISA-COM library
The next step is to assign the message-based session to a specific instrument
using the resource manager. There are easy and difficult methods to do this, the
hardest of which would be an automated scan of the resources available.
The code example shown below details how you connect to an instrument
where the GPIB address is known.
4.4 10-second BER measurement example using the N4962A serial BERT 12.5 Gb/s and N4963A clock synthesizer
13.5 GHz with a VISA-COM library in Visual C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ivi.Visa.Interop;
namespace TG1B1A_VISA_demo
{
class Program
{
static void Main(string[] args)
{
// resource manager and message-based session manager
ResourceManager rMgr = new ResourceManagerClass();
FormattedIO488 src = new FormattedIO488Class();
FormattedIO488 BERT = new FormattedIO488Class();
// measurement setup
string srcAddress = “GPIB::16”; // GPIB address of N4963A CLOCK
SYNTHESIZER13.5 GHZ
double srcFreq = 10e9; // frequency in Hz
string BERTAddress = “GPIB::5”; // GPIB address of N4962A SERIAL BERT 12.5
GB/S
string BERTPattern = “PRBS7”; // PRBS pattern
double BERTAmplitude = 0.5; // output amplitude
double BERTGateTime = 10; // measurement gate time
double BERTErrThreshold = 1e-5; // pre-measurement error threshold
bool BERTErrInj = false; // error injection
string BERTErrInjRate = “1E2”; // error injection rate
// connect to instruments
src.IO = (IMessage)rMgr.Open(srcAddress, AccessMode.NO_LOCK, 2000, null);
src.IO.Timeout = 2000;
BERT.IO = (IMessage)rMgr.Open(BERTAddress, AccessMode.NO_LOCK,
2000, null);
BERT.IO.Timeout = 2000;
// setup clock
Console.Write(“N4963A CLOCK SYNTHESIZER13.5 GHZ “ + srcAddress + “ setup..”);
src.IO.Clear();
src.WriteString(“*RST;*OPC?”, true);
string temp = src.ReadString();
src.WriteString(“:FREQ “ + srcFreq, true);
src.WriteString(“:AMPL 1 1.5”, true);
src.WriteString(“:AMPL 2 1.5”, true);
src.WriteString(“:AMPL 3 0.8”, true);
src.WriteString(“:AMPL 4 0.8”, true);
src.WriteString(“:OUTP ON”, true);
Console.WriteLine(“done”);