Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

synchronizing analog and digital output

It is rather amazing that after years of discussions NI still did not publish any complete C example on the subject.

 

I have a very standard problem:

M-series board, DAQmx, analog and digital outputs have to generate pattern in a loop, synchroneously

In fact I just need a digital pulse at the beginning of the analog pattern

 

This is what I want to do:

3 tasks: AO, DO and ctr0

ctr0 generates continuously nSamples clocks on PFI12

AO and DO have patterns , nSamples long and continuous otput

Sample clocks of AO and DO are set to PFI12

ctr0 task will start the last.

 

Any comments ?

Boris

0 Kudos
Message 1 of 6
(6,379 Views)

Take a look at the National Instruments folder in you myDocuments. Navigate to CVI->samples->DAQmx->Analog Out->Generate Voltage. Look at the folder titled Cont Gen Volt Wfm-Ext Clk- Dig Start and see if this or one of the other examples help you with how to do what you want. If the examples are not there, try running the installation for DAQmx again and select the Help and Examples to be installed. I believe that is where they are installed from. Have a great day. I am also posting this in the duplicate forum post. 

Alex D
Systems Engineer
Academic Research
National Instruments
0 Kudos
Message 2 of 6
(6,360 Views)

Take a look at the National Instruments folder in you myDocumentsNavigate to CVI->samples->DAQmx->Analog Out->Generate VoltageLook at the folder titled Cont Gen Volt Wfm-Ext ClkDig Start and see if this or one of the other examples help you with how to do what you wantIf the examples are not theretry running the installation for DAQmx again and select the Help and Examples to be installedI believe that is where they are installed fromHave a great dayI am also posting this in the duplicate forum post

Alex D
Systems Engineer
Academic Research
National Instruments
0 Kudos
Message 3 of 6
(6,359 Views)

Thank you Alex, I got the point. I went down my plan and got it working with one exception.

I need to change frequency of the sample clock task.

 

I create the counter task in MAX, load and run it.

However when I want to change the frequency using DAQmxSetCOPulseFreq(task, "Dev2/ctr0", rate) - I receive

Specified property is not supported by the device or is not applicable to the task. Error -200452 (fffcf0fc)

 

Another question is - how to access task property by name using C interface ?

 

Boris

 

 

0 Kudos
Message 4 of 6
(6,345 Views)

You will need to make sure to stop and clear the task then reconfigure it before you run the task again. The device usually does not allow the modification of a task. Essentially I would place on top of your current program a loop which stops the task, clears it, creates a new task, and then runs the current program. That should allow you to change the frequency. 

 

Try that and see if that fixes the problem.

 

As for your second question you will need to malloc memory and then populate it with the data you need. There are functions that can get you that data. Take a look at the help documentation for text based DAQmx. Its very good and can help you figure out exactly what you need. 

Alex D
Systems Engineer
Academic Research
National Instruments
Message 5 of 6
(6,324 Views)

Thank you Alex - this solved the problem. I cleared and re-created the task.

Boris

0 Kudos
Message 6 of 6
(6,302 Views)