PS3000A_ID_Streaming_Example application fft

Post your MATLAB discussions here
Post Reply
SG95
Newbie
Posts: 0
Joined: Tue Nov 26, 2019 10:04 am

PS3000A_ID_Streaming_Example application fft

Post by SG95 » Tue Dec 10, 2019 1:52 pm

Hi

For my thesis i'm using matlab on a picoscope. I am using the example code PS3000A_ID_Streaming_Example provided with picotech-picosdk-ps3000a-matlab-instrument-driver-9c2a427. I am trying to do a fast fourier transformation in real time so i think its best to use the example code PS3000A_ID_Streaming_Example. For that i want to understand how precisely the code works. So when the fast fourier is performed on the live data with for example is a sinus. I want to see the peak of the fft change when the amplitude changes of the live data or shift towards the frequency when i change the frequency of the sinus. Can someone help me to explain how the live streaming data works? so how does it saves the data, which variables should i take into account, etc.

thank you in advance

Gerry
PICO STAFF
PICO STAFF
Posts: 548
Joined: Mon Aug 11, 2014 11:14 am

Re: PS3000A_ID_Streaming_Example application fft

Post by Gerry » Wed Dec 11, 2019 11:39 am

Hi SG95,

If an FFT was calculated using individual, or small groups of samples to plot small parts of the spectrum, gradually building up the complete spectrum over time, then it would be convenient to calculate and plot streamed data as it is being received. But when you perform an FFT you are transforming a complete buffer of Time domain data into a complete buffer of Frequency domain data, and to minimize data loss, you need to ensure that you can plot the FFT faster than the rate that you are capturing a buffer of data. So, the time to (a) transmit all of the samples required for the number of bins you will transform them into, (b) transform them using a method that includes calculating the FFT, and then (c) display the data, should not be longer than the time to capture the data. For this reason block mode would be better than streaming mode, as you can be doing (a), (b) and (c) while you are capturing the next buffer of data (if you are streaming the data then you will have significantly less time and therefore be more likely to lose data).

For real-time display you need to also ensure that you are not using too many samples or bins, and/or not sampling too slowly, so that the time to capture the data you need is short enough for the spectrum plots to appear continuous.

The easiest way to understand how block mode is implemented would be to
1/ Look through the description on page 10 of the Programmer's Guide (here: https://www.picotech.com/download/manuals/picoscope-3000-series-a-api-programmers-guide.pdf) and the sequence of functions on Page 11
2/ Download the example code from Github (see here: https://github.com/picotech), go through the code of the functions mentioned on page 11, and then step through the relevant parts of the code so that you can see what it does.

Regards,

Gerry
Gerry
Technical Specialist

SG95
Newbie
Posts: 0
Joined: Tue Nov 26, 2019 10:04 am

Re: PS3000A_ID_Streaming_Example application fft

Post by SG95 » Thu Feb 06, 2020 1:33 pm

hi

so if i understand this, the first thing that the script does is set up the device. like it says in the sequence. for capturing multiple blocks after each other to make it like real time you have to repeat: ps3000aRunBlock, ps3000ablockready, ps3000asetDataBuffer and ps3000aGet values. is this possible with a while loop where the argument represents the number of data blocks you want to capture? so in the script its a while loop between capture data and plot data?

best regards
Attachments
code.PNG
flowchart_blockmode.PNG

NeilH
PICO STAFF
PICO STAFF
Posts: 158
Joined: Tue Jul 18, 2017 8:28 am

Re: PS3000A_ID_Streaming_Example application fft

Post by NeilH » Tue Feb 11, 2020 9:18 am

What exactly are you trying to do in MATLAB?
Neil
Technical Support Engineer

SG95
Newbie
Posts: 0
Joined: Tue Nov 26, 2019 10:04 am

Re: PS3000A_ID_Streaming_Example application fft

Post by SG95 » Fri Feb 14, 2020 10:30 am

hi neil

i am trying to capture an elektromagnetic spectrum. so the main objective is to read data for like1 or 2 minutes. i understand that for in block mode the best thing tot do is to capture multiple blocks with a duration between block as low as possible(idealistic is 0) beceause to determine the exposure to elektromagnetic fields you need to capture every peak. so when the time between 2 blocks is to big it could be that it didnt capture a peak. for this exposer i need e method called weighted peak method. this method consist of an fft. so for eacht block of data i need a fft. then i will try to transfer the information of this fft(amplitude, phase) to an other script(CSV) to calculate the exposure. and repeat this for every block. the first step is to make it real time i guess. but I don't quite understand how to do this. I hope you understand what im trying to do?

Post Reply