I'm using the PS2000.dll in C#. Altered the C# examples from PS2000A and PS3000.dll.
I want to collect data using "PS2000_run_block".
This works fine except from triggering.
ps2000_set_trigger returns "1", so it should be alright?
Am I missing something?
It worked fine for a PicoScope 2206 I have here, too.
short status;
int range = 8;
status = Imports.SetChannel(_handle, 0, 1, 1, range);
Console.WriteLine("Collect block triggered...");
short auto_trigger_ms = 10000; // start recording after 10 seconds, even if trigger was not found
short threshold = 10; // (mv/range)*maxValue32512
short source = 0; // channel A
status = Imports.ps2000_set_trigger(_handle, source, threshold, 0, 0, auto_trigger_ms);
uint sampleCount = BUFFER_SIZE;
int timeIndisposed = -1;
_timebase = 15;
_oversample = 2;
int timeInterval;
int timeunits;
int maxSamples;
status = Imports.ps2000_get_timebase(_handle, (short)_timebase, 1024, out timeInterval, out timeunits, _oversample, out maxSamples);
status = Imports.ps2000_run_block(_handle,(int) sampleCount, (short)_timebase, _oversample, out timeIndisposed);
Console.WriteLine("Run Block with status: {0}", status);
Console.WriteLine("Waiting for data ( {0} ms indisposed) ...Press a key to abort", timeIndisposed);
_ready = false;
while (!_ready && !Console.KeyAvailable)
{
_ready = (Imports.Ready(_handle) > 0);
Thread.Sleep(1000);
}
[DllImport(_DRIVER_FILENAME)]
public static extern short ps2000_set_trigger(
short handle,
short source,
short threshold,
int direction,
short delay,
short auto_trigger_ms);
It is a signal that gives values from 0-145 when idle and then goes up to about 16000 (ADC counts).
So I thought I was right to specify the threshold to something like 1000. I tested a lot with the threshold.
Oh, I accidentally posted a test, where I set the threshold to 10.
That all looks reasonable. Can you post your project either here or to support@picotech.com and I will run some tests. I don't currently have a C# example to work from.
I have tried your code selecting T to start the triggered block and it appears to be working. Just to verify that it wasn't the timeout trigger I put the auto timeout to 30 seconds so that I had time to adjust my input signal.
I have tried with different ADC count values for the threshold and these reflect the values I read back.
Man, I'm so angry.
With a really hight threshold it works for me, too.
My test environment gives back values around 6000, when idle.
So I thought, a threshold of 7000 or 8000 would be sufficient.
Is there a tolerance here?
And does it trigger, if I am above the threshold at the beginning. Then go below and then above again?
A rising trigger will trigger when you go from a low value through the threshold to a high level, so starting high going low then back high will trigger as you rise again.
There is also a built in hysteresis setting, 1.5% I believe although I can't check at the moment , so it has to start below the lower level and go above the higher level.