09-29-2009 01:34 PM
I am using the PCI-6723 board and I am trying to attempt to produce a waveform pattern using the an analog output channel. The waveform consists of 5 different voltage levels. The main problem is that the first 4 voltage levels are expected to have time intervals of 926 microseconds and the time interval of the last voltage level is expected to be 1.296 milliseconds. Also, the waveform should be triggered on the trailing edge of a sample clock of 200Hz with a 0.1% Duty Cycle. Is this even possible? If so, any help would be greatly appreciated. Thanks in advance!
Here is what I currently have, but it does not accomplish my goal.
int32 written; float64 data[5] = {-0.23, 0.38, 1.12, 1.78, 0.10}; //volts //long time[5] = { 926, 926, 926, 926, 1296}; //microseconds // DAQmx Configure Clock DAQmxErrChk (DAQmxCreateTask("",&taskHandleFRQ)); DAQmxErrChk (DAQmxCreateCOPulseChanFreq(taskHandleFRQ,"Dev3/ctr0","",DAQmx_Val_Hz,DAQmx_Val_Low,0,200,0.001)); DAQmxErrChk (DAQmxCfgImplicitTiming(taskHandleFRQ,DAQmx_Val_ContSamps,1)); // DAQmx Start Code DAQmxErrChk (DAQmxStartTask(taskHandleFRQ)); // DAQmx Configure Code DAQmxErrChk (DAQmxCreateTask("",&taskHandle)); DAQmxErrChk (DAQmxCreateAOVoltageChan(taskHandle,"Dev3/ao0","",-10.0,10.0,DAQmx_Val_Volts,NULL)); DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"/Dev3/Ctr0Out",1000.0,DAQmx_Val_Falling,DAQmx_Val_ContSamps,5)); // DAQmx Write Code DAQmxErrChk (DAQmxWriteAnalogF64(taskHandle,5,0,10.0,DAQmx_Val_GroupByChannel,data,&written,NULL)); // DAQmx Start Code DAQmxErrChk (DAQmxStartTask(taskHandle));
Solved! Go to Solution.
10-01-2009 02:58 PM
void CDevDlg::OnRdr1e1() { float64 data[5] = {-0.23, 0.38, 1.12, 1.78, 0.10}; //volts /* float64 data[4001]; float64 volt[5] = {-0.23, 0.38, 1.12, 1.78, 0.10}; //volts int x=0,d; for(int v=0; v<4; v++) { for(d=0; d<741; d++) { data[x++] = volt[v]; } } for(d=0; d<1037; d++) { data[x++] = volt[4]; } */ // DAQmx Configure Clock DAQmxErrChk (DAQmxCreateTask("",&taskHandleFRQ)); DAQmxErrChk (DAQmxCreateCOPulseChanFreq(taskHandleFRQ,"Dev3/ctr0","",DAQmx_Val_Hz,DAQmx_Val_Low,0,200,0.001)); DAQmxErrChk (DAQmxCfgImplicitTiming(taskHandleFRQ,DAQmx_Val_ContSamps,5)); // DAQmxErrChk (DAQmxCfgImplicitTiming(taskHandleFRQ,DAQmx_Val_ContSamps,800000)); // DAQmx Start Code DAQmxErrChk (DAQmxStartTask(taskHandleFRQ)); // DAQmx Configure Code DAQmxErrChk (DAQmxCreateTask("",&taskHandle)); DAQmxErrChk (DAQmxCreateAOVoltageChan(taskHandle,"Dev3/ao0","",-10.0,10.0,DAQmx_Val_Volts,NULL)); DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",1000,DAQmx_Val_Rising,DAQmx_Val_ContSamps,5)); // DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",800000,DAQmx_Val_Rising,DAQmx_Val_ContSamps,4001)); DAQmxErrChk (DAQmxCfgDigEdgeStartTrig(taskHandle,"/Dev3/Ctr0Out",DAQmx_Val_Falling)); // DAQmx Write Code DAQmxErrChk (DAQmxWriteAnalogF64(taskHandle,5,1,10.0,DAQmx_Val_GroupByChannel,data,NULL,NULL)); // DAQmxErrChk (DAQmxWriteAnalogF64(taskHandle,4001,1,10.0,DAQmx_Val_GroupByChannel,data,NULL,NULL)); }
10-02-2009 09:15 AM
Bingo. This code seems to be working much better. Seems like I needed to reduce my number of samples by 1 in order to fit the desired waveform within the sample clock's 5 millisecond period.
However, if anyone knows a better way of achieving these results, I am open for any ideas.
void CDevDlg::OnRdr1e1() { float64 data[4000]; float64 volt[5] = {-0.23, 0.38, 1.12, 1.78, 0.10}; //volts int x=0,d; for(int v=0; v<4; v++) { for(d=0; d<741; d++) { data[x++] = volt[v]; } } for(d=0; d<1036; d++) { data[x++] = volt[4]; } // DAQmx Configure Clock DAQmxErrChk (DAQmxCreateTask("",&taskHandleFRQ)); DAQmxErrChk (DAQmxCreateCOPulseChanFreq(taskHandleFRQ,"Dev3/ctr0","",DAQmx_Val_Hz,DAQmx_Val_Low,0,200,0.001)); DAQmxErrChk (DAQmxCfgImplicitTiming(taskHandleFRQ,DAQmx_Val_ContSamps,800000)); // DAQmx Start Code DAQmxErrChk (DAQmxStartTask(taskHandleFRQ)); // DAQmx Configure Code DAQmxErrChk (DAQmxCreateTask("",&taskHandle)); DAQmxErrChk (DAQmxCreateAOVoltageChan(taskHandle,"Dev3/ao0","",-0.5,2.0,DAQmx_Val_Volts,NULL)); DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",800000,DAQmx_Val_Rising,DAQmx_Val_ContSamps,4000)); DAQmxErrChk (DAQmxCfgDigEdgeStartTrig(taskHandle,"/Dev3/Ctr0Out",DAQmx_Val_Falling)); // DAQmx Write Code DAQmxErrChk (DAQmxWriteAnalogF64(taskHandle,4000,1,10.0,DAQmx_Val_GroupByChannel,data,NULL,NULL)); }
03-14-2011 04:47 AM - edited 03-14-2011 04:48 AM
Hello! I have a confusion regarding the following:
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",800000,DAQmx_Val_Rising,DAQmx_Val_ContSamps,4000));
DAQmxErrChk (DAQmxCfgDigEdgeStartTrig(taskHandle,"/Dev3/Ctr0Out",DAQmx_Val_Falling));
Why did you specify DAQmx_Val_Rising on the first function call and DAQmx_Val_Falling on the second one? Wasn't it necessary to specify the same edge for the generating signal?