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
Super User
Super 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: 2658
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
Super User
Super 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
Super User
Super 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: 2658
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
Super User
Super 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
Super User
Super User
 
Posts: 20
Joined: Tue Aug 18, 2015 3:23 pm


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

Who is online

Users browsing this forum: No registered users and 0 guests