Oscilloscope buffers

Post any questions you may have about our current range of oscilloscopes
Post Reply
ARC
Newbie
Posts: 0
Joined: Wed Aug 08, 2012 8:38 am

Oscilloscope buffers

Post by ARC »

Hello,

I want to record 2 signals sometimes the same and sometimes different on channel A and B. i have been trying to figure out how to print the buffer values into separate files. Im always setting the channel to sample every 10us with no aggregation, in ac mode and channel range is 500mv. Which is all ok for the signals I'm measuring.
Am i right in thinking that buffers[j] j is the port (0 or 1 in my case with 2206) and i is the position in the buffer?
because as a test i have only channel A connected and when i retrieve data from the buffers like this:

Code: Select all

for (i = g_startIndex; i < (long)(g_startIndex + g_sampleCount); i++) 
{
	if(afile != NULL)
	{
		for (j = 0; j < unit->channelCount; j++) 
		{
			if (unit->channelSettings[j].enabled) 
			{
				if (channelbtrig == 1)//channel A&B
				{
					if (j == 0)
					{
						int data = adc_to_mv(buffers[j][i], unit->channelSettings[PS2000A_CHANNEL_A+j].range, unit);//channel A
						fprintf(afile, "%d\n", buffers[j][i]);
					}

					else if (j == 1)
					{
						int data = adc_to_mv(buffers[j][i], unit->channelSettings[PS2000A_CHANNEL_A+j].range, unit);//channel B
						fprintf(bfile, "%d\n", buffers[j][i]);
					}				
				}
				else
				{
					int data = adc_to_mv(buffers[j][i], unit->channelSettings[PS2000A_CHANNEL_A+j].range, unit);//Channel A
					fprintf(afile, "%d\n", data);			
				}
			}
			else
			{
		                return;
			}
			if (g_manualstop == 1)
			{
				goto endwhile;
			}
		}
	else
	{
                return(status);
	}
}
I get the same in both afile and bfile (just different named txt files). but obviously there is nothing connected to channel b so im expecting a file of 0's.
Is this how it works?

The above code is from StreamDataHandler function at line 771. this code is a modified version of the PicoScope SDK 10_4_1_6

I have attached my code.

Thanks for the help :)
Attachments
PS2000Acon.c
my .dll program
(64.28 KiB) Downloaded 511 times

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

Re: Oscilloscope buffers

Post by Martyn »

Check the buffer creation

Code: Select all

			for (i = 0; i < unit->channelCount; i++) 
			{
				buffers[i * 2] = (short*)malloc(sampleCount * sizeof(short));
				buffers[i * 2 + 1] = (short*)malloc(sampleCount * sizeof(short));
				status = ps2000aSetDataBuffers(unit->handle, (short)i, buffers[i * 2], buffers[i * 2 + 1], sampleCount, 0, PS2000A_RATIO_MODE_NONE);
				if (status != 0) return status;
			}

It is setup for aggregation, even though you are not using it, such that
Channel A for buffers[0] and buffers[1]
Channel B for buffers[2] and buffers[3]
Martyn
Technical Support Manager

ARC
Newbie
Posts: 0
Joined: Wed Aug 08, 2012 8:38 am

Re: Oscilloscope buffers

Post by ARC »

Thank you that all makes sense now.

Thanks for the help :)

Post Reply