Test and Measurement Forum

Block Mode with PS5203 does not work with one single capture

Post your C and C++ discussions here

Block Mode with PS5203 does not work with one single capture

Postby Jansen » Fri Jul 29, 2016 7:37 pm

Hi, I'm using the rapid block mode to capture one or more power traces. However, after starting my software and capturing a single trace, getValuesBulk does not write anything into the buffer I've allocated for the trace. If i change the number of captures to two, capture the traces, everything works fine. Even when I switch the amount back to one single trace.

Here is some output of the software. All functions for preparing, capturing and receiving a trace return PICO_OK.

Code: Select all
[...]
[21:16:23] [Debug] PicoScope5000(0xff7fc0) Opening the device...
WaitForMultipleObjects Complete
[21:16:26] [Debug] PicoScope5000(0xff7fc0) Handle: 16384
[21:16:26] [Debug] PicoScope5000(0xff7fc0) Device opened!

[21:16:26] [Debug] PicoScope5000(0xff7fc0) on_connected
[21:16:26] [Debug] PicoScope5000Channel(0x1042f10, name = "0") on_connected
[21:16:26] [Debug] PicoScope5000(0xff7fc0) Channel 0 set to true
[21:16:26] [Debug] PicoScope5000Channel(0x1049e88, name = "1") on_connected
[21:16:26] [Debug] PicoScope5000(0xff7fc0) Channel 1 set to false

[21:16:34] [Debug] PicoScope5000(0xff7fc0) Memory Segments set to 1 . Max Samples per capture 33553982
[21:16:34] [Debug] PicoScope5000(0xff7fc0) Number of Captures set to 1
[21:16:34] [Debug] PicoScope5000(0xff7fc0) runBlock worked!

[21:16:34] [Debug] PicoScope5000Channel(0x1042f10, name = "0") Deleting old traces
[21:16:34] [Debug] PicoScope5000Channel(0x1042f10, name = "0") Allocating Traces
[21:16:34] [Debug] PicoScope5000Channel(0x1049e88, name = "1") Deleting old traces
[21:16:34] [Debug] PicoScope5000(0xff7fc0) Callback
[21:16:34] [Debug] PicoScope5000Channel(0x1042f10, name = "0") Setting Data Buffers for  1 traces

[21:16:34] [Debug] PicoScope5000(0xff7fc0) Channel: 0 Bufferaddress: 0x4cc7f48 bufferSize. 10000 waveform: 0
[21:16:34] [Debug] PicoScope5000(0xff7fc0) ps_setDataBufferBulk worked

[21:16:34] [Debug] PicoScope5000Channel(0x1049e88, name = "1") Setting Data Buffers for  0 traces
[21:16:34] [Debug] PicoScope5000(0xff7fc0) Downloading Data from Scope
[21:16:34] [Debug] PicoScope5000(0xff7fc0) noOfWantedSamples: 10000 fromSegmentIndex: 0 toSegmentIndex: 0
[21:16:34] [Debug] PicoScope5000(0xff7fc0) ps_getValuesBulk worked
[21:16:34] [Debug] AbstractPlot(0x1048d88, name="AbstractPlot") New Traces available
[...]


The software also supports 6000 series picoscopes. They are working fine and use the same codepaths beside the model specific functions.

Information about the scope copied from the PicoScope software:
Code: Select all
Model: PicoScope 5203
Serial number: AT062/60
USB-Version: 2,0
Calibration Date: Friday, 16. July 2010
Hardware version: 1
Driver version: 1.4.2.434


Is this enough information for you to have a look into the driver to check if the origin of my problem could be there or do you need more?

Edit: To be more specific: I'm talking about the rapid block mode.
Jansen
Newbie
 
Posts: 0
Joined: Tue Jun 17, 2014 2:56 pm

Re: Block Mode with PS5203 does not work with one single cap

Postby Hitesh » Mon Aug 01, 2016 9:07 am

Hi Jansen,

Could you please post your code to show the setup of the scope and the data capture for the condition where the data is not captured into the data buffers?

Regards,
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 2009
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Block Mode with PS5203 does not work with one single cap

Postby Jansen » Mon Aug 01, 2016 9:37 pm

Hi Hitesh, posting the setup functions etc of my program is a little bit more complicated, since most things happen in a GUI. I will create a minimal working example asap to demonstrate the problem.

Another finding: When running the program under a debugger the problem does not appear (MinGW 5.3.0 32bit with Qt 5.7)...
Jansen
Newbie
 
Posts: 0
Joined: Tue Jun 17, 2014 2:56 pm

Re: Block Mode with PS5203 does not work with one single cap

Postby Jansen » Tue Aug 02, 2016 12:19 pm

Here is a minimal working example, which shows the problem.
The example uses Channel A, captures 100 post trigger samples, does not use a trigger and prints the buffer in the end. Running the plain executable prints only zeroes on exit, but running it under a debugger shows values.

Code: Select all
#include <iostream>
#include <stdio.h>
#include "picoStatus.h"
#include "ps5000Api.h"
using namespace std;

short m_handle;
PICO_STATUS status;

