11-23-2005 04:36 AM
12-06-2005 09:14 AM
Still no answers....
I have two weeks until a product shall be ready to use, and I need the get this problem solved.
Background:
I'm using a task with analog input channels and a task with one analog output channel. I also have a task with 32 digital lines which I need to have at a certain sample rate, different from the analog channels. Therefor I need to use a counter or an external clock as sample clock for the digital task. It's easier to solve this problem in software than hardware and for that reason I want to use a counter as sample clock.
1. How do I setup a counter as sample clock?
2. How do I connect the output from this counter as the sample clock for the digital task?
It's probably very easy to do, but I have failed. I'm using Measurement Studio and a 6259 DAQ board.
12-06-2005 10:23 AM
12-06-2005 09:35 PM
12-07-2005 02:20 AM
Thank you for your answers, but I can't get it to work.
When I use "ai/SampleClock" as sample clock everything works correct. When I try to use a counter as sample clock the task completes imediately, before any digital signals has been sent/measured. The task even completes before I have started the trigger, which is very confusing. No error appears.
I think that something is wrong about how I setup the counter. I use the code below:
// Create counter task
CNiDAQmxTask m_Task(_T("ATask"));
m_Task.COChannels.CreatePulseChannelTicks(_T("Dev1/ctr0"), "", _T("20MHzTimebase"), DAQmxCOPulseIdleStateLow, 0, 100, 100);
m_Task.Triggers.StartTrigger.ConfigureDigitalEdgeTrigger("PFI0", DAQmxDigitalEdgeStartTriggerEdgeRising);
// Create digital output task
// The code below works with "ai/SampleClock" as sample clock
CNiDAQmxTask m_Task3(_T("ATask3"));
m_Task3.DOChannels.CreateChannel("Dev1/port0/line0", "", DAQmxOneChannelForAllLines);
m_Task3.Timing.ConfigureSampleClock("Dev1/Ctr0InternalOutput" /*"ai/SampleClock"*/, 0, DAQmxSampleClockActiveEdgeRising, DAQmxSampleQuantityModeFiniteSamples, 400);
// Create samples
CNiUInt32Vector ui_data; for(int i = 0; i < 200; i++) for(unsigned int j = 0; j < 2; j++)ui_data.Append(j);
// Create digital writer
CNiDAQmxDigitalSingleChannelWriter m_writer3(m_Task3.Stream);
m_writer3.WriteMultiSamplePortAsync(
true, ui_data);
// Wait until task completes
m_Task3.WaitUntilDone(-1);
12-07-2005 08:38 AM
Hi pek-
Two things: first, the clock source should be "/Dev1/Ctr0InternalOutput" . Don't forget the leading slash.
Second, you are never starting the counter generation task. You need to start the digital task, then start the counter task so that that digital task is waiting for the counter clock and THEN the counter task is waiting for the trigger. Right now you're just starting the digital task and the counter task is never running.
You may want to check out some shipping examples that show how to perform both the counter output and digital output with "external" clock. For .NET, these can be found in C:\Program Files\National Instruments\MeasurementStudioVS2003\DotNET\Examples\DAQmx\Counter\Generate Pulse\GenDigPulseTrainContinuous_DigStart and C:\Program Files\National Instruments\MeasurementStudioVS2003\DotNET\Examples\DAQmx\Digital\Generate Values\WriteDigChan_ExtClk\, respectively.
Hopefully this helps-
12-07-2005 09:30 AM
12-07-2005 09:52 AM
Hi pek-
In general, the leading slash is only required for timing sources. This means that "/Dev1/PFI0" and "/Dev1/Ctr0InternalOutput" are required for sample clock source and trigger source inputs. When you are creating channels (i.e. "Dev1/ctr0") the slash is not necessary.
Hopefully this helps-