Test and Measurement Forum

3204A streaming does not work when setting trigger on

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

3204A streaming does not work when setting trigger on

Postby JerryZhi » Tue Jan 29, 2013 4:46 am

Hi,I am writing my own software in delphi with scope 3204A. Now both block mode and streaming mode run OK without trigger on. However, when I set trigger on in my code, block mode runs OK when the trigger event occurs but the streaming mode does not work no matter the trigger event occurs or not.

Then I debug the code step by step, the program is in the loop waiting for the callback from the scope but never get it. I find that my condition is similar with the case in http://www.picotech.com/support/topic6357.html , but I still can not solve my problem.
Could you please help me solve this problem? Thank you very much.
Below is the relevant code of the streaming mode.
Code: Select all
procedure TfmPS.ScopeInit;
var
  status : smallint;
  triggerconditions : pTriggerconditions;
  channelpropertiesArray : pTchannelPropertiesArray ;
  channelproperties : pchannelProperties;
begin
       new(triggerConditions);
       new(channelpropertiesArray);
       New(channelproperties);
            triggerConditions.channelA   := 0 ;
            triggerConditions.channelB   := 0 ;
            triggerConditions.channelC   := 0 ;
            triggerConditions.channelD   := 0 ;
            triggerConditions.channelExt := 1 ;
            triggerConditions.aux        := 0 ;
            triggerConditions.pulseWidthQualifier := 0;

           channelpropertiesArray[0] := 6000;
           channelpropertiesArray[1] := 1024;
           channelpropertiesArray[2] := 0;
           channelpropertiesArray[3] := 0;
           channelpropertiesArray[4] := 4;
           channelpropertiesArray[5] := 0;

           channelproperties.thresholdMajor := 6000;
           channelproperties.thresholdMinor := 1024;
           channelproperties.hysteresis := 0;
           channelproperties.channel := 4;
           channelproperties.thresholdMode := Level;
    status := ps3000aSetTriggerChannelConditions(ps3000a_handle, triggerConditions, 1);
    status :=    ps3000aSetTriggerChannelDirections(ps3000a_handle, 0, 0, 0, 0, 0, 0);
      SetTriggerProperties(ps3000a_handle, channelpropertiesArray, 5, 1, 0);
   // status :=  ps3000aSetTriggerChannelProperties(ps3000a_handle,channelproperties,5,1,2000);
           Dispose(triggerconditions);
           Dispose(channelpropertiesArray);
           Dispose(channelproperties);

end;

procedure TfmPS.RunStream;
var
     sampleTime : integer;
     sampleInterval : integer;
begin
           ps3000aSetEts(ps3000a_handle, 0, 0, 0, sampleTime);
           ps3000aSetChannel(ps3000a_handle, 0, 1 {true}, 1{true}, 10,0);
           ps3000aSetChannel(ps3000a_handle, 1, 0 {false}, 0{false}, 7,0);
           ps3000aSetDataBuffers(ps3000a_handle, 0, @channelA, @channelAmin, 10000,0,0);
           ps3000aSetDataBuffers(ps3000a_handle, 1, @channelB, @channelBmin, 10000,0,0);
           { start streaming }
           sampleInterval := 400;
           ps3000aRunStreaming(ps3000a_handle, sampleInterval, PS5000_NS,
                                    0, 10000, 1{true}, 1, 0, 10000);
end;
procedure CallbackStreaming
          (  handle : smallint;
             noOfSamples : integer;
             startIndex : integer;
             overflow : smallint;
             triggerAt : integer;
             triggered : smallint;
             autoStop : smallInt; {boolean;}
             parameter : Pointer
   );
{$IFDEF WIN32} stdcall; {$ENDIF}
var
i : Integer;
begin
     ready := true;
     GstartIndex := startIndex;
     streaming := not (autoStop = 1);
     sampleCount := noOfSamples;

end;
procedure TfmPS5000.tmr1Timer(Sender: TObject);
var
  i : integer;
begin
       if  streaming then
     begin
       ready := false;
          ps3000aGetStreamingLatestValues(ps3000a_handle, CallbackStreaming, nil);
      if (sampleCount > 0) and  ready  then
        begin
             for i := prev to (prev + sampleCount-1) do
           begin
              fmPS5000.iPlot1.Channel[0].AddXY(i,channelA[i-prev]);
           end;
        end;
          prev := prev + samplecount+1;
     end
    else
    begin
       btnFastBlock.Enabled := true;
           btnStreaming.Caption := 'Start Streaming';
       ps3000aStop(ps3000a_handle);
    end;

end;
JerryZhi
Newbie
 
Posts: 0
Joined: Mon Jan 28, 2013 1:18 am

Re: 3204A streaming does not work when setting trigger on

Postby Hitesh » Tue Feb 05, 2013 11:12 am

Hi JerryZhi,

Are you intending to usea gated or threshold trigger?

Try changing the corresponding lines in your code to the examples I have given below:

ps3000aSetTriggerChannelDirections - set the direction to PS3000A_RISING:

Code: Select all
status :=    ps3000aSetTriggerChannelDirections(ps3000a_handle, 0, 0, 0, 0, 2, 0);


With the SetTriggerProperties, you are only passing in 1 structure (you do not need to tell the function the number of elements in the structure/array, and the auxEnable variable is not being used.

Code: Select all
SetTriggerProperties(ps3000a_handle, channelpropertiesArray, 1, 0, 0);


You can also use the ps3000aSetSimpleTrigger() function. Please ensure that you are using the dll from the latest SDK.

Hope this helps.
Hitesh

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

Re: 3204A streaming does not work when setting trigger on

Postby JerryZhi » Fri Mar 01, 2013 4:07 pm

Hi,

Thank you for your reply. As what you said in the reply, I have updated the latest dll and also tried the ps3000aSetSimpleTrigger() function. However, the problem is still not solved. With setting trigger on, block mode runs OK but Streaming mode still does not work well.

below is the streaming code
Code: Select all
btnStreaming.Caption := 'Stop Streaming';
           ps3000aSetEts(ps3000a_handle, 0, 0, 0, sampleTime);
           ps3000aSetChannel(ps3000a_handle, 0, 1 {true}, 1{true}, 10,0);
           ps3000aSetChannel(ps3000a_handle, 1, 0 {false}, 0{false}, 7,0);
           ps3000aSetDataBuffers(ps3000a_handle, 0, @channelA, @channelAmin, 10000,0,0);
           ps3000aSetDataBuffers(ps3000a_handle, 1, @channelB, @channelBmin, 10000,0,0);

            ps3000aSetSimpleTrigger(ps3000a_handle,1,channel_external,1000,ABOVE,10,2000);

           sampleInterval := 400;
           ps3000aRunStreaming(ps3000a_handle, sampleInterval, PS5000_NS,
                                    5000, 5000, 0{true}, 1, 0, 10000);

And,if you can give me your email address,we can communicate in email and I can send my project to you to find where it is wrong in the code. my email: zhi.jianlei@ihr-sh.com. Thank you very much for your kind help.
JerryZhi
Newbie
 
Posts: 0
Joined: Mon Jan 28, 2013 1:18 am

Re: 3204A streaming does not work when setting trigger on

Postby Martyn » Fri Mar 01, 2013 4:32 pm

Send your code to support@picotech.com and we will take a look
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2339
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 1 guest