Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Pulse train generation via CTR0OUT with DAQmx?

Hi All,

I want to create a pulse train generator in DAQmx. I tried many things but the code still doesn't work.
I wish to use CTR0OUT (alias GPCTR0) as pulse train output.
Can anybody help me with a little sample code?
(I'm using PCI-6023E.)

Thanks!

- George Cs.
0 Kudos
Message 1 of 7
(4,487 Views)
Dear George

I'm assuming you're trying to implement the pulse train generator in an NI
development environment ...

In LabVIEW consider the example 'C:\Programme\National Instruments\LabVIEW
8.2\examples\DAQmx\Counter\Generate Pulse.llb\Gen Dig Pulse
Train-Continuous.vi'.

In CVI you should get started looking at 'C:\Programme\National
Instruments\CVI81\samples\DAQmx\Counter\Generate Pulse\Dig Pulse
Train-Cont\DigPulseTrain-Cont.prj'.

Best regards

Philipp R.
0 Kudos
Message 2 of 7
(4,478 Views)
Dear Philipp!

>I'm assuming you're trying to implement the pulse train generator in an NI development environment ...

No. I'm using DAQmx API functions only. I surveyed the Ansi C examples, but there is no CTR0OUT example.
I tried the following functions with many combinations, without any success:

DAQmxCreateTask("", &TaskGPCTR);
DAQmxCreateCOPulseChanFreq(TaskGPCTR, "Dev1/ctr0", "", DAQmx_Val_Hz, DAQmx_Val_Low, 0.0, 10.00, 0.50);
DAQmxCreateCOPulseChanFreq(TaskGPCTR, "Dev1/Ctr0Out", "", DAQmx_Val_Hz, DAQmx_Val_Low, 0.0, 10.00, 0.50);
DAQmxCreateCOPulseChanTicks(TaskGPCTR, "Dev1/ctr0", "", "/Dev1/Ctr0Out", DAQmx_Val_Low, 0, 10, 10);
DAQmxCfgDigEdgeStartTrig(TaskGPCTR, "/Dev1/Ctr0Out", DAQmx_Val_Rising);
DAQmxCfgImplicitTiming(TaskGPCTR, DAQmx_Val_ContSamps, 1000);
DAQmxExportSignal(TaskGPCTR, DAQmx_Val_CounterOutputEvent, "/Dev1/Ctr0InternalOutput");
DAQmxStartTask(TaskGPCTR);

So I need a tiny code snippet for this task!

Thanks!

- George

Message Edited by George Cs on 09-05-2007 06:12 AM

0 Kudos
Message 3 of 7
(4,476 Views)
Dear George

The simplest piece of code that proved to work for me was:

#include <NIDAQmx.h>
static TaskHandle gTaskHandle = 0;
DAQmxCreateTask ("", &gTaskHandle);
DAQmxCreateCOPulseChanFreq (gTaskHandle, "Dev1/ctr0", "", DAQmx_Val_Hz, DAQmx_Val_Low, 0.0, 1.0, 0.5);
DAQmxCfgImplicitTiming (gTaskHandle, DAQmx_Val_ContSamps, 1000);
DAQmxStartTask (gTaskHandle);

What exactly happens if you run that?

Best regards

Philipp R.
0 Kudos
Message 4 of 7
(4,468 Views)
I don't believe it!...
I just realized that I'm continually trying to acquire the generated square wave on "Dev1/ai0" while CTR0OUT pin is connected to ACH1 ("Dev1/ai1")!... 8-/
Of course your sample is working. (I started with the same code one day ago...)
Mea culpa...

Thank you for the tip!

Best regards

- George

Message Edited by George Cs on 09-05-2007 09:03 AM

0 Kudos
Message 5 of 7
(4,466 Views)

Do you see pulses on CTR0OUT?

I'm trying to do the same thing.  I thought I would see the pulses on CTR0OUT but I don't.

-CBJohnson

0 Kudos
Message 6 of 7
(4,091 Views)
Hi CBJohnson,

Yes, of course I see the pulses, though my code is a little bit different, because I wrote it in Delphi pascal and I used another pulse frequency, but this sample code is ok.

Greets

- George Cs -
0 Kudos
Message 7 of 7
(4,080 Views)