Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

sync 2 counters with a USB-6229 (M-series) (tried the example)

I'm reading in two angular encoders simultaneously with the 2 counter inputs on a USB-6229, and I'm having trouble syncing them up.  I've modified the example code from this very helpful post which suggests using the Arm Start Trigger, but I don't quite get the results I expect.

 

In my case, the two encoders are on the same axle, so their motion is locked together.  As such, whatever differences I see between their outputs when the axle is moving should stay the same once the motion stops, as neither output should be changing anymore. This is not what I see.  If I subtract their outputs and graph them (see sample code), I see their offset go up to 5-6 pulses, depending on how fast I move the axle.  But once I stop, the difference between the two outputs always drops back to zero.

 

Here is an example of the output I see:

screenshot.2.png

 

This is typical of what I see: there is some offset between my encoders, but it drops back to zero once I stop the axle.

 

As a result, I suspect that I'm still having syncing issues.  Any ideas?  I've attached my code.

 

 

 

0 Kudos
Message 1 of 4
(4,908 Views)

Just so I am clear on your question, the problem is not that you see zero when the axle stops, but that you are not seeing zero when the axle is moving? This is what is causing you to assume that the counts are not being taken in simultaneously?

Thanks

Nick

National Instruments
Applications Engineer
0 Kudos
Message 2 of 4
(4,888 Views)

Yes, that is the issue.  I expect that whatever value I'm seeing immediately after I stop the axle should continue (as nothing is moving now).  Instead, it continues to change, and always ends up at zero (or +/- 1, since the encoders aren't perfectly aligned).

 

Josh

0 Kudos
Message 3 of 4
(4,869 Views)

Hey Josh,

Ok we need to rule out either the counters or the encoders. To do this I need you to run two tests.

Test 1. Remove the encoders from the counter inputs and run the same Digital pulse to both of the counters. You could use a DIO line on the 6229 or another device if you have it available. From there we can determine if the counters are in fact being synced or if the encoders are the problem.

Test 2. Connect one encoder to both of the counter inputs and see if you see the exact same count on both the counters. This will rule out the encoders being the problem if you see the same signal.

Thanks again

Nick

National Instruments
Applications Engineer
0 Kudos
Message 4 of 4
(4,849 Views)