I'm having trouble with multi-channel clocked acquisition on an NI 622x card. I can't seem to get the right parameters set up for (near) continuous acquisition, using the defaults listed in the example or otherwise. I'm having trouble discovering what the issues are. I have no trouble with the code in aiex1.cpp, but I can't seem to get this to work. I don't even get the correct number of samples; the fifo queue only seems to collect two values once every second or so, even with the parameters entered in the example. This code works flawlessly for E-Series cards, but fails spectacularly for M-Series cards. By changing a few of the parameters, I can get the acquisition speed to increase somewhat, but only slightly. For some reason, the code examples show smileys in html. Those should just be colons.
😉Here are the relevant code snippets:
NI.m:
-( BOOL )aiSetup {
UInt32 i;
UInt32 scanInterval = 2000;
// Convert ticks
UInt16 convert = 280;
BOOL continuous = FALSE;
[ self initMITE ];
[ self initialize ];
[ self configureTimebase ];
[ self resetPLL ];
[ self resetAnalogTrigger ];
[ self aiReset ];
[ self aiPersonalize:_aiNIConvertOutputSelect ]; // 3 for 622x cards
[ self aiClearFifo ];
[ self resetADC ]; // does nothing unless card is 625x series
[ self aiDisarm ];
[ self aiClearConfigurationMemory ];
for( i = 0; i < _aiChannelsToRecord; i++ ) // 2 channels
[ self aiConfigureChannel:( _aiFirstChannel + i ) :_aiGainIndex :kBiPolar :_aiChannelType
😞 i == ( _aiChannelsToRecord - 1 ) ) ? TRUE : FALSE ]; // first channel = 0, _gainIndex = 1, channel type = differential
[ self aiSetFIFORequestMode ];
[ self aiEnvironmentalize ];
[ self aiHardwareGating ];
[ self aiTrigger:kAISTART1SelectPulse :kAISTART1PolarityRisingEdge :kAISTART2SelectPulse :kAISTART2PolarityRisingEdge ];
[ self aiSampleStop:( _aiChannelsToRecord > 1 ) ? TRUE : FALSE ];
[ self aiNumberOfSamples:_aiFramesPerBuffer :0 :continuous ]; // 32 samples
[ self aiSampleStart:scanInterval :3 :kAISTARTSelectSITC :kAISTARTPolarityRisingEdge ];
[ self aiConvert:280 :3 :continuous ];
[ self aiClearFifo ];
return TRUE;
}
-( void )aiStartScan {
[ self aiArm:TRUE ];
[ self aiStart ];
}
-( void )aiEndScan {
if( [ self aiDataAvaliable ] ) [ self aiClearFifo ]; // Just in case the buffer contains extra values... never evaluates
[ self aiDisarm ];
}
AcquisitionController.m: // This is where the work gets done
-( void )aiSample {
[ _device aiSetup ]; // device = NI 622x
// Start sampling
_aiSampling = TRUE;
while( _aiSampling ) {
i = 0;
[ _device aiStartScan ];
while( i < numSamples ) { // channels * framesperbuffer = 64
if( [ _device aiDataAvaliable ] ) {
*( _aiInputBuffer + i ) = [ _device aiGetNextValue ] / normalizescale;
i++;
}
}
[ _device aiEndScan ];
... // buffer the scans
}
}
----
Rob Dotson
Asst. Research Scientist
Center for Neural Science
New York University