I have a PCI 6602 board that I have set up with the following code: GPCTR_Control (2, ND_COUNTER_0, ND_RESET); GPCTR_Set_Application (2, ND_COUNTER_0, ND_POSITION_MSR); GPCTR_Change_Parameter (2, ND_COUNTER_0, ND_INITIAL_COUNT, 0); GPCTR_Control (2, ND_COUNTER_0, ND_PROGRAM);
I use the following line to read the counter periodically. GPCTR_Watch (2, ND_COUNTER_0, ND_COUNT, &depth1_raw); The encoder I use is a BEI that has both 20 and 1200 PPF outputs. When I connect the 20 PPR outputs to the PCI-6602 it counts up and down perfectly. However, when I connect the 1200 PPR outputs it counts up perfectly, but then doubles the cont when it counts down. (Counts down twice as fast as it counts up).. I checked the signal phase with a scope and it looks as good as the 10PPR signal. Even when I turn the encoder very slowly, it does the same thing. The encoder signals are labeled as follows. Pin1 = A 20 PPR Pin2 = B 20 PPR Pin3 = Z 1200 PPR Pin4 = Z+90 1200 PPR Pin5 = PWR GND Pin6 = +5V Pin7 = Chassis Gnd.
There are two things you can try to troubleshoot this issue. First swap the two 1200 PPR lines. The counter should count in the opposite direction and depending on the encoding scheme you have chosen (X1, X2, etc.), may display the double count in the up direction. If you do see the same behavior in the opposite direction, then it is possible that one edge of the TTL pulse is not as clean as the other. The PCI-6602 has software configurable deglitching/debouncing filters to clean up TTL edges. Try setting these to 5 microseconds for each line using the Line_Change_Attribute() function. You can speed these up later, if necessary for your application. Also, be sure to specify the encoding scheme using the GPCTR_Change_Parameter() function. Take a look at the example TIOquadEncoderPosMeasure.C in the \NI-DAQ\Examples\VisualC\ folder or the equivalent VB example. Please let me know how this works.
Brent Runnels Applications Engineer National Instruments
That should be just fine, as the 6602 has 8 counters on it.
Take a look at this tutorial, and pay particular attention to the TIO section
which pertains to the 6602. That should get you pointed in the right direction.