There are many types of motors including:

  • DC Motors are usually the main motors that drive a robots wheels or tracks; DC motors can be powerful and are commonly used in things like motorized wheelchairs. FRC robots, we commonly use CIM motors and mini-CIM motors; vendors such as AndyMark supply many types of DC motors that may include integrated gear boxes that convert motor speed to torque.
  • This page provides an excellent look into FRC motors and their characteristics.
  • This chart provides details including max rpm, max power, torque,current consumption, etc. for a large number of FRC-legal motors.
  • Servo Motors and Stepper Motors are used to effect fine control such as for manipulating objects; they are usually much less powerful than large DC motors but can be controlled precisely.
  • Special purpose motors such as Denso window motors are often used in high torque, low speed applications. These motors have anti-theft locking pins to prevent them from being backdriven; this can be useful in applications where backdriving might be a problem, but often causes problems, particularly when driven by a Talon or Jaguar. You can remove the locking pins in 15 minutes by following these directions.

Motor Control Motors generally use electromagnets to generate physical motion such as rotating a shaft. Electromagnets typically require much more current than a micro-controller can source directly. To control motors, micro-controllers typically use a transistor as a valve; turning the transistor on or off requires a very small amount of current, but when turned on, the transistor can allow large amounts of current to flow through it to the motor.

DC motor controllers often use 4 transistors in an H-Bridge circuit; this allows the motor direction to be reversed by swapping the direction of current flow through the motor. DC motor speed is often controlled using pulse-width modulation (PWM). In many cases, there are dedicated integrated circuits to provide this functionality such as Arduino Motor Shields; and code libraries to support them. FRC robots use advanced motor controllers such as the Talon SRX which contain an H-bridge and a sophisticated Cortex ARM microcontroller that offers a wide range of capablities including CAN networking and precise control of even large DC motors via PID closed-loop control (see more on this below).

Working with motors involves many considerations including protecting the motors from overheating if they are working too hard (e.g. stalled), braking control, and using the motors efficiently. For more details about DC motor control see (see here)

Real world motors must deal with inertia. Use of closed-loop control allows motors to drive actuators to specific speeds or positions.

Motor Speed vs. Load Controlling a motor precisely is difficult because when you apply power to a motor, how fast/far it moves depends on the motor's load (how much work the motor is doing). With the same power applied, a drive motor will go slower up hill or carrying a heavy load and go faster down hill or with a light load. To achieve a constant drive speed, we need to monitor how fast the motor is actually moving and adjust power continuously.

Measuring Speed We monitor motor speed by attaching encoders to the motor shaft; encoders use optical, mechanical, or magnetic switches to generate pulses as the motor rotates; the faster the motor spins, the faster the pulses arrive. We can even count pulses to determine exactly how far the motor has moved.

Closed Loop Control Talons use encoders to achieve "closed-loop" control: your program sets the Talon to achieve a particular speed (rate) or position (displacement) and the Talon automatically and continuously adjusts power to the motor, measures the speed or position with an encoder, and adjusts power again to keep the motor at the desired speed or position.

In the real world, closed-loop control is tricky: the Talon must account for changing loads on the motor and the inertia of its mechanisms (arm, entire robot, etc.). If motor power is adjusted too quickly, the motor can overshoot its goal; if power is adjusted too slowly, the mechanism may not respond to changes in a timely fashion. The control loop can even become unstable and oscillate around its target.

PID Control Closed-loop motor control (including the software built into the Talons) typically uses PID control loops to achieve the mechanism's control objectives: balancing responsiveness with stability. PID control considers 3 factors (P, I, D) when deciding how to adjust motor power to balance responsiveness (how fast the motor responds to changes) with stability (not over/under shooting the target). Because motors drive different mechanisms with different loads, inertia, speeds, and responsiveness requirements, you must tune the PID factors properly for each Talon when you configure it for close-loop control; this page discusses in plain language what that means.

