Test and Measurement Forum

Measurements

Post your VB and VBA discussions here

Measurements

Postby BDR » Tue Aug 18, 2015 3:39 pm

Good day,

Is there a skippy code or picoscope code that only takes the measurement value from the scope and not the entire trace?

Eg. Measure the True RMS value between trigger points, or cursors, and automatically call the MAX value and AVG value into a declared variable.

This would save a lot of processing time for the laptop. Speed is the aim.

I just require this value to be dumped into a calibrated diode detector program I have in VBA to convert the value.
BDR
Super User
Super User
 
Posts: 20
Joined: Tue Aug 18, 2015 3:23 pm

Re: Measurements

Postby Martyn » Mon Aug 24, 2015 9:17 am

The measurements are performed by the PicoScope 6 software, post collection, using the Laptops processing power.
The most efficient way would be to use the VBA application to do the data collection from the driver, and then process the data as required.
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2344
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Measurements

Postby BDR » Mon Aug 24, 2015 11:43 am

I had a feeling that this was the case after playing with it.

I have written the software to do the same processing, but I have noticed a major difference. The speed at which my software makes the calculation is much slower. While I am streaming the data I am calculating. It takes about 23 seconds to calculate from the point where the scope triggers for a 10 second window. The PicoScope software finishes the calculation a second after the capture is complete, mine takes an extra 13 seconds. Do you think that this is due to the nature of VBA? Is the PicoScope software using less points to do a similar calculation? Is there anyway to export this value from the PicoScope software? (why re-invent the wheel)
BDR
Super User
Super User
 
Posts: 20
Joined: Tue Aug 18, 2015 3:23 pm

Re: Measurements

Postby BDR » Mon Aug 24, 2015 11:57 am

I should also mention that I was playing with the buffer size on the scope and noticed a considerable speed difference when using the maximum vs a small chunk. My sample rate isn't any faster than 9.8MS/s. It should come out to 98MS for a 9.8 second window. I am setting this with about a 102ns between points. I figured that you wouldn't see any speed difference since it is just under the buffer size.

When reading the specifications that the scope has a 100MS buffer, it also says it can use the PC as a buffer. How do you do this? The code written for ps6000SetDataBuffer in the manual seems to only refer to the buffers on the channels. I tried declaring a variant in replacement of a channel buffer, but this seems to just crash VBA.
BDR
Super User
Super User
 
Posts: 20
Joined: Tue Aug 18, 2015 3:23 pm

Re: Measurements

Postby Martyn » Fri Aug 28, 2015 8:40 am

I would look at downsampling the data from the device as part of the data collection, that is what the PicoScope 6 software is doing. This helps to reduce the loading on the USB bus.

As you are sampling at low rates it would be possible to use streaming mode which will transfer data directly to the PC's memory rather than collecting to the device. Once you have all the data in the PC, you would then be able to perform the calculations without the need to download data from the device.
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2344
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Measurements

Postby BDR » Mon Feb 15, 2016 3:35 pm

One more question about the measurement coming from the picoscope software.

I was reading about the picoscope processing an image for the PC to view the signal, and reprocesses when you want to see more detail.

Are the measurement results from the pico software downsampled as well or are they based on the raw data?

It says "whole trace" so I would assume it is averaging each raw data point.
BDR
Super User
Super User
 
Posts: 20
Joined: Tue Aug 18, 2015 3:23 pm

Re: Measurements

Postby Martyn » Fri Feb 19, 2016 11:57 am

When you apply measurements, the software will call down a subset of the data from the device to perform the calculation. The amount of data will be appropriate for the measurement(s) you have requested and whether you are looking at the full window or a portion of it.
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2344
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Measurements

Postby BDR » Mon Feb 29, 2016 7:10 pm

I am trying to figure out the downsampling mode.

I have turned on averaging mode. My program keeps returning that the ratio is invalid. I have tried putting in several values into the downsample ratio. It keeps giving me the same error.

I was expecting that if you put in 4, every 4 points will be averaged.

I am able to stream with my program, but I fall behind 3.4 seconds for every 10 seconds of recording. There is no dataloss up until I reach 30 seconds. I don't know if this is because I am using VBA. I have an i7 chip in the laptop. I have set VBA to realtime processesing. There is only two codes in the loop. One to indicate where the sample index is and one doing math to convert the values to mV and then taking averaging the RMS value. Once it exits the loop it divides it by the total number of samples.

Would you be able to assist with this downsample ratio?
BDR
Super User
Super User
 
Posts: 20
Joined: Tue Aug 18, 2015 3:23 pm

Re: Measurements

Postby Martyn » Tue Mar 01, 2016 1:29 pm

