Just try this simple test sketch, see if you get stable counts.
unsigned long start;
const byte
encoderPinA = 3,
encoderPinB = 4;
const uint16_t end = 300;
int speed;
volatile long pulse;
long PulseCopy
void setup()
{
Serial.begin(9600);
attachInterrupt(digitalPinToInterrupt(encoderPinA), readEncoder, RISING);
pinMode(encoderPinA,INPUT);
pinMode(encoderPinB,INPUT);
}
void loop()
{
if(millis() - start > end)
{
noInterrupts();
pulseCopy = pulse;
interrupts();
Serial.println(pulseCopy);
start += end;
}
}
void readEncoder()
{
digitalRead(4) ? --pulse : ++pulse;
}