Unfortunately, the same program did not work on my first 100 attempts.
//Define Variables we'll be connecting to//int32_t encPosition;double encPosition, encPositionOld;
I took another look at your code, and in addition to all the unnecessary code, you are definitely misusing the encoder library.For example, you should NOT be using the "double" type for encPosition.Code: [Select]//Define Variables we'll be connecting to//int32_t encPosition;double encPosition, encPositionOld;
ID myPID( &encPosition, &pidOutput, &target, Kp, Ki, Kd, DIRECT);
I find the encoder counting to be working exceptionally good.
Should be simpler to just count pulses than decode quadrature.
I used the 7474 ic, and it worked right away. I set the maximum pulse-out @ 255, and I've got the full speed of this 12v motor accurately positioning, using that device. Thank you - that worked great! Took out all that overhead processing, just 2 lines of code in the interrupts and it works like a charm.
Simple hardware that decodes quadrature into up pulses on one pin, down pulses on the other pin. Just a 74HC74 dual D flip-flop.https://sites.google.com/site/radiohamtechnology/49er-digital-vfo...