Test and Measurement Forum

Unable to trigger PS 2204, using C#

Post your .Net discussions here

Unable to trigger PS 2204, using C#

Postby ruff » Mon Mar 04, 2013 12:39 pm

Hello!

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.

Code: Select all
      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);
      }


And here the driver import:
Code: Select all
        [DllImport(_DRIVER_FILENAME)]
        public static extern short ps2000_set_trigger(
                                                short handle,
                                                 short source,
                                                 short threshold,
                                                 int direction,
                                                 short delay,
                                                 short auto_trigger_ms);
ruff
Newbie
 
Posts: 0
Joined: Mon Mar 04, 2013 12:24 pm

Re: Unable to trigger PS 2204, using C#

Postby Martyn » Mon Mar 04, 2013 1:07 pm

Does the auto trigger kick in after 10 seconds ?

What signal are you expecting to trigger from ?
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2280
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Unable to trigger PS 2204, using C#

Postby ruff » Mon Mar 04, 2013 1:12 pm

Yes, the auto trigger kicks in.

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.
ruff
Newbie
 
Posts: 0
Joined: Mon Mar 04, 2013 12:24 pm

Re: Unable to trigger PS 2204, using C#

Postby Martyn » Mon Mar 04, 2013 1:25 pm

I was going to say increase the threshold because I thought 10 would be on the low side. I will look again.
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2280
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Unable to trigger PS 2204, using C#

Postby Martyn » Mon Mar 04, 2013 1:43 pm

Code: Select all
      status = Imports.ps2000_get_timebase(_handle, (short)_timebase, 1024, out timeInterval, out timeunits, _oversample, out maxSamples);

Can you tell me what values are returned for timeInterval, timeunits and maxSamples
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2280
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Unable to trigger PS 2204, using C#

Postby ruff » Mon Mar 04, 2013 1:45 pm

timeInterval: 1638400
timeunits: 2
maxSamples: 4032
ruff
Newbie
 
Posts: 0
Joined: Mon Mar 04, 2013 12:24 pm

Re: Unable to trigger PS 2204, using C#

Postby Martyn » Mon Mar 04, 2013 2:18 pm

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.
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2280
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Unable to trigger PS 2204, using C#

Postby ruff » Mon Mar 04, 2013 2:45 pm

here you can find my test project:
https://www.dropbox.com/s/nyifaqbb9korp ... sole.zip?m

Only look at
CollectBlockTriggered
ruff
Newbie
 
Posts: 0
Joined: Mon Mar 04, 2013 12:24 pm

Re: Unable to trigger PS 2204, using C#

Postby Martyn » Tue Mar 05, 2013 11:32 am

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.
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2280
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Unable to trigger PS 2204, using C#

Postby ruff » Wed Mar 06, 2013 7:50 am

HOORAY!
AT LAST.

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?
ruff
Newbie
 
Posts: 0
Joined: Mon Mar 04, 2013 12:24 pm

Re: Unable to trigger PS 2204, using C#

Postby Martyn » Thu Mar 07, 2013 3:37 pm

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.
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2280
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots


Return to .Net Languages (C#, VB.Net, .)

Who is online

Users browsing this forum: No registered users and 0 guests