Cordless Drill Motor as Gear Motor

The idea is to take apart a relatively cheap cordless drill and use the motor as a mains powered gear motor with arduino speed control.

Step 1. Dismantle a drill.

I happened to have this drill in the junk box because the battery was no longer holding it’s charge. The motor was working perfectly fine. I considered keeping the speed control circuit and direction switch but dismantling them to see how they worked left me with a pile of bits and a few lose springs.

The useful bits to keep are the motor (with attached gearbox and chuck) and the MOSFET (with attached heatsink).

It would help at this stage if you label the Gate Source and Drain legs of the MOSFET.

Step 2. Prove the motor working.

First thought was to plug it into a low voltage (5V) high current (2A) switch mode mains adapter. All this did was cause the adapter to cut out. It turns put that the motor is an inductive load so Ohm’s law doesn’t help much. Googling seems to suggest this type of motor quite easily draws 20A – far too much for any adapter I have lying around.

So, prove the motor working by connecting it to the battery. It doesn’t matter which way around. Careful it doesn’t jump off the desk as it’ll spin at it’s top speed.

Step 3. Connect up the MOSFET.
The following diagram found on Instructables was a great help here:

Marc Cryan’s motor control diagram – great help!

I include my own circuit diagram which may or may not be clearer:

Battery driven motor circuit, on off switch control

At this stage I’ve left out the arduino as it’s worth checking the MOSFET is wired in the correct way before proceeding (I got it wrong first time). Instead the diagram includes a switch – two wires that can be touched together works well.

Closing the switch should cause the motor to spin at it’s top speed. I didn’t run it like this for long as I really don’t know what good it does to the MOSFET.

Step 4. Program the arduino.
Now is a good time to make sure the arduino can be programmed and works correctly. I include here a basic sketch which allows the PWM duty cycle on pin 3 to be set by sending a single ASCII character over serial.

int motor = 3;           // the pin that the motor is attached to, this
                         // can't be changed without changing pwm code below
int inrush_speed = 255;  // start on max to overcome inrush current
int inrush_delay = 100;  // time in miliseconds required to overcome inrush
int default_speed = 30;  // returns to this speed after inrush
int incomingByte;        // for incoming serial data

void setup() { 
  // declare motor pin to be an output:
  pinMode(motor, OUTPUT);

  // Set up high frequency PWM
  TCCR2A = _BV(COM2A1) | _BV(COM2B1) | _BV(WGM21) | _BV(WGM20);
  TCCR2B = _BV(CS00);

  // Set up serial port
  Serial.begin(9600);     // opens serial port, sets data rate to 9600 bps
  Serial.println("READY");

  // Start the motor spinning with a high speed
  analogWrite(motor, inrush_speed);
  // For a short amount of time
  delay(inrush_delay);
  // Now initialise motor at a sensibly slow speed
  OCR2B = default_speed;
}

void loop() { 
  // do something only when you receive data:
  if (Serial.available() > 0) {
    // read the incoming character as a value:
    incomingByte = Serial.read();
    // write it back out:
    Serial.println(incomingByte, DEC);
    // set the motor speed to the ascii value
    OCR2B = incomingByte;
  }                   
}

Note that I’m not using analogWrite here since i found the 490Hz pwm signal resulted in the motor whining at low duty cycle. Instead I’m using the timers directly with no prescaler to get a much higher frequency pwm signal.

Once the sketch is loaded, attach an led and suitable resistor to pin 3, bring up the serial console and send a few characters. If all’s gone well you should see the led brightness change as different characters are sent. The arduino should send back the code for each character as you send it. An ASCII lookup table will help you predict the brightness of each character.

Step 5. Connect arduino to motor circuit.

Thus is an easy step, just connect the gnd pin from the arduino to the negative terminal on the battery, remove the led and associated resistor, then connect pin3 in place of the switch. I include an updated circuit diagram:

Battery powered, arduino controlled motor circuit

It’s worth mentioning at this point that the most the arduino can push out on pin 3 is 5V. This means that the drill can’t be driven at full speed in this scheme. If you wish to be able to run the drill at full speed I believe you can use a resistor to pull the gate high (to the battery high voltage) then connect the arduino to a transistor that when closed pulls it low. I haven’t tried this though.

The current behaviour is fine for my purposes and probably a requirement if you’re running from an underpowered adapter as I am. Speaking of which:

Step 6. Connect mains adapter.
I used the adapter that was previously powering the battery charger, rated to a slightly higher voltage than the battery was rated. Now that the arduino is ramping down the voltage it ‘just works’, with one caveat: the motor would only start with a fairly high (20%) duty cycle. This was not ideal, so to overcome it I included in the sketch above some code to make the initialisation speed very fast but only for a few milliseconds. In practice this is not noticeable. I haven’t checked the current usage on startup but I assume there’s a moderate spike – it’s not caused me any problems though.

Step 7. Profit!

The completed arduino motor speed control circuit
Advertisements