Home/Support/Support Forum/Quadrature Decoder not functioning
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Quadrature Decoder not functioning

0 votes
Good day.
I am trying to use the Quadrature Decoder on Rabbit 6000 with the RCM6700 kit. For some reason it does not work properly, the value returned (either by qd_read function or by reading the QDC1R register) is always 0.

I am using it the following way:

#define QD1_USEPORTD
#define QD2_USEPORTD //Using port D

int main(void) {
....
qd_init(1);
...
//some time after the encoder sends the pulses
ires = qd_read(1); //Always returns 0
// Tried ires = RdPortI(QDC1R); - same results

I also tried to manually set up timers the following way (before qd_init):
WrPortI(TAPR, &TAPRShadow, 0x01); //Preselector to divide by 2
WrPortI(0x00A2, &TAECRShadow, 0x00); //TAECR (for some reason the Dynamic C does not recognize TAECR as a defined value), for the Timer 10 to be clocked by TAPR
WrPortI(TACSR, &TACSRShadow, 0x01); //Enable Timer A

But it didn't work either.
What could be a cause? Am I missing some step?
And I would also like to know, are there any samples for QD usage? I failed to find any.
Thank you!
asked Jun 15, 2016 in Rabbit Software by alexander-ldi New to the Community (0 points)

Please log in or register to answer this question.

1 Answer

0 votes
You might be able to adapt one of the quadrature decoder samples from Dynamic C 9.62 (See Samples/Rabbit3000/QD_*.C).

Have you confirmed the signals going into the ports on the Rabbit by using a scope or logic probe?

The sample code is fairly simple:
Code:
void main() { long reading1, reading2; qd_init(1); qd_zero(1); qd_zero(2); while(1) { // this costate prints out the decoder values twice per second costate { reading1 = qd_read(1); reading2 = qd_read(2); printf("qd1: %10ld qd2: %10ld\n", reading1, reading2); waitfor(DelayMs(500)); } // this costate zeroes QD channel 1 every 5 seconds costate { waitfor(DelaySec(5)); qd_zero(1); } } }
answered Jun 23, 2016 by TomCollins Veteran of the Digi Community (1,459 points)
edited Jun 23, 2016 by TomCollins
...