Matlab Resolution is worse than Picolog 6 Software

Post your MATLAB discussions here
jcwalpole
Newbie
Posts: 0
Joined: Fri Dec 04, 2020 1:52 pm

Matlab Resolution is worse than Picolog 6 Software

Post by jcwalpole »

Hi,

I'm using a Picolog 1216. When collecting data from the Picolog the voltage resolution is around 0.5mV which is limited by the different between integer adc counts. However, with the PicoLog 6 software the resolution is much higher. How is this the case and how would I get a similar precision from data collected in MatLab?

Thanks,
James

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

Re: Matlab Resolution is worse than Picolog 6 Software

Post by Gerry »

Hi James,

How are you determining that the PicoLog 6 resolution is larger? (could you give us some example data).

Regards,

Gerry
Gerry
Technical Specialist

jcwalpole
Newbie
Posts: 0
Joined: Fri Dec 04, 2020 1:52 pm

Re: Matlab Resolution is worse than Picolog 6 Software

Post by jcwalpole »

Hi Gerry,

In the PicoLog software the data is quoted to the nearest 0.001 mV. For example in a set of data that I took the first two values were 0.914608 V and 0.914609 V. When using Matlab to collect data, the maximum ADC value for the Picolog 1216 is 4095 so the resolution of the data is set by 1x2.5/4095=0.6 mV and this is reflected in the data.

Thanks,
James

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

Re: Matlab Resolution is worse than Picolog 6 Software

Post by Gerry »

Hi James,

Could you post a Picolog data file so that we can see what is being captured.

Regards,

Gerry
Gerry
Technical Specialist

jcwalpole
Newbie
Posts: 0
Joined: Fri Dec 04, 2020 1:52 pm

Re: Matlab Resolution is worse than Picolog 6 Software

Post by jcwalpole »

Hi Gerry,

Here is some sample data from Picolog:
Jan 12, 2021 9-40-51 AM.picolog
(22 KiB) Downloaded 714 times
and some from MATLAB
pl1000MatlabExample.xlsx
(4.72 KiB) Downloaded 655 times
Thanks,
James

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

Re: Matlab Resolution is worse than Picolog 6 Software

Post by Gerry »

Hi James,

Sorry for the delay in responding.

The increased resolution that you are referring to is due to the averaging of the waveform by the selected Sample Mode for the channel. The averaging process changes the individual quantised values used in the calculation to a statistical composite value that is not bound by the sampling process. You will see that if you select Latest Sample the resolution goes back to what you have in Matlab.

The effect can be explained by an analogy. If you look at the printing process of Newspapers where the printing press is monochrome only, with just black dots they are able to print intermediate shades of grey which depend upon the concentration of the black dots. So, when displaying averaged sample values we are able to display intermediate values which depend upon the concentraion of values around a mean.

The effect in PicoLog 6 is similar to the Resolution Enhancement done in PicoScope 6 channels, with the exception that it is more of a stepping average, while Res Enhance is more of a rolling average (so PicoLog averaging also reduces the number of samples, while Res Enhance doesn't). So if you want to reproduce it in Matlab you can just average each number of samples into 1 value, or you can go one better and perform your own Resolution Enhancement (without downsampling the data at the same time) by replacing every sample value with the average of a number of samples around it.

Regards,

Gerry
Gerry
Technical Specialist

jcwalpole
Newbie
Posts: 0
Joined: Fri Dec 04, 2020 1:52 pm

Re: Matlab Resolution is worse than Picolog 6 Software

Post by jcwalpole »

Hi Gerry,

Thanks for the clear explanation, that makes a lot of sense. Thanks for your help.

Best wishes,
James

brucep
Newbie
Posts: 0
Joined: Wed Jan 20, 2021 10:42 pm

Re: Matlab Resolution is worse than Picolog 6 Software

Post by brucep »

Hi Gerry,

I'd like to follow this question since I have the similar confusion. I'm trying to measure the same signal with both matlab and my picoscope 5443D with the same settings (8 bits, 125 MS), and the PS graph is captured from my instant signal from channel B, not the average one. However, the results look quite different as I attached below. It looks like the noise in matlab is much larger and I can not see my echo signal in it. I'm wondering if you have any suggestions for it? Thanks so much.
Attachments
PS.tif
(66.34 KiB) Not downloaded yet

brucep
Newbie
Posts: 0
Joined: Wed Jan 20, 2021 10:42 pm

Re: Matlab Resolution is worse than Picolog 6 Software

Post by brucep »

It looks like I miss one fig above.

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

Re: Matlab Resolution is worse than Picolog 6 Software

Post by Gerry »

Hi brucep,

Could you post your data file created in PicoScope 6, so that we can see what you're referring to.

Regards,

Gerry
Gerry
Technical Specialist

brucep
Newbie
Posts: 0
Joined: Wed Jan 20, 2021 10:42 pm

Re: Matlab Resolution is worse than Picolog 6 Software

Post by brucep »

Hi Gerry,

Thanks for your reply. I've attached my psdata file in the reply and it looks like there are some problems with my Matlab code and I've figured it somehow. However, I do have another two questions about Matlab streaming data collection and I'm wondering if you could help.
1) I've read the API programmer's guide on another topic and it says the streaming mode is directly writing the data into the PC. I'm now trying to collect data with a high sampling rate (125 MS). While for a 4s streaming, it takes over an hour for the collection, I'm wondering during this period, where is my data stored and if the result is credible?
2) In the PicoScope 6, I can get a sampling rate high to 500 MS for two channels in my 5443D and 1 GS for one channel. While in the Matlab, I cannot adjust the streaming interval lower than 8e-9(125 MS) even under 8 bits resolution, I'm wondering why this would happen and can we change this?

