07-19-2010 08:10 AM
I am using the PCI-6225 card and trying to generate a pair of pulses using the digital lines and internal clock, but I am getting some odd/unexpected results. Can someone explain?
Basically what I want to do is generate a regular pulse over a (configured) set of lines. The pulse will, typically, be 10ms wide at intervals between 900ms and 1,100ms. The interval will only change occasionally and is usually 1 second (1,000).
After looking at the various C# examples I created something like the following
private DigitalWaveform[] m_digitalWaveform = null;
private DigitalWaveform m_positiveDigitalWaveform = null;
...
m_digitalTask = new Task;
m_digitalTask.DOChannels.CreateChannel(
"Dev1/port0/line0", "", ChannelLineGrouping.OneChannelForEachLine);
m_digitalTask.DOChannels.CreateChannel(
"Dev1/port0/line1", "", ChannelLineGrouping.OneChannelForEachLine);
m_digitalTask.DOChannels.CreateChannel(
"Dev1/port0/line2", "", ChannelLineGrouping.OneChannelForEachLine);
// etc. ...
// Repeat for each configured line
double pulseSampleRate = 1000;
int numberPulseOfSamples = 1000; // This varies between 900 and 1,100.
int pulseWidth = numberPulseOfSamples / 100;
int numberOfChannels = m_digitalTask.DOChannels.Count;
m_digitalTask.Timing.ConfigureSampleClock(
"/Dev1/Ctr1Source",
pulseSampleRate, // 1,000 or anything!
SampleClockActiveEdge.Rising,
SampleQuantityMode.ContinuousSamples,
numberPulseOfSamples);
m_digitalTask.Control(TaskAction.Verify);
// m_digitalTask.Done += new TaskDoneEventHandler(OnDigitalTaskDone);
// m_digitalTask.SampleClock += new SampleClockEventHandler(OnClockSamplePulse);
m_digitalWriter = new DigitalMultiChannelWriter(m_digitalTask.Stream);
// Create an array of waveforms (1 per channel/line). Each waveform being the same with the 1st 1%
// being up and the other 99% being down. Set the Timing interval at 1ms.
m_digitalWaveform = new DigitalWaveform[numberOfChannels];
m_positiveDigitalWaveform = new DigitalWaveform(numberOfSamples, 1, DigitalState.ForceDown);
for (int sample=0; sample < pulseWidth; sample++)
{
m_positiveDigitalWaveform.Signals[0].States[sample] = DigitalState.ForceUp;
}
m_positiveDigitalWaveform.Timing = WaveformTiming.CreateWithRegularInterval(
new TimeSpan(0, 0, 0, 0, 1));
for (int channel=0; channel < numberOfChannels; channel++)
{
m_digitalWaveform[channel] = m_positiveDigitalWaveform;
}
m_digitalWriter.WriteWaveform(false,m_digitalWaveform);
m_digitalTask.Start();
1. First of all this only did something if the selected clock source was /Dev1/Ctr1Source. No other clock would do, even though there are 2 clocks on the board (e.g. /Dev1/Ctr0Source did nothing).
2. Secondly the waveform timing seemed to be ignored, e.g. leave it out or setting to something other than 1ms made no difference.
3. Thirdly the pulse sample rate also seemed to be ignored, e.g. set it to 1 or 1,000 made no difference.
4. Fourthly the pulse seemed to be spread over odd intervals. Set the integer numberPulseOfSamples as follows
NumberPulseOfSamples Interval
========================================
1,000 9 (ish) seconds
2,000 18 (ish) seconds
4,000 36 (ish) seconds
1,500 6½ (ish) seconds
3,000 8½ (ish) seconds
800 7 (ish) seconds
Setting the number of pulse samples to a low value (500) threw an error (-200016, "device memory underflow") when stopping the task.
Can someone shed some light on what is going on and how I can get what I want?
07-20-2010 10:23 PM
Do the original examples work? have you been able to use both Counter0Source and Counter1Source with them?
07-21-2010 09:16 AM
I only seem able to select Ctr1Source, but this may be because (?) I have some clocked analogue input going on at the same time, so perhaps Ctr0Source is busy with this. Unfortunately, the 2 examples of clocked digital wave forms doing a write use PipelinedSampleClock or BurstHandshake, although there are reads using a "SampleClock". If you try to run the 2 examples you get an error
Property: NationalInstruments.DAQmx.Timing.SampleTimingType
You Have Requested: NationalInstruments.DAQmx.SampleTimingType.PipelinedSampleClock (or SampleTimingType.BurstHandshake)
You Can Select: NationalInstruments.DAQmx.SampleTimingType.SampleClock, NationalInstruments.DAQmx.SampleTimingType.OnDemand, NationalInstruments.DAQmx.SampleTimingType.ChangeDetection
Task Name: _unnamedTask<0>
Status Code: -200077
So I guess the PCI-6225 board doesn't support them.