11-14-2006 11:22 AM
{
//available number of samples for ctr3 and ctr4 connected to Dev2 is always 0
_availableSamples = (
int)_measurementTasks[i].Stream.AvailableSamplesPerChannel;_availableSamples =
Math.Min(_numOfSamples, _availableSamples); //numOfSample is 14500_dataReader[i].BeginReadMultiSampleInt32(_availableSamples,_myCallBack,
null); if (i != _measurementTasks.GetLength(0) - 1)_bTaskRunning =
false; else_bTaskRunning =
true; Thread.Sleep(1);}
But in the EndRead API it reads the data for Ctr3 and Ctr 4 of device 2
private void CounterReadCallback(IAsyncResult ar){
try{
lock
(_measurementTasks.SyncRoot){
if (_bTaskRunning){
string strErrMsg = string.Empty; for (int k = 0; k < _measurementTasks.GetLength(0); k++){
int[] data;// = new int[_availableSamples]; lock (_dataReader[k]){//Here while calling this API I get the data for Ctr3 and Ctr4 connected to Device 2
data = _dataReader[k].EndReadMultiSampleInt32(ar);
}
}
}
if (!_bStop){
_acqStartWriteThreadEvent.Set();
}
}
Because of this I'm concerned about the data I get from the Ctr4 and Ctr 5 .
Please respond quickly. I have only one day to get this working.
Thank you
Murugan
11-14-2006 12:58 PM
Hi Kenn
I have also checked all my connections.
1) 5 counters are array of 5 tasks.
2) Dev1/Ctr0 is the source . Dev1/Ctr6 is the gate.
3) Period measurement is created for Dev1/Ctr0,Dev1/Ctr1,Dev1/Ctr2 and Dev2/Ctr3,Dev2/Ctr4
4) For all the counters the same source is used (signal generator ) so the counterTimebaseSource for all the task is
CounterTimebaseSource = "/Dev1/PFI39"; (Dev1/Ctr0 source)
PeriodTerminal = "/Dev1/PFI12"; (gate output of Dev1/Ctr6 )
5) ArmsStartTrigger for the first 3 counters
ConfigureDigitalEdgeTrigger("/Dev1/PFI0", DigitalEdgeArmStartTriggerEdge.Rising)
and for the last 2 counters
ConfigureDigitalEdgeTrigger("/Dev2/PFI0", DigitalEdgeArmStartTriggerEdge.Rising)
I have also tried using the same Device
6) Digital trigger is set using
_firstTask.DOChannels.CreateChannel(
"/Dev1/port0/line0", "DigitalTrigger",ChannelLineGrouping.OneChannelForAllLines);_firstTask.Control(
TaskAction.Verify); int numLines = (int)_firstTask.DOChannels["DigitalTrigger"].NumberOfLines; bool[] dataArray = new bool[numLines]; DigitalSingleChannelWriter writer = new DigitalSingleChannelWriter(_firstTask.Stream);dataArray[0] =
true;writer.WriteSingleSampleMultiLine(
true, dataArray);dataArray[0] =
false;writer.WriteSingleSampleMultiLine(
true, dataArray);But the available samples per channel for the counter in the device 2 is always zero.
I'm missing something?
Thanks
Murugan
11-14-2006 02:15 PM