Hi
I have made a scripts thats open a running sample from a LC-MS. It then translate the XiC value from a chrommatogram in to a analog output voltage. The Output voltage is only changed from each new scan (ActualCycles). The scrips works fine to approx. 5 sample and then the computer starts to reboots. The CPU is running at approx. 100%. How can change the script so it be come more stabil. I'm using VB6 and DAQmx 8.5 on a XP computer. The DA converter is NI USB-6211. The Doevents have made it more stabil. Why?
part of the script:
Data_is_recorded:
theAnalyst.ActiveControl = xicGraph
Set Xicdata = xicGraph.SeriesColl.Item(1).DataObject
Set theWF = Xicdata.GetWiffFileObject
Actualcycles = theWF.GetActualNumberOfCycles(sampleIndex, 0)
If Actualcycles = expectedcycles Then
GoTo end_script
Else
If Actualcycles > lastcycles Then
DoEvents
Set DataPoint = xicGraph.SeriesColl.Item(1).DataObject
thenumberOfDataPoint = DataPoint.GetNumberOfDataPoints
Call DataPoint.GetDataPoint(thenumberOfDataPoint, theXvalue, theYvalue)
Dim taskHandle As Long
Dim clockEdge As Long
Dim sampsPerCycle As Double
Dim desiredSampleClockRate As Double
Dim resultingFrequency As Double
Dim amplitude As Double
Dim numSampsPerChannel As Long
Dim numChannels As Long
Dim errorCode As Long
Dim errorString As String
Dim sampsPerChanWritten As Long
Dim XICVolt As Double
' Create the DAQmx task.
Call DAQmxCreateTask("", taskHandle)
' Add an analog output channel to the task and check to see whether there is only ONE task.
Call DAQmxCreateAOVoltageChan(taskHandle, "Dev2/ao0", "aoChannel", "-10", "10", DAQmx_Val_VoltageUnits2_Volts, "")
Call DAQmxGetTaskNumChans(taskHandle, numChannels)
If numChannels > 1 Then
errorCode = -1
errorString = "Please specify only one channel."
Err.Raise errorCode, , errorString
End If
XICVolt = (theYvalue / 10000000#)
' Write to the desired channel(s).
Call DAQmxWriteAnalogF64(taskHandle, 1, True, 10#, _
DAQmx_Val_GroupByScanNumber, XICVolt, sampsPerChanWritten, ByVal 0&)
Else
lastcycles = theWF.GetActualNumberOfCycles(sampleIndex, 0)
End If
GoTo Data_is_recorded
end_script:
End If
Best regards
Peter