Hi,
I'm trying to write a continuous digital waveform to lines 0 and 1 of port 0; I have the PCI-6229 and am using MS Visual C# express edition. I have successfully used this set-up to do single-sample writes to these lines on port 0, but I can't figure out how to generate a continuous (repeating) waveform. I have attached the code I am using; it will compile and run without generating exceptions, but when I monitor the output lines on the DAQ card, I see nothing. I don't see even a single run-through of the waveform data, much less a continuous stream of data. Does anyone know what I'm doing wrong?
Thanks,
Elizabeth
public void GrayEncoderWrite(double periodS)
{
uint nSamples = (uint)(1 << 2);
/* Mask the data to the 2 LSBs */
uint mask = nSamples - 1;
/* Create a new task */
doTask = new Task(); // Task doTask is a data member of the form
/* Attach an output channel to the task */
doTask.DOChannels.CreateChannel("dev1/port0/line0:1",
"", ChannelLineGrouping.OneChannelForAllLines);
/* Configure timing for channel: sample rate is 1/periodS */
doTask.Timing.ConfigureSampleClock("/dev1/pfi0", 1.0 / periodS,
SampleClockActiveEdge.Rising,
SampleQuantityMode.ContinuousSamples);
/* Configure channel writer */
DigitalSingleChannelWriter dWriter =
new DigitalSingleChannelWriter(doTask.Stream);
/* Create waveform to write
* Turn the Gray-encoded initial state into an index integer
*/
uint[] grayWaveformUint = new uint[nSamples];
for (uint i = 0; i < nSamples; i++)
grayWaveformUint[i & mask] = i^(i>>1);
/* Do a Gray-encoded waveform starting at the initial state
*/
DigitalWaveform grayWaveform = DigitalWaveform.FromPort(grayWaveformUint, (byte)mask);
grayWaveform.Timing = WaveformTiming.CreateWithRegularInterval(TimeSpan.FromSeconds(periodS));
/* Write waveform to channel */
dWriter.WriteWaveform(true, grayWaveform);
/* Write the initial state and start the clock */
writingSqWave_ = true;
}
// the task is stopped/disposed of in another function