There are many types of motors including: * [https://en.wikipedia.org/wiki/DC_motor 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 [http://www.andymark.com/Motor-p/am-0255.htm CIM motors] and mini-CIM motors; vendors such as !AndyMark supply [http://www.andymark.com/Motors-s/260.htm many types of DC motors] that may include integrated gear boxes that convert motor speed to torque. * [http://frcdesigns.com/2015/07/28/a-look-into-robot-components-part-1-motors/ This page] provides an excellent look into FRC motors and their characteristics. * [http://team-paragon.org/wp-content/uploads/2013/01/2013_FIRST_Motors-571.pdf This chart] provides details including max rpm, max power, torque,current consumption, etc. for a large number of FRC-legal motors. * [http://www.jameco.com/jameco/workshop/howitworks/how-servo-motors-work.html Servo Motors] and [http://www.instructables.com/id/BYJ48-Stepper-Motor/ 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 [http://www.chiefdelphi.com/media/papers/download/3449 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 [https://en.wikipedia.org/wiki/H_bridge 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 [http://www.electronics-tutorials.ws/blog/pulse-width-modulation.html pulse-width modulation] (PWM). In many cases, there are dedicated integrated circuits to provide this functionality such as [http://www.gearbest.com/other-accessories/pp_218079.html Arduino Motor Shields]; and [http://playground.arduino.cc/Main/AdafruitMotorShield code libraries] to support them. FRC robots use advanced motor controllers such as the [http://www.vexrobotics.com/217-8080.html 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 [http://www.4qd.co.uk/faq/motrat.html 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 [https://en.wikipedia.org/wiki/PID_controller Wikipedia] and [http://www.expertune.com/tutor.aspx this tutorial] and [http://www.csimn.com/CSI_pages/PIDforDummies.html PID for Dummies]. You can implement a PID control loop using the Talon SRX or with the !RoboRio; you should refer to the [https://www.ctr-electronics.com/Talon%20SRX%20Software%20Reference%20Manual.pdf 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 [https://wpilib.screenstepslive.com/s/4485/m/13809/l/241901-pidsubsystems-for-built-in-pid-control here] and [http://cntsoftware.com/robotics/pdf/WPILib_programming.pdf here], and [https://www.assembla.com/spaces/rbhsrobotics/documents/cS2tESqASr45PGacwqjQYw/download/cS2tESqASr45PGacwqjQYw# here]. * [http://www.orientalmotor.com/technology/articles/motor-sizing-calculations.html Motor Sizing Calculations] * [https://developer.mbed.org/users/4180_1/notebook/an-introduction-to-servos/ More servos] * Inexpensive geared motors for homebrew bots: [http://www.gearbest.com/dc-motor-_gear/ gearbest] $2.25 and up * Arduino Servo [https://www.youtube.com/watch?v=ZySGP4AwGCY tutorial]