Intermittent Hang on PS6403 during ps6000RunBlock

Post your C and C++ discussions here
Hamsteh
Newbie
Posts: 0
Joined: Mon Aug 09, 2010 5:36 am

Intermittent Hang on PS6403 during ps6000RunBlock

Post by Hamsteh »

Hi there.

I have written a small console application that simply stores a given amount of samples at a given sample frequency.

What i am finding at the moment is that it will occasionally hang when ps6000RunBlock is called. My wait loop with timeout and ps6000GetValues will return a status of PICO_NO_SAMPLES_AVAILABLE. I am using the exact same timebase/buffer size with each test and it will seemingly randomly hang.

My input signal is just random voltage from a piezoelectric bimorph.

Regards,
Alex

Snippet of RunBlock module:

Code: Select all

//Run Block
    g_timebase = 15629;
    g_nSamples = 50000; 
    g_blockReady = FALSE;
    timestamp("Calling ps6000RunBlock now...");
    status = ps6000RunBlock(    unit->handle,       //unit handle
                                0,                  //unused
                                g_nSamples,         //number of samples
                                g_timebase,         //timebase
                                0,                  //oversample flag
                                &timeIndisposed,    //pointer to approx time variable
                                0,                  //memory segment index
                                CallBackBlock,      //pointer to callback function
                                NULL );             //pParameter
    printf("\tps6000RunBlock ------ %d \n", (int)status);

//Wait for block to complete then ps6000Stop
    while(!g_blockReady)
    {
        Sleep(1); //do nothing
        time_waited++;

        if(time_waited>time_to_wait)
        {
            printf("Waiting loop timed out...\n");
            printf("g_blockReady flag = %d \n\n", g_blockReady);
            break;
        }
    }

Chris
Site Admin
Site Admin
Posts: 169
Joined: Tue Aug 17, 2010 9:00 am
Location: St. Neots

Re: Intermittent Hang on PS6403 during ps6000RunBlock

Post by Chris »

Hi Alex

Have you tried recreating this problem using the example software in our SDK?

The SDK software can be downloaded from ...

http://www.picotech.com/software.html

You will need to create a new, empty project, and import...
picoStatus.h
ps6000Api.h
PS6000.lib
PS6000con.c

Chris

Hamsteh
Newbie
Posts: 0
Joined: Mon Aug 09, 2010 5:36 am

Re: Intermittent Hang on PS6403 during ps6000RunBlock

Post by Hamsteh »

Thankyou for your reply. I see you have a new SDK out since last I checked but I have so far found a few issues that stop the example code from compiling under CodeBlocks.
  • enThresholdDirection (lines 53-58 of PS6000con.m) need to be changed to the PS6000 specific, enPS6000ThresholdDirection
  • likewise enPulseWidthType (line 68) must be changed to enPS6000PulseWidthType
  • there are also MSDN VS-specific functions like __min() and fopen_s included.
A few of the issues I encountered in the older SDK have been removed however. (such as two occurences of PS6000_PS in a ps6000api.h enumeration)

I am working my way through and will attempt to repeat my problem once I can compile.

Hamsteh
Newbie
Posts: 0
Joined: Mon Aug 09, 2010 5:36 am

Re: Intermittent Hang on PS6403 during ps6000RunBlock

Post by Hamsteh »

I was unable to reproduce my hangs when using your example code once compiled, and as a result have been steeping through the CollectBlockImmediate() and BlockDataHAndler() functions comparing with mine. Had a couple of questions:

First what is the purpose of using ps6000SetDataBuffers with the buffers[i*2] and buffers[i*2 +1] for each channel when aggregation is not used?

Having tried this in my code I find my 50000 samples are split between these two buffers, even with aggregation and downsampling off...

Secondly, I have tried using the ps6000FlashLed function for debugging and can not get it to function the way I would expect. Calling it with the 'start' argument as anything other than numbers <0 (-1 for instance) has no effect. And when called with start = -1 it flashes continuously, even after runBlock has been called. Calling FlashLed again with start = 0 does not stop the flashing either as i would expect.

I appreciate your assistance on this matter.

Regards,
Alex

Chris
Site Admin
Site Admin
Posts: 169
Joined: Tue Aug 17, 2010 9:00 am
Location: St. Neots

Re: Intermittent Hang on PS6403 during ps6000RunBlock

Post by Chris »

Hi Alex

The example code has been modified from an example that used agregation, so you are correct, in this example the call to ps6000SetDataBuffers should have the second buffer parameter set to NULL (and the buffers[i * 2 + 1] lines removed, buffer[1 * 2] changed to buffer, etc, etc)

