I'm successfully reading a single channel at a time and receiving data back. However, when I read 3 channels at once, all data is 0. None of the functions return an error code. Am I doing something wrong? None of the examples I saw show reading from multiple channels. Here is the full set of code.
CTR-04
InstaCal: 6.74
C# universal Library
Windows 10, latest updates
// Init the board
DaqBoard = new MccBoard(0);
for (int i = 0; i < 3; i++)
{
var error = DaqBoard.CConfigScan(i, CounterMode.PulseWidth, CounterDebounceTime.Debounce25500us,
CounterDebounceMode.TriggerAfterStable, CounterEdgeDetection.RisingEdge, CounterTickSize.Tick20pt83ns, i);
}
int rate = 1000;
int dataPoints = 3;
long[] array1 = new long[3];
long[] array2 = new long[3];
long[] array3 = new long[3];
long[,] multiArray = new long[3, 3];
Question
bsee
I'm successfully reading a single channel at a time and receiving data back. However, when I read 3 channels at once, all data is 0. None of the functions return an error code. Am I doing something wrong? None of the examples I saw show reading from multiple channels. Here is the full set of code.
// Init the board
DaqBoard = new MccBoard(0);
for (int i = 0; i < 3; i++)
{
var error = DaqBoard.CConfigScan(i, CounterMode.PulseWidth, CounterDebounceTime.Debounce25500us,
CounterDebounceMode.TriggerAfterStable, CounterEdgeDetection.RisingEdge, CounterTickSize.Tick20pt83ns, i);
}
int rate = 1000;
int dataPoints = 3;
long[] array1 = new long[3];
long[] array2 = new long[3];
long[] array3 = new long[3];
long[,] multiArray = new long[3, 3];
IntPtr memoryHandle = IntPtr.Zero;
memoryHandle = MccService.WinBufAlloc64Ex(1000);
// The following 3 individual CInScan calls return data successfully.
var scanError1 = DaqBoard.CInScan(0, 0, dataPoints, ref rate, memoryHandle, ScanOptions.Ctr64Bit);
var channelCopy1 = MccService.WinBufToArray64(memoryHandle, array1, 0, 3);
var scanError2 = DaqBoard.CInScan(1, 1, dataPoints, ref rate, memoryHandle, ScanOptions.Ctr64Bit);
var channelCopy2 = MccService.WinBufToArray64(memoryHandle, array2, 0, 3);
var scanError3 = DaqBoard.CInScan(2, 2, dataPoints, ref rate, memoryHandle, ScanOptions.Ctr64Bit);
var channelCopy3 = MccService.WinBufToArray64(memoryHandle, array3, 0, 3);
// The CInScan to read from multiple channels returns all 0s.
var scanErrorMulti = DaqBoard.CInScan(0, 2, dataPoints * 3, ref rate, memoryHandle, ScanOptions.Ctr64Bit);
var multiChannelCopy = MccService.WinBufToArray64(memoryHandle, multiArray, 0, 3, 3);
Link to comment
Share on other sites
8 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now