I had working code to do quadrature decoding based on the timer setup shown in thread posted 9 months ago by drinkdhmo "hardware quadrature decoding issues". The development was moved to a different computer. IDE version 009 was downloaded and installed on this machine. With this version of the IDE, the encoder output from the Timer only moves a few counts in each direction and behaves weird. The code works fine on IDE version 006. Is anyone else experiencing this type of problem or have a solution?
IDE 009 quadrature decoding issues
(4 posts) (3 voices)-
Posted 4 years ago #
-
This is very interesting. Can you provide the code? Also, have you tried 0.0.10 Beta? (see the blog for a link)
Posted 4 years ago # -
Sorry about the delay in getting back to you.
Below is the code I am using to setup the timer the quadrature encoder:
pinMode(5, INPUT);
pinMode(9, INPUT);
Timer* encoderTimer;
encoderTimer = (Timer*)TIMER4_BASE;
encoderTimer->CCMR1 = 0xF1F1; //CC1S=01
encoderTimer->CCMR2 = 0x0000;
encoderTimer->CCER = 0x0011;
encoderTimer->SMCR = 0x0003; //SMS=011
encoderTimer->CR1 = 0x0001; //CEN=1
encoderTimer->CR2 = 0x0000;
encoderTimer->PSC = 0x0000;Timer4.setCompare1(CPR - 1);
Timer4.setCompare2(MAX_CNT - CPR + 1);
Timer4.attachCompare1Interrupt(pendOverflow);
Timer4.attachCompare2Interrupt(pendUnderflow);
encoderTimer->CNT = 0x0000; //reset the counter before we use itI tried using the 0.0.10 Beta and the results were the same as version 009. Version 006 still produces the correct output with this timer setup.
Posted 4 years ago # -
rjgrahek,
Thanks for the update. I've added a bug targeting 0.0.12:
Posted 4 years ago #
Reply
You must log in to post.