OR the ps6000SetDataBuffers call replaced with a call to ps6000SetDataBuffer.

I have tried the ps6000Flash call, and recreated problem you are experiencing. This has been reported to the development team. As a work around, please use the -1 parameter to start the LED flashing, and 1 to stop it. (i.e. let it flash once, then it will stop)

Regards,

Chris.

Hamsteh
Newbie
Posts: 0
Joined: Mon Aug 09, 2010 5:36 am

Re: Intermittent Hang on PS6403 during ps6000RunBlock

Post by Hamsteh »

Hi Chris,

Thankyou for your reply.

I have since written a very basic C console application from scratch to read a block of data from the picoscope and I am STILL encountering the same intermittent errors of the runBlock function not finishing when expected. (Input is a 100Hz, 1V Sinusoid from a signal-generator)

Perhaps you would be able to examine this simple code for obvious errors?

Regards,
Alex.
Attachments
basic_ps6403_RunBlock.c
(6.54 KiB) Downloaded 569 times

Chris
Site Admin
Site Admin
Posts: 169
Joined: Tue Aug 17, 2010 9:00 am
Location: St. Neots

Re: Intermittent Hang on PS6403 during ps6000RunBlock

Post by Chris »

Hi Alex

From the code you sent, I notice that the g_blockReady flag isn't being reset to FALSE.

This wouldn't be a problem in the actual code you sent, as it would only run through once, but if you were using this functionality in another program where you could call the ps6000RunBlock more than once, you would need to make sure that g_blockReady=FALSE; is set each time.

I have modified your code to loop the
ps6000RunBlock
ps6000SetDataBuffer
ps6000GetValues

functions, making sure that g_blockReady=FALSE; is set at the start of the loop, and it all seems ok.

Modified code attached for you to try yourself.

Chris
Attachments
basic_ps6403_RunBlock.c
(6.53 KiB) Downloaded 607 times

Hamsteh
Newbie
Posts: 0
Joined: Mon Aug 09, 2010 5:36 am

Re: Intermittent Hang on PS6403 during ps6000RunBlock

Post by Hamsteh »

Hi Chris thankyou very much for your time.

I have just compiled and run the modified code you sent and the first time it looped through perfectly.

I then closed the console application and restarted it, and it is currently hanging at the first ps6000RunBlock call.

Did you try re-running the application multiple times? I have found it will work perfectly fine an arbitrary number of times and then fail an equally random amount of times.

For instance I reran the application 4 times successfully before failing on the fifth; hanging on the first ps6000RunBlock call until i manually cancelled. This is the console output:

Code: Select all

ps6000OpenUnit -- 0
ps6000SetChannel -- 0
ps6000SetChannel -- 0
ps6000SetChannel -- 0
ps6000SetChannel -- 0
ps6000SetTriggerChannelConditions -- 0
ps6000SetTriggerChannelDirections -- 0
ps6000SetTriggerChannelProperties -- 0
ps6000RunBlock -- 0
ps6000SetDataBuffer -- 0
ps6000GetValues -- 25

Status Value not PICO_OK.
Any Key to Exit.


Loop 1000
ps6000Stop -- 0
Data saved to data.txt in project directory
ps6000CloseUnit -- 0

Main Function Complete.
Any Key to Exit.

This is the same issue I was having before... I really am stumped.

Regards,
Alex.

Chris
Site Admin
Site Admin
Posts: 169
Joined: Tue Aug 17, 2010 9:00 am
Location: St. Neots

Re: Intermittent Hang on PS6403 during ps6000RunBlock

Post by Chris »

Hi Alex

I've run this test all day, and not found any problems.

In order to help track what's going wrong, i've added some printf statements to give an indication of the state of the g_blockReady flag, to check that it is being used to wait for the conversion to have taken place before ps6000GetValues is called.

Please let me know what information this gives us.

Thanks

Chris
Attachments
basic_ps6403_RunBlock.c
(6.79 KiB) Downloaded 562 times

Hamsteh
Newbie
Posts: 0
Joined: Mon Aug 09, 2010 5:36 am

Re: Intermittent Hang on PS6403 during ps6000RunBlock

Post by Hamsteh »

Hi Chris,
I compiled your latest edit and ran it three times successfully. (i am referring to restarting the whole compiled application each time). ie. Hitting 'Run' or 'Compile and Run' in the ide application (in my case CodeBlocks)

On the fourth 'Run' it hung here (i gave it a good minute before manually aborting the wait loop):

Code: Select all

