07-07-2009 04:53 AM
Hello!
Our application has one AO and one AI voltage task with minVal fixed to -10 and maxVal fixed to +10. We acquire/generate m samples n times (for a total of m*n samples). It's possible to reconfigure the minVal/maxVal each of the n times (depending on the generated/acquired samples) in a quick way? If I'm correct, this is possible by stopping and recreating the task (calling DAQmxClearTask, then DAQmxCreateTask and finally DAQmxCreateAIVoltageChan or DAQmxCreateAOVoltageChan), but as far as I know this is a slow operation and this is not a good thing for our application. Are there other ways to do this? Actually we're using the NI PCI-6229 card.
Thanks in advance!
Solved! Go to Solution.
07-08-2009 03:36 AM
Hi,
it is possible to set (and also get) the minimum and maximum values for a DAQmx channel: in LabVIEW through DAQmx channel property nodes Analog Input:Maximum Value and Analog Input:Minimum Value, in textual programming languages with functions DAQmxSetAIMin, DAQmxSetAIMax (and similarly for AO channels).
However, for M-series boards it is not possible to set these properties while the task is running, so you will have to stop the task, set the new values and start the task again.
I hope that this will help!
Bye!
Licia
07-10-2009 04:15 AM
Grazie 🙂
So something like this should do the work (I've added the code that seeks for max and min values and the function calls to DAQmxSetAOMin and DAQmxSetAIMin:
'=================================================== AO =============================================== '** START AN ANALOG OUTPUT OPERATION AT GIVEN BITRATE, TASK ALWAYS OPERATIVE ** Public Sub StartAOTask(OutData() As Double, SampsNum As Long, Bitrate As Double) If mBoardEn Then Dim i As Long, min As Double, max As Double min = OutData(0) max = min For i = 0 To UBound(OutData) If OutData(i) < min Then min = OutData(i) If OutData(i) > max Then max = OutData(i) Next Call DAQmxErrChk(DAQmxStopTask(mAOTaskHnd)) Call DAQmxErrChk(DAQmxSetAOMin(mAOTaskHnd, "AO0:2", min)) Call DAQmxErrChk(DAQmxSetAOMax(mAOTaskHnd, "AO0:2", max)) Call DAQmxErrChk(DAQmxCfgSampClkTiming(mAOTaskHnd, "", Bitrate, mDAQmx_Val_Rising, mDAQmx_Val_FiniteSamps, LI2Curr(SampsNum))) Call DAQmxErrChk(DAQmxWriteAnalogF64(mAOTaskHnd, SampsNum, mAutoStart, mTimeOut, mDAQmx_Val_GroupByScanNumber, OutData(0), mManagedSamples, 0&)) End If End Sub
And the task was defined so:
Call DAQmxErrChk(DAQmxCreateTask("", mAOTaskHnd)) 'Create AO - task 4 analog output Call DAQmxErrChk(DAQmxCreateAOVoltageChan(mAOTaskHnd, "Dev1"/ao0:2", "AO", -10#, 10#, mDAQmx_Val_Volts, 0&))
Is this looking OK?