Test and Measurement Forum

Average Function

Post your .Net discussions here

Average Function

Postby BDR » Wed Feb 08, 2017 11:52 am

Is it possible to have the average function take the rms instead of the arithmetic mean?

Eg. PS6000_RATIO_MODE_AVERAGE

*Update.

I have tried this average mode, and the buffers are always empty. I have searched the forum and found other people having the same trouble.

*2nd Update

I have unravelled the confusion. I was reading the manual and the enumerate said 0 for none, and =2 for average. It is actually 3. The averaging now seems to work, although I am still wondering if the FPGA can be changed to do the square.

*3rd update

The averaging isn't working at all. As I increase the averaging and sample rate, the computer begins to not keep up with the sampling rate. This makes me believe that the averaging isn't working at all.

I cannot understand the manual. Should I be using the GetStreamingLatestValues, or ps6000GetValuesAsync with the ps6000DataReady callback?
When I try declaring the call back, it simply says that it doesn't exist in the .dll. The manual has no examples of how to declare or use this averaging hardware.
BDR
Active User
Active User
 
Posts: 20
Joined: Tue Aug 18, 2015 3:23 pm

Re: Average Function

Postby Martyn » Fri Feb 10, 2017 1:03 pm

We probably need to see your code to understand what you are doing, and what may be going wrong.

Downsample averaging is a technique to reduce the amount of data you need to retrieve from the device. If you have 10000 samples collected in a buffer, and you downsample and average by a factor of four, you will receive just 2500 samples covering the buffer.

Is this what you are expecting from the average function ?
Martyn
Technical Support Manager
Martyn
Site Admin
Site Admin
 
Posts: 3217
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Average Function

Postby BDR » Fri Feb 10, 2017 5:27 pm

I have figured out what the problem is now. The average function is now working. I did not realise that I also had to set the data buffer to average mode as well. At least it seems that way. Everything runs now.

When the scope uses hardware to average points, I am assuming it is doing (p1 + p2 + p3) / 3 if it is set for 3. Then passing that average as a single point.

Is there anyway to get it to do SQRT((p1 ^2 + P2 ^2 + P3 ^2) / 3) or even just the square and then my software completes it.
BDR
Active User
Active User
 
Posts: 20
Joined: Tue Aug 18, 2015 3:23 pm

Re: Average Function

Postby BDR » Tue Feb 14, 2017 11:49 am

Never mind, I have figured out a better way of doing business :O)
BDR
Active User
Active User
 
Posts: 20
Joined: Tue Aug 18, 2015 3:23 pm

Re: Average Function

Postby Martyn » Tue Feb 14, 2017 12:17 pm

Thanks for letting us know :)
Martyn
Technical Support Manager
Martyn
Site Admin
Site Admin
 
Posts: 3217
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Average Function

Postby BDR » Wed Feb 15, 2017 4:21 pm

Are the math channels done on the scope, or post process on the PC?
BDR
Active User
Active User
 
Posts: 20
Joined: Tue Aug 18, 2015 3:23 pm

Re: Average Function

Postby ishoro13 » Tue Feb 21, 2017 11:37 am

Hello BDR,

Could you please attache the code for AVERAGE FUNCTION, just now I'm using following code in python:
Code: Select all
self.raw_data = self.scope.getDataV('A', self.nSamples,startIndex=0, downSampleRatio=8, downSampleMode=2, returnOverflow=False);


But it is arithmetic mean, what I need is sum of the levels of the waveform samples divided by the number of samples.

So I guess it could be implemented something like that:
Code: Select all
self.scope.setNoOfCaptures(32)/32

But unfortunately it didn't work, do I need to use buffer function as well?
ishoro13
Newbie
 
Posts: 0
Joined: Thu Feb 02, 2017 5:27 pm

Re: Average Function

Postby BDR » Wed Feb 22, 2017 4:30 pm

I cannot post code because I am on a defence network.

If you are using the averaging on the scope, the total number of samples you should receive should decrease by the ratio you entre into the streaming call or block call AND setdatabuffer.

