Post your MATLAB discussions here

tiaschaer
 Newbie
 Posts: 0
 Joined: Tue Feb 26, 2019 5:34 pm
Post
by tiaschaer » Tue Feb 26, 2019 6:02 pm
Hi guys,
I have a PicoScope 4824 and need some help regarding the frequency of the AWG.
The frequency of the AWG can be set with the following code
Code: Select all
set(PicoDevice.Signalgenerator(1), 'startFrequency', setFreqHz);
set(PicoDevice.Signalgenerator(1), 'stopFrequency', setFreqHz);
where setFreqHz is a MATLAB double defining the frequency in Hz.
Since the AWG frequency resolution is < 20mHz (see device specs), the set value setFreqHz is rounded to the nearest available frequency, which I call "actual frequency". Since I am working with frequencies in the range of 1Hz  10Hz, 20mHz represents a nonnegligible difference from the desired set frequency.
My simple question is now: How do I get the AWG actual frequency in MATLAB?
Thank you a lot for your help!

tiaschaer
 Newbie
 Posts: 0
 Joined: Tue Feb 26, 2019 5:34 pm
Post
by tiaschaer » Wed Mar 20, 2019 1:32 pm
Hi guys,
Nobody can help?
Thanks,
Mattia

Hitesh
 PICO STAFF
 Posts: 2855
 Joined: Tue May 31, 2011 3:43 pm
 Location: St. Neots, Cambridgeshire
Post
by Hitesh » Tue Mar 26, 2019 5:16 pm
Hi Mattia,
Sorry for the delay in someone responding to you.
The MATLAB Instrument Driver unfortunately does not report back the actual frequency being output (there isn't a function to do this in the shared library).
However, it should be possible to calculate this using the formula in the delta phase in the Programmer's Guide (see section 4.57.2 Calculating deltaPhase).
Please note that there is a freq2delta() function in the PicoScope Support Toolbox that you can use to calculate this. The delta phase is an integer value that you can then use to calculate the actual frequency. Try rounding the delta phase down to the nearest integer integer and calculate the frequency. You can then try capturing an output of your signal from the AWG, calculate the frequency and compare it against the first calculation.
Hope this helps,
Hitesh
Software Dev. Engineer