5242A PICO_NOT_RESPONDING calling ps5000aRunBlock

Post your C and C++ discussions here
Post Reply
Manuel Z
Newbie
Posts: 0
Joined: Mon Oct 05, 2015 1:20 pm

5242A PICO_NOT_RESPONDING calling ps5000aRunBlock

Post by Manuel Z » Mon Oct 05, 2015 1:31 pm

Hi,

we try to run a simple data recording out of LabWindows CVI (C-code) of two channels using block mode. The first time we call the function ps5000aRunBlock and download the recorded data works well. But if we repeat this, we get PICO_STATUS = 0x07 (PICO_NOT_RESPONDING) as response when calling ps5000aRunBlock from the driver sporadically. This error appears only in about 5% of the cases but always when calling ps5000aRunBlock! Seems like the PC looses the connection to PicoScope somehow. Does somebody have an idea about a root cause :?:
- Thank you!

Here you can see our source code:

Code: Select all

/****************************************************************************
*
*  PicoScope_5242A_init_config
*  this function opens the pico scope 5242A and configures the channels and trigger
*
****************************************************************************/
void PicoScope_5242A_init_config(void)
{
	// Structure for trigger conditions
	struct tPS5000ATriggerConditions CHB_Conditions = {	PS5000A_CONDITION_DONT_CARE,	// CHA
														PS5000A_CONDITION_TRUE,			// CHB
														PS5000A_CONDITION_DONT_CARE,	// CHC
														PS5000A_CONDITION_DONT_CARE,	// CHD
														PS5000A_CONDITION_DONT_CARE,	// external
														PS5000A_CONDITION_DONT_CARE,	// aux
														PS5000A_CONDITION_DONT_CARE,	// pulseWidthQualifier
														};
								 
	// Structure for trigger configuration
	struct tPS5000ATriggerChannelProperties CHB_Properties = {	32767,				   // set higher trigger threshold to maximum (is not used)
																0,				       // set hysteresis minimum      
																13762,				   // set lower trigger threshold to 0.21V. 13762 = MAX_ADC_COUNTS / MAX_VOLTAGE * THRESHOLD = 32767 / 0.5V * 0.21V
																655,				   // set hysteresis to 10mV. 655 = MAX_ADC_COUNTS / MAX_VOLTAGE * HYSTERESIS = 32767 / 0.5V * 0.01         
																PS5000A_CHANNEL_B,
																PS5000A_LEVEL
	                                                         }; 
	                                                    
	char Error[100];
	static UNIT unit; 
	static PICO_STATUS status=1;
	float PS5000A_CHANNEL_A_OFFSET, PS5000A_CHANNEL_B_OFFSET;
	int iTriggerThresholdADCCount, iAutoTrigger_ms, autoTriggerMilliseconds;
	unsigned int iTriggerDelay;
	short nChannelProperties, thresholdUpper, thresholdUpperHysteresis, thresholdLower, thresholdLowerHysteresis;
	// timebase
	uint32_t timebase;
	int32_t noSamples;
	float timeIntervalNanoseconds;
	int32_t maxSamples;
	uint32_t segmentIndex;
	
	
	// Open device
	status = ps5000aOpenUnit(&picohandle, NULL, PS5000A_DR_15BIT);
	// Error?
	if(status != PICO_OK) 
	{
			sprintf(Error, "Unable to open PicoScope. Error code : 0x%08lx\n", status);
			MessagePopup("Error", Error);
	}
	
	// Configure Channels 
	PS5000A_CHANNEL_A_OFFSET = 0.0;
	status = ps5000aSetChannel(picohandle,
							   PS5000A_CHANNEL_A,
		                       TRUE,
		                       PS5000A_DC,
		                       PS5000A_2V,
							   PS5000A_CHANNEL_A_OFFSET);
	if(status != PICO_OK) 
	{
			sprintf(Error, "Unable to initialize PicoScope channel. Error code : 0x%08lx\n", status);
			MessagePopup("Error", Error);
	}
	
	PS5000A_CHANNEL_B_OFFSET = 0.0;
	status = ps5000aSetChannel(picohandle, 
		 					   PS5000A_CHANNEL_B,
		                       TRUE,
		                       PS5000A_DC,
		                       PS5000A_500MV,	// normally 5V but 10/1 current probe -> 0.5V		   
							   PS5000A_CHANNEL_B_OFFSET);
	if(status != PICO_OK) 
	{
			sprintf(Error, "Unable to initialize PicoScope channel. Error code : 0x%08lx\n", status);
			MessagePopup("Error", Error);
	}
	
	
	// Get timebase, just for information
	// Sampletime = 5s
	// e.g. Samplerate = 1000S/s
	// -> sample interval: 1ms
	// -> Memory: 5000S/Channel
	// timebase @ 15bit resolution: (1ms * 125000000) + 2 = 125002
	timebase = 125002;
	noSamples = 5000;
	segmentIndex = 0;
	status = ps5000aGetTimebase2(picohandle,
								 timebase,
								 noSamples,
								 &timeIntervalNanoseconds,
								 &maxSamples,
								 segmentIndex);
	if(status != PICO_OK) 
	{
			sprintf(Error, "Unable to get PicoScope timebase. Error code : 0x%08lx\n", status);
			MessagePopup("Error", Error);
	}
	
	// Set trigger conditions
	status = ps5000aSetTriggerChannelConditions(picohandle,
											    &CHB_Conditions,
											    1);				// 1 condition structure
	if(status != PICO_OK) 
	{
			sprintf(Error, "Unable to set PicoScope trigger conditions. Error code : 0x%08lx\n", status);
			MessagePopup("Error", Error);
	}
	
	// Configure trigger
	status = ps5000aSetTriggerChannelDirections(picohandle,
												PS5000A_NONE,  	  // CHA
												PS5000A_FALLING_LOWER,  // CHB
												PS5000A_NONE,     // CHC
												PS5000A_NONE,     // CHD
												PS5000A_NONE,     // ext
												PS5000A_NONE);    // aux
	if(status != PICO_OK) 
	{
			sprintf(Error, "Unable to initialize PicoScope trigger direction. Error code : 0x%08lx\n", status);
			MessagePopup("Error", Error);
	}
	
	
	autoTriggerMilliseconds = 10000;
	nChannelProperties = 1; // the size of the channelProperties array. If zero, triggering is switched off. -> 1 channel triggered
	status = ps5000aSetTriggerChannelProperties(picohandle,
												&CHB_Properties,
												nChannelProperties,
												NULL,
												autoTriggerMilliseconds);
	if(status != PICO_OK) 
	{
			sprintf(Error, "Unable to initialize PicoScope trigger channel properties. Error code : 0x%08lx\n", status);
			MessagePopup("Error", Error);
	}
	
	// Set trigger delay											   
	status = ps5000aSetTriggerDelay(picohandle,
									0);			// the time between the trigger occurring and the first sample in samples
	if(status != PICO_OK) 
	{
			sprintf(Error, "Unable to set PicoScope trigger delay. Error code : 0x%08lx\n", status);
			MessagePopup("Error", Error);
	} 
	
}


/****************************************************************************
*
*  PicoScope_5242A_arm
*  this function arms 5242A to capture data
*
****************************************************************************/
void PicoScope_5242A_arm(void)
{
	char Error[100];
	static PICO_STATUS status=1; 
	
	long timeInterval = 1;
	long sampleCount= 6000;
	unsigned long maxSamples;
	
	// Sampletime = 5s
	// e.g. Samplerate = 1000S/s
	// -> sample interval: 1ms
	// -> Memory: 5000S/Channel
	// timebase @ 15bit resolution: (1ms * 125000000) + 2 = 125002
	int noOfPreTriggerSamples = 500, noOfPostTriggerSamples = 4500, timeIndisposedMs;
	unsigned int timebase = 125002, segmentIndex = 0;
	
		
	status = ps5000aRunBlock(picohandle,
							 noOfPreTriggerSamples,
							 noOfPostTriggerSamples,
							 timebase,
							 &timeIndisposedMs,
							 segmentIndex,
							 NULL,
							 NULL);

	if(status != PICO_OK) 
	{
			sprintf(Error, "Unable to arm PicoScope. Error code : 0x%08lx\n", status);
			MessagePopup("Error", Error);
	}
}


/****************************************************************************
*
*  PicoScope_5242A_get_data
*  Download data recorded by PicoScope
*
****************************************************************************/
void PicoScope_5242A_get_data(short *ChannelA, short *ChannelB)
{
	char Error[100];
	int i=0, bufferLth;
	unsigned int segmentIndex, startIndex, noOfSamples;
	short sReady, overflow;
	static PICO_STATUS status=1;
	
	// finish data capturing
	status = ps5000aStop(picohandle);
		
	if(status != PICO_OK) 
	{
			sprintf(Error, "Unable to close PicoScope. Error code : 0x%08lx\n", status);
			MessagePopup("Error", Error);
	}
	
	// Wait for 13 seconds for PicoScope to get ready
	do 
	{
		status = ps5000aIsReady(picohandle, &sReady);
		Sleep(100);
		i++;
		if(i>=130) break;
	} while(!sReady); 
	
	
	// Configure PicoScop data buffer for Channel A
	bufferLth = 5000;
	segmentIndex = 0;
	status = ps5000aSetDataBuffer(picohandle,
								  PS5000A_CHANNEL_A,
								  ChannelA,
								  bufferLth,
								  segmentIndex,
								  PS5000A_RATIO_MODE_NONE);
	if(status != PICO_OK) 
	{
			sprintf(Error, "Unable to set PicoScope data buffer. Error code : 0x%08lx\n", status);
			MessagePopup("Error", Error);
	}
	
	status = ps5000aSetDataBuffer(picohandle,
								  PS5000A_CHANNEL_B,
								  ChannelB,
								  bufferLth,
								  segmentIndex,
								  PS5000A_RATIO_MODE_NONE);
	if(status != PICO_OK) 
	{
			sprintf(Error, "Unable to set PicoScope data buffer. Error code : 0x%08lx\n", status);
			MessagePopup("Error", Error);
	}

	
	// download recorded data for Channel A
	startIndex = 0;
	noOfSamples = 5000;
	status = ps5000aGetValues(picohandle,
							  startIndex,
							  &noOfSamples,
							  PS5000A_RATIO_MODE_NONE,
							  PS5000A_RATIO_MODE_NONE,
							  segmentIndex,
							  &overflow);
	
	
							  
	if(status != PICO_OK) 
	{
			sprintf(Error, "Unable to download recorded data from PicoScope. Error code : 0x%08lx\n", status);
			MessagePopup("Error", Error);
	}
}


void PicoScope_5242A_close(void)
{
	static PICO_STATUS status=1;
	char Error[100];
	
	// close device
	status = ps5000aStop(picohandle);
		
	if(status != PICO_OK) 
	{
			sprintf(Error, "Unable to close PicoScope. Error code : 0x%08lx\n", status);
			MessagePopup("Error", Error);
	}
}

Hitesh
Site Admin
Site Admin
Posts: 2794
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: 5242A PICO_NOT_RESPONDING calling ps5000aRunBlock

Post by Hitesh » Thu Oct 08, 2015 9:17 am

Hi Manuel Z,

It looks as though your code is stopping the device before the scope has completed the data collection.

Please call ps5000aStop in your PicoScope_5242A_get_data function after the device has indicated that it is ready.

Regards,
Hitesh

Technical Support Engineer

Manuel Z
Newbie
Posts: 0
Joined: Mon Oct 05, 2015 1:20 pm

Re: 5242A PICO_NOT_RESPONDING calling ps5000aRunBlock

Post by Manuel Z » Mon Oct 12, 2015 7:50 am

Hi Hitesh,

thank you for your response!

We tried it with calling ps5000aStop after the is ready indication but after 26 successful runs the 27th ps5000aRunBlock call was again answered with a 0x07. :cry:

What could happen that PicoScope is not answering any commands comming from PC? Is it a driver issue maybe?

Regards

Hitesh
Site Admin
Site Admin
Posts: 2794
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: 5242A PICO_NOT_RESPONDING calling ps5000aRunBlock

Post by Hitesh » Tue Oct 13, 2015 11:31 am

Hi Manuel Z,

Which version of the ps5000a.dll are you using?

When you refer to the 27th run presumably you are running a loop to collect the data and not opening and closing the unit each time?

Regards,
Hitesh

Technical Support Engineer

Manuel Z
Newbie
Posts: 0
Joined: Mon Oct 05, 2015 1:20 pm

Re: 5242A PICO_NOT_RESPONDING calling ps5000aRunBlock

Post by Manuel Z » Mon Oct 19, 2015 8:59 am

Hi Hitesh,
Which version of the ps5000a.dll are you using?
we're using the dll from the delivered CD R10.5.2.1.
When you refer to the 27th run presumably you are running a loop to collect the data and not opening and closing the unit each time?
Exactly, we're calling "PicoScope_5242A_init_config" in the beginning and "PicoScope_5242A_close" in the end. The functions "PicoScope_5242A_arm" and "PicoScope_5242A_get_data" run in a loop.

Do we have to open and close the unit each time we want to record data?

Hitesh
Site Admin
Site Admin
Posts: 2794
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: 5242A PICO_NOT_RESPONDING calling ps5000aRunBlock

Post by Hitesh » Mon Oct 19, 2015 9:49 am

Hi Manuel,

It looks as though you are using a relatively older driver.

Please could you download and install the latest SDK (32 or 64-bit) from our Downloads page.

Please also refer to this post for an installation guide.

Try the ps5000a.dll provided through this installer and see if there is any improvement.

Once you have opened a connection to a device, there is no need to close the connection until you have completed your data acquisition session.

Regards,
Hitesh

Technical Support Engineer

Manuel Z
Newbie
Posts: 0
Joined: Mon Oct 05, 2015 1:20 pm

Re: 5242A PICO_NOT_RESPONDING calling ps5000aRunBlock

Post by Manuel Z » Thu Oct 29, 2015 2:36 pm

Hi Hitesh,

thx for your ideas! :)

We updated the driver to 10.6.10.22 without success. :(

As next step we remove the closing of the unit each time so that we'll only call the close function once at the end of our process.

Regards

Hitesh
Site Admin
Site Admin
Posts: 2794
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: 5242A PICO_NOT_RESPONDING calling ps5000aRunBlock

Post by Hitesh » Fri Oct 30, 2015 1:15 pm

Hi Manuel,

Please let us know the outcome of your test with the new driver.

Thanks,
Hitesh

Technical Support Engineer

Manuel Z
Newbie
Posts: 0
Joined: Mon Oct 05, 2015 1:20 pm

Re: 5242A PICO_NOT_RESPONDING calling ps5000aRunBlock

Post by Manuel Z » Wed Mar 02, 2016 1:11 pm

Hi Hitesh,

after a long time I finally respond...
As I wrote in my last reply, the update of the driver caused no effect.
Now we finished the implementation phase and there are no errors anymore. Maybe that's because we only run our sequence once and during implementation we had problems e.g. after the 26th run in a row.

Nevertheless thank you for your help!

Hitesh
Site Admin
Site Admin
Posts: 2794
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: 5242A PICO_NOT_RESPONDING calling ps5000aRunBlock

Post by Hitesh » Fri Mar 04, 2016 9:38 am

Hi Manuel Z,

Thanks for posting a response.

If you do encounter the issue again please post back here or e-mail support@picotech.com and we will look to assist you further.

Regards,
Hitesh

Technical Support Engineer

Post Reply