High-Speed Digitizers

cancel
Showing results for 
Search instead for 
Did you mean: 

only fetching one channel

Hello,
 
I am working in Visual C++; I have attached a simplified version of my code.  I'm using an NI5105 and trying to acquire 8 channels at 6MSa/s.  I am only capturing one channel, though.  If I use "0,1,2,3,4,5,6,7" I capture channel 0 (apparently); if I use "1,2,3,4,5,6,7" I seem to get channel 1. 
 
I'm using a niScope_FetchBinary16 command in a modified FetchForever example code (please see the attached code).  My hardware can handle 160MB/s writes and I need the binary fetch to keep under that.
 
The obvious problem would be that I was not actually saving the data correctly, but I haven't found any problems with my save routine.  I'm hoping someone can spot a problem I can't.
 
The real code is a multi-threaded application (which I seem to need to do to handle the data rates), which is why I'm simplifying the code.  If I need to post the full code I will, I'm hoping there's a moderately obscure problem in the attached code though. 
 
Thanks,
Greg
 

channelName =

"0,1,2,3,4,5,6,7";

verticalRange = 2;

verticalOffset = 0.0;

verticalCoupling = NISCOPE_VAL_DC;

probeAttenuation = 1.0;

minRecordLength = 1;

refPosition = 0.0;

numRecords = 1;

enforceRealtime = NISCOPE_VAL_TRUE;

minSampleRate = 6e6;

maxNumSamplesPerFetch = 800000;

// Open the NI-SCOPE instrument handle

handleErr(niScope_init(resourceName,NISCOPE_VAL_FALSE,NISCOPE_VAL_FALSE,&vi));

// Configure some common properties

handleErr (niScope_ConfigureVertical (vi, channelName, verticalRange, verticalOffset, verticalCoupling, probeAttenuation, NISCOPE_VAL_TRUE));

handleErr(niScope_ConfigureChanCharacteristics(vi,channelName,NISCOPE_VAL_50_OHMS,NISCOPE_VAL_BANDWIDTH_FULL));

handleErr (niScope_ConfigureHorizontalTiming (vi, minSampleRate, minRecordLength,refPosition, numRecords, enforceRealtime));

 

// Configure software trigger, but never send the trigger.

// This starts an infinite acquisition, until you call niScope_Abort

// or niScope_close

handleErr (niScope_ConfigureTriggerSoftware (vi, 0.0, 0.0));

// Start acquiring data

handleErr (niScope_InitiateAcquisition (vi));

// specify the number of waveforms

handleErr (niScope_ActualNumWfms (vi, channelName, &numWfms));

while(1)

{

   handleErr(niScope_FetchBinary16 (vi, channelName, 0.0, maxNumSamplesPerFetch, (ViInt16*)waveformPtr1, wfmInfo1));

   // please see alternative save attempt below

   fwrite(waveformPtr1,

sizeof(ViInt16),wfmInfo1[0].actualSamples*numWfms,ofFile);

   ProcessEvent();

}

// alternative save attempt

ViInt16* ptrData = ArgList.waveformPtr1;

for(int ii=0;ii<iChannels;++ii)

{

   fwrite(&ArgList.wfmInfo1[ii].actualSamples,

sizeof(ViInt32),1,ofFile);

   fwrite(ptrData,

sizeof(ViInt16),ArgList.wfmInfo1[ii].actualSamples,ofFile);

   ptrData += ArgList.wfmInfo1[ii].actualSamples;

   cout << ArgList.wfmInfo1[ii].actualSamples <<

" "; // this always shows the same number of samples for each Fetch command

}

cout << endl;

 
 
0 Kudos
Message 1 of 4
(6,579 Views)
So it turns out that in the long run, I am capturing data for all channels, but they are not syncronized.  Each file is a seconds worth of data, and what was happening is in the first file channel 2 wasn't recording data yet, but in subsequent files it showed up.  However, I still have a big problem because I'm running a frequency modulated signal into the two channels and the data is not lining up. 

I'll search the forums for help on this, but any hints would be appreciated.

Cheers,
Greg
0 Kudos
Message 2 of 4
(6,550 Views)
The root question continues here...
0 Kudos
Message 3 of 4
(6,509 Views)
Hi Greg,
 
It is best to continue the issue in a single thread and Jeff has already performed some analysis on the issue so it can continue as linked above:
 
Can/Does the ni5105 perform simultaneous sampling on its channels?
http://forums.ni.com/ni/board/message?board.id=150&thread.id=2072
Steve B

0 Kudos
Message 4 of 4
(6,497 Views)