Test and Measurement Forum

Logical Triggering

Post general discussions on using our drivers to write your own software here

Logical Triggering

Postby BSI » Mon Nov 21, 2011 7:45 pm

With a 4227 set on logical triggering "Trigger on Input A or Input B" , does the driver return which input has received the trigger? I need to know which input was triggered to process my data accordingly. Processing will depend whether the signal was coming in from Input A or Input B.
Thx.
Laurent
BSI
Newbie
 
Posts: 0
Joined: Wed May 12, 2010 3:15 pm
Location: Canada

Re: Logical Triggering

Postby Hitesh » Wed Nov 23, 2011 12:00 pm

Hi Laurent,

Looking at the Programmer's Guide, unfortunately there isn't a direct way of establishing the channel on which a trigger occurred due to the way the FPGA handles the trigger.

If you are able to provide any information on how you wish to process the data, we could look at finding a way around this as you can obtain the number of the sample at which the trigger occurred from the callback function.

I hope this helps.

Regards,
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 1997
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Logical Triggering

Postby BSI » Thu Nov 24, 2011 6:38 pm

Hi Hitesh,

Can you clarify "the Number of the Sample" from your post please?

Essentially I have 2 inputs connected to the digitizer. The signal comes alternatively from either A or B, and I want to make sure that when a trigger occurs from signal A (B) , it is actually the case so that I can pull the data from A (B). All my signals coming from A are averaged together, and I don't want to mix them with B signals. Same idea from B signals being averaged together.

Maybe I could just re-arm the digitizer and force it to trigger on A only, then later on B only... But I wanted to have better sense of what the logical triggering could do
Thx
L.
BSI
Newbie
 
Posts: 0
Joined: Wed May 12, 2010 3:15 pm
Location: Canada

Re: Logical Triggering

Postby Hitesh » Mon Nov 28, 2011 4:52 pm

Hi Laurent,

In the callback function for Streaming there are 2 variables called triggerAt and triggered.

You can use these to show when a trigger occurred and at which sample in the buffer but it does not tell which channel the trigger occurred on.

Below is some example code that was used to resolve another query concerning the PicoScope 3000A series:

Code: Select all
void PREF4 CallBackStreaming(   short handle, long noOfSamples, unsigned long   startIndex,
                  short overflow, unsigned long triggerAt, short triggered,
                  short autoStop, void   *pParameter)
{
   // used for streaming
   g_sampleCount = noOfSamples;
   g_startIndex   = startIndex;
   g_autoStopped      = autoStop;

   // flag to say done reading data
   g_ready = TRUE;

   // flags to show if & where a trigger has occurred
   g_trig = triggered;
   g_trigAt = triggerAt;
}


In the StreamDataHandler function:

Code: Select all
void StreamDataHandler(UNIT * unit, unsigned long preTrigger)
{
   long i, j;
   unsigned long sampleCount= BUFFER_SIZE * 10; /*  *10 is to make sure buffer large enough */
   FILE * fp = NULL;
   short * buffers[PS3000A_MAX_CHANNEL_BUFFERS];
   PICO_STATUS status;
   unsigned long sampleInterval = 1;
   int index = 0;
   int totalSamples;
   unsigned long triggeredAt = 0;

   for (i = 0; i < unit->channelCount; i++) // create data buffers
   {
      buffers[i * 2] = (short*) malloc(sampleCount * sizeof(short));
      buffers[i * 2 + 1] = (short*)malloc(sampleCount * sizeof(short));
      status = ps3000aSetDataBuffers(   unit->handle,
                                                      i,
                                                      buffers[i * 2],
                                                      buffers[i * 2 + 1],
                                                      sampleCount,
                                                      0,
                                                      PS3000A_RATIO_MODE_NONE);
   }

   printf("Waiting for trigger...Press a key to abort\n");
   g_autoStopped = FALSE;

   status = ps3000aRunStreaming(unit->handle,
                                             &sampleInterval,
                                             PS3000A_US,
                                             preTrigger,
                                             1000000 - preTrigger,
                                             //FALSE,
                                             TRUE,
                                             1000,
                                             PS3000A_RATIO_MODE_AGGREGATE,
                                             sampleCount);

totalSamples = 0;
   while (!_kbhit() && !g_autoStopped)
   {
      /* Poll until data is received. Until then, GetStreamingLatestValues wont call the callback */
      Sleep(100);
      g_ready = FALSE;

      status = ps3000aGetStreamingLatestValues(unit->handle, CallBackStreaming, NULL);
      index ++;

      if (g_ready && g_sampleCount > 0) /* can be ready and have no data, if autoStop has fired */
      {
         if (g_trig)
            triggeredAt = totalSamples += g_trigAt;
         totalSamples += g_sampleCount;
         printf("\nCollected %li samples, index = %lu, Total: %d samples  ", g_sampleCount, g_startIndex, totalSamples);

         if (g_trig)
            printf("Trig. at index %lu", triggeredAt);

         // File processing

   ps3000aStop(unit->handle);

   if (!g_autoStopped)
   {
      printf("\ndata collection aborted\n");
      _getch();
   }

   for (i = 0; i < unit->channelCount * 2; i++)
   {
      free(buffers[i]);
   }



While data is being collected, the code finds the position in the buffer of the data values where the trigger occurred and adds it to the total number of samples collected so far to determine the sample since the start of capture at which the trigger occurred.

If your signals are repetitve, then the option you suggested of alternating trigger would be an option. It may be that you have to examine the data to determine on which channel the trigger occurred.

Is the 4227 the PicoScope you are referring to in your other post concerning conformal coating?

Thanks,
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 1997
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Logical Triggering

Postby BSI » Tue Mar 20, 2012 12:15 am

Thx Hitesh.
I am using RapidBlock Mode, not streaming.

Yes, this is the same 4227 I was referring to with regards to conformal coating.
Laurent
BSI
Newbie
 
Posts: 0
Joined: Wed May 12, 2010 3:15 pm
Location: Canada

Re: Logical Triggering

Postby Hitesh » Thu Mar 22, 2012 4:03 pm

Hi Laurent,

Thanks for the reply.

With the call to the ps4000RunBlock() command, the callback function will not provide an indication of the trigger point. There is the pParameter which can be used to send any data such as a status flag back to the application.

Regards,
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 1997
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Logical Triggering

Postby BSI » Tue Mar 27, 2012 6:43 pm

Thx Hitesh, I will look into it.
Regards,
Laurent
BSI
Newbie
 
Posts: 0
Joined: Wed May 12, 2010 3:15 pm
Location: Canada


Return to General Software Discussions

Who is online

Users browsing this forum: No registered users and 1 guest