Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to use PCI-6551 & PCI-6115 in the same Measurement Studio VB6 application (Blocking issue??)

Hi,

Here is my setup....

I have a PCI-6551 50 MHz digital waveform and a PCI 6115 DAQ Device installed in a PC.

The 6551 is setup to read a .hws file and output those 20 signals.  I have one of those signals wired to the Digital Trigger input of the 6115.  When a positive going signal comes along on the trigger input, I want the 6115 DAQ to sample one of the analog inputs.

I tweaked a sample app to  get the PCI-6551 WFG to do exactly what it's supposed to do...works great.
I tweaked a sample app to get the PCI-6115 DAQ to sample an analog input (using an external trigger from an external pulse generator), it too does exactly what it's suppposed to do...works great.

The trouble starts when I try to fold both of these actions into one application.  I think I'm running into a blocking issue and I don't know how to get around it.

Generate_Button_Click() is invoked when a form button is pushed.  In that subroutine, I "arm" the DAQ and have it waiting for a trigger.  Later in the routine, I start the waveform generator which should provide the trigger to the DAQ.  I confirm with a scope that all the signals (including the trigger) are being generated.  However, it seems that the DAQ is blocked from looking at the trigger and sampling an input during the whole time that I am outputing my waveform.

Any thoughts if this is a blocking issue and what I might do to get around it.

Thanks,
Rich
<VB code below>



'Option Explicit
Dim global_counter As Long



''''''DAQ CARD STUFF

Private Sub Go_Again()
CWAI1.Start
End Sub

Private Sub CWAI1_AcquiredData(ScaledData As Variant, BinaryCodes As Variant)

   Text1.Text = global_counter
   global_counter = global_counter + 1
   DoEvents
   Go_Again

End Sub

Private Sub Quit_Click()
    End
End Sub

Private Sub CWAI1_DAQError(ByVal StatusCode As Long, ByVal ContextID As Long, ByVal ContextDescription As String)
    MsgBox "CWAI1 Error: " & StatusCode & vbCrLf & "Context: " & ContextDescription & vbCrLf & CWDAQTools1.GetErrorText(StatusCode)
End Sub

Private Sub CWAI1_DAQWarning(ByVal StatusCode As Long, ByVal ContextID As Long, ByVal ContextDescription As String)
    MsgBox "CWAI1 Warning: " & StatusCode & vbCrLf & "Context: " & ContextDescription & vbCrLf & CWDAQTools1.GetErrorText(StatusCode)
End Sub



'''' END DAQ CARD STUFF




Private Sub Generate_Button_Click()

    'variable declaration and initialization of locals
    Dim resourceName As String
    Dim IDQuery As Long
    Dim ResetDevice As Long
    Dim optionString As String
    Dim viSession As Long
    Dim channelList As String
    Dim clockSource As String
    Dim clockRate As Double
    Dim generationMode As Long
    Dim value As Long
    Dim wfm1dataU8() As Byte
    Dim wfm1dataU16() As Integer
    Dim wfm1dataU32() As Long
    Dim wfm2dataU8() As Byte
    Dim wfm2dataU16() As Integer
    Dim wfm2dataU32() As Long
    Dim i As Integer
    Dim wfm1Name As String
    Dim wfm1SamplesToWrite As Long
    Dim wfm2Name As String
    Dim wfm2SamplesToWrite As Long
    Dim myScript As String

     CWAI1.Configure  'configure DAQ
     CWAI1.Start
     ' at this point the DAQ is waiting for a trigger pulse to do a sample
     DoEvents


    'resourceName = Resource_Name.Text
    resourceName = "Dev3"

    IDQuery = 0
    ResetDevice = 0
    optionString = ""
    'channelList = Channel_List.Text
    channelList = "0-19"

    clockSource = NIHSDIO_VAL_ON_BOARD_CLOCK_STR
   ' clockRate = Val(Clock_Rate.Text)
   clockRate = Val("4000000")


    generationMode = NIHSDIO_VAL_WAVEFORM

    Error_Out.Text = "Image Captured"

    'Initialize a generation session
    CheckErr InitGenerationSession(resourceName, IDQuery, ResetDevice, optionString, viSession)
    'Configure the channels for dynamic generation
    CheckErr AssignDynamicChannels(viSession, channelList)
    'Configure the Sample clock source and rate
    CheckErr ConfigureSampleClock(viSession, clockSource, clockRate)
    'Set the generation mode to Scripted
    CheckErr ConfigureGenerationMode(viSession, generationMode)

    CheckErr ConfigureDataVoltageLogicFamily(viSession, channelList,
NIHSDIO_VAL_5_0V_LOGIC)


    CheckErr WriteNamedWaveformFromFileHWS(viSession, wfm1Name, "c:\aps.hws", VI_FALSE, 626688)


    'Commit any pending attributes to hardware and start the dynamic generation DoEvents
    Initiate (viSession)
    ' at this point, the waveform generation starts but it appears that it blocks the DAQ's ability to watch for a trigger.


    'Wait for user input to abort generation
   ' MsgBox "Generation started.  Hit <OK> to abort the generation." & vbCrLf, vbOKOnly, "Abort Generation"
   MsgBox "Image captured.  Click <OK>." & vbCrLf, vbOKOnly, "Abort Generation"
    'Abort generation and close the session
    CheckErr Abort(viSession)
    CheckErr closeSession(viSession)
End Sub

Private Sub Close_Button_Click()
    End
End Sub

Public Function CheckErr(X As Long)
    'Function that checks for errors
    Dim errorMessage As String
    errorMessage = Space(1024)
    If X <> 0 Then
        error_message viSession, X, errorMessage
        Error_Out.Text = "Error Found!" & vbCrLf & "Code: " & X & vbCrLf & errorMessage
    End If
End Function





0 Kudos
Message 1 of 2
(6,611 Views)
Hey RichD,

Do you essentially want to use the output of the 6551 as a sampling clock for the 6115?  Are you using the NI-DAQmx driver or Traditional DAQ driver?  I will take some time to look at your code and let you know if I see anything out of place.

Where did you find the sample applications that you tweaked?

Regards,
Erik
0 Kudos
Message 2 of 2
(6,592 Views)