Hi
I am using NI 6624 counter board and building an app in C#.
I have one counter (0) which counts edges of Index pulse (Z) from a Angle encoder and triggering on PFI4 on rising edge of Z pulse. Where I set a new lap while motor is spinning. Between each Z pulse there is 360 Degrees (time).
Another counter (3) is triggering on PFI0. Around 15 degrees after Z pulse.
The problem is that before next Z pulse the counter 3 is not reading its value on time which means it missed the lap.
Can someone please suggest how I can make the two counters synchronize?
I want counter 3 to always read before the next trigger of Counter 0.
Below are my counter 0 & 3 code in C#
_myTask = new Task();
// Counter 0 use the Z pulse to count laps
_myTask.CIChannels.CreateCountEdgesChannel("CNT/ctr0", "LapCnt", CICountEdgesActiveEdge.Rising,
(long)0, CICountEdgesCountDirection.Up);
_myTask.Stream.ReadWaitMode = ReadWaitMode.Yield;
_myTask.Timing.ConfigureSampleClock("/CNT/PFI4", 350.0, SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples, 5);
_myCounterReader = new CounterReader(_myTask.Stream) { SynchronizeCallbacks = true };
_myTask.Start();
_myCounterReader.BeginReadSingleSampleInt32(_asyncDaqmCb, _myTask);
Counter 3:
_myTaskBeta = new Task();
_myTaskBeta.CIChannels.CreateAngularEncoderChannel("CNT/ctr3", "AngleCnt3", CIEncoderDecodingType.X4, true, 0.0, CIEncoderZIndexPhase.AHighBHigh, 600, 0.0, CIAngularEncoderUnits.Degrees);
_myTaskBeta.Stream.ReadWaitMode = ReadWaitMode.Poll;
_myTaskBeta.Timing.ConfigureSampleClock("/CNT/PFI0", 350.0, SampleClockActiveEdge.Falling, SampleQuantityMode.ContinuousSamples, 5);
_counterInReaderBeta = new CounterReader(_myTaskBeta.Stream) { SynchronizeCallbacks = true };
_myTaskBeta.Start();
_counterInReaderBeta.BeginReadSingleSampleDouble(_asyncDaqmCbBeta, _myTaskBeta);