Test and Measurement Forum

interval trigger

Post your C and C++ discussions here

interval trigger

Postby dwlee » Fri Jun 29, 2012 2:43 pm

Hello,

I've been using picoscope 3206B for my research work and started working on writing up my own application using the provided C example. I successfully compiled the example with Visual C++ 2008.

Now I'm interested in implementation of interval trigger rather than simple edge triggers. I saw a post with regard to pulse width trigger (post23431.html#p23431) as shown below. I'd like to capture incoming pulses on Channel A when the interval happens to be less than 50ns with rising edge (which is about 12 or 13 samples when the sampling interval is set to 4ns).

For example, Pulse Width Trigger example looks like below. I think interval trigger looks very similar to the following example, but could anyone tell me what needs to be changed to implement a "interval trigger"?
Thank you very much in advance!

Code: Select all
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// this part looks ok to me. Just change PS4000 part to PS3000A accordingly
struct tTriggerChannelProperties sourceDetails = { triggerVoltage, triggerVoltageHys,
0,
0, PS4000_CHANNEL_A, LEVEL };

// this park could be ok too
struct tTriggerConditions conditions = {
CONDITION_TRUE, CONDITION_DONT_CARE, CONDITION_DONT_CARE, CONDITION_DONT_CARE, CONDITION_DONT_CARE, CONDITION_DONT_CARE, CONDITION_TRUE };

// change FALLING to RISING
struct tTriggerDirections directions = {
FALLING, NONE, NONE, NONE, NONE, NONE };

struct tPwqConditions pwqconditions;

// don't see any problem with this part
pwqconditions.channelA = CONDITION_TRUE;
pwqconditions.channelB = CONDITION_DONT_CARE;
pwqconditions.channelC = CONDITION_DONT_CARE;
pwqconditions.channelD = CONDITION_DONT_CARE;
pwqconditions.external = CONDITION_DONT_CARE;
pwqconditions.aux = CONDITION_DONT_CARE;

// I think this part is the most important ones to implement interval trigger. right??
pulseWidth.conditions = &pwqconditions;
pulseWidth.lower = 8; // change this number accordingly to suit my need
pulseWidth.upper = 0;
pulseWidth.type = PW_TYPE_LESS_THAN; // might need to be changed
pulseWidth.nConditions = 1;
pulseWidth.direction = RISING_LOWER;
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
dwlee
Newbie
 
Posts: 0
Joined: Fri Jun 29, 2012 2:23 pm

Re: interval trigger

Postby Martyn » Mon Jul 02, 2012 1:04 pm

