NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
chuchu_chuchu
Posts: 2
0 Kudos

how to unrigister the call back function,in vb6 with DAQmx 8.5

I use daqmx api which named DAQmxRegisterEveryNSamplesEvent to register my call back function,When I invoke the function  DAQmxErrChk (DAQmxStopTask(taskHandleAnalog)) to stop my Task.then i call the procedure AD_OPEN  again,it raise an error ,tell me that i need to unregister the event,the data has transfer into the buffer.how can i unregister the event,please look at the following code.

Spoiler
 

 

Private Sub create()

 

   Dim channel As String
    Dim minVoltage, maxVoltage As Double
    Dim samplesPerChannelPerRead As Double
    Dim sampleMode As Long
    Dim boolVal As Boolean
    On Error GoTo AdErrorHandler:
    ' Get values from UI controls
    channel = "Dev2/ai1:2"
    minVoltage = -10
    maxVoltage = 10
    samplesPerChannelPerRead = 100
     If (taskHandleAnalog <> 0) Then
         DAQmxErrChk (DAQmxStopTask(taskHandleAnalog))
        DAQmxErrChk (DAQmxClearTask(taskHandleAnalog))
        taskhandle = 0
    End If
    ' Configure the task
    DAQmxErrChk (DAQmxCreateTask("", taskHandleAnalog))
     DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandleAnalog, "Dev2/ai0", "", DAQmx_Val_InputTermCfg_RSE, minVoltage, maxVoltage, DAQmx_Val_VoltageUnits2_Volts, vbNullString))

    DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandleAnalog, channel, "", DAQmx_Val_InputTermCfg_Diff, minVoltage, maxVoltage, DAQmx_Val_VoltageUnits2_Volts, vbNullString))

End Sub

 

Private Sub AD_Open()

    DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandleAnalog, "", 200, DAQmx_Val_Rising, DAQmx_Val_AcquisitionType_ContSamps, samplesPerChannelPerRead))
    'Find number of samples specified
    DAQmxErrChk (DAQmxGetTaskNumChans(taskHandleAnalog, numChannels))
    'Configure Event Callbacks
    DAQmxErrChk (DAQmxRegisterEveryNSamplesEvent(taskHandleAnalog, 1, 4, 0, AddressOf EveryNSamplesEventHandler1, Nothing))

 ReDim dataBuffer(numChannels * samplesPerChannelPerRead - 1)
    ' Start the DAQmx Task
'    DAQmxErrChk (DAQmxCfgDigEdgeStartTrig(taskHandleAnalog, "/Dev1/PFI2", DAQmx_Val_Edge1_Falling))
    DAQmxErrChk (DAQmxStartTask(taskHandleAnalog))
    ' Update UI
    Exit Sub
AdErrorHandler:
    MsgBox Err.Description
End Sub

Active Participant
D_Biel
Posts: 640
0 Kudos

Re: how to unrigister the call back function,in vb6 with DAQmx 8.5

This may be a bit late, so hopefully you found this on your own. But in order to unregister the event pass a null value for the callback function parameter in the DAQmxRegisterEveryNSamplesEvent function (Nothing in VB).

National Instruments
Product Support Engineer
By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page