The problems PID is intended to solve You might want to move a mechanism to a particular position and then stop and hold it at that position. To move the mechanism, you apply power to the motor, ramping it up until the motor overcomes the mechanism's inertia and starts moving; the trick then is to get the mechanism to stop in the desired position and then continuously adjust power to the motor to hold it there. PID must account for many factors; for example, it can't just cut power to the motor when it reaches the target position because the inertia of the mechanism will carry it past (overshoot). Moreover, in many cases, the motor must have continuous power applied or the mechanism will backdrive and fall away from its target position. PID control must ramp power to the motor so the mechanism quickly reaches the target position, but ramp down the power as it approaches the target position and then continuously adjust power to maintain position. It's tricky.

Similarly, if you want a motor to spin at 100rpm, taking the simplest approach, you might apply full power to the motor to get it started and then measure again, but with no load, full power might get it spinning at 2000rpm before you can measure again - severely overshooting your goal. Conversely if the motor is under heavy load and was running a bit too fast (e.g. 110rpm at last measurement), cutting all power to the motor might cause it to drop to 0rpm before you measure again - severely undershooting the goal. A system like this is very responsive to changes but is not stable: it over/undershoots goals by adjusting power too much and can even oscillate (never stabilize on the desired goal).

Rather than turning power entirely on or off, you might slowly ramp power to the motor, measuring frequently, until you hit your target speed and then monitoring and adjusting power gradually and continuously to maintain that speed. However, slow changes in speed might make the mechanism insufficiently responsive: taking too long to get up to speed or respond to external changes. If the motor suddenly encountered a load that slowed it down (e.g. driving up a hill), it might take a long time to get back up to speed only to have crested the hill and be going down hill too fast...until the control loop caught up. This system is very stable, but is not adequately responsive.

Balancing responsiveness with stability is tricky. It's also important to recognize that different mechanisms have different requirements: a shooter flywheel moves very fast and needs to respond to sudden changes in load (e.g. when a boulder is kicked into the flywheel); a drive motor carries a heavy load and inertia is a critical factor; a breacher arm moves relatively slowly and load changes are less sudden. The control loops for each motor need different balances of responsiveness and stability.

What PID means PID is used to balance responsiveness and stability using factors P, I, D, and sometimes F that you can tune. When you configure your PID control loop (in the Talon or RoboRio), you will need to set those 3 factors. There is no perfect setting, it's always going to be a trade off between responsiveness, overshoot, and stability, but you should experiment with different values to tune your mechanism properly (there are also mathematical approaches to tuning that you can find with some googling).

  • Proportion (P): Power is increased/decreased in proportion to how far the last measurement was from its goal (i.e. the instantaneous error): if far from goal, add a lot of power, if close to goal, add a little power). Adjusting P determines how responsive the system is. Adding P increases responsiveness, but too much P will cause oscillation around the steady state point.
  • Integral (I): Power is increased/decreased in proportion to the average size and duration of the error: this can help reduce the steady state error to zero but will increase the tendency to overshoot the target set point initially.
  • Derivative (D): Power is increased/decreased in proportion to the rate at which the motor is approaching its goal (i.e. if the motor is not closing in fast enough, increase power, if it is closing in fast, decrease power); D increases stability by slowing the motor as it approaches its goal; this helps reduce overshoot.
  • FeedForward (F): Adds a constant to the output to keep it from going to zero

PID control loops are an important concept and the basics are explained in Wikipedia and this tutorial and PID for Dummies. You can implement a PID control loop using the Talon SRX or with the RoboRio; you should refer to the Talon software manual section 12.4 (page 75) for a detailed explanation of how to configure the Talon for PID control with Java example code. In cases where PID control can't be implemented via the TalonSRX (e.g. for a non-Talon-controlled motor or when the feedback mechanism can't connect to the Talon), the RoboRio can also implement PID control using the PIDController and PIDSubsystem classes; see here and here, and here.

Last modified 5 years ago Last modified on Jul 11, 2016, 12:20:13 AM