Code: Select all
/****************************************************************************
* CollectStreamingTriggered
*  this function demonstrates how to collect a stream of data
*  from the unit (start collecting on trigger)
***************************************************************************/
void CollectStreamingTriggered(UNIT * unit)
{
   short triggerVoltage = mv_to_adc(500,   unit->channelSettings[PS3000A_CHANNEL_A].range, unit); // ChannelInfo stores ADC counts


   struct tPS3000ATriggerChannelProperties sourceDetails = {   triggerVoltage,
                                                256 * 10,
                                                triggerVoltage,
                                                256 * 10,
                                                PS3000A_CHANNEL_A,
                                                PS3000A_LEVEL };

   struct tPS3000ATriggerConditions conditions = {   PS3000A_CONDITION_TRUE,
                                       PS3000A_CONDITION_DONT_CARE,
                                       PS3000A_CONDITION_DONT_CARE,
                                       PS3000A_CONDITION_DONT_CARE,
                                       PS3000A_CONDITION_DONT_CARE,
                                       PS3000A_CONDITION_DONT_CARE,
                                       PS3000A_CONDITION_TRUE };

   struct tPS3000APwqConditions pwqconditions = {   PS3000A_CONDITION_TRUE,
                                       PS3000A_CONDITION_DONT_CARE,
                                       PS3000A_CONDITION_DONT_CARE,
                                       PS3000A_CONDITION_DONT_CARE,
                                       PS3000A_CONDITION_DONT_CARE,
                                       PS3000A_CONDITION_DONT_CARE };

   struct tTriggerDirections directions = {   PS3000A_RISING,
                                    PS3000A_NONE,
                                    PS3000A_NONE,
                                    PS3000A_NONE,
                                    PS3000A_NONE,
                                    PS3000A_NONE };


   struct tPwq pulseWidth = {&pwqconditions,1,PS3000A_RISING,0,0,PS3000A_PW_TYPE_IN_RANGE};
//   memset(&pulseWidth, 0, sizeof(struct tPwq));

   printf("Collect streaming triggered...\n");
   printf("Data is written to disk file (stream.txt)\n");
   printf("Press a key to start\n");
   _getch();
   SetDefaults(unit);

//typedef struct tTriggerDirections
{
   
//   PS3000A_PWQ_CONDITIONS * conditions;
//   short nConditions;
//   PS3000A_THRESHOLD_DIRECTION direction;
//   unsigned long lower;
//   unsigned long upper;
//   PS3000A_PULSE_WIDTH_TYPE type;

//    Play around with the values 
   SetTrigger(unit->handle, &sourceDetails, 1, &conditions, 1, &directions, &pulseWidth, 50, 100, 0);

   StreamDataHandler(unit, 100000);
}
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2339
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: interval trigger

Postby Martyn » Mon Jul 02, 2012 1:21 pm

If you select timebase 100 = 1568ns sample interval the following code will trigger for a pulse between approx 50us and 100us

Code: Select all
/****************************************************************************
* CollectStreamingTriggered
*  this function demonstrates how to collect a stream of data
*  from the unit (start collecting on trigger)
***************************************************************************/
void CollectStreamingTriggered(UNIT * unit)
{
   short triggerVoltage = mv_to_adc(1000,   unit->channelSettings[PS3000A_CHANNEL_A].range, unit); // ChannelInfo stores ADC counts


   struct tPS3000ATriggerChannelProperties sourceDetails = {   triggerVoltage,
                                                256 * 10,
                                                triggerVoltage,
                                                256 * 10,
                                                PS3000A_CHANNEL_A,
                                                PS3000A_LEVEL };

   struct tPS3000ATriggerConditions conditions = {   PS3000A_CONDITION_TRUE,
                                       PS3000A_CONDITION_DONT_CARE,
                                       PS3000A_CONDITION_DONT_CARE,
                                       PS3000A_CONDITION_DONT_CARE,
                                       PS3000A_CONDITION_DONT_CARE,
                                       PS3000A_CONDITION_DONT_CARE,
                                       PS3000A_CONDITION_TRUE };

   struct tPS3000APwqConditions pwqconditions = {   PS3000A_CONDITION_TRUE,
                                       PS3000A_CONDITION_DONT_CARE,
                                       PS3000A_CONDITION_DONT_CARE,
                                       PS3000A_CONDITION_DONT_CARE,
                                       PS3000A_CONDITION_DONT_CARE,
                                       PS3000A_CONDITION_DONT_CARE };

   struct tTriggerDirections directions = {   PS3000A_RISING,
                                    PS3000A_NONE,
                                    PS3000A_NONE,
                                    PS3000A_NONE,
                                    PS3000A_NONE,
                                    PS3000A_NONE };


   struct tPwq pulseWidth = {&pwqconditions,1,PS3000A_RISING,100,200,PS3000A_PW_TYPE_IN_RANGE};

   printf("Collect streaming triggered...\n");
   printf("Data is written to disk file (stream.txt)\n");
   printf("Press a key to start\n");
   _getch();
   SetDefaults(unit);

   /* Trigger enabled
   * Rising edge
   * Threshold = 1000mV */
   SetTrigger(unit->handle, &sourceDetails, 1, &conditions, 1, &directions, &pulseWidth, 0, 0, 0);

   StreamDataHandler(unit, 100000);


Play around with the lower(100) and upper(200) number of samples here to change the settings
Code: Select all
   struct tPwq pulseWidth = {&pwqconditions,1,PS3000A_RISING,100,200,PS3000A_PW_TYPE_IN_RANGE};
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2339
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: interval trigger

Postby dwlee » Mon Jul 02, 2012 6:09 pm

Two source codes in the first and the second reply are slightly different. I presume that the second reply is what you want me to study? When I set up the interval trigger through Picoscope 6, all I have to do is to select "greater than" and "50ns" time options. I see this example use a kind of time range which I think could do the same trick.

My current experiment setup is under maintanance so that I'll test this in the next few weeks and let you know whether it works or not. Thank you very much for your quick response.
dwlee
Newbie
 
Posts: 0
Joined: Fri Jun 29, 2012 2:23 pm

Re: interval trigger

Postby Martyn » Tue Jul 03, 2012 6:08 am

Yes the second is from the console example running with my 3206a, so has the correct calls and settings for triggers. I will await the results of your tests.
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2339
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots


Return to C and C++

Who is online

Users browsing this forum: No registered users and 0 guests