When both wheels are running, I hoped that both left and right rpm values would be calculated so I can compare them and adjust the wheel speeds so the car goes straight. However, when both motors are rotating only the first interrupt is invoked. The second only fires when I hold the right wheel still.
This is my first project and use of interrupts. I thought they would work like events in c# but instead it's like only the first interrupt will run unless the motor stalls and then the second one is called. But as soon as the first one is let free again, the second stops calling.
No two motors are identical and what you mention above is usually the case. At a given speed, it is possible to empirically reduce one of the PWM values so that the motors run the same speed, but that won't work well if the motor loads change.
It is much easier just to count pulses when the vehicle is moving in one direction. If the right and left counts for a given period of time differ, adjust one of the PWM values to correct. Something like this:
The Arduino Encoder library can read those encoders, but you need four interrupt-capable inputs to handle the two sets of A and B outputs. Which Arduino do you have?
Theoretically and at low speeds, yes. But performance suffers if interrupts are not used on both channels, and I suspect it would skip counts at high speeds, considering that the encoder is on the motor shaft.
160rpm *(1920pulse/rev)/(60sec/min)= 5120pulse per sec
The library triggers on change, versus the OP's single edge, so it would indeed be twice the computational load. It would count twice/sec and there's two motors, so full speed would leave about 48us/interrupt, versus the OP's 96us/interrupt. Using a Mega with 4 interrupts for the encoder library would count at twice the rate again, leaving only 24us/interrupt. It still seems feasible, but overkill. I might have to check the limits.
A pair of wheel mounted 16 slot encoders triggering on RISING would need much less computation: 160RPM*16PPR/60SPM=42PPS for each wheel, or 11718us/interrupt.