Hi all,
I have been trying to use the Interrupt technique to count the rising and falling edge signal from the optical encoder. I did a test using a function generator (TTL square wave).
I have found that the maximum frequency of the square wave signal was 55 Hz.
I wonder if there is possibility to improve the maximum interrupt frequency up to 500 KHz. I copied a simple code for my test below
#define qIntEncoderPinA 2
volatile int _qEncoderTicks = 0;
void setup() {
Serial.begin(9600);
attachInterrupt(qIntEncoderPinA, qInterruptHandler, CHANGE);
}
void loop() {
Serial.println(_qEncoderTicks);
_qEncoderTicks = 0;
delay(1000);
}
void qInterruptHandler(){
_qEncoderTicks ++;
}
Please kindly advice me if anyone knows the solution and that would be very much appreciated.
Thank you.
Regards
Indrazno