Rotational Encoder Interrupt Error

Hello,

I am trying to make a cart that will move back and forth in a sinusoidal motion controlled by an arduino uno. I'm basing my code off of this project DC motor control with PID - Exhibition - Arduino Forum. The motor has a closed loop feedback system with a PID controller. The sensor is an analog rotational encoder that is attached to the motors shaft (see link for motor and scroll down to encoder section for more details). I'm having trouble using the interrupt pin. When I begin running the program it without applying power to the motor controller the program outputs the correct desired speed. As soon as I turn on the motor controllers power the program stops running, and never resumes. I assume this is because the encoder triggers the interrupt which is good, but the issue is that the processor never resumes normal function. For more information on the motor, controller, and my code look below. The white and yellow wires are attached to pins 2, and 3 respectively.

Motor: Pololu - 30:1 Metal Gearmotor 37Dx52L mm 12V with 64 CPR Encoder (No End Cap)
Motor Controller: Pololu Dual VNH5019 Motor Driver Shield for Arduino (ash02a)

#include "DualVNH5019MotorShield.h"
 
DualVNH5019MotorShield md;

#define encodPinA1      3                       // encoder A pin
#define encodPinB1      2                       // encoder B pin
int speed_req;
int speed_act;
int error;
volatile long count = 0;                        // rev counter
 
void setup(){
  pinMode(encodPinA1, INPUT); 
  pinMode(encodPinB1, INPUT); 
  attachInterrupt(1, rencoder, FALLING);
  Serial.begin(115200);
  Serial.println("Dual VNH5019 Motor Shield");
  md.init();
}

void loop() {
  static int PID = 0;
  getParam();                                                                 // check keyboard
  getMotorData();                                                           // calculate speed, volts and Amps
  PID= updatePid(speed_req, speed_act);                        // compute PWM value
  Serial.print(" start loop ");
  md.setM1Speed(speed_req);                                               // send PWM to motor
  printMotorInfo();                                                           // display data
}
 
int getParam(){                                        //defines the speed the cart should be travelling
  float pi = 3.14;
  double time;
  float w;                                             //omega value (frequency in rad/s)
  float phi;                                           //phase shift of sine curve
  w = .2;
  phi = 0*(pi/180);
  time = millis();                                           //outputs time since program began in seconds
  float a = 1;                                               //amplitude (units unknown)
  speed_req = 400*(a*cos(w*(time/1000) + phi)/(a));    // because it is a speed value it has to be derivative of pos
  return speed_req;
}

void rencoder()  {                                    // pulse and direction, direct port reading to save cycles
  Serial.print("INTERRUPT");
  if (PINB & 0b00000001)    count++;                  // if(digitalRead(encodPinB1)==HIGH)   count ++;
  else                      count--;                  // if (digitalRead(encodPinB1)==LOW)   count --;
  //Serial.print("interrupt"); 
  //Serial.println(count);
}

int updatePid(int targetValue, int currentValue)   {             // compute PWM value
  float pidTerm = 0;                                             // PID correction
  float kp = .4;                                // PID proportional control Gain
  float kd =  1;                                // PID Derivitave control gain
  float ki =  1;                                // PID integral control gain
  static int last_error=0;                             
  //error = abs(targetValue) - abs(currentValue); 
  error = abs(speed_req) - abs(speed_act);
  pidTerm = (kp * error) + (kd * (error - last_error)) + (ki * (error + last_error));                  
  last_error = error;
  return constrain(int(pidTerm), -400, 400);
}

void getMotorData()  {                // calculate speed, volts and Amps
  static long countAnt = 0;                                                     // last count
  float LOOPTIME = 0;
  static float last_loop;
  LOOPTIME = millis() - last_loop;
  speed_act = ((count - countAnt)*(60*(1000/LOOPTIME)))/(48*34);              // 16 pulses X 34 gear ratio = 1633 counts per output shaft rev
  countAnt = count;          
  last_loop = millis();
}

void printMotorInfo(){                                                          // display data                   
  Serial.print("  Time:   ");        Serial.print(millis());
  //Serial.print("  Volage:  ");       Serial.print(analogRead(piezo));  
  Serial.print("  Speed required:");             Serial.print(speed_req);  
  Serial.print("  RPM:");          Serial.println(speed_act);    
}

I forgot to add pictures.

void rencoder()  {                                    // pulse and direction, direct port reading to save cycles
  Serial.print("INTERRUPT");
  if (PINB & 0b00000001)    count++;                  // if(digitalRead(encodPinB1)==HIGH)   count ++;
  else                      count--;                  // if (digitalRead(encodPinB1)==LOW)   count --;
  //Serial.print("interrupt"); 
  //Serial.println(count);
}

Doing a Serial.print() inside a interrupt handler is a bad idea. If the handler is called fast enough, the serial buffer fills up and you end in a dead lock.