Hi,
I've a 6259 DAQ card that I create 4 analog output with on-board regeneration. At least I think it is using on-board memory to regenerate the signals.
Even though that it works, I would like to get a better understanding on what is going on. The following are the questions:
1) The 6259 specification states that "the Analog Ouput FIFO size is 8191 samples shared among channels used".
Since I'm using 4 channels, is that mean each channel only have a FIFO size of 2046?
2) I've defined the sample per buffer size to be 16000. That means the minimum FIFO size needs to be 16000 in order to hold
the waveform. If the totol FIFO size is 8191, hold is that work?
3) Can I configure timing sample clock rate for each channel? The current implementation use a single sample clock rate,
which forces me to use the cyclePerBuffer value to get the frequency from 100 to 1 hz. Is there a better way to implement this?
4) On the " m_Task->Timing.ConfigureSampleClock" function call, the last parameter for buffer size is set to 1000, how is this value
related to the actual FIFO size used in the signal generation?
Thanks in advance
Ray
m_CyclesPerBuffer = 100;
m_DesiredFrequency = 100;
m_SamplesPerBuffer = 16000;
m_Task = std::auto_ptr<CNiDAQmxTask>(new CNiDAQmxTask(m_TaskName));
m_Task->AOChannels.CreateVoltageChannel(m_HrztChannel0Name, _T("HorizontalChannel0"),
m_Minimum, m_Maximum, DAQmxAOVoltageUnitsVolts);
m_Task->AOChannels.CreateVoltageChannel(m_VrtlChannel0Name, _T("VerticalChannel0"),
m_Minimum, m_Maximum, DAQmxAOVoltageUnitsVolts);
m_Task->AOChannels.CreateVoltageChannel(m_HrztChannel1Name, _T("HorizontalChannel1"),
m_Minimum, m_Maximum, DAQmxAOVoltageUnitsVolts);
m_Task->AOChannels.CreateVoltageChannel(m_VrtlChannel1Name, _T("VerticalChannel1"),
m_Minimum, m_Maximum, DAQmxAOVoltageUnitsVolts);
// Verify the task before doing the waveform calculations
m_Task->Control(DAQmxTaskVerify);
// First configure the Task timing parameters
if(m_Task->Timing.SampleTimingType == DAQmxSampleTimingTypeOnDemand)
m_Task->Timing.SampleTimingType = DAQmxSampleTimingTypeSampleClock;
m_DesiredSampleClockRate = (m_DesiredFrequency * m_SamplesPerBuffer) / m_CyclesPerBuffer;
m_SamplesPerCycle = m_SamplesPerBuffer / m_CyclesPerBuffer;
// Determine the actual sample clock rate
m_Task->Timing.SampleClockRate = m_DesiredSampleClockRate;
m_ResultingSampleClockRate = m_Task->Timing.SampleClockRate;
m_ResultingFrequency = m_ResultingSampleClockRate / (m_SamplesPerBuffer / m_CyclesPerBuffer);
CNiReal64Vector waveForm1, waveForm2;
// Create waveforms, waveForm1 is at 100Hz, waveForm2 is at 1Hz
GenerateSawtoothWave(waveForm1, m_ResultingFrequency, m_Amplitude,
m_ResultingSampleClockRate, m_SamplesPerBuffer, m_CyclesPerBuffer);
GenerateSawtoothWave(waveForm2, 1, m_Amplitude, m_ResultingSampleClockRate,
m_SamplesPerBuffer, 1);
// Configure the sample clock with the calculated rate
m_Task->Timing.ConfigureSampleClock(
_T(""),
m_ResultingSampleClockRate,
DAQmxSampleClockActiveEdgeRising,
DAQmxSampleQuantityModeContinuousSamples, 1000);
CNiReal64Matrix combinedMatrix;
combinedMatrix.SetSize(4, waveForm1.GetSize(), CNiMatrix::NiMatrixDoNotInit);
CNiDAQmxAnalogMultiChannelWriter writer(m_Task->Stream);
combinedMatrix.AssignRow(0, waveForm1);
combinedMatrix.AssignRow(1, waveForm2);
combinedMatrix.AssignRow(2, waveForm1);
combinedMatrix.AssignRow(3, waveForm2);
writer.WriteMultiSample(false, combinedMatrix);
m_Task->Start();