Reading triggered data on Pico 2204A

Post your .Net discussions here
Post Reply
davidpruitt
Advanced User
Advanced User
Posts: 0
Joined: Tue May 17, 2016 6:45 pm

Reading triggered data on Pico 2204A

Post by davidpruitt »

Hey all, just got a Pico 2204A. I am new to the device, and I am writing a simple C# app that reads in data after a simple trigger.

The signal that I am reading on the scope is a simple square wave. The square wave has about 13 pulses over a 500 ms period. I don't care to see the entire pulse train. I really only want to see the first pulse. When I view the signal using the Pico software, it looks like this (and this is what I want to see):
pico_app.png
Notice the settings: timebase is about 200 uS per division, voltage is +/- 10 V (so the square wave itself is 7-8 V in height from baseline).

So I am writing a C# app, and I basically want to be able to see that same signal. Unfortunately, currently in my code this is what I see (with the values plotted in a Matlab figure):
c_figure.png
c_figure.png (2.83 KiB) Viewed 5514 times
As you can see, we are capturing the signal, but we are missing the first half of the square wave, and only capturing the negative portion of it.

Here is my code (using the provided Pico SDK for C# downloaded from this site):

Code: Select all

static void Main()
{
	//Open the scope, set the channel, and set a trigger.
	short scopeHandle = Imports.OpenUnit();
	Imports.SetChannel(scopeHandle, Imports.Channel.ChannelA, 1, 1, Imports.Range.Range_20V);
	Imports.SetTrigger(scopeHandle, (short)Imports.Channel.ChannelA, 0,
		(short)Imports.ThresholdDirection.Rising,
		0, 0);

	//Set the timebase
	int time_interval = 0;
	short time_units = 0;
	int max_samples;
	short result = Imports.GetTimebase(scopeHandle, 7, 1024, out time_interval,
			out time_units, 0, out max_samples);

	int time_indisposed_ms = 0;
	Imports.RunBlock(scopeHandle, 1024, 7, 1, out time_indisposed_ms);
	while(Imports.Isready(scopeHandle) == 0) { /* loop until ready */ }
	
	//Read values from event on scope
	short[] values = new short[1024];
	short overflow = 0;
	long num_values_returned = Imports.GetValues(scopeHandle, values, null, null, null, out overflow, 1024);
	
	//Write values to file
	StreamWriter writer = new StreamWriter("values.txt");
	for (int i = 0; i < 1024; i++)
	{
		writer.WriteLine(values[i].ToString());
	}
	writer.Close();

	Imports.CloseUnit(scopeHandle);
}
As you can see, the code is pretty simple. Any ideas what I am doing wrong? Code is also attached to this post as a .cs file.

Thanks for any help!
Attachments

[The extension cs has been deactivated and can no longer be displayed.]


davidpruitt
Advanced User
Advanced User
Posts: 0
Joined: Tue May 17, 2016 6:45 pm

Re: Reading triggered data on Pico 2204A

Post by davidpruitt »

I was able to solve this issue. For those who have the same issue in the future, it's because the trigger delay needs to be set to -50 instead of 0, essentially telling the oscilloscope to return data from both right before and right after the trigger event, with the trigger event centered in the middle of the data.

Post Reply