ps6000OpenUnit -- 0
ps6000SetChannel -- 0
ps6000SetChannel -- 0
ps6000SetChannel -- 0
ps6000SetChannel -- 0
ps6000SetTriggerChannelConditions -- 0
ps6000SetTriggerChannelDirections -- 0
ps6000SetTriggerChannelProperties -- 0
ps6000RunBlock -- 0

Pre While loop g_blockReady = 0
Until i hit a key to exit the loop.

Final console output was this:

Code: Select all

ps6000OpenUnit -- 0
ps6000SetChannel -- 0
ps6000SetChannel -- 0
ps6000SetChannel -- 0
ps6000SetChannel -- 0
ps6000SetTriggerChannelConditions -- 0
ps6000SetTriggerChannelDirections -- 0
ps6000SetTriggerChannelProperties -- 0
ps6000RunBlock -- 0

Pre While loop g_blockReady = 0
Post While loop g_blockReady = 0
ps6000SetDataBuffer -- 0
ps6000GetValues -- 25

Status Value not PICO_OK.
Any Key to Exit.


Loop 1000

g_blockReady should be FALSE Here...it is 0
g_blockReady should now be TRUE it is 1ps6000Stop -- 0
Data saved to data.txt in project directory
ps6000CloseUnit -- 0

Main Function Complete.
Any Key to Exit.
I should double check that I'm being clear here: it is not the loops which fail - it seems that if the first RunBlock call works they all do. Its just upon 'Running' the compiled application again that it seems to randomly fail.

Thankyou for your time,
Alex

Chris
Site Admin
Site Admin
Posts: 169
Joined: Tue Aug 17, 2010 9:00 am
Location: St. Neots

Re: Intermittent Hang on PS6403 during ps6000RunBlock

Post by Chris »

Hi Alex

Thanks for clarifying that, so the problem is that sometimes the CallBackBlock doesn't get called at all. This never happens on the first run, but sometimes happens when the application is re-run.

Again, I've tried this here, and it always works.

I've attached a zip of 2 compiled versions of the release code for you to try. (1 loops 1000 times, the other 10...thought the 10 version might speed up your testing!)

Let me know what happens,

-Chris.
Attachments
RunBlockTest.zip
(8.72 KiB) Downloaded 534 times

Hamsteh
Newbie
Posts: 0
Joined: Mon Aug 09, 2010 5:36 am

Re: Intermittent Hang on PS6403 during ps6000RunBlock

Post by Hamsteh »

Hi Chris,

Your understanding of my problem is correct 'except' that it does occasionally happen on first run. For instance I have just run your 10xLoop executable a number of times and got the following results.

Firstly it failed the first 5-10 times i ran it then my results were:
1,0,1,1,1,0,1,1,0,0,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1.
(1 denotes a successful completion. 0 denotes failed first RunBlock)

You can see the results seem fairly random. Nothing was changed in this time, I am using a signal generator outputting a 25Hz Sinusoidal wave and all I am doing is re-running the executable after success or failure.

The fact that you can not reproduce this issue suggests that it is either my Picoscope 6403 itself or perhaps my software environment to blame surely? I am running Windows XP SP2 if that helps.

Regards and thank you for your time so far,
Alex.

Chris
Site Admin
Site Admin
Posts: 169
Joined: Tue Aug 17, 2010 9:00 am
Location: St. Neots

Re: Intermittent Hang on PS6403 during ps6000RunBlock

Post by Chris »

Hi Alex

In an earlier post, you said that the SDK example worked.

Could you try it again to see if using the SDK example causes it to hang.

If this is the case, you can return the unit to us for testing / repair.

to do this, email

support@picotech.com

describing the problem and we can start the returns RMA process for you.

regards,

Chris

Hamsteh
Newbie
Posts: 0
Joined: Mon Aug 09, 2010 5:36 am

Re: Intermittent Hang on PS6403 during ps6000RunBlock

Post by Hamsteh »

Hi Chris,

Do you have a compiled version of ps6000con from the SDK that you can send me?

I find that there are a 'lot' of corrections necessary to even get it to compile - perhaps you have an older version that is correct or one that has been pre-modified?

Regards,
Alex

Chris
Site Admin
Site Admin
Posts: 169
Joined: Tue Aug 17, 2010 9:00 am
Location: St. Neots

Re: Intermittent Hang on PS6403 during ps6000RunBlock

Post by Chris »

Hi Alex

Compiled console example attached.


What compiler are you using?

-Chris.
Attachments
PS6000con.zip
(9.32 KiB) Downloaded 542 times

Post Reply