Test and Measurement Forum

Help with RapidBlockMode with PS5444B and VB.net

Post your .Net discussions here

Help with RapidBlockMode with PS5444B and VB.net

Postby antoniop78 » Thu May 18, 2017 12:19 pm

Hi, I'm not able to write a code to capture 5 waves in RapidBlockMode and VB.net.

The functions:
status = ps5000aSetTriggerChannelConditions(handle, Ch_Conditions, 1)
and
status = ps5000aSetTriggerChannelProperties(handle, Ch_prop(0), 1, 0, autoTriggerMs)

gives me the error "SEHException was unhandled" and I can't get the status

This is the code:

Code: Select all
******************************************************************************************
        Dim handle As Short
        Dim status As UInteger
        Dim numPreTriggerSamples As Integer
        Dim numPostTriggerSamples As Integer
        Dim timeIntervalNs As Single
        Dim maxSamples As Integer
        Dim segmentIndex As UInteger
        Dim getTimebase2Status As UInteger
        Dim delay As UInteger
        Dim autoTriggerMs As Long
        Dim Ch_Conditions As TriggerConditions
        Dim Ch_prop(0) As TRIGGER_CHANNEL_PROPERTIES

        handle = 0
        ps5000aCloseUnit(handle)
        status = ps5000aOpenUnit(handle, vbNullString, DeviceResolution.PS5000A_DR_12BIT)

        deviceReady = False
        timeBase = 7
        numPreTriggerSamples = 20
        numPostTriggerSamples = 200
        totalSamples = numPreTriggerSamples + numPostTriggerSamples
        timeIntervalNs = CSng(0.0)
        maxSamples = 0
        segmentIndex = 0
        getTimebase2Status = 14 ' Initialise as invalid timebase
        '
        status = ps5000aMaximumValue(handle, maxADCValue) ' Find maximum ADC count (resolution dependent)
        'getDeviceInfo(handle) 'Read and display the device information
        '
        'Setup CHannels A e B
        status = ps5000aSetChannel(handle, Channel.PS5000A_CHANNEL_A, CShort(1), CouplingMode.PS5000A_DC, VoltageRange.PS5000A_10V, 0.0)
        status = ps5000aSetBandwidthFilter(handle, Channel.PS5000A_CHANNEL_A, BandwidthLimiter.PS5000A_BW_20MHZ)
        status = ps5000aSetChannel(handle, Channel.PS5000A_CHANNEL_B, CShort(1), CouplingMode.PS5000A_DC, VoltageRange.PS5000A_20V, 0.0)
        status = ps5000aSetBandwidthFilter(handle, Channel.PS5000A_CHANNEL_B, BandwidthLimiter.PS5000A_BW_20MHZ)
        '
        'Trun Off Channels C e D
        status = ps5000aSetChannel(handle, Channel.PS5000A_CHANNEL_C, CShort(0), CouplingMode.PS5000A_DC, VoltageRange.PS5000A_1V, 0.0)
        status = ps5000aSetChannel(handle, Channel.PS5000A_CHANNEL_D, CShort(0), CouplingMode.PS5000A_DC, VoltageRange.PS5000A_1V, 0.0)
        '
        Do Until getTimebase2Status = 0
            getTimebase2Status = ps5000aGetTimebase2(handle, timeBase, totalSamples, timeIntervalNs, maxSamples, segmentIndex)
            If getTimebase2Status <> 0 Then
                timeBase = timeBase + 1
            End If
        Loop
        '
        delay = 0
        autoTriggerMs = 2000
        '
        'stop triggering
        status = ps5000aStop(handle)
        '
        'ThresholdDirection for Channels A,B,C,D,Ext,Aux
        status = ps5000aSetTriggerChannelDirections(handle, ThresholdDirection2.PS5000A_RISING, ThresholdDirection2.PS5000A_NONE, ThresholdDirection2.PS5000A_NONE, ThresholdDirection2.PS5000A_NONE, ThresholdDirection2.PS5000A_NONE, ThresholdDirection2.PS5000A_NONE)
        '
        'Set Trigger Channels Conditions
        Ch_Conditions.ChannelA = TriggerState.CONDITION_TRUE
        Ch_Conditions.ChannelB = TriggerState.CONDITION_DONT_CARE
        Ch_Conditions.ChannelC = TriggerState.CONDITION_DONT_CARE
        Ch_Conditions.ChannelD = TriggerState.CONDITION_DONT_CARE
        Ch_Conditions.Aux = TriggerState.CONDITION_DONT_CARE
        Ch_Conditions.External = TriggerState.CONDITION_DONT_CARE
        Ch_Conditions.pulseWidthQualifier = TriggerState.CONDITION_DONT_CARE
        status = ps5000aSetTriggerChannelConditions(handle, Ch_Conditions, 1)
        '
        'Set Trigger Channels Properties
        Ch_prop(0).Channel = Channel.PS5000A_CHANNEL_A
        Ch_prop(0).thresholdLower = mvToAdc(0, VoltageRange.PS5000A_5V)
        Ch_prop(0).thresholdLowerHysteresis = 256
        Ch_prop(0).thresholdUpper = mvToAdc(0, VoltageRange.PS5000A_5V)
        Ch_prop(0).thresholdUpperHysteresis = 256
        Ch_prop(0).thresholdMode = ThresholdMode.WINDOW
        status = ps5000aSetTriggerChannelProperties(handle, Ch_prop(0), 1, 0, autoTriggerMs)
        '
        status = ps5000aMemorySegments(handle, 5, totalSamples)
        status = ps5000aSetNoOfCaptures(handle, 5)

        ' Create instance of delegate
        ps5000aBlockCallback = New ps5000aBlockReady(AddressOf BlockCallback)
        '
        Dim timeIndisposedMs As Integer = 0
        ' Capture block
        status = ps5000aRunBlock(handle, numPreTriggerSamples, numPostTriggerSamples, timeBase, timeIndisposedMs, segmentIndex, ps5000aBlockCallback, IntPtr.Zero)
        '
        While deviceReady = False
            Me.Refresh()
        End While
        ' Stop the device
        status = ps5000aStop(handle)
******************************************************************************************

Can someon help me ?
antoniop78
Newbie
 
Posts: 0
Joined: Thu May 18, 2017 12:00 pm

Re: Help with RapidBlockMode with PS5444B and VB.net

Postby Hitesh » Fri May 19, 2017 12:39 pm

Hi antoniop78,

Have you referred to our rapid block with simple trigger example for the ps5000a driver on GitHub?

It would be useful to see how you have defined the Advanced Trigger functions as these are not currently defined in the PS5000AImports.vb file. It is possible that an incorrect definition for a parameter in a function could be causing this.

Regards,
Hitesh

Technical Support Engineer
Hitesh
Site Admin
Site Admin
 
Posts: 2387
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Help with RapidBlockMode with PS5444B and VB.net

Postby antoniop78 » Wed May 24, 2017 6:27 pm

Thank you for your quick reply.
I'm out of work, when I'll come back I will try the example and will let you know.
Thanks
Antonio
antoniop78
Newbie
 
Posts: 0
Joined: Thu May 18, 2017 12:00 pm

Re: Help with RapidBlockMode with PS5444B and VB.net

Postby antoniop78 » Wed Jun 07, 2017 8:01 am

Thank you, with the examples I was able to create my own software.

Thanks again
Bye
Antonio
antoniop78
Newbie
 
Posts: 0
Joined: Thu May 18, 2017 12:00 pm

Re: Help with RapidBlockMode with PS5444B and VB.net

Postby Hitesh » Fri Jun 09, 2017 8:24 am

Hi Antonio,

Good to hear you got things working.

Feel free to share snippets of code here to help other Users to raise a Pull Request on GitHub.

Regards,
Hitesh

Technical Support Engineer
Hitesh
Site Admin
Site Admin
 
Posts: 2387
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire


Return to .Net Languages (C#, VB.Net, .)

Who is online

Users browsing this forum: No registered users and 0 guests