int main(int argc, char *argv[])
{
    // Settings
    int nSegments = 1;
    int nNoOfCaptures = 1;
    uint32_t noOfWantedSamples = 100; // Posttrigger

   
    // Alloc buffer, set all to zero
    short* traceBuffer = (short*) calloc(noOfWantedSamples, sizeof(short)*noOfWantedSamples);


    // Open Device
    status = ps5000OpenUnit(&m_handle);
    if (status != PICO_OK){
        cout << "Unable to open device." << "Error code:" << status << endl;
        return 1;
    }
    else cout << "Device opened!" << endl;

   
    // Set Channel
    status = ps5000SetChannel(m_handle,
                              PS5000_CHANNEL_A,
                              true, // enable
                              false, //channel coupling
                              PS5000_500MV
                              );
    if (status != PICO_OK)
    {
        cout << "Unable to set Channel" << endl;
        cout << "Error code:" << status << endl;
    }
    else cout << "Channel set" << endl;


    // Set MemorySegments
    int nMaxSamples;
    status = ps5000MemorySegments(m_handle, nSegments, &nMaxSamples);
    if (status != PICO_OK)
    {
        cout << "Unable to set Memory Segments" << endl;
        cout << "Error code:" << status << endl;
    }
    else cout << "Memory Segments set to " << nSegments << ". Max Samples per capture " << nMaxSamples << endl;


    // Set no of captures
    status = ps5000SetNoOfCaptures(m_handle, nNoOfCaptures);
    if (status != PICO_OK)
    {
        cout << "Unable to set noOfCaptures. " << "Error code:" << status << endl;
    }
    else cout << "Number of Captures set to " << nNoOfCaptures << endl;


    // Start the scope
    int timeIndisposedMs;
    status = ps5000RunBlock(m_handle,
                            0, // no of pre trigger samples
                            noOfWantedSamples, // no of post trigger samples
                            4, // timebase
                            0, // Oversample
                            &timeIndisposedMs,
                            0, // segment index
                            //&callback_scopeReady, //callback function
                            NULL,
                            NULL);

    if (status != PICO_OK)
    {
        cout << "Unable to runBlock" << endl;
        cout << "Error code :" << status << endl;

    }
    else cout << "runBlock worked!";

   
    // Wait for scope to finish capture
    short rdy = 0;
    while(rdy == 0){
        ps5000IsReady(m_handle, &rdy);
    }
    cout << "Scope rdy" << endl;

   
    // Set the databuffers
    status = ps5000SetDataBufferBulk(m_handle,
                                     PS5000_CHANNEL_A,
                                     traceBuffer,
                                     noOfWantedSamples, // Buffersize
                                     0 // Waveform
                                     );
    if (status != PICO_OK) cout << "Unable to set databuffer." << "Error code :" << status<< endl;
    else cout << "ps_setDataBufferBulk worked" << endl;


    // Receive the data
    short overflow[1];
    status = ps5000GetValuesBulk(m_handle,
                                 &noOfWantedSamples,
                                 0,
                                 0,
                                 overflow
                                 );
    if (status != PICO_OK) cout << "GetValuesBulk failed." << "Error code:" << status << endl;
    else cout << "ps_getValuesBulk worked" << endl;


    // Print buffer
    for(int i = 0; i<noOfWantedSamples; i++) printf("%hu\n", traceBuffer[i]);

   
    // Finish
    status = ps5000CloseUnit(m_handle);
    return 0;
}
Jansen
Newbie
 
Posts: 0
Joined: Tue Jun 17, 2014 2:56 pm

Re: Block Mode with PS5203 does not work with one single cap

Postby Hitesh » Wed Aug 03, 2016 11:18 am

Hi Jansen,

Thanks for posting the code.

I've run some tests and found that there might be an issue with trying to retrieve a single waveform using the 'bulk' functions.

Please find below a code file with some changes to use ps5000SetDataBuffer() and ps5000GetValues() if the number of captures is 1, and the 'bulk' functions if the number of captures is greater than 1. For the latter it has been hard-coded to retrieve only 2 waveforms.

Please note that you should use the correct data types for setting the number of segments and captures (unsigned short or uint16_t if using the stdint.h data types). Similarly, when passing the number of samples to the relevant parameters in the ps5000RunBlock() and ps5000SetDataBuffer/ps5000SetDataBufferBulk() functions, please ensure that the data type is an int (int32_t)/

PS5000aRapidBlock.cpp
Updated source code file
(4.76 KiB) Downloaded 12 times

Please try this and if you are still experiencing issues, please e-mail support@picotech.com and I can made a set of drivers available for you (please indicate if it is 32-bit or 64-bit that you require).

Regards,
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 2009
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Block Mode with PS5203 does not work with one single cap

Postby Jansen » Wed Aug 03, 2016 12:15 pm

Hi Hitesh,
your code works fine. But this was only a minimal working example and using the GetValues function for a single capture would result in a fairly large change in the logic of my code. An updated driver would be nice. I will contact you via email.

Thanks for the nice support!

Regards,
Jan
Jansen
Newbie
 
Posts: 0
Joined: Tue Jun 17, 2014 2:56 pm

Re: Block Mode with PS5203 does not work with one single cap

Postby Hitesh » Thu Aug 04, 2016 9:34 am

Hi Jansen,

As per the e-mail that I sent to you via your support ticket and for the benefit of other Users, the recommended workaround is to use the ps5000SetDataBuffer()/ps5000GetValues() combination for a single capture and the ps5000SetDataBufferBulk()/ps5000GetValuesBulk() combination for multiple waveform captures.

Regards,
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 2009
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire


Return to C and C++

Who is online

Users browsing this forum: No registered users and 0 guests