I am trying to get data from four rotary encoders with 90,500 ppr each which comes with a high torque planetary gear DC motor
link for planetary motors from where I purchased them:
they have given vague specs of 2,000 ppr in text while 3,62,000 cpr (counts per revolution,which is 4 times ppr) is mentioned separately.
Also, they have mentioned pinouts of only four wires coming out of encoders (black,brown,red and orange) but there are total six wires coming from encoders (yellow and green coloured wires are extra).
I am not able to find use of those wires or a 6 wire output encoder anywhere.
We calculated our ppr by testing motor at 10% of its max speed (around 10 rpm) and concluded it was a 90,500 ppr encoder
I am using interrupts for all four of them to read data and simultaneously using loop function to get data from an IMU via I2C communication.
Problem comes whenever I rotate my encoders at rated speed.
Due to its very high ppr, loop function is not being able to execute as my code is going in one of four the ISR vectors continuously.
Also, output pulses of encoders are missed whenever an ISR vector is fired and hence all of my encoders are giving random data.
How can I get their data as well as run my loop function for my IMU data??
Is there a way to change frequency by which an arduino mega reads data from digital pins and send them??
In my code, I have used pin change interrupt pins using PcInt::attachInterrupt() function as my simple external interrupt pins are occupied for communication (four interrupt pins of mega are also SCL,SDA,Tx,Rx pins which leaves only 2 pins left for interrupt)
encoder_interrupt.ino (2.78 KB)
