Triggering AWG for Frquency Sweeps

Post your MATLAB discussions here
Post Reply
jasmin287
Newbie
Posts: 1
Joined: Mon Aug 15, 2016 9:21 am

Triggering AWG for Frquency Sweeps

Post by jasmin287 »

Hi everyone!

I'm trying to use AWG in order to create gaussian pulses in a certain frequency, and then sweep the frequency of the pulses, let's say every few seconds.

What happens now is that the pulses remain on the Start frequency that I have set, and do not change.
I believe the problem is in the trigger, although I have tried changing the trigger's source and type, but no luck there.

Can someone please guide me on this? What seems to be the issue?
* The code is leaning on the example codes, but with adjustments that have tried.

Code: Select all

PS4000Config;

%% Device Connection

% Create a device object. 
ps4000DeviceObj = icdevice('picotech_ps4000_generic.mdd');

% Connect device object to hardware.
connect(ps4000DeviceObj);


%% Paramteres
sigma=1.5;
variance=sigma^2;

timebase = 120; %( timebase + 1 ) / 10,000,000 = sample interval (sec)
startfreq = 10; %Hz
stopfreq = 50; %Hz
pktpk = 1000; % Peak to peak in mV
dwell = 1; % Dwell time between sweeps
increment = 20; %sweep inc. in Hz

% Calculated paramteres
sampleintervalS = (timebase + 1) / 10000000; % Sample interval in sec
sampletime = (( stopfreq - startfreq ) * dwell) / increment ; % How long to measure in sec
% numsamples = ceil( sampletime / sampleintervalS); 
numsamples = 1e6;

%% Obtain Signal Generator Group Object
% Signal Generator properties and functions are located in the Instrument
% Driver's signalGenerator group.

sigGenGroupObj = get(ps4000DeviceObj, 'Signalgenerator');
sigGenGroupObj = sigGenGroupObj(1);

%% Arbitrary Waveform Generator - Set Parameters

% Configure property value(s).
set(ps4000DeviceObj.Signalgenerator(1), 'startFrequency', startfreq);
set(ps4000DeviceObj.Signalgenerator(1), 'stopFrequency', stopfreq);
set(ps4000DeviceObj.Signalgenerator(1), 'offsetVoltage', 0.0);
set(ps4000DeviceObj.Signalgenerator(1), 'peakToPeakVoltage', pktpk);

% Define Arbitrary Waveform - must be in range -1 to +1
% Arbitrary waveforms can also be read in from text and csv files using
% dlmread and csvread respectively.
% AWG Files created using PicoScope 6 can be read using the above method.

awgBufferSize = get(sigGenGroupObj, 'awgBufferSize');
x = [-pi:(2*pi)/(awgBufferSize - 1):pi];
y = normalise((exp(-x.^2/(2*variance))));


% Increment      : 0 (Hz)
% Dwell Time     : 1 (s)
% Arb. Waveform  : y (defined above)
% Sweep Type     : 0 (ps3000aEnuminfo.enPS3000ASweepType.PS3000A_UP)
% Operatiom?
% Operation      : 0 (ps3000aEnuminfo.enPS3000AExtraOperations.PS3000A_ES_OFF)
% Shots          : 2
% Sweeps         : 0
% Trigger Type   : 0 (ps3000aEnuminfo.enPS3000ASigGenTrigType.PS3000A_SIGGEN_RISING)
% Trigger Source : 4 (ps3000aEnuminfo.enPS3000ASigGenTrigSource.PS3000A_SIGGEN_SOFT_TRIG)
% Ext. Threshold : 0
[status.setSigGenArbitrary] = invoke(sigGenGroupObj, 'setSigGenArbitrary', increment, dwell, y, 0, 0, 0, 0, 1, 3, 1, 0);
Any help would be appreciated!

Thank you so much,
Jasmine

Hitesh

Re: Triggering AWG for Frquency Sweeps

Post by Hitesh »

Hi Jasmine,

What is the specific trigger condition under which you wish to start the sweep? Have you tested the setup using the PicoScope 6 software?

With the parameters set below it looks as though you are setup a scope trigger (1) with a gate low setting (3), which I don't think is correct.

We do have a guide on how to trigger PicoScope signal generators using the API functions which might provide some guidance.

Regards,

jasmin287
Newbie
Posts: 1
Joined: Mon Aug 15, 2016 9:21 am

Re: Triggering AWG for Frquency Sweeps

Post by jasmin287 »

Hi Hitesh, thank you for your reply.

When testing with the PicoScope 6, there's no need to even setup a trigger. I simply set a Sweep Mode and the signal is sweeping just like that, yet according to what I understand from the guide, by code a rigger must be set.

I would prefer to start the sweep by command (e.g. "sweep_now"), since there is no specific event that should trigger it for now.
I have also gone over the guide that you sent and tried setting up a software trigger (high gate), and then activate it using:

Code: Select all

status = invoke(sigGenGroupObj, 'ps4000SigGenSoftwareControl' , 1);
Or something like that, but it doesn't run. It seems maybe I'm using a wrong handle, but I have tried the same line with ps4000DeviceObj and also triggerGroupObj , but none work, and I get an error (Status code: 48)

What am I doing wrong?

Thanks,
Jasmine

Hitesh

Re: Triggering AWG for Frquency Sweeps

Post by Hitesh »

Hi Jasmine,

If you do not specify a trigger when calling the function to output the signal, the signal generator will start to sweep the frequency of the output.

If you specify a trigger, then the device will output at the start frequency until the trigger event occurs.

Gated triggers apply to the situation where the external trigger input (where available) is used. If you would like to start the sweep using a trigger, then please advise what type of trigger you wish to use (input channel, external trigger or software) and I can specify which parameters you need to set.

The error code 48 when converted to a hexadecimal value indicates PICO_SIGGEN_TRIGGER_SOURCE (refer to the PicoStatus.m file), so there seems to be an issue with the trigger source selected. In the case of using the software trigger you should be able to use something like:

Code: Select all

% Increment      : 0 (Hz)
% Dwell Time     : 1 (s)
% Arb. Waveform  : y (defined above)
% Sweep Type     : 0 (ps4000Enuminfo.enSweepType.UP)
% Operation      : 0 (enPS4000OperationTypes.PS4000_OP_NONE)
% Index Mode     : 0 (ps4000Enuminfo.enIndexMode.SINGLE)
% Shots          : 0
% Sweeps         : 1 (Single sweep)
% Trigger Type   : 0 (ps4000Enuminfo.enSigGenTrigType.SIGGEN_RISING)
% Trigger Source : 4 (ps4000Enuminfo.enSigGenTrigSource.SIGGEN_SOFT_TRIG)
% Ext. Threshold : 0
[status.setSigGenArbitrary] = invoke(sigGenGroupObj, 'setSigGenArbitrary', increment, dwell, y, 0, 0, 0, 0, 1, 0, 4, 0);

status = invoke(sigGenGroupObj, 'ps4000SigGenSoftwareControl' , 1);
How are you observing the output of the signal generator - are you using another oscilloscope to view the waveform or sending the output to an input channel on the PicoScope?

Regards,

jasmin287
Newbie
Posts: 1
Joined: Mon Aug 15, 2016 9:21 am

Re: Triggering AWG for Frquency Sweeps

Post by jasmin287 »

I am using another input of the Picoscope in order to observe the output.

Is there a way to set this trigger to after I start the data capture? I work in streaming mode.

Thanks!
Jasmine

Hitesh

Re: Triggering AWG for Frquency Sweeps

Post by Hitesh »

Hi Jasmine,

After you call ps4000RunStreaming(), try calling ps4000SigGenSoftwareControl() before you start the loop to check for data.

If this still does not work, please post your MATLAB code here or e-mail it to support@picotech.com

Regards,

GUAN YUTIAN
Newbie
Posts: 0
Joined: Fri Nov 29, 2019 12:01 pm

Re: Triggering AWG for Frquency Sweeps

Post by GUAN YUTIAN »

Hi Jasmine,
I meet the same problem .How do you solve the problem ?I use software trigger to control the generator ,but it's useless. Could you give me the code?
Thanks
YUTIAN

Martyn
Site Admin
Site Admin
Posts: 4491
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Triggering AWG for Frquency Sweeps

Post by Martyn »

This is an old topic so I would suggest sending your code to support@picotech.com and the team can take a look.
Martyn
Technical Support Manager

Post Reply