Programming Guide 1 Programming Overview This chapter introduces build communication between series function/arbitrary waveform generator and the PC. It also introduces how to remote control. 1.1 Build communication 1.1.1 Install NI-VISA Before programming, you need to install NI-VISA, which you can download from the NI-VISA web site.
Page 5
Programming Guide iii. The NI-VISA installing dialog is shown above. Click Next to start the installation process. Set the install path, default path is “C:\Program Files\National Instruments\”, you can change it. Click Next, dialog shown as above. Click Next twice, in the License Agreement dialog, select the “I accept the above 2 License Agreement(s).”,and click Next, dialog shown as below:...
Programming Guide Click Next to run installation. Now the installation is complete, reboot your PC. 1.1.2 Connect the instrument Depending on your specific model your function/arbitrary waveform generator may be able to communicate with a PC through the USB or LAN interface. This manual takes the USB as an example.
Programming Guide b. Wait for the installation to complete and then proceed to the next step. 1.2 How To Remote Control 1.2.1 User-defined Programming Users can use SCPI commands to program and control the function/arbitrary waveform generator. For details, refer to the introductions in "Programming Examples".
Programming Guide 2 Introduction to the SCPI Language 2.1 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 [ ] Square brackets enclose optional items. … An ellipsis indicates that the items both to its left and right may be repeated for a number of times. 2.6 Table of Command & Queries Short Long Form Subsystem What Command/Query does *IDN *IDN...
Page 10
Programming Guide SCSV SCREEN_SAVE SYSTEM Sets or gets screen save state. ROSC ROSCILLATOR SIGNAL Sets or gets state of clock source. FCNT FREQCOUNTER SIGNAL Sets or gets frequency counter parameters. INVT INVERT SIGNAL Sets or gets polarity of current channel. COUP COUPLING SIGNAL...
Programming Guide 3 Commands and Queries 3.1 IEEE 488.2 Common Command Introduction IEEE standard defines the common commands used for querying the basic information of the instrument or executing basic operations. These commands usually start with "*" and the length of the keywords of the command is usually 3 characters.
Programming Guide 3.1.4 ESE DESCRIPTION The *ESE command sets the Standard Event Status Enable register (ESE). This command allows one or more events in the ESR register to be reflected in the ESB summary message bit (bit 5) of the STB register. The *ESE? query reads the contents of the ESE register.
Programming Guide RELATED COMMANDS *CLS, *ESE 3.1.6 RST DESCRIPTION The *RST command initiates a device reset. The *RST recalls the default setup. COMMAND SYNTAX * RST EXAMPLE This example resets the signal generator: *RST 3.1.7 SRE DESCRIPTION The *SRE command sets the Service Request Enable register (SRE).
Programming Guide *SRE 17 3.1.8 STB DESCRIPTION The *STB? query reads the contents of the 488.2 defined status register (STB), and the Master Summary Status (MSS). The response represents the values of bits 0 to 5 and 7 of the Status Byte register and the MSS summary message.
Programming Guide RELATED COMMANDS *CAL Note: Parameter/command SDG800 SDG1000 SDG2000X SDG5000 SDG1000X 3.1.10 DESCRIPTION The *WAI (WAIT to continue) command, requires by the IEEE 488.2 standard, has no effect on the instrument, as the signal generator only starts processing a command when the previous command has been entirely executed.
Programming Guide External input overload condition detected 6…4 Reserved Reserved Reserved Channel 2 overload condition detected Channel 1 overload condition detected Note: Parameter/command SDG800 SDG1000 SDG2000X SDG5000 SDG1000x 3.1.12 DESCRIPTION The CMR? query reads and clears the contents of the command error register (CMR) .See the table below which specifies the last syntax error type detected by the instrument.
Programming Guide Note: Parameter/command SDG800 SDG1000 SDG2000X SDG5000 SDG1000X 3.2 Comm_Header Command DESCRIPTION This command is used to change the query command returned format. “SHORT” parameter returns short format. “LONG” parameter returns long format. “OFF” returns nothing. COMMAND SYNTAX CHDR (Comm_HeaDeR) <parameter> <parameter>:= {SHORT,LONG,OFF} QUERY SYNTAX CHDR (Comm_HeaDeR)?
Page 19
Programming Guide Turn on Turn off Value of load ( LOAD <load> default unit is ohm Value of polarity PLRT <NOR, INVT> parameter < load>:= {please see the note below.} QUERY SYNTAX <channel>: OUTP(OUTPut)? RESPONSE FORMAT <channel>: OUTP <load> EXAMPLE Turn on channel one.
Programming Guide 3.4 Basic Wave Command DESCRIPTION Sets or gets basic wave parameters. In SDG1000X if turn on wave combine, you can’t set wave to square. Combining a square waveform is not possible. COMMAND SYNTAX <channel>:BSWV(BaSic_WaVe) <parameter> <channel>:={C1, C2} <parameter>:= {a parameter from the table below} Parameters Value Description...
Page 21
Programming Guide switch > is Noise, you can set this parameter. <bandwidth Value of noise bandwidth. Only when wave type is BANDWIDTH value> noise, you can set this parameter. Note: if the command doesn’t set basic wave type, WVPT parameter will be set to current wave type.
Programming Guide OFST,0V,HLEV,1V,LLEV,-1V,PHSE,0 Set noise bandwidth value of channel one to 100MHz C1: BSWV BANDWIDTH, 100000000 Note: Parameter/command SDG800 SDG1000 SDG2000X SDG5000 SDG1000X no(single <channel> channel) RISE BANDSTATE BANDWIDTH 3.5 Modulate Wave Command DESCRIPTION Sets or gets modulation parameters. COMMAND <channel>:MDWV(MoDulateWaVe)<parameter>...
Page 23
Programming Guide frequency> source is set to INT, you can set the parameter. FM, SRC <src> FM signal source. FM modulation wave. Only when FM signal FM, MDSP <mod wave shape> source is set to INT, you can set the parameter.
Page 24
Programming Guide CARR, FRQ <frequency> Value of carrier frequency. CARR, AMP <amplitude> Value of carrier amplitude. CARR, OFST <offset> Value of carrier offset. Value of carrier symmetry. Only ramp can set CARR, SYM <symmetry> this parameter. Value of duty cycle. Only square and pulse CARR, DUTY <duty>...
Page 25
Programming Guide Note: There are some parameters Value depends on the model, You can read version datasheet to get specific parameters QUERY SYNTAX <channel>: MDWV (MoDulateWaVe)? <channel>:={C1, C2} RESPONSE <channel>:MDWV <parameter> FORMAT <parameter> :={ Return all parameter of the current modulation parameters.} EXAMPLE Set channel one modulation type to AM.
Page 27
Programming Guide PHSE Note: If carrier is Pulse or Noise you can’t turn on sweep. If you want to set CARR and STATE, the first parameter has to be one of them. where: <state>:= {ON, OFF} <time>:= { Default unit is "S". Value depends on the model.} <stop frequency>...
Programming Guide FRQ, 1000HZ, AMP, 4V, OFST, 0V, DUTY, 50, PHSE, 0 Read channel two sweep parameters of which STATE is OFF. C2: SWWV? Return: C2: SWWV STATE, OFF Note: Parameter/command SDG800 SDG1000 SDG2000X SDG5000 SDG1000X no(single <channel> channel) TRMD EDGE 3.7 Burst Wave Command DESCRIPTION...
Page 29
Programming Guide EDGE <edge> Value of edge. When carrier is NOISE wave, you can’t set it. When NCYC is chosen and TRSR is set to EXT, you can set it. TIME <circle time> Value of Ncycle number. When carrier is NOISE wave, you can’t set it.
Page 30
Programming Guide <wave type>:={SINE ,SQUARE, RAMP, PULSE, NOISE, ARB} <frequency> :={ Default unit is "HZ". Value depends on the model.} <amplitude>:= {Default unit is "V". Value depends on the model.} <offset>:= {Default unit is "V". Value depends on the model.} <duty>:= {0% to 100%.} <symmetry>...
Programming Guide Read channel two burst parameters of which STATE is OFF. C2: BTWV? Return: C2: BTWV STATE, OFF Note: Parameter/command SDG800 SDG1000 SDG2000X SDG5000 SDG1000X no(single <channel> channel) TRMD EDGE CARR, DLY CARR, RISE CARR, FALL 3.8 Parameter Copy Command DESCRIPTION Copies parameters from one channel to another.
Page 32
Programming Guide COMMAND SYNTAX <channel> ARWV(ArbWaVe) INDEX,<value1>, NAME,<value2> <channel>:={C1, C2} < value1>: the table below shows what the index number mean.) < value2>: see table below. QUERY SYNTAX <channel>: ARWV (ARbWaVe)? <channel>:={C1, C2} RESPONSE FORMAT <channel>:ARWV <index> EXAMPLE Set StairUp arbitrary wave output by index. C1:ARWV INDEX, 2 Read system current wave.
Programming Guide QUERY SYNTAX NBFM (NumBer_ForMat)? RESPONSE FORMAT NBFM <parameter> EXAMPLE Set point format to DOT. NBFM PNT, DOT Set Separator format to ON. NBFM SEPT,ON Read number format. NBFM? Return: NBFM PNT, DOT, SEPT, ON 3.12 Language Command DESCRIPTION Sets or gets system language.
Programming Guide 3.13 Configuration Command DESCRIPTION Sets or gets the power-on system setting.. COMMAND SYNTAX SCFG(Sys_CFG)<parameter> <parameter>:= {DEFAULT, LAST} QUERY SYNTAX SCFG (Sys_CFG)? RESPONSE FORMAT SCFG <parameter> EXAMPLE Set the power-on system setting to LAST. SCFG LAST 3.14 Buzzer Command DESCRIPTION Turns on or off the buzzer.
Programming Guide EXAMPLE Set screen save time to 5 minutes. SCSV 5 Read the current screen save time. SCreen_SaVe? Return: SCSV 5MIN 3.16 Clock Source Command DESCRIPTION Sets or gets the clock source. COMMAND SYNTAX ROSC (ROSCillator) <parameter> <parameter>:= {INT, EXT} QUERY SYNTAX ROSC (ROSCillator)? RESPONSE FORMAT...
Programming Guide <triglev> Value of trigger level. MODE <mode> Value of mode. <HFR> State of HFR. where: < state >:={ON, OFF} <frequency>:= {Default unit is "Hz". Value range depends on the model.} < mode >:={AC, DC} <HFR>:={ON, OFF} QUERY SYNTAX FCNT (FreqCouNTer)? RESPONSE FORMAT FCNT <...
Programming Guide Set C1 ON: C1: INVT ON Read the polarity of channel one. C1: INVT? Return: C1: INVT ON Notes: Parameter/command SDG800 SDG1000 SDG2000X SDG5000 SDG1000X no(single <channel> channel) 2. The <channel> is a selectable parameter. If channel is not set, default is current channel.
Programming Guide < bsch >:= {CH1, CH2} < frq_dev >:={ Default unit is “Hz”, value range depends on the model} < pha_dev >:={ Default unit is “°”value range depends on the model } <fcoup>,<acoup>,<pcoup>:={ON, OFF} <frat>,<prat>,< arat >:={a ratio value. value range depends on the model } <adev>:={ a deviation value.
Programming Guide COMMAND SYNTAX VOLTPRT<parameter> <parameter>:= {ON, OFF} QUERY SYNTAX VOLTPRT? RESPONSE FORMAT VOLTPRT<parameter> Note: Parameter/command SDG800 SDG1000 SDG2000X SDG5000 SDG1000X VOLTPRT 3.21 Store List Command DESCRIPTION This command is used to read the stored wave data names if the store unit is empty;...
Programming Guide <parameter1>:={a integer value between 1 and 223} <parameter2>:={a integer value between 0 and 255} <parameter3>:={a integer value between 0 and 255} <parameter4>:={a integer value between 0 and 255} QUERY SYNTAX SYST:COMM:LAN:IPAD (SYSTem:COMMunicate:LAN:IPADdress)? EXAMPLES Set IP address to 10.11.13.203 SYSTem: COMMunicate: LAN:IPADdress 10.11.13.203 Get IP address.
Programming Guide Parameter/command SDG800 SDG1000 SDG2000X SDG5000 SDG1000X SYST:COMM:LAN:SMAS 3.26 Gateway Command DESCRIPTION The Command can set and get system Gateway. COMMAND SYNTAX SYST:COMM:LAN:GAT(SYSTem:COMMunicate:LAN:GATeway) <parameter1>.<parameter2>.<parameter3>.<parameter4> <parameter1>:={a integer value between 0 and 223} <parameter2>:={a integer value between 0 and 255} <parameter3>:={a integer value between 0 and 255} <parameter4>:={a integer value between 0 and 255} QUERY SYNTAX SYSTem:COMMunicate:LAN:GATeway?
Programming Guide QUERY SYNTAX <channel>: SRATE? EXAMPLES Get the channel one sample rate value C1: SRATE? Return: C1: SRATE MODE, DDS Set channel one to TureArb mode. C1: SRATE MODE, TARB Set channel one sample rate value to 1000000Sa/s. C1: SRATE VALUE, 1000000 Note: Parameter/command SDG800...
Programming Guide 4 Programming Examples This chapter gives some examples for the programmer. In these examples you can see how to use the NI-VISA lib and the commands which have been described before this chapter to control our devices. By the examples’ guide, you can develop more functions application as you want.
Page 50
Programming Guide Set lib path set lib file: Set lib path: the NI-VISA install path, in our computer we set the path is : C:\Program Files\IVI Foundation\VISA\WinNT \lib\msc. Set this path to project---properties---Linker---General---Additional Library Directories: as seen in the pictures below. file:project---properties---Linker---Command Line---Additional Options:...
Page 51
Programming Guide /* 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. /* The general flow of the code is */ Open Resource Manager Open VISA Session to an Instrument...
Page 52
Programming Guide return status; /* Find all the USB TMC VISA resources in our system and store the number of resources in the system in numInstrs. status = viFindRsrc (defaultRM, "USB?*INSTR", &findList, &numInstrs, instrResourceString); if (status<VI_SUCCESS) printf ("An error occurred while finding resources.\nHit enter to continue."); fflush(stdin);...
Page 53
Programming Guide 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 54
Programming Guide system("pause"); // pause to keep off the console flashed. return 0; Result: 3.2 TCP/IP access code. Write a function TCP_IP_Test: int TCP_IP_Test(char *pIP) char outputBuffer[VI_FIND_BUFLEN]; ViSession defaultRM, instr; ViStatus status; ViUInt32 count; ViUInt16 portNo; /* First we will need to open the default resource manager. */ status = viOpenDefaultRM (&defaultRM);...
Programming Guide status = viOpen (defaultRM, head, VI_LOAD_CONFIG, VI_NULL, &instr); if (status<VI_SUCCESS) printf ("An error occurred opening the session\n"); viClose(defaultRM); status = viPrintf(instr, "*idn?\n"); status = viScanf(instr, "%t", outputBuffer); if (status<VI_SUCCESS) printf("viRead failed with error code: %x \n",status); viClose(defaultRM); }else printf ("\ndata read from device: %*s\n", 0,outputBuffer);...
Page 56
Programming Guide Follow the steps to complete the example: Open Visual Basic, build a standard application program project (Standard EXE) Set the project environment to use the NI-VISA lib, Click the Existing tab of Project>>Add Existing Item. Search for the visa32.bas file in the include folder under the NI-VISA installation path and add the file.
Page 57
Programming Guide Dim defaultRM As Long Dim instrsesn As Long Dim numlnstrs As Long Dim findList As Long Dim retCount As Long Dim writeCount As Long Dim status As Long Dim instrResourceString As String * VI_FIND_BUFLEN Dim Buffer As String * MAX_CNT Dim i As Integer ' First we must call viOpenDefaultRM to get the manager ' handle.
Page 58
Programming Guide ' Now we will open VISA sessions to all USB TMC instruments. ' We must use the handle from viOpenDefaultRM and we must ' also use a string that indicates which instrument to open. This ' is called the instrument descriptor. The format for this string ' can be found in the function panel by right clicking on the ' descriptor parameter.
Page 59
Programming Guide End If ' Now we will attempt to read back a response from the device to ' the identification query that was sent. We will use the viRead ' function to acquire the data. ' After the data has been read the response is displayed. status = viRead(instrsesn, Buffer, MAX_CNT, retCount) If (status <...
Page 60
Programming Guide ' First we will need to open the default resource manager. status = viOpenDefaultRM(defaultRM) If (status < VI_SUCCESS) Then resultTxt.Text = "Could not open a session to the VISA Resource Manager!" TCP_IP_Test = status Exit Function End If ' Now we will open a session via TCP/IP device status = viOpen(defaultRM, "TCPIP0::"...
Page 61
Programming Guide status = viClose(defaultRM) TCP_IP_Test = 0 End Function 3.3、Button control code: Private Sub exitBtn_Click() End Sub Private Sub tcpipBtn_Click() Dim stat As Long stat = TCP_IP_Test(ipTxt.Text) If (stat < VI_SUCCESS) Then resultTxt.Text = Hex(stat) End If End Sub Private Sub usbBtn_Click() Dim stat As Long stat = Usbtmc_test...
Programming Guide 4.3 Example of MATLAB Environment: Win7 32bit system, MATLAB R2010b The function of this example: Use the NI-VISA, to control the device with USBTMC or TCP/IP access to do a write and read. Follow the steps to complete the example: Open MATLAB, modify the current directory.
Page 63
Programming Guide %Request the data outputbuffer = fscanf(vu); disp(outputbuffer); %Close the VISA object fclose(vu); delete(vu); clear vu; 1.2 TCP/IP access code. Write a function TCP_IP_Test: function TCP_IP_test( IPstr ) % 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.
Programming Guide fclose(vt); delete(vt); clear vt; 4.4 Example of LabVIEW Environment: Win7 32bit system, LabVIEW 2011 The functions of this example: use the NI-VISA, to control the device with USBTMC and TCP/IP access to do a write and read. Follow the steps to complete the example: 1、...
Page 65
Programming Guide In this example, the VI opens a VISA session to a USBTMC device, writes a command to the device, and reads back the response. In this example, the specific command being sent is the device ID query. Check with your device manufacturer for the device command set.
Page 66
Programming Guide Note: you can obtain the source code of above examples, please visit SIGLENT website at www.siglent.com.
Need help?
Do you have a question about the SDG Series and is the answer not in the manual?
Questions and answers