Programming Guide Content PROGRAMMING OVERVIEW ....................3 VISA ....................3 UILD COMMUNICATION VIA 1.1.1 Install NI-VISA ........................3 1.1.2 Connect the instrument ......................7 ........................8 EMOTE ONTROL 1.2.1 User-defined Programming ....................8 1.2.2 Using SCPI via NI-MAX ......................8 1.2.3 Using SCPI over Telnet ......................
Programming Guide 1 Programming Overview By using USB and LAN interfaces, in combination with NI-VISA and programming languages, users can remotely control the waveform generator. Through LAN interface, VXI-11, Sockets and Telnet protocols can be used to communicate with the instruments. This chapter introduces how to build communication between the instrument and the PC.
Page 5
Programming Guide c. Click Unzip, the install process will launch after unzipping files. If your computer needs to install the .NET Framework 4, it may auto start. d. The NI-VISA install dialog is shown above. Click Next to start the installation process.
Page 6
Programming Guide e. Set the install path, default path is “C:\Program Files\National Instruments\”, you can change it, if you prefer. Click Next, dialog as shown above. Click Next twice, in the License Agreement dialog, select the “I accept the above 2 License Agreement(s).”,and click Next, dialog as shown below:...
Page 7
Programming Guide g. Click Next to begin installation. h. Now the installation is complete. Reboot your PC.
Programming Guide 1.1.2 Connect the instrument Depending on the specific model, the arbitrary waveform generator may be able to communicate with a PC through the USB or LAN interface. Connect the arbitrary waveform generator and the USB Host interface of the PC using a USB cable.
Programming Guide Remote Control 1.2.1 User-defined Programming Users can send SCPI commands via a computer to program and control the arbitrary waveform generator. For details, refer to the introductions in " Programming Examples". 1.2.2 Using SCPI via NI-MAX NI-MAX is a program created and maintained by National Instruments. It provides a basic remote control interface for VXI, LAN, USB, GPIB, and Serial communications.
Page 10
Programming Guide 4. At the Telnet command line, type: open XXX.XXX.XXX.XXX 5024 Where XXX.XXX.XXX.XXX is the instrument’s IP address and 5024 is the port. You should see a response similar to the following: 5. At the SCPI> prompt, input the SCPI commands such as *IDN? to return the company name, model number, serial number, and firmware version number.
7. Type quit at the prompt or close the Telnet window to close the connection to the instrument and exit Telnet. 1.2.4 Using SCPI over Socket Socket API can be used to control the SDG series by LAN without installing any other libraries. This can reduce the complexity of programming. SOCKET ADDRESS...
Programming Guide 2 Introduction to the SCPI Language About Commands & Queries This section lists and describes the remote control commands and queries recognized by the instrument. All commands and queries can be executed in either local or remote state. Each command or query, with syntax and other information, has some examples listed.
Programming Guide number of times. Table of Command & Queries Short Long Form Subsystem What Command/Query does *IDN *IDN SYSTEM Gets identification from device. *OPC *OPC SYSTEM Gets or sets the OPC bit (0) in the Event Status Register (ESR). *RST *RST SYSTEM...
Page 14
Programming Guide Short Long Form Subsystem What Command/Query does MM:LAN:S NICATE:LAN:SMA subnet mask. SYST:CO SYSTEM:COMMU SYSTEM The Command can set and get system MM:LAN:G NICATE:LAN:GAT Gateway. EWAY SRATE SAMPLERATE SIGNAL Sets or gets the arbitrary wave mode, sampling rate and interpolation method. HARM HARMonic SIGNAL...
Format 1: *IDN, <device id>,<model>,<serial number>,<firmware version>, <hardware version> Format 2: <manufacturer>,<model>,<serial number>,<firmware version> <device id>:= “SDG”. <manufacturer>:= “Siglent Technologies”. <model>:= A model identifier less than 14 characters, should not contain the word “MODEL”. <serial number>:= The serial number. <firmware version>:= The firmware version number.
CHDR <parameter> EXAMPLE Set query command format to long: CHDR LONG Read query command format: CHDR? Return: COMM_HEADER LONG Note: The table below shows the availability of the command in each SDG series. Parameter SDG6000X SDG800 SDG1000 SDG2000X SDG5000 SDG1000X...
Programming Guide Output Command DESCRIPTION This command enables or disables the output port(s) at the front panel. The query returns “ON” or “OFF” and “LOAD”, “PLRT”, “RATIO” parameters. COMMAND <channel>:OUTPut ON|OFF,LOAD,<load>,PLRT, <polarity> SYNTAX <channel>:= {C1, C2}. <load>:= {see the note below}. The unit is ohm. <polarity>:= {NOR, INVT}, in which NOR refers to normal, and INVT refers to invert.
Set the polarity of CH1 to normal: C1:OUTP PLRT,NOR turn on NoiseSum and set the signal-to-noise ratio C1:NOISE_ADD STATE,ON,RATIO,120 Set the maximum output amplitude C1:BSWV MAX_OUTPUT_AMP,5 Note: The table below shows the availability of the command in each SDG series. Parameter SDG6000X SDG800 SDG1000 SDG2000X...
Page 20
Programming Guide := offset. The unit is volts "V". Refer to the data sheet for OFST <offset> the range of valid values. Not valid when WVTP is NOISE. :={0 to 100}. Symmetry of RAMP. The unit is "%". Only <symmetry> settable when WVTP is RAMP.
Page 21
Programming Guide differential settable when WVTP is PRBS. switch> := PRBS bit rate. The unit is bits-per-second "bps". Refer <prbs BITRATE to the data sheet for the range of valid values. Only rate> settable when WVTP is PRBS. <prbs LOGICLEVE :={ TTL_CMOS, LVTTL_LVCMOS, ECL, LVPECL, logiclevel LVDS }.
Programming Guide The table below shows the availability of some command parameters in each SDG series. Parameter SDG2000 SDG1000 SDG6000 SDG6000 SDG800 SDG1000 SDG5000 /command <channel> RISE FALL BANDSTATE BANDWIDTH LENGTH EDGE DIFFSTATE BITRATE LOGICLEVEL AMPDBM In SDG1000X if Wave Combine is enabled, WVTP cannot be set to SQUARE. Modulate Wave Command DESCRIPTION This commend sets or gets the modulation parameters.
Page 23
Programming Guide Parameters Value Description :={ON, OFF}. Enable or disable modulation. STATE <state> STATE must be set to ON before you set or read other parameters of the modulation. AM, SRC <src> := {INT, EXT}. AM signal source. := {SINE, SQUARE, TRIANGLE, UPRAMP, DNRAMP, NOISE, ARB}.
Page 24
Programming Guide := {0 to 360}. PM phase deviation. The unit is PM, DEVI <PM phase offset> "degree". Only settable when SRC is INT. PWM, SRC <src> := {INT, EXT}. PWM signal source. := PWM frequency. The unit is Hertz "Hz". PWM, FRQ <PWM frequency>...
Page 25
Programming Guide := rise time when the carrier is PULSE. The CARR, RISE <rise> unit is seconds "s". Refer to the data sheet for the range of valid values. := fall time when the carrier is PULSE. The CARR, FALL <fall>...
Programming Guide Set CH1 FM frequency to 1000 Hz: C1:MDWV FM,FRQ,1000 Set CH1 carrier to SINE: C1:MDWV CARR,WVTP,SINE Set CH1 carrier frequency to 1000 Hz: C1:MDWV CARR,FRQ,1000 Note: The table below shows the availability of some command parameters in each SDG series.
Page 27
Programming Guide LOG refers to Logarithmic. <direction> := {UP, DOWN}. Sweep direction. TRSR <trig_src> := {EXT, INT, MAN}. Trigger source. EXT refers to External, INT refers to Internal and MAN refers to Manual. MTRIG := send a manual trigger. Only valid when TRSR is MAN.
Programming Guide Set CH1 stop frequency to 1000 Hz: C1:SWWV STOP,1000 Set trigger source of CH1 to Manual: C1:SWWV TRSR,MAN Send a manual trigger to CH1: C1:SWWV MTRIG Read CH2 sweep parameters when STATE is ON: C2:SWWV? Return: C2:SWWV STATE,ON,TIME,1S,STOP,100HZ,START,100HZ, TRSR,MAN,TRMD,OFF,SWMD,LINE,DIR,UP,CARR,WVTP, SQUARE,FRQ,1000HZ,AMP,4V,OFST,0V,DUTY,50,PHSE,0 Read CH2 sweep parameters when STATE is OFF:...
Page 29
Programming Guide parameters of the burst. <period> := burst period. Refer to the data sheet for the range of valid values. The unit is seconds “s”. Not valid when: Carrier is NOISE GATE_NCYC is GATE (except "X" series) ...
Page 30
Programming Guide values. := carrier offset. The unit is volts "V". Refer to the data CARR, OFST <offset> sheet for the range of valid values. := {0 to 100}. Carrier symmetry when the carrier is CARR, SYM <symmetry> RAMP. The unit is "%". CARR, := {0 to 100}.
Note: the parameters C1 and C2 must be set to the device together. EXAMPLE Copy parameters from CH1 to CH2. PACP C2,C1 Note: The table below shows the availability of the command in each SDG series. Parameter SDG6000X SDG800 SDG1000...
Page 32
Programming Guide format of query omit the character ‘M’, and directly uses the value to represent the index number. COMMAND SYNTAX <channel>:ArbWaVe INDEX,<index> <channel>:ArbWaVe NAME,<name> <channel>:= {C1, C2}. <index>: the index of the arbitrary waveform from the table below. <name>: the name of the arbitrary waveform from the table below. .QUERY SYNTAX <channel>:ARbWaVe? <channel>:= {C1, C2}.
Turn on sync output and set the source as modulating signal of CH1: C1:SYNC ON,TYPE,MOD_CH1 Read state of CH1 sync. C1:SYNC? Return: C1:SYNC ON,TYPE,MOD_CH1 Note: The table below shows the availability of the command in each SDG series. Parameter SDG6000X SDG800 SDG1000 SDG2000X SDG5000...
Programming Guide 3.11 Number Format Command DESCRIPTION This command sets or gets the number format. COMMAND SYNTAX NumBer_ForMat PNT,<pnt>, NumBer_ForMa SEPT,<sept> <pnt>:= {Dot, Comma}. The point format. <sept>:= {Space, Off, On}. The separator format. NBFM? QUERY SYNTAX NBFM PNT,<pnt>, SEPT,<sept> RESPONSE FORMAT EXAMPLE Set point format to DOT:...
Programming Guide Return: LAGG EN Note: The table below shows the availability of some command parameters in each SDG series. Parameter SDG6000X SDG800 SDG1000 SDG2000X SDG5000 SDG1000X /command /X-E 3.13 Configuration Command DESCRIPTION This command sets or gets the the power-on system setting. COMMAND SYNTAX Sys_CFG <mode>...
RESPONSE FORMAT ROSC <src>,10MOUT,ON|OFF EXAMPLE Set internal time base as the source: ROSC INT Enable 10MHz output: ROSC 10MOUT,ON Note: The table below shows the availability of the command in each SDG series. Parameter SDG800 SDG1000 SDG2000X SDG5000 SDG1000X SDG6000X...
Programming Guide /command /X-E ROSC 3.17 Frequency Counter Command DESCRIPTION This command sets or gets the frequency counter parameters. COMMAND SYNTAX FreqCouNTer <parameter>,<value> <parameter>:= {a parameter from the table below}. <value>:= {value of the corresponding parameter}. Parameters Value Description :={ON, OFF} STATE <state>...
Programming Guide FCNT REFQ,1000 Query frequency counter information: FCNT? Return: FCNT STATE,ON,FRQ,10000000HZ,DUTY,59.8568,REFQ, 1e+07HZ,TRG,0V,PW,5.98568e-08S,NW,4.01432e- 08S,FRQDEV,0ppm,MODE,AC,HFR,OFF Note: The table below shows the availability of the command in each SDG series. Parameter SDG6000X SDG800 SDG1000 SDG2000X SDG5000 SDG1000X /command /X-E FCNT 3.18 Invert Command DESCRIPTION This command sets or gets the polarity of specified channel.
Programming Guide 3.19 Coupling Command DESCRIPTION This command sets or gets the channel coupling parameters. Only when TRACE is set to OFF, the other coupling parameters can be set. COMMAND SYNTAX COUPling <parameter>,<value> <parameter>:= {a parameter from the table below}. <value>:={value of the corresponding parameter}.
This commend sets or gets the state of over-voltage protection. COMMAND SYNTAX VOLTPRT <state> <state>:= {ON, OFF} QUERY SYNTAX VOLTPRT? RESPONSE FORMAT VOLTPRT <state> Note: The table below shows the availability of the command in each SDG series. Parameter SDG800 SDG1000 SDG2000X SDG5000 SDG1000X SDG6000X...
Programming Guide /command /X-E VOLTPRT 3.21 Store List Command DESCRIPTION This command is used to read the stored waveforms list with indexes and names. If the store unit is empty, the command will return “EMPTY” string. QUERY SYNTAX SToreList? SToreList? BUILDIN|USER Read all arbitrary data saved in a SDG1000.
Programming Guide Dnramp, M90, ECG4, M91, ECG5, M92, ECG6, M93, ECG7, M94, ECG8, M95, ECG9, M96, ECG10, M97, ECG11, M98, ECG12, M99, ECG13 Read wave data defined by user from a SDG1000X: STL? USER Return: STL WVNM,sinc_8M,sinc_3000000,sinc_1664000, ramp_8M,sinc_2000000,sinc_50000,square_8M,sinc_5000, wave1,square_1M Note: The table below shows the availability of some command parameters in each SDG series.
Page 44
User- WVDT? User-defined: defined: defined: defined: Format2 Format2 Format2 Format2 The table below shows the details of Mn parameters in each SDG series. Model Description of Mn 0<=n<=59. SDG800 M0~M49: build-in (32KB). M50~M59: user-defined (32KB). 0<=n<=59. SDG1000 M0~M49: build-in (32KB).
Programming Guide Not necessary when sending waveform data. 0<=n<=68. M0~M35: build-in (32KB). SDG5000 M36~M59: user-defined (32KB). M60~M67: user-defined (1024KB). 0<=n<=196. SDG1000X M0~M196: build-in (32KB). Not necessary when sending waveform data. 0<=n<=196. SDG6000X/X-E M0~M196: build-in (32KB). Not necessary when sending waveform data. 3.23 Virtual Key Command DESCRIPTION This command is used to simulate pressing a key on the front panel.
Page 46
Programming Guide KB_NUMBER_0 KB_NUMBER_1 KB_NUMBER_2 KB_NUMBER_3 Keys and Indices on the SDG1000X/SDG2000X/SDG6000X/SDG6000X-E Keys and Indices on the SDG5000...
Programming Guide Keys and Indices on the SDG1000/SDG800 EXAMPLE VKEY VALUE,15,STATE,1 VKEY VALUE,KB_SWEEP,STATE,1 Note: The table below shows the availability of some command parameters in each SDG series. Parameter SDG6000X SDG800 SDG1000 SDG2000X SDG5000 SDG1000X /command /X-E KB_FUNC6 KB_STORE_RECAL KB_HELP KB_CHANNEL KB_SINE KB_SQUARE...
QUERY SYNTAX SYSTem:COMMunicate:LAN:IPADdress? EXAMPLES Set IP address to 10.11.13.203: SYST:COMM:LAN:IPAD “10.11.13.203” Get the IP address: SYST:COMM:LAN:IPAD? Return: “10.11.13.203” Note: The table below shows the availability of the command in each SDG series.: Parameter SDG6000X SDG800 SDG1000 SDG2000X SDG5000 SDG1000X /command...
Programming Guide SYST:COMM:LAN:SMAS? Return: “255.0.0.0” Note: The table below shows the availability of the command in each SDG series. Parameter SDG6000X SDG800 SDG1000 SDG2000X SDG5000 SDG1000X /command /X-E SYST:COMM:LAN:S 3.26 Gateway Command This command sets and gets the system gateway.
Set sampling rate of CH1 to 1000000Sa/s: C1:SRATE VALUE,1000000 Set CH1 to TureArb mode and set interpolation to SINC13 C1:SRATE MODE,TARB,INTER,SINC13 Note: The table below shows the availability of the command and some parameters in each SDG series. Parameter SDG6000X SDG800 SDG1000...
Set the 2nd harmonic of CH1 to -6 dBc: C1:HARM HARMORDER,2,HARMDBC,-6 Get the harmonic information of CH1: C1:HARM? Return: C1:HARM ,HARMSTATE,ON,HARMTYPE,EVEN,HARMORDER,2,H ARMAMP,2.004748935V,HARMDBC,-6dBc,HARMPHASE,0 Note: The table below shows the availability of the command in each SDG series. Parameter SDG6000X SDG800 SDG1000 SDG2000X SDG5000...
Turn on the waveform combining of CH1: C1:CMBN ON Query the waveform combining state of CH2: C2:CMBN? Return: C2:CMBN OFF Note: The table below shows the availability of the command in each SDG series. Parameter SDG6000X SDG800 SDG1000 SDG2000X SDG5000...
Return from MASTER mode : CASCADE STATE,ON,MODE,MASTER Set the device as slave and the delay to 0.0000001s: EXAMPLE CASCADE STATE,ON,MODE,SLAVE,DELAY,0.0000001 3.32 IQ Commands The table below shows the availability of IQ commands in each SDG series. Parameter SDG2000 SDG1000 SDG6000 SDG6000...
Programming Guide 3.32.2 :IQ:SAMPlerate DESCRIPTION This command sets the I/Q sampling rate. COMMAND SYNTAX [:SOURce]:IQ:SAMPlerate <sample_rate><unit> <sample_rate>:= sample rate. Refer to the data sheet for the range of valid values. <unit>:= {Hz, kHz, MHz, GHz}. The default unit is Hertz “Hz”. [:SOURce]:IQ:SAMPlerate? QUERY SYNTAX <sample_rate>...
Programming Guide <unit>:= {Vrms, mVrms, dBm}. The default unit is volts, root- mean-square “Vrms”. [:SOURce]:IQ:AMPLitude? QUERY SYNTAX <amplitude> (expressed Vrms.) RESPONSE FORMAT Set the I/Q amplitude (sqrt(I )) to 0.2 Vrms: EXAMPLE :IQ:AMPL 0.2 3.32.5 :IQ:IQADjustment:GAIN DESCRIPTION This command adjusts the ratio of I to Q while preserving the composite.
Programming Guide 3.32.7 :IQ:IQADjustment:QOFFset DESCRIPTION This command adjusts the Q channel offset value. COMMAND SYNTAX [:SOURce]:IQ:IQADjustment:QOFFset <offset><unit> <offset>:= Q offset. <unit>:= {V, mV, uV}. The default unit is volts “V”. QUERY SYNTAX [:SOURce]:IQ:IQADjustment:QOFFset? RESPONSE FORMAT <offset> (expressed in V.) EXAMPLE Set the Q offset to -1 mV: :IQ:IQAD:QOFF -0.001V 3.32.8...
Programming Guide Set the trigger source to INT: EXAMPLE :IQ:TRIGger:SOURce INTernal 3.32.10 :IQ:WAVEload:BUILtin DESCRIPTION This command selects I/Q waveform from the built in waveform list. COMMAND SYNTAX [:SOURce]:IQ:WAVEload:BUILtin <wave_name> <wave_name>:= {A waveform name from the table below}. QUERY SYNTAX [:SOURce]:IQ:WAVEload? RESPONSE FORMAT BUILtin|USERstored <wave_name>...
Page 58
Programming Guide 3.32.12 :IQ:FrequencySampling DESCRIPTION This command sets the I/Q Frequency sampling rate. COMMAND SYNTAX [:SOURce]:IQ: FrequencySampling <sampling> < sampling >:= {500-300000000}. The unit is S/s QUERY SYNTAX [:SOURce]:IQ:FrequencySampling? [:SOURce]:IQ:FrequencySamplingLimit? <sampling> RESPONSE FORMAT MAX,<max_sampling>,MIN,< min_sampling > EXAMPLE Set the I/Q frequency sampling to 2000000: :IQ:FrequencySampling 2000000...
Programming Guide 4 Programming Examples This chapter gives some examples for the programmer. In these examples you can see how to use VISA or sockets, in combination with the commands described above to control the generator. By following these examples, you can develop many more applications. Examples of Using VISA 4.1.1 VC++ Example Environment: Windows 7 32-bit, Visual Studio.
Page 60
Programming Guide In " project---properties---Linker---General---Additional Library Directories " set the value to the NI-VISA installation path (e.g. C:\Program Files\IVI Foundation\VISA\WinNT\include), as shown in the figure below: In "project---properties---Linker---Command Line---Additional" set the value to visa32.lib, as shown in the figure below:...
Page 61
Programming Guide Include visa.h file in the projectname.cpp file: #include <visa.h> 3. Coding: USBTMC: Usbtmc_test() /* This code demonstrates sending synchronous read & write commands */ /* to an USB Test & Measurement Class (USBTMC) instrument using /* NI-VISA /* The example writes the "*IDN?\n" string to all the USBTMC /* devices connected to the system and attempts to read back /* results using the write and read functions.
Page 62
Programming Guide ViUInt32 numInstrs; ViFindList findList; ViStatus status; char instrResourceString[VI_FIND_BUFLEN]; unsigned char buffer[100]; /** First we must call viOpenDefaultRM to get the manager * handle. We will store this handle in defaultRM.*/ status=viOpenDefaultRM (&defaultRM); (status<VI_SUCCESS) printf ("Could not open a session to the VISA Resource Manager!\n"); return status;...
Page 63
Programming Guide &instr); (status<VI_SUCCESS) printf ("Cannot open a session to the device %d.\n", i+1); continue; /* * At this point we now have a session open to the USB TMC instrument. * We will now use the viPrintf function to send the device the string "*IDN?\n", * asking for the device's identification.
Page 64
Programming Guide Usbtmc_test(); return Run result TCP/IP: int TCP_IP_Test(char *pIP) char outputBuffer[VI_FIND_BUFLEN]; ViSession defaultRM, instr; ViStatus status; /* First we will need to open the default resource manager. */ status = viOpenDefaultRM (&defaultRM); (status<VI_SUCCESS) printf("Could not open a session to the VISA Resource Manager!\n"); /* Now we will open a session via TCP/IP device */ char head[256] ="TCPIP0::";...
Page 65
Programming Guide printf("viRead failed with error code: %x \n",status); viClose(defaultRM); else printf ("\nMesseage read from device: %*s\n", 0,outputBuffer); status = viClose (instr); status = viClose (defaultRM); printf("Press 'Enter' to exit."); fflush(stdin); getchar(); return int _tmain(int argc, _TCHAR* argv[]) printf("Please input IP address:"); char ip[256];...
Programming Guide 4.1.2 VB Example Environment: Windows 7 32-bit, Microsoft Visual Basic 6.0 Description: Query the instrument information using "IDN?" command over NI-VISA, with the access through USBTMC and TCP/IP separately. Steps: 1. Open Visual Basic, and build a standard application program project. 2.
Page 67
Programming Guide Write the Identification Query Using viWrite Try to Read a Response With viRead Close the VISA Session Const MAX_CNT = 200 defaultRM As Long instrsesn As Long numlnstrs As Long findList As Long retCount As Long status As Long instrResourceString As String * VI_FIND_BUFLEN...
Page 68
Programming Guide i = 0 numInstrs (i > 0) Then status = viFindNext(findList, instrResourceString) End If status = viOpen(defaultRM, instrResourceString, VI_NULL, VI_NULL, instrsesn) (status < VI_SUCCESS) Then resultTxt.Text = "Cannot open a session to the device " + CStr(i + 1) GoTo NextFind End If...
Page 69
Programming Guide defaultRM As Long instrsesn As Long status As Long count As Long ' First we will need to open the default resource manager. status = viOpenDefaultRM(defaultRM) (status < VI_SUCCESS) Then resultTxt.Text = "Could not open a session to the VISA Resource Manager!" TCP_IP_Test = status Exit Function End If...
Page 70
Programming Guide End Sub Private Sub tcpipBtn_Click() stat As Long stat = TCP_IP_Test(ipTxt.Text) (stat < VI_SUCCESS) Then resultTxt.Text = Hex(stat) End If End Sub Private Sub usbBtn_Click() stat As Long stat = Usbtmc_test (stat < VI_SUCCESS) Then resultTxt.Text = Hex(stat) End If End Sub Run result:...
Programming Guide 4.1.3 MATLAB Example Environment: Windows 7 32-bit, MATLAB R2013a Description: Query the instrument information using "IDN?" command over NI-VISA, with the access through USBTMC and TCP/IP separately. Steps: 1. Open MATLAB, and modify the current directory. In this demo, the current directory is modified to "D:\USBTMC_TCPIP_Demo".
Page 72
Programming Guide TCP/IP: Write a function TCP_IP_Test: function TCP_IP_test() % This code demonstrates sending synchronous read & write commands % to an TCP/IP instrument using NI-VISA %Create a VISA-TCPIP object connected to an instrument %configured with IP address. vt = visa('ni',['TCPIP0::','10.11.13.32','::INSTR']); %Open the VISA object created fopen(vt);...
Programming Guide 4.1.4 LabVIEW Example Environment: Windows 7 32-bit, LabVIEW 2011 Description: Query the instrument information using "IDN?" command over NI-VISA, with the access through USBTMC and TCP/IP separately. Steps: 1. Open LabVIEW, and create a VI file. 2. Add controls. Right-click in the Front Panel interface, select and add VISA resource name, error in, error out and some indicators from the Controls column.
Page 74
Programming Guide 6. Communicating with the device via TCP/IP is similar to USBTMC. But you need to change VISA Write and VISA Read Function to Synchronous I/O. The LabVIEW default is asynchronous I/O. Right-click the node and select Synchronous I/O Mod>>Synchronous from the shortcut menu to write or read data synchronously.
Programming Guide 4.1.5 Python Example Environment: Python2.7, PyVISA 1.4 (Please install PyVISA after installing Python2.7. Please refer https://pyvisa.readthedocs.io/en/stable/getting.html for PyVISA installation guide. Description: Use Python script to build an 8-point 16-bit arbitrary waveform (0x1000, 0x2000, 0x3000, 0x4000, 0x5000, 0x6000, 0x7000, 0x7fff) and save the waveform data in "wave1.bin", then download it to the instrument , finally read it back from the instrument and save it as "wave2.bin".
Page 76
Programming Guide b = '0' + b c = binascii.a2b_hex(b) #Hexadecimal integer to ASCii encoded string f.write(c) f.close() def send_wawe_data(dev): """send wave1.bin to the device""" f = open("wave1.bin", "rb") #wave1.bin is the waveform to be sent data = f.read() print 'write bytes:',len(data) dev.write("C1:WVDT WVNM,wave1,FREQ,2000.0,AMPL,4.0,OFST,0.0,PHASE,0.0,WAVEDATA,%s"...
Programming Guide Examples of Using Sockets 4.2.1 Python Example Python has a low-level networking module that provides access to the socket interface. Python scripts can be written for sockets to do a variety of tests and measurement tasks. Environment: Windows 7 32-bit, Python v2.7.5 Description: Open a socket, send a query, and repeat this loop for 10 times, finally close the socket.
Page 79
Programming Guide return s def SocketQuery(Sock, cmd): try : #Send cmd string Sock.sendall(cmd) time.sleep(1) except socket.error: #Send failed print ('Send failed') sys.exit() reply = Sock.recv(4096) return reply def SocketClose(Sock): #close the socket Sock.close() time.sleep(.300) def main(): global remote_ip global port global count # Body: send the SCPI commands *IDN? 10 times and print the return message s = SocketConnect()
Need help?
Do you have a question about the SDG Series and is the answer not in the manual?
Questions and answers