Test and Measurement Forum

Streaming mode and trigger

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

Streaming mode and trigger

Postby kenneth » Fri Apr 05, 2013 4:41 pm

We are having some difficulty determining when triggering occurs in streaming mode. We followed the template from the examples provided of the SDKs. The first trigger is apparent in the callback variable g_trig. However, successive triggers do not produce a TRUE value for g_trig. Our code is attached. Any help would be appreciated.

Code: Select all
status=ps4000SetSimpleTrigger(handle,1, PS4000_EXTERNAL,200,RISING,0,0);
     overview=(short *) malloc(Noutput*10*sizeof(short));
               
        //Set data buffer for channel A for length of nsamples to bufferA
        status = ps4000SetDataBuffer(handle, PS4000_CHANNEL_A, overview, Noutput*10);
        status = ps4000RunStreaming( handle, &sampleInterval, PS4000_NS, 10, Noutput-10, FALSE, 1,  Noutput*10);
c0 = clock();
         j=0;
         while (!g_autoStop)
        {
             c1 = clock();
             if (((float) (c1 - c0)/CLOCKS_PER_SEC)>10)
                 break;
                   
       
        //Sleep(1);
      g_ready = FALSE;
        g_trig =FALSE;
      status = ps4000GetStreamingLatestValues(handle, CallBackStreaming, NULL);
       
       
      if (g_ready && g_sampleCount > 0)
        {
            printf("g_trig = %d\n", g_trig);
            if (g_trig)
            {
            triggeredAt =  g_trigAt;
                printf("Trig. at index %lu in overview buffer, and %d in wfmA\n", triggeredAt,triggeredAt-g_startIndex);
               
            }
         
         for (i=0;i<g_sampleCount;i++)
            {
                outputvaluesA[j]=overview[g_startIndex+i];
                j++;
                if (j>=Noutput)
                    break;
               
            }
            if (j>=Noutput)
                    break;
ps4000Stop(handle);
      free(overview);
kenneth
Newbie
 
Posts: 0
Joined: Wed Jan 23, 2013 11:52 pm

Re: Streaming mode and trigger

Postby kenneth » Fri Apr 05, 2013 8:58 pm

As a second problem, the sample interval returned by ps4000RunStream appears to be off by ~ 8ns. We asked for a 167 ns sample interval, ps4000RunStream returned 160 ns. We acquired a signal at 540 kHz, and with the return sample rate (160 ns), the measured frequency was 512 kHz.

Any help would be great appreciated...
kenneth
Newbie
 
Posts: 0
Joined: Wed Jan 23, 2013 11:52 pm

Re: Streaming mode and trigger

Postby Martyn » Fri Apr 05, 2013 9:31 pm

Please let us know the driver version you are using. I will check this out when I am in the office on Monday.
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2291
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Streaming mode and trigger

Postby kenneth » Sun Apr 07, 2013 10:10 pm

Martyn,

We have the latest SDK drivers (R6.6.57, I believe). As a third problem, we noticed, while going through the support forum, that the AWG and streaming mode could not be used concurrently. Was this problem addressed in the latest SDK?

Thanks
-Ken
kenneth
Newbie
 
Posts: 0
Joined: Wed Jan 23, 2013 11:52 pm

Re: Streaming mode and trigger

Postby Martyn » Mon Apr 08, 2013 8:56 am

Should have asked what 4000 series device you have as there are some differences between them and I need to test against the same model.
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2291
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Streaming mode and trigger

Postby kenneth » Mon Apr 08, 2013 1:41 pm

We have the 4227 model
kenneth
Newbie
 
Posts: 0
Joined: Wed Jan 23, 2013 11:52 pm

Re: Streaming mode and trigger

Postby Martyn » Tue Apr 09, 2013 8:03 am

The trigger value will only be relevant the first time you see it set, unless you stop and start streaming again, it is a one time value.

With regards to the sample interval, 167nsecs is not a valid setting for the hardware it needs to be related to the internal clocks in the device and the driver returns the chosen value closest to the requested one, in this case 160nsecs.

A signal at 540kHz will be represented by approx 11.5 samples at 160nsecs for a full cycle. What signal are you feeding into the device, and what is the signal source ?
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2291
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Streaming mode and trigger

Postby kenneth » Tue Apr 09, 2013 2:43 pm

We are using an Agilent function generator (33250A) as the input. With the picoscope software, Picoscope 6, we confirmed that the signal was as we expected (540 kHz, 500 mVp).

Now, in regards to the sampling issue, we accounted for the actual sampleinterval by having the function return sampleInterval, thereby accounting for the actual sampling frequency of the scope. With this knowledge, we should be able to properly determine the sample interval and frequency content. I should say, we've repeated this exercise in Block mode (i.e. have the function return the sampleInterval), and had no difficulties properly determining the waveform frequency content.

Thanks for your help
kenneth
Newbie
 
Posts: 0
Joined: Wed Jan 23, 2013 11:52 pm

Re: Streaming mode and trigger

Postby Martyn » Tue Apr 09, 2013 7:33 pm

Did you have Picoscope running in streaming mode, 100ms/div or slower setting. Check Tools->Preferences>Sampling for transition time and right click on display and view properties to see actual scope settings. Try changing settings until you get a sample interval of 128ns, which is the closest with Picoscope, and see if frequency is still 540kHz, over the whole trace or between cursors.
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2291
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Streaming mode and trigger

Postby kenneth » Wed Apr 10, 2013 10:14 pm

We used a 1 kHz signal in picoscope 6 in streaming mode (100 ms/div) and 1 microsecond sample interval, and were able to obtain the correct frequency based on the period. However, we noticed that 1 microsecond was the shortest sample interval, regardless of what we set for the number of samples in streaming mode (i.e. 100 ms/div). Thus, we were not able to check our original frequency of 540 kHz. I should note we were using the latest and greatest version of Picoscope 6 (6.6.57.20).

As a side note, we noticed the function setSimpleTrigger is missing from the header file from the latest SDK.

Thanks for your help
kenneth
Newbie
 
Posts: 0
Joined: Wed Jan 23, 2013 11:52 pm

Re: Streaming mode and trigger

Postby Martyn » Thu Apr 11, 2013 9:31 am

Interestingly with the beta version of the software it is possible to set it in streaming mode and have a reported sample interval of 167ns, I need to investigate this. The settings are 100ms/div with the requested number of samples per screen set to 6MS.

With these settings the frequency measurement does not report accurate values.

I believe your issue and the values returned by PicoScope Beta are linked. Can you tell me how many samples you are using to calculate out the frequency, and how you are doing this.
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2291
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Streaming mode and trigger

Postby kenneth » Thu Apr 11, 2013 7:01 pm

In out script, the variable "Noutput" is set to 5000, and we collect that many samples. The script also returns the sample interval, from which we know the sample frequency (1/sample interval). We do an FFT of the time waveform, and the frequency vector for this FFt can then be set to (0:2499)*sample frequency/5000.
kenneth
Newbie
 
Posts: 0
Joined: Wed Jan 23, 2013 11:52 pm

Re: Streaming mode and trigger

Postby Martyn » Thu Apr 11, 2013 8:09 pm

Thanks for the info. I will do some tests when I am back in the office tomorrow.
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2291
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots


Return to General Software Discussions

Who is online

Users browsing this forum: No registered users and 0 guests