Hello, we've been so confused with this issue we've been having and nobody knows what's going on.
We are (required) to use the high performance Arduino encoder library from here to read a pair of 2 phase encoders on some DC motors for speed estimation.
We also are using the I2C library in order to communicate with some sensors we have / other arduinos.
We've tried this with a Mega 2560.
In our main loop, we are just reading the encoder values using the library methods and it all works great and we are able to estimate the speed.
Separately, we can use I2C to successfully talk to other Arduinos or to our sensors.
The problem occurs when we try to do both at the same time. It is the same code from the 2 separately working cases, just put together in the same main loop doing simple things. When we have I2C hooked up, the encoder values do not change and we get a speed of 0. As soon as we disconnect either or both of the SCL/SDA pins we suddenly get working encoders/speeds again (via Serial). As soon as we reconnect, the encoders die again. We also seem to get garbage from I2C when running with the encoders.
We are not putting our encoder pins on the Mega SDA/SCL pins. We have tried full interrupt, half interrupt, and no interrupts on the encoder pins (2/2 are on interrupt pins, 1/2 are on interrupt pins, 0 are on interrupt pins) since the library supports this functionality. This results in no change.
We believe there is some sort of blocking going on between the two systems, but that doesn't really make sense since the encoder ISR's shouldn't be taking that much time nor the I2C ISR's.
Has anyone had experience with this issue before?