Best,
Yande
Attachments
8bit_125MS_sampling_rate_pulse_echo_2.8MHz_PS.psdata
(481.82 KiB) Downloaded 663 times

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

Re: Matlab Resolution is worse than Picolog 6 Software

Post by Gerry »

Hi Yande,

To answer your questions:

1/ Streaming is way of transferring the data to the computer, effectively in real-time, as it is being acquired by the hardware PicoScope. When streaming data to the PC, the data is transferred to the buffer in the Driver. It is the responsibility of your application code to transfer it from the Driver buffer to the buffer that you have created for your application code, and you need to be doing this at a rate that is faster than the rate that the data is transferred to the Driver buffer to avoid data loss (the Driver is a circular buffer, so it will overwrite old data with new data once the buffer is full). So, if you are doing that correctly then 4s of streaming should take only slightly longer than 4s to acquire all of the data, and the data should be in the buffer that you have transferred it to.

2/ In PicoScope 6, Streaming is referred to as 'Slow Sampling Mode', and the fastest Timebase that you can use is, by default 100ms/div. So, you will only get relatively slow sample rates when streaming in PicoScope 6 and also when streaming in Matlab. This is because, at faster data rates, the data is arriving too quickly to be able to reliably transfer it over USB and process it on the computer, all in real-time. (Note that you can tell when you are in Slow Sampling Mode in PicoScope 6, because, with an empty graph, you will see the waveform being drawn as the data is being collected).
So, at faster rates (such as 500MS/s and 1GS/s) the hardware PicoScope needs to wait until it has acquired all of the data before transferring to to the computer. These faster sample rates are referred to as 'Fast Sampling Mode' in PicoScope 6, which is referred to as 'Block Mode' in the Programmers Guide (and also 'Rapid Block Mode' and 'ETS Mode').

Regards,

Gerry
Gerry
Technical Specialist

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

Re: Matlab Resolution is worse than Picolog 6 Software

Post by Gerry »

Hi Yande,

I forgot to add that the Matlab example files on Github (see here: https://github.com/picotech/picosdk-ps5 ... ent-driver) have examples of streaming code that you can look through, to see how it is done.

Regards,

Gerry
Gerry
Technical Specialist

brucep
Newbie
Posts: 0
Joined: Wed Jan 20, 2021 10:42 pm

Re: Matlab Resolution is worse than Picolog 6 Software

Post by brucep »

Hi Gerry,

Thanks so much for your explanation. I'm having one more question that may need your help with. One thing I found in my final data in channelBFinal (PS5000A_ID_Streaming_Example) is that the data is defined as int16 type (1 mV) which kind of too low resolution for me since my signal is usually several mV to several tens of mV. I'm trying to change the pDriverBufferChA and pAppBufferChA type from int16 to single. But it turns out that it will also affect other functions which I don't really understand with the following instructions:

Error using privateExecuteMCode (line 44)
Pointer types must match data type.

Error in instrgate (line 20)
[varargout{1:nout}] = feval(varargin{:});

Error in icdevice/invoke (line 73)
output = instrgate('privateExecuteMCode', code, obj, varargin, nargout);

Error in PS5000A_ID_Streaming_Example (line 202)
status.setDataBufferChA = invoke(ps5000aDeviceObj, 'ps5000aSetDataBuffer', ...

I'm wondering how we can solve this. One way I'm thinking about is to use another array to collect the bufferChBmV values, which looks like double type data (I'm not sure as it's collecting data from pAppBufferChA, which should still be int16?). In addition, it will also double the capacity I need. Do you have any suggestions for this? Thanks so much!

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

Re: Matlab Resolution is worse than Picolog 6 Software

Post by Gerry »

Hi Yande,

As this is Language specific (doesn't look as if it benefits Forum members) it's being answered on your support ticket.

Regards,

Gerry
Gerry
Technical Specialist

Post Reply