Unusual problems with my drive software

I have reduced my UNO program to a minimum to find and demonstrate my problem:
If I un-comment this line then A motor will not run://servoTurret.attach(6);  // Turret servo pin 6
If I un-comment this line then B motor will not run://irrecv.enableIRIn();    // Start the IR receiver
If I remove the above lines then both motors run correctly.
All libraries are as downloaded from arduino.cc. The drive is: http://www.elechouse.com/elechouse/index.php?main_page=product_info&cPath=100_146&products_id=2179 I tried their library for the drive but that was also buggy (did not allow A forward if B is reverse, etc.).

Interrupt timer conflict in the libraries?
Do I have to put the motor drive software in a separate UNO like the arduino robot?

Here is my code:

#include <Servo.h> 
#include <IRremote.h>           // IR receiver library

Servo servoTurret;               // Turret servo object
IRrecv irrecv(12);

int IN_A1 = 3;     // input RPWM (forward A motor)
int IN_A2 = 10;    // input LPWM (reverse A motor)
int IN_B1 = 9;     // input RPWM (forward B motor)
int IN_B2 = 11;    // input LPWM (reverse B motor)
int motorAdjustment = 0;

void setup(void)
{

//servoTurret.attach(6);  // Turret servo pin 6  
//irrecv.enableIRIn();    // Start the IR receiver
  
    /** PWM pin configurate */
    pinMode(IN_A1, OUTPUT);    //(PWM forward A motor)
    pinMode(IN_A2, OUTPUT);    //(PWM reverse A motor)
    pinMode(IN_B1, OUTPUT);    //(PWM forward B motor)
    pinMode(IN_B2, OUTPUT);    //(PWM reverse B motor)
//motors stop
    digitalWrite(IN_A1, HIGH);
    digitalWrite(IN_A2, HIGH);
    digitalWrite(IN_B1, HIGH);
    digitalWrite(IN_B2, HIGH);

// increase frequency of PWM on pins 9 & 10 (TCCR1B) and pins 3 & 11 (TCCR2B)
int prescalerVal = 0x07; // create a variable called prescalerVal and set it equal to the binary number "00000111"
TCCR1B &= ~prescalerVal; //AND the value in TCCR0B with binary number "11111000"
TCCR2B &= ~prescalerVal; //AND the value in TCCR0B with binary number "11111000"

prescalerVal = 0x02; //set prescalerVal equal to binary number "00000010"
TCCR1B |= prescalerVal; //OR the value in TCCR0B with binary number "00000010"
TCCR2B |= prescalerVal; //OR the value in TCCR0B with binary number "00000010"
}

void loop(void)
{
  motorsWrite(20, 20);  
  delay(3000);              // wait for 3 seconds
  motorsStop();  
  delay(3000);              
}

void motorsStop() {              //Robot.motorsStop();           // fast stop
  analogWrite(IN_A1,255);
  analogWrite(IN_A2,255);

  analogWrite(IN_B1,255);
  analogWrite(IN_B2,255);
}

void motorsWrite(int speedL, int speedR){
    speedL = ~speedL;        // invert speed because
    speedR = ~speedR;        // lower PWM = higher speed.
	
      //motor adjustment to run straight using percentage
    	if(motorAdjustment<0){
		speedR*=(1+motorAdjustment);
	}else{
		speedL*=(1-motorAdjustment);
	}
  
  	if(speedL>0){                        // positive = forward
		analogWrite(IN_A1,speedL);
		analogWrite(IN_A2,0);
	}else{                              // negative = reverse
		analogWrite(IN_A1,0);
		analogWrite(IN_A2,-speedL);
	}
	
	if(speedR>0){                        
		analogWrite(IN_B1,speedR);
		analogWrite(IN_B2,0);
	}else{
		analogWrite(IN_B1,0);
		analogWrite(IN_B2,-speedR);
	}
}

The IR library needs a timer to measure the incoming pulses. The UNO only has three timers. When the IR library takes over one of them, PWM on two pins goes away.

The Servo library needs a timer to generate the necessary pulses. When the Servo library grabs a timer, PWM on two more pins goes away.

You can look at the libraries to determine which timers they grab. From there, you could look at which timers are used for which PWM pins. Or, you could just experiment to determine which pins are still available for PWM - there should still be two. Whether they are two pins that your shield can use (assuming that it is a shield), or not, remains to be seen. If it's not a shield, then your good to go, when you connect to the two remaining (functioning) PWM pins.

From the documentation for the Servo library:

The Servo library supports up to 12 motors on most Arduino boards and 48 on the Arduino Mega. On boards other than the Mega, use of the library disables analogWrite() (PWM) functionality on pins 9 and 10, whether or not there is a Servo on those pins. On the Mega, up to 12 servos can be used without interfering with PWM functionality; use of 12 to 23 motors will disable PWM on pins 11 and 12.

Thanks Paul - that is what I had suspected. Problem is this drive board needs four PWM outputs (two motors * two directions) so I guess I am out of luck. Three timers is very restrictive. Many robots need a servo, IR and a drive. Is that why the new arduino robot has a separate motor UNO and all the extra hassle of communicating between the two UNOs?

I haven't used it, but I seem to remember reading that there was an alternate Servo library which didn't take up the same hardware timer.

I don't remember now whether it used a different timer or whether it did the whole thing in software, but if you're struggling with timer conflict there seem to be some alternatives available.

Problem is this drive board needs four PWM outputs (two motors * two directions) so I guess I am out of luck.

The directions do not need PWM pins. The motor is either spinning clockwise or counterclockwise. What sense would there be in a direction value of 148?