Can you post your code so that we can take a look, and hopefully we can help you out.
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2344
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Measurements

Postby BDR » Wed Mar 02, 2016 12:28 pm

Good day,

I have solved my problem, and I do not need to downsample. Other people may run into this problem.

Start Loop

Slow Code: TRUERMS = ((Sample(i) / 32512) * Vertical Scale) ^ 2 + TRUERMS

Faster Code: TRUERMS = (((Sample(i) / 32512) * Vertical Scale) * ((Sample(i) / 32512) * Vertical Scale)) + TRUERMS

Loop

Then divide by the total number of samples and root once you exit the loop. When you set Applications.Calculation = xlCalculationManual it seems to go slightly faster as well. I seem to be able to get up to 20MS/s while calculating the true rms before the computer can no longer keep up. I am using a 32bit version of excel currentely, and will eventually get a 64bit verison.

I am now having a problem with the Picoscope sending back an error of: PICO_MEMORY_FAIL: - Not enough memory could be allocated on the host machine. This happens when I try to demand a lot of samples 600MSamples+. Is there a way to have it continually run forever until I tell it to stop?

There is plenty of memory available on the laptop. Is there a setting in excel that I have to set to demand more resources from the hardware? It seems to do this calculation before attempting to stream. Is there a way around this problem so that the Picoscope will at least make an attempt?
BDR
Super User
Super User
 
Posts: 20
Joined: Tue Aug 18, 2015 3:23 pm

Re: Measurements

Postby BDR » Thu Mar 03, 2016 3:31 pm

One more problem to solve from the previous post...

I have tried downsampling anyways to see how much vertical accuracy is lost. I have turned up the sample rate equal to the downsample rate. I have been playing with it to see the trade off between real time and vertical accuracy. I seem to hit a wall when I tried to turn the sample rate beyond 156MS/s. It seems to be programmed because of the USB3 limit. If I am downsampling, should I not be able to surpass the 156MS/s limit?
BDR
Super User
Super User
 
Posts: 20
Joined: Tue Aug 18, 2015 3:23 pm

Re: Measurements

Postby BDR » Fri Mar 04, 2016 1:52 pm

Is there a command to determine what sample rate has been chosen by the scope once you pass the channel parameters?

If I set the channel to 102ns I have noticed that I am closer to 102.4ns. I need to know that exact number so that I can determine the limit of real time measurements.
BDR
Super User
Super User
 
Posts: 20
Joined: Tue Aug 18, 2015 3:23 pm

Re: Measurements

Postby Gerry » Mon Mar 07, 2016 4:55 pm

Hi BDR,

Transfer rates over USB can vary widely due to the real time utilization of the bus, and we have found that the fastest reliable transfer rate of PicoScope data over USB 3.00 is 156MS/s. For this reason the maximum streaming rate has been capped at that rate.

The exact sample interval used should be available in the location pointed to by *sampleInterval, when you exit the runStreaming() command, and will be in the units that you specified when executing the function (further details are in the Programmers Guide for your PicoScope).

Regards,

Gerry
Gerry
Technical Specialist
Gerry
PICO STAFF
PICO STAFF
 
Posts: 78
Joined: Mon Aug 11, 2014 11:14 am

Re: Measurements

Postby BDR » Mon Mar 14, 2016 5:26 pm

Good day,

Thank you. I didn't not realise that there was also a return from variable.

I am still stuck at 20MS/s while calculating the RMS with no dataloss. When I try to repaint any values in a window for the user to see (once in 2-3seconds), it takes away too much from the computer to keep up. I will just have to play with it to see what is optimum.
BDR
Super User
Super User
 
Posts: 20
Joined: Tue Aug 18, 2015 3:23 pm

Re: Measurements

Postby Gerry » Tue Mar 22, 2016 5:16 pm

Hi BDR,

How are you calculating the RMS values?

If you're calculating the values from the raw sample data, but only displaying RMS values every 2 or 3 seconds, then you would be better off letting the driver reduce the amount of calculations that need to be done, by downsampling in 'Average' mode, and then calculating the RMS values from the downsampled values. You can still collect and store the raw sample values if they're required for later calculations. You can get both downsampled, and raw data from the driver, because the call back function will place the full sample value data in one buffer, and the downsampled data in another. You just need to setup the buffers and provide their location to the callback function.

Regards,

Gerry
Gerry
Technical Specialist
Gerry
PICO STAFF
PICO STAFF
 
Posts: 78
Joined: Mon Aug 11, 2014 11:14 am


Return to VB and VBA (Excel, Access)

Who is online

Users browsing this forum: No registered users and 0 guests