Brushed DC Motor Tutorial (อ้างอิง www.arduino-board.com/arduino/brushed-motor? )


Brushed DC Motor Tutorial




Motor Control
If the driver board looks familiar - it should. It is the one from the stepper motor tutorial. It can drive two brushed DC motors at the same time. Each brushed motor requires two PWM outputs, so the Uno can drive a maximum of two brushed motors at once, if speed control is required.

The schematic with two brushed motors. We only used one in the tutorial. If you should decide to use both, make sure the power supply can provide the required current.
#define MTR_POS 10
#define MTR_NEG 11

void setup() {

  // Motor stopped.
  analogWrite(MTR_POS, 0);
  analogWrite(MTR_NEG, 0);
}

void loop() {
  int x;
  // Ramp the motor to full speed CW.
  for (x = 0; x < 255; ++x)
  {
    analogWrite(MTR_POS, x);
    delay(10);
  }
  // Ramp the motor to stop.
  for (x = 255; x > 0; --x)
  {
    analogWrite(MTR_POS, x);
    delay(10);
  }
  delay(500);
  // Ramp the motor to full speed CCW.
  for (x = 0; x < 255; ++x)
  {
    analogWrite(MTR_NEG, x);
    delay(10);
  }
  // Ramp the motor to stop.
  for (x = 255; x > 0; --x)
  {
    analogWrite(MTR_NEG, x);
    delay(10);
  }
  delay(500);
}
    

What It Does

The motor starts out with 0, corresponding to 0 Volts, on both terminals. Every 10mS the program increases the voltage by increasing the pulse width on the positive terminal. When the positive terminal has 255, or 12V on it, the program then starts slowly decreasing the voltage back to zero. The effect of this is the motor speed, which starts at zero, is ramped up to full speed in 2.55 seconds, then back to stopped in another 2.55 seconds.
Then, after a half-second delay, the negative terminal is driven from zero up to 12V in 2.55 seconds. This ramps the motor speed up to full again, but this time in the opposite direction (counterclockwise). The program then ramps the speed down to a full stop, waits half of a second and repeats the whole process.

ความคิดเห็น

โพสต์ยอดนิยมจากบล็อกนี้

Pic1

Arduino Real Time Clock Tutorial using DS1307

Pic4