MATLAB Answers


How can I properly time instrument (signal generator) signal transmission using SCPI commands?

Asked by Zach Colwell on 18 Dec 2018
I am working with a Rohde & Schwarz signal generator (SMC100A). I am remotely programming this instrument using SCPI through matlab. I need to generate a sequence of pulses where each pulse is swept over time from 100MHz-300MHz so the pulse transmits each frequency for roughly 50us. In other words each pulse transmits a signal at 100MHz for 50us, then 101 MHz for 50us until finally reaching 300MHz for 50us. Then, since this is the end of pulse, we wait 1ms until transmitting another pulse.
I am reading my pulse generation using an oscilloscope, which is how I know the pulse sequence generation is incorrect.
For now, I am just trying to generate one pulse after another (two pulses total) in order to make sure I understand the process of sequential commands.
I am able to generate a single pulse fine, as that is a simple sawtooth frequency sweep. My problem comes in when trying to generate another pulse after the first one.
I believe the issue to be my misunderstanding of the "*OPC?" Query Command but I am not sure where my misunderstanding lies.
Currently I am performing these steps in the code:
1) Initialize the hardware
2) Setup the frequency sweep
3) Execute the first pulse
4) Send the "*OPC?" command to the instrument
5) Send another pulse
6) Send the "*OPC?" command to the instrument
7) Turn off the RF signal generation
What I expect to happen is one pulse transmits, a second pulse transmits and then the RF signal is turned off completely.
What is actually happening is one frequency of one pulse is sent, the RF power is turned off, and the signal generator is still sweeping through all frequencies of the pulse.
This leads me to believe "*OPC?" does not operate the way I believed but I do not know how to fix it.
My code is below. "SMC100A" refers to the VISA_Instrument object instantiated.
Is there a straightforward way for me to properly time the equipment to make this pulse sequence possible?
Thank you.
%Pulse Setup (User Input)
pulseCenter = 200e6; %Center frequency of pulse
pulseDelta = 100e6; %Change in frequency from center to max/min
pulseStep = 1e6;
dwellTime = .01; %Time of each frequency transmission within a pulse
powerLevel__dBm = (-30);
%Command-input transcribed from user input
startFREQ = num2str(pulseCenter - pulseDelta);
stopFREQ = num2str(pulseCenter + pulseDelta);
stepFREQ = num2str(pulseStep);
dwellTIME = num2str(dwellTime);
powerLevel_dBm = num2str(powerLevel__dBm);
%Enter instrument/device IP Address
Device_IP = '000000000'; %Input IP Here
SMC100A = VISA_Instrument(strcat('TCPIP::',Device_IP,'::INSTR'));
%Initialize Device
systemResponse = SMC100A.QueryString('*IDN?'); %System identification
fprintf('\nInstrument Identification string: %s\n', systemResponse);
SMC100A.Write('*RST;*CLS'); % Reset the instrument, clear the Error queue
SMC100A.Write('INIT:CONT OFF'); % Switch OFF the continuous sweep
SMC100A.Write('SYST:DISP:UPD ON'); % Display update ON
SMC100A.ErrorChecking(); % Error Checking after Initialization block
% Setup Frequency Sweep
SMC100A.Write('OUTP ON'); %Turn RF ON
SMC100A.Write('TRIG:FSWeep:SOUR SING'); %Set Trigger to 1 trigger 1 sweep
SMC100A.Write('SOUR:SWE:FREQ:SHAP SAWT'); %Set sweep to sawtooth
SMC100A.Write('SOUR:FREQ:MODE SWE') %Set frequency sweep to autosweep when triggered
SMC100A.ErrorChecking(); % Error Checking
SMC100A.Write(strcat(['POW' ' ' powerLevel_dBm]));%Set Power Level
SMC100A.Write(strcat(['SWE:STEP:LIN' ' ' stepFREQ])); %Set step freq within pulse
SMC100A.Write(strcat(['SWE:DWEL' ' ' dwellTIME])); %Set frequency transmit time
SMC100A.Write(strcat(['FREQ:STAR' ' ' startFREQ])); %Set start frequency
SMC100A.Write(strcat(['FREQ:STOP' ' ' stopFREQ])); %Set stop frequency
SMC100A.ErrorChecking(); % Error Checking
%Execute Pulse 1
SMC100A.Write('*WAI'); %Wait for setup to be complete
SMC100A.Write('SOUR:SWE:FREQ:EXEC'); %Execute Sweep 1
buffer = SMC100A.QueryInteger('*OPC?');
SMC100A.ErrorChecking(); % Error Checking
%Execute Pulse 2
SMC100A.Write('SOUR:SWE:FREQ:EXEC'); %Execute Sweep 2
buffer = SMC100A.QueryInteger('*OPC?');
SMC100A.ErrorChecking(); % Error Checking
%Turn of RF Power
SMC100A.Write('OUTP OFF');
SMC100A.ErrorChecking(); % Error Checking


Sign in to comment.

0 Answers