How to use pulse width qualifiers to detect latching trigger

Post your C and C++ discussions here
Post Reply
bloer
Newbie
Posts: 0
Joined: Thu Jul 26, 2018 8:46 pm

How to use pulse width qualifiers to detect latching trigger

Post by bloer » Mon Feb 04, 2019 7:29 pm

I have a Picoscope 5444B. In my application, the trigger is a digital latch (several seconds long) on EXT. In early testing, it worked fine to use a simple rising edge trigger. However I'm now in an environment where I am getting occasional bursts of noise pickup on that line that are causing spurious triggers. The noise bursts last for a few microseconds. So I would like to trigger on a pulse that rises above threshold and remains above threshold for ~1 ms, but NOT on the falling edge of such a pulse.

I can't quite figure out how to do this with the ps5000a API. Do I need to set both a trigger threshold (SetTriggerChannel*) and pulse width qualifier? Or just the latter?

Thanks!

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

Re: How to use pulse width qualifiers to detect latching trigger

Post by Martyn » Mon Feb 11, 2019 11:18 am

Advanced trigger setup using the API commands is a bit of a dark art.

The easiest way to go about this is to first try setting up the trigger using the PicoScope 6 software, and if you are able to trigger on the event exactly as you require we can then work out the settings required for the advanced trigger commands.
Martyn
Technical Support Manager

bloer
Newbie
Posts: 0
Joined: Thu Jul 26, 2018 8:46 pm

Re: How to use pulse width qualifiers to detect latching trigger

Post by bloer » Thu Apr 04, 2019 8:54 pm

Hello Martyn,

I have two issues:

1) In the current picoscope GUI on linux, I cannot get a dropout trigger to work on EXT. If I put my signal into e.g. channel A with all the same settings, the trigger works as expected, but when I move back to EXT, I get no triggers. Is this a bug?

2) Is there an example for how to set a dropout trigger using the API? The programmer's manual mentions it in the Trigger introduction, but never again.

Thanks!
Ben

bloer
Newbie
Posts: 0
Joined: Thu Jul 26, 2018 8:46 pm

Re: How to use pulse width qualifiers to detect latching trigger

Post by bloer » Fri Apr 05, 2019 7:05 pm

I am not a big fan of the API right now. I am using the code below (C++11) to try to make a "dropout" trigger on EXT:

Code: Select all

      PS5000A_CHANNEL ch = PS5000A_EXTERNAL;
      PS5000A_THRESHOLD_DIRECTION direction = PS5000A_RISING;
      PS5000A_CONDITIONS_INFO coninfo = (PS5000A_CONDITIONS_INFO)(PS5000A_CLEAR | PS5000A_ADD);
      PS5000A_CONDITION pwcon{ch, PS5000A_CONDITION_TRUE};
      status = ps5000aSetPulseWidthQualifierConditions(_handle,&pwcon,1,coninfo);
      if(ErrorCheck("SetPulseWidthQualifierConditions"))
         return status;
      
      PS5000A_DIRECTION pwdir{ ch, direction };
      status = ps5000aSetPulseWidthQualifierDirections(_handle,&pwdir,1);
      if(ErrorCheck("SetPulseWidthQualifierDirections"))
         return status;

      status = ps5000aSetPulseWidthQualifierProperties(_handle,
                                                       10,
                                                       10,
                                                       PS5000A_PW_TYPE_GREATER_THAN);
      if(ErrorCheck("SetPulseWidthQualifierProperties"))
         return status;

      PS5000A_CONDITION trigcon{ PS5000A_PULSE_WIDTH_SOURCE, PS5000A_CONDITION_TRUE };
      status = ps5000aSetTriggerChannelConditionsV2(_handle, &trigcon,1,coninfo);
      if(ErrorCheck("SetTriggerChannelConditionsV2"))
         return status;
      //status = ps5000aSetTriggerChannelConditionsV2(_handle, 0, 0, PS5000A_CLEAR);

      PS5000A_TRIGGER_CHANNEL_PROPERTIES_V2 trigprops{ trigger.threshold, 1, //upper, hysteresis
            trigger.threshold, 1, //lower, hysteresis
            PS5000A_PULSE_WIDTH_SOURCE}; //channel
      
   
      status = ps5000aSetTriggerChannelPropertiesV2(_handle, &trigprops,1,0);
      if(ErrorCheck("SetTriggerChannelPropertiesV2"))
         return status;
When I call ps5000aSetTriggerChannelPropertiesV2 with PS5000A_PULSE_WIDTH_SOURCE as the channel, I get error 0x10, invalid channel. But the documentation of PS5000A_CHANNEL enum in the programmer's guide has an asterisk by PS5000A_PULSE_WIDTH_SOURCE that says "For use as a trigger source by functions such as ps5000aSetTriggerChannelPropertiesV2".

Please provide some working examples of advanced trigger setup. The C examples on github do not meet this need as the pulse width qualifier settings are always disabled.

Post Reply