There are a few ways of getting your total number of samples, but the easiest way to do so is used the AvailableData call, and simply declare a variable in your program that you can add this too.

When you want your result you divide it by the running number once you've dealt with the last set of incoming data. You don't want to by accident do this prior to finishing the averaging if you are using the AvailableData call. If you are simply counting as you go, then you can do it when you like.
BDR
Active User
Active User
 
Posts: 20
Joined: Tue Aug 18, 2015 3:23 pm

Re: Average Function

Postby Stone_Mei » Mon Apr 02, 2018 7:28 am

Hi BDR!

Could you please tell me which API functions did you use to implement The average?

Thank you!
Stone_Mei
Newbie
 
Posts: 0
Joined: Fri Dec 22, 2017 6:28 am

Re: Average Function

Postby Martyn » Mon Apr 02, 2018 8:25 am

Look at Downsampling Modes on Page 37 of the Programmer's Guide
Martyn
Technical Support Manager
Martyn
Site Admin
Site Admin
 
Posts: 3217
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Average Function

Postby Stone_Mei » Tue Apr 03, 2018 7:24 am

Hi Martyn!

I have some questions about Pico4824 Aerage function,so I send e-mail to support@picotech.com for several times .Unfortunately, all e-mail were returned all the time.
Stone_Mei
Newbie
 
Posts: 0
Joined: Fri Dec 22, 2017 6:28 am

Re: Average Function

Postby Martyn » Tue Apr 03, 2018 7:41 am

Please try sending an email again, I will check the servers and spam folders, we receive other emails from your company.
Martyn
Technical Support Manager
Martyn
Site Admin
Site Admin
 
Posts: 3217
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Average Function

Postby Stone_Mei » Wed Apr 04, 2018 8:05 am

Hi Martyn!
I have tried again,it was returned again.
Maybe somebody put me on the blacklist

The mailbox prompt message is as attachment screenshot in Chinese:
IP server feedback: your mail or account or mail domain was black.
Attachments
1.jpg
Stone_Mei
Newbie
 
Posts: 0
Joined: Fri Dec 22, 2017 6:28 am

Re: Average Function

Postby Stone_Mei » Wed Apr 04, 2018 8:30 am

Hi Martyn!

My question and requirement is as follows:
Instrument:Pico4824
Need Function:Average of Downsampling
Programming language:C#
Channel:only one
Error one:
status = Imports.SetDataBuffers(handle, (Imports.Channel)i, maxBuffers, minBuffers, (int)sampleCount, 0, Imports.DownSamplingMode.Average);// .None);
status=13 #define PICO_INVALID_PARAMETER 0x0000000DUL

Error two:
status = Imports.GetValues(handle, 0, ref sampleCount, 10, Imports.DownSamplingMode.Average, 0, out overflow);
status=70 #define PICO_BUFFERS_NOT_SET 0x00000046UL
The return values of sampleCount is FFFFFFFF.

Not only that,for DECIMATE and AGGREGATE function,the error is same.

I also have a Pico6000 series oscilloscope,I only change some values of the procedure based SDK Demo,Pico600series oscilloscope is working good.Pico4824 procedure is simillar to Pico6000 series oscilloscope
I don't know what's wrong.Maybe you can help me.

The attachment is procedure file.
My english is poor,Hard you.

Maybe you can find my e-mail in blacklist.
Attachments
PS4000A.rar
(98.23 KiB) Downloaded 83 times
Stone_Mei
Newbie
 
Posts: 0
Joined: Fri Dec 22, 2017 6:28 am

Re: Average Function

Postby Martyn » Wed Apr 04, 2018 10:07 am

I can't find emails but have looked at the code and in the first instance I would try
Code: Select all
uint sampleCount = BUFFER_SIZE;
Martyn
Technical Support Manager
Martyn
Site Admin
Site Admin
 
Posts: 3217
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Next

Return to .Net Languages (C#, VB.Net, .)

Who is online

Users browsing this forum: No registered users and 0 guests