Test and Measurement Forum

Built-In Signal Generator

Post general discussions on using our drivers to write your own software here

Built-In Signal Generator

Postby svebert » Thu Feb 24, 2011 9:32 am

Hallo,

I am writing a Matlab-program to measure with the pico 4227. At the moment i try to understand the signal generator and got it working with the api-function and this code
Code: Select all
[Status] = calllib('ps4000','ps4000SetSigGenBuiltIn',UnitHandle, SigGen.offsetVoltage, SigGen.pkToPk, SigGen.waveType, SigGen.startFrequency, SigGen.stopFrequency, SigGen.increment, SigGen.dwellTime, SigGen.sweepType, SigGen.whiteNoise, SigGen.shots, SigGen.sweeps, SigGen.triggerType, SigGen.triggerSource, SigGen.extInThreshold);
    disp(strcat('GenBuiltIn=',num2str(Status)));

where SigGen holds all the numbers to set the signal generator up.

The problem is, that the measured frequency does not correlate to the frequency i set.

I set 100 Hz for example and measured 42, 80 and 60 Hz. I dont understand this!?!?!

Here are my settings
Code: Select all
%SigGen offset Voltage in muV
SigGen.offsetVoltage=int32(0);
%Peak to peak voltage in muV
SigGen.pkToPk=uint32(600000); %>=500mV and <=4V
%Signal type, please select from table below. Don't forget the single
%quotation marks.
%SigGen.waveType='PS4000_SINE';
SigGen.waveType=int16(0);
%Table of possible built-in waveforms
%'PS4000_SINE' sine wave
%'PS4000_SQUARE' square wave
%'PS4000_TRIANGLE' triangle wave
%'PS4000_RAMP_UP' rising sawtooth
%'PS4000_RAMP_DOWN' falling sawtooth
%'PS4000_DC_VOLTAGE' DC voltage

%Start/stop frequency (picoscope sweeps from start to stop frequency if they are
%different)

SigGen.startFrequency=single(100); %needs to be >=0 and <= 2 000 000
SigGen.stopFrequency=single(100); %needs to be >=0 and <= 2 000 000
SigGen.increment=single(0); %increment of sweep
SigGen.dwellTime=single(0); %time between every increment
SigGen.sweepType='DOWN'; %sweep 'direction', pls select from table below
%table of possible sweepTypes
%'UP'
%'DOWN'
%'UPDOWN'
%'DOWNUP'

%if whiteNoise is set to 1 all settings except offsetVoltage and pkToPk
%will be ignored
SigGen.whiteNoise=int16(0); % either 0 or 1

%number of waveforms to be produced after trigger event
SigGen.shots=uint32(1); %needs to be >=0 and <=???

%number of sweeps to be produced after trigger event,  if this is set to non-zero, shots must be set to
%0
SigGen.sweeps=uint32(0); %needs to be >=0 and <=???


%trigger type to trigger the signal generator
SigGen.triggerType='SIGGEN_RISING'; %pls select from table below
%Table of signal generator trigger type
%'SIGGEN_RISING'
%'SIGGEN_FALLING'
%'SIGGEN_GATE_HIGH' %not supported yet because SIGGEN_SOFT_TRIG not used
%'SIGGEN_GATE_LOW'  %not supported yet --"--

SigGen.triggerSource='SIGGEN_SCOPE_TRIG';
%Table of signal generator trigger sources
%'SIGGEN_NONE' %if other than this is set either shots or sweeps must be
%set to non-zero
%'SIGGEN_SCOPE_TRIG'
%'SIGGEN_AUX_IN'
%'SIGGEN_EXT_IN'
%'SIGGEN_SOFT_TRIG' %not used but wiht the lib-function
%ps4000SigGenSoftwareControl than with SIGGEN_GATE_HIGH/LOW signal
%generator can be triggerd
%if ExtIn is set for trigger source this sets the trigger level
SigGen.extInThreshold=int16(0); %in adc counts

I need more information, the manual doesnt say anything to the units. In what unit shall i input the startFrequency and stopFrequency.
Why do i measure more than one shot? i set shots=1 and the SigGen sends infinitly many shots.
What is about the triggering?
I set SIGGEN_SCOPE_TRIG and i thought (because there is no signal on the scope) the trigger signal would never be send, but the SigGen starts. Why?
Then I thought the trigger Signal would be send 1 time because of the autotrigger-signal what is send after 10ms in my case.
Why does this SOFT_TRIG not work? The function I need is not in the library (header-file). How do I set the Gate high or low?

Thanks for any answers
Sven
svebert
 

Re: Built-In Signal Generator

Postby svebert » Tue Mar 01, 2011 10:35 am

ok, i don't work anymore with the built-in signal generator but with the arbitrary signal generator.
Can please somebody explain this delta-phase to me?
I thought I have understood it but i haven't. In the c-sample there is this formula
Code: Select all
delta = ((frequency * waveformSize) / 8192.0) * 4294967296.0 * 8e-9;
I don't understand it.
Despite the fact that it is not working for me....
I thought every delta the generator steps one index higher in the waveform buffer. But that is not working for me.
Also I cant set the offset voltage. Nothing happens when I alter the value of this parameter in ps4000SetSigGenArbitrary.

Any advises?
svebert
 

Re: Built-In Signal Generator

Postby Chris » Fri Mar 11, 2011 8:50 am

Every 50ns, the delta phase value is added to the "phase accumulator". This is a 32-bit value, of which the top 13 bits are used as the index for the 8k waveform buffer. This means that in order to advance one sample through the waveform buffer, you must add 2^(32-13) = 524288 to the phase accumulator. If you want to advance one sample every 50ns, set the delta phase value to 524288. If you set the delta phase value to 1, the AWG will advance one sample every 524288 * 50ns = 26ms.

The general formula for output frequency (assuming the waveform buffer contains one "cycle" of your wave) is:

Frequency = 20 MHz * ( [Delta Phase] / [2 ^ (32-13)] ) / [Waveform Length]

The reason for the phase accumulator architecture is that it allows lower-frequency signals to be generated (by indexing an 8k buffer directly, the slowest signal you could generate would be 2.4kHz) and gives very precise output frequency resolution (the resolution is 20MHz/2^32 = 0.005Hz).

Any remainder is carried over when the phase accumulator wraps around.
Chris
Site Admin
Site Admin
 
Posts: 169
Joined: Tue Aug 17, 2010 9:00 am
Location: St. Neots


Return to General Software Discussions

Who is online

Users browsing this forum: No registered users and 0 guests