Test and Measurement Forum

Streaming Choices

Post your VB and VBA discussions here

Streaming Choices

Postby BDR » Mon Aug 31, 2015 2:35 pm

I am trying to figure out how to only stream after a trigger event has occured. I tried set the "pre trigger samples" value to zero. Right now it almost seems pointless to have a trigger set.

With older scopes you could simply poll the scope until a trigger event occured.

The picoscope manual is very cryptic to me, as I am use to the old skippy code instead.
Is there a way you can do this? My current laptop doesn't have a lot of memory. It would also be nice if I could have a trigger event stop the streaming. I am guessing that this has to be done as a post process.
BDR
Super User
Super User
 
Posts: 20
Joined: Tue Aug 18, 2015 3:23 pm

Re: Streaming Choices

Postby BDR » Wed Sep 02, 2015 6:37 pm

I have been playing with the programming, and the problem may be that I don't understand the syntax.

I am under the impression from the manual that you can do something like

Call ps6000SetChannel(handle, 0, 1, PS6000_DC_50R, PS6000_50MV, 0, PS6000_BW_FULL)

I don't believe this works because I cannot hear the circuit change from 1M to 50ohm.

Do I have to know what all the numbers represent?

eg. Call ps6000SetChannel(handle, 0, 1, 8, 0, 0)

Where can you find this information?
BDR
Super User
Super User
 
Posts: 20
Joined: Tue Aug 18, 2015 3:23 pm

Re: Streaming Choices

Postby Martyn » Wed Sep 02, 2015 8:13 pm

Once you begin streaming data will start to be transferred from the scope to the driver, when the trigger event is met the scope will indicate to the driver the actual sample the trigger occurred at. All you need to do is to ignore data in the callback until you see the triggered flag and triggered at values.

If you also set the auto stop flag the driver will stop collecting the data and will then hold a buffer with the post trigger samples in.
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2355
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Streaming Choices

Postby BDR » Thu Sep 03, 2015 12:28 pm

Thanks for the info. Now that I know there is a flag, I will look for it and figure out how to use it.

I seem to have a bigger problem though. When I go to set up channels in VBA, I cannot hear the circuitry changing over from 1M to 50ohm. I tried making a button to switch from one to the other. If I can't hear anything, it is not working. As I compare my program to the example programs, there is virtually no difference other than I am writing out the command inside eg. Call ps6000SetChannel(handle, 0, 1, PS6000_DC_50R, PS6000_50MV, 0 , PS6000_BW_FULL), or
Call ps6000SetChannel(handle, 0 ,1 , PS6000_DC_1M, PS6000_5V, 0 , PS6000_BW_FULL)

Do they need to be strings?

The program only executes half the commands. It continues along and collects data, but I cannot confirm that the trigger and channel was set properly.
BDR
Super User
Super User
 
Posts: 20
Joined: Tue Aug 18, 2015 3:23 pm

Re: Streaming Choices

Postby Martyn » Thu Sep 03, 2015 1:42 pm

Can you try
Code: Select all
status = ps6000SetChannel

rather than
Code: Select all
Call ps6000SetChannel

as this will give an indication of what the driver thinks is wrong.
Additionally can you post your function declaration so we can see how you have defined the parameters.
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2355
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Streaming Choices

Postby BDR » Thu Sep 03, 2015 5:13 pm

Code: Select all
Type TRIGGER_CONDITION
channelA As Long
channelB As Long
channelC As Long
channelD As Long
external As Long
aux As Long
pulseWidthQualifier As Long
End Type

Declare Function ps6000OpenUnit Lib "ps6000.dll" (ByRef handle As Integer, ByVal serial As Byte) As Long
Declare Sub ps6000CloseUnit Lib "ps6000.dll" (ByVal handle As Integer)

Declare Function ps6000GetUnitInfo Lib "ps6000.dll" (ByVal handle As Integer, ByVal str As String, ByVal length As Integer, ByRef requiredSize As Integer, ByVal info As Integer) As Long

Declare Function ps6000SetChannel Lib "ps6000.dll" (ByVal handle As Integer, ByVal channel As Long, ByVal enabled As Integer, ByVal dc As Long, ByVal range As Long, ByVal analogueOffset As Single, ByVal bandwidth As Long) As Long
Declare Function ps6000GetTimebase Lib "ps6000.dll" (ByVal handle As Integer, ByVal timebase As Long, ByVal noSamples As Long, ByRef timeInterval As Long, ByVal oversample As Integer, ByRef maxSamples As Long, ByVal segment As Long) As Long
Declare Function ps6000SetDataBuffer Lib "ps6000.dll" (ByVal handle As Integer, ByVal channel As Long, ByRef buffer As Integer, ByVal length As Long, ByVal downSampleRatioMode As Long) As Long
Declare Function ps6000GetValues Lib "ps6000.dll" (ByVal handle As Integer, ByVal startIndex As Long, ByRef numSamples As Long, ByVal downSampleRatio As Long, ByVal downSampleRatioMode As Long, ByVal segmentIndex As Long, ByRef overflow As Integer) As Long
Declare Function ps6000Stop Lib "ps6000.dll" (ByVal handle As Integer) As Long

Declare Function ps6000RunStreaming Lib "ps6000.dll" (ByVal handle As Integer, ByRef sampleInterval As Long, ByVal sampleIntervalTimeUnits As Long, ByVal maxPreTriggerSamples As Long, ByVal maxPostTriggerSamples As Long, ByVal autoStop As Integer, ByVal downSampleRatio As Long, ByVal downSampleRatioMode As Long, ByVal overviewBufferSize As Long) As Long

' Trigger functions
Declare Function ps6000SetSimpleTrigger Lib "ps6000.dll" (ByVal handle As Integer, ByVal enable As Integer, ByVal source As Long, ByVal Threshold As Integer, ByVal direction As Long, ByVal delay As Long, ByVal autoTriggerMs As Integer) As Long
Declare Function ps6000SetTriggerChannelConditions Lib "ps6000.dll" (ByVal handle As Integer, ByRef conditions As TRIGGER_CONDITION, ByVal nConditions As Integer) As Long
Declare Function ps6000SetTriggerChannelDirections Lib "ps6000.dll" (ByVal handle As Integer, ByVal channelA As Long, ByVal channelB As Long, ByVal channelC As Long, ByVal channelD As Long, ByVal ext As Long, ByVal aux As Long) As Long
Declare Function SetTriggerProperties Lib "ps6000Wrap.dll" (ByVal handle As Integer, ByRef triggerChannelPropertiesArray As Long, ByVal nProperties As Integer, ByVal autoTrig As Long) As Long

Declare Function RunBlock Lib "ps6000Wrap.dll" (ByVal handle As Integer, ByVal noPreTriggerSamples As Long, ByVal noPostTriggerSamples As Long, ByVal timebase As Long, ByVal oversample As Integer, ByVal segmentIndex As Long) As Long
Declare Function GetStreamingLatestValues Lib "ps6000Wrap.dll" (ByVal handle As Integer) As Long
Declare Function AvailableData Lib "ps6000Wrap.dll" (ByVal handle As Integer, ByRef startIndex As Long) As Long
Declare Function AutoStopped Lib "ps6000Wrap.dll" (ByVal handle As Integer) As Integer
Declare Function IsReady Lib "ps6000Wrap.dll" (ByVal handle As Integer) As Integer

Declare Sub setChannelCount Lib "ps6000Wrap.dll" (ByVal handle As Integer, ByVal channelCount As Integer)
Declare Function setEnabledChannels Lib "ps6000Wrap.dll" (ByVal handle As Integer, ByRef enabledChannels As Integer) As Integer
Declare Function setAppAndDriverBuffers Lib "ps6000Wrap.dll" (ByVal handle As Integer, ByVal channel As Integer, ByRef appBuffer As Integer, ByRef driverBuffer As Integer, ByVal bufferLength As Long) As Integer

Declare Sub Sleep Lib "kernel32.dll" (ByVal time As Long)

Dim handle As Integer
Dim status As Integer
Dim str As String * 20


Const maxADCCount = 32512     ' Maximum ADC Count for device is 32512
BDR
Super User
Super User
 
Posts: 20
Joined: Tue Aug 18, 2015 3:23 pm

Re: Streaming Choices

Postby BDR » Thu Sep 03, 2015 5:22 pm

The status never changes from zero.
BDR
Super User
Super User
 
Posts: 20
Joined: Tue Aug 18, 2015 3:23 pm

Re: Streaming Choices

Postby Martyn » Thu Sep 10, 2015 12:16 pm

If, as you step past each line, the status return is zero then the parameters being passed into the function calls are accepted by the driver as valid.

It may be easier if you can send your full code to us at support@picotech.com and then we can run this up with a scope and see what happens.
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2355
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Streaming Choices

Postby ljspeltdutch » Tue Nov 24, 2015 3:23 pm

Does this mean that in streaming mode the triggered flag returns to 0 with the next getstreamingvalues call? and the flag will be set again on the next trigger? i.e. a case where autostop is never called with continuous streaming..

Kind regards

Loek
ljspeltdutch
Newbie
 
Posts: 0
Joined: Thu Jul 16, 2015 4:36 pm

Re: Streaming Choices

Postby Martyn » Wed Nov 25, 2015 9:04 am

No, it is only possible to have one trigger event for a streaming run, so once set the flag will stay set.

If you need to look for a new trigger event you would have to stop the scope and then restart it, which is how the PicoScope 6 software handles streaming.
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2355
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots


Return to VB and VBA (Excel, Access)

Who is online

Users browsing this forum: No registered users and 0 guests