more than 8 channels when triggering problems

Forum for discussing PicoLog
Post Reply
martinGolf
Newbie
Posts: 0
Joined: Sat Oct 02, 2010 7:58 am

more than 8 channels when triggering problems

Post by martinGolf »

Hi,

I'm trying to capture a block of data on 12 or more channels in trigger mode with a PcoLog.

When using 8 or less channels then all works correctly. When setting up more than 8 channels and setting the trigger then the sample data in the interleaved buffer is mixed up.

i.e. Data for a particular channel gets placed elsewhere in the sample buffer.

When using 8 or less channels then data is assigned in the interleaved buffer correctly. i.e Data for channel 1 is in the place for channel 1 (e.g. sample[0]) and data for channel 2 in the place for channel 2 (e.g. sample[1]).

When setting up for more than 8 channels then data is sometimes placed correctly in the buffer but at other times it is moved elsewhere. e.g. Channel 1 data will turn up in the buffer location for channel 4 (sample[3].

It's totaly sparodic so I can't write a work-around in the code.

Any one have any ideas what may be causing this or is it that the PicoLog driver cannot support more than 8 channels in trigger mode?


Regards,

Martin

Hitesh

Re: more than 8 channels when triggering problems

Post by Hitesh »

Hi Martin,

What are the status codes returned by the functions pl1000SetTrigger, pl1000Run and pl1000GetValues?

Any snippets of code you can send would be helpful in terms of debugging.

Regards,

martinGolf
Newbie
Posts: 0
Joined: Sat Oct 02, 2010 7:58 am

Re: more than 8 channels when triggering problems

Post by martinGolf »

Hi Hitesh,

thanks for getting back to me.

Code is as follows:

Code: Select all

void collect_block_triggered (void)
{

	unsigned long nSamples = 1000;
	short nChannels = 12;
	unsigned long nSamplesPerChannel = 1000;
	unsigned long nSamplesCollected;

	usForBlock = 100000;

	short	channels [12];
	channels[0] = 1;//PL1000_CHANNEL_1;
	channels[1] = 2;//PL1000_CHANNEL_2;
	channels[2] = 3;//PL1000_CHANNEL_3;
	channels[3] = 4;//PL1000_CHANNEL_4;
	channels[4] = 5;//PL1000_CHANNEL_5;
	channels[5] = 6;//PL1000_CHANNEL_6;
	channels[6] = 7;//PL1000_CHANNEL_7;
	channels[7] = 8;//PL1000_CHANNEL_8;
	channels[8] = 9;//PL1000_CHANNEL_9;
	channels[9] = 10;//PL1000_CHANNEL_10;
	channels[10] = 11;//PL1000_CHANNEL_11;
	channels[11] = 12;//PL1000_CHANNEL_12;



	unsigned int i;
	unsigned short *overflow = 0;
	unsigned long triggerIndex = 0;

	//Set the trigger
	int triggerLevel = mv_to_adc(200);

	status = pl1000SetTrigger(g_handle, 1, 0, 0, PL1000_CHANNEL_1, 0, triggerLevel , 10, 0); // rising
	//set sampling rate and channels
	status = pl1000SetInterval(g_handle, &usForBlock, nSamples , channels, nChannels);


	//Run
	status = pl1000Run(g_handle, nSamples, BM_SINGLE);

	//Wait until unit is ready
	isReady = 0;
	
	

	while(isReady == 0 && (!_kbhit ()))
	{
		status = pl1000Ready(g_handle, &isReady);
	}

	nSamplesCollected = nSamplesPerChannel;
	status = pl1000GetValues(g_handle, samples, &nSamplesCollected, overflow, &triggerIndex);

	
	
	status = pl1000Stop(g_handle);
	
	
	int n = 0;
	
	for(i = 0; i < nSamplesPerChannel * nChannels; i ++, n ++)
		{
			chSamples[0][n] = adc_to_mv(samples[i]/5);

			if(nChannels >= 2)	{i ++;	chSamples[1][n] = adc_to_mv(samples[i]/5);	}
			if(nChannels >= 3)	{i ++;	chSamples[2][n] = adc_to_mv(samples[i]/5);	}
			if(nChannels >= 4)	{i ++;	chSamples[3][n] = adc_to_mv(samples[i]/5);	}
			if(nChannels >= 5)	{i ++;	chSamples[4][n] = adc_to_mv(samples[i]/5);	}
			if(nChannels >= 6)	{i ++;	chSamples[5][n] = adc_to_mv(samples[i]/5);	}
			if(nChannels >= 7)	{i ++;	chSamples[6][n] = adc_to_mv(samples[i]/5);	}
			if(nChannels >= 8)	{i ++;	chSamples[7][n] = adc_to_mv(samples[i]/5);	}
			if(nChannels >= 9)	{i ++;	chSamples[8][n] = adc_to_mv(samples[i]/5);	}
			if(nChannels >= 10)	{i ++;	chSamples[9][n] = adc_to_mv(samples[i]/5);	}
			if(nChannels >= 11)	{i ++;	chSamples[10][n] = adc_to_mv(samples[i]/5);	}
			if(nChannels >= 12)	{i ++;	chSamples[11][n] = adc_to_mv(samples[i]/5);	}
			if(nChannels >= 13)	{i ++;	chSamples[12][n] = adc_to_mv(samples[i]/5);	}
			if(nChannels >= 14)	{i ++;	chSamples[13][n] = adc_to_mv(samples[i]/5);	}
			if(nChannels >= 15)	{i ++;	chSamples[14][n] = adc_to_mv(samples[i]/5);	}
			if(nChannels >= 16)	{i ++;	chSamples[15][n] = adc_to_mv(samples[i]/5);	}

		}
	
}
[/b]
All status returns are OK

Martin

Martyn
Site Admin
Site Admin
Posts: 4491
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: more than 8 channels when triggering problems

Post by Martyn »

Martin,
Try adding a delay in the loop when checking for driver isReady, this should solve your issue

Code: Select all

   while(isReady == 0 && (!_kbhit ()))
   {
      Sleep(20);
      status = pl1000Ready(g_handle, &isReady);
   }
Martyn
Technical Support Manager

Post Reply