06-15-2011 05:42 AM
Hi,
I am using PCI-MIO-16E1 for generating continuous analog output, however, I have failed to do so. I have verified that there is no voltage increment through the use of voltmeter.
Note that I have physical wires attached to the Dev1/ao0 port and an AO GND for enabling voltage output to control my hardware/voltmeter.
The code that I have used:
DAQmxErrChk DAQmxCreateTask("", task_Ao0)
DAQmxErrChk DAQmxCreateAOVoltageChan(task_Ao0, "Dev1/ao0", "aoChannel0", -10, 10, DAQmx_Val_VoltageUnits2_Volts, "")
DAQmxErrChk DAQmxCfgSampClkTiming(task_Ao0, "", updaterate, DAQmx_Val_Falling, DAQmx_Val_AcquisitionType_FiniteSamps, ulCount)
DAQmxErrChk DAQmxCfgDigEdgeStartTrig(task_Ao0, "", "/Dev1/PFI0", DAQmx_Val_Edge1_Rising)
DAQmxErrChk DAQmxWriteAnalogF64(task_Ao0, ulCount, False, 10#, DAQmx_Val_GroupByChannel, pdBuffer(0), ulCount_real, ByVal 0&)
Cyc = 0
Cycle = 10
While (Cyc < Cycle)
DAQmxStartTask(task_Ao0)
Result = 1
While (Result < 0 or Result >0)
Result = DAQmxIsTaskDone(task_Ao0, State)
DoEvents
Wend
DAQmxErrChk DAQmxStopTask(task_Ao0)
Cyc = Cyc + 1
Wend
Hope that someone could help me fast.
Thanks!
06-16-2011 11:22 AM
I would first start testing your device in Measurement & Automation Explorer to see if you can generate any analog output from your PCI card. Highlight your device in Devices and Interfaces and use the Test Panels to generate an analog voltage. Once you've verified that your card is working properly, I would recommend starting with our ANSI C shipping examples that can be found in National Instruments » NI-DAQ » Text-Based Code Support » ANSI C Examles. You will find plenty of examples on generating a continuous AO signal.
As far as your code, it looks like you are trying to start your task off a digital trigger from PFI0. You also have your timing set to finite samples instead of continuous. It looks you are using Cyc and Cycle to loop through starting and stopping your task 10 times. You should only have to start your task once, generate your signal, and then stop the task at the end unless you're trying to trigger a finite waveform from the first 10 digital pulses of PFI0.