Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Create a waveform using PCI-6723 AO with various time intervals on trailing edge of sample clock of 200Hz and 0.1% duty cycle

Solved!
Go to solution

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));

 

 

 

 

 

0 Kudos
Message 1 of 4
(7,586 Views)
I have been working on some code all day to produce the waveform and associated clock and I believe that I am really close.

The code that I have shown here seems to trigger off the sample clock with a waveform around 1ms per step (the simple case).

However, when I try to bump up the sample rate to 800kHz and create my waveform from 4001 samples of data with the sample clock falling edge as the trigger (as seen in the commented code), the trigger no longer seems to be associated with the waveform.

Any ideas? I think I am almost there.

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)); }

 

0 Kudos
Message 2 of 4
(7,567 Views)
Solution
Accepted by topic author VJohnson

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)); }

 

 

 

0 Kudos
Message 3 of 4
(7,560 Views)

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?
0 Kudos
Message 4 of 4
(6,099 Views)