Motors and Servomotors

Overview of DC motors, servomotors, and their control

8166

Electric motors produce motion by harnessing the interaction between a constantly changing magnetic field produced by an electromagnet, and a second, static magnetic field produced by a permanent magnet (or another electromagnet). The current flow through the electromagnet determines its field strength and direction, and so a motor controller circuit can control the speed and direction of a motor by controlling current flow through the electromagnet.

In a common “brushed" DC motor, the electromagnets are attached to the spinning center of the motor, called the rotor. Current is delivered to the electromagnet coils through two brushes that are attached to the motor terminals. The motor terminals deliver current to the brushes from an external power supply (typically from 5V to 12V for small “hobby" motors).

The brushes contact the commutator, which is a rotating electrical switch whose contacts are connected directly to the coils. The commutator has one contact per coil, and two adjacent coils receive current from each commutator contact. Since the brushes are held in fixed positions, they provide a constant voltage to the commutator. The commutator sends current through one of the coils, creating a magnetic field that interacts with the magnetic field created by the permanent magnets. This field produces a torque which rotates the rotor, and so moves the commutator so that the brushes contact a different set of commutator contacts. As the motor rotates, the brushes contact different commutator terminals in an endless cycle (as long as power is applied). Once per revolution, the current through the each coil reverses direction, creating a reversing magnetic field that continues to generate torque from the unchanging felids produced by the permanent magnets.

Figure 1. Brushed DC motor anatmoy
Figure 1. Brushed DC motor anatmoy

Many types of motors have been built over the years, including rotating brushed DC motors as described above; rotating brushless DC motors with stationary coils that can be energized and controlled by electronic switches (so no commutator is needed); AC motors that use electromagnets whose fields are produced by out-of-phase AC currents; three-phase motors, linear motors, and several others. Many very good references exist that describe the design and function of electric motors, and you are encouraged read some of them (see for example the Wikipedia page on electric motors). For this project, we are concerned with smaller brushed DC motors that might be found in small appliances, tools, and toys.

Motor torque (and speed) is a direct function of the amount of current delivered to the coils, and coil current is controlled by the voltage imposed across the coils. A DC voltage applied to the motor terminals will produce a constant current through the coils, and a constant current will produce a constant torque. The higher the applied voltage, the greater the torque. Motors can consume a relatively large amount of current - even small motors can consume one or more Amperes. Accurately controlling large analog currents and voltages requires more expensive components and more careful design. A better method of controlling motor voltage takes advantage of the filter effect created by the motor itself.

Motor windings provide a series inductive load that creates an effective low-pass filter. A pulse-width modulation signal driving a power transistor can create a series of constant-voltage pulses that will be filtered/integrated by the motor-winding filter into an analog voltage. The motor filter will effectively attenuate PWM frequencies above the tens of Hertz range, resulting in a relatively clean and constant analog voltage at the motor terminal. The motor controller only needs to change the duty cycle of the PWM signal to increase or decrease the effective voltage applied to the coils.

Figure 2. PWM signal for driving a brushed DC motor
Figure 2. PWM signal for driving a brushed DC motor

Smaller DC motors (no larger than a C size battery) typically rotate at 3000-8000 RPMs when they are unloaded and driven with a constant voltage. Since this rotational rate is too fast for many applications, “gearmotors" that include an integral gear box to reduce rotation and increase torque are also quite common. Smaller DC gearmotors typically rotate in the range of 10-100RPMs, and they can generate up to about 10nM of torque, or about 1 watt of rotational power (enough to lift a 1Kg weight at 1 meter per second). Most smaller motors have a rated voltage (12V is somewhat typical), but they can typically operate with a relatively wider range of voltages. For example, a 12V motor could operate at 5V, but with lower efficiency and lower torque. Likewise, a 12V motor could also operate at up to 16V-20V, but with lower efficiency and higher torque (at some point, too high a voltage will drive too much current through the coils and overheat them to the point of damage).

Brushed DC motors can most often be operated in either direction with equal efficiency, so typical motor controllers use an H-bridge circuit that can drive current through the motor in either direction. In the figure below, a constant “Dir" signal sets motor direction, and the PWM energizes the coils as described above. The FET driver circuit elements are shown to call attention to the fact that power FETs typically have a large gate capacitance that is difficult to drive from a typical logic-level IC pin that can only source a few millamps. And further, if only nFETs are used as shown, then in order to turn on, the high-side nFET must have a gate voltage that is higher than the motor power supply voltage (and that’s what FET drivers do).

Figure 3. H-Bridge circuit for DC motor control
Figure 3. H-Bridge circuit for DC motor control

Servomotors

The term servomotor most typically refers to a rotating brushed-DC motor that is contained inside a plastic housing, together with a gearbox and a closed-loop controller circuit. The gearbox greatly reduces rotational speed to something like 1 RPM, and greatly increases torque. The controller circuit receives an input signal, and then moves the motor shaft to the rotational position specified by the control input signal, and holds it there. The motor shaft can typically only rotate over a fixed angle of less than 360 degrees – typically in the 90 to 120 degree range. “Hobby servos” are typically used to control steering in RC cars, flap or aileron position in RC planes, or other mechanical system that only move over a fixed range.

Figure 4. A hobby servo
Figure 4. A hobby servo
Figure 5. Inside a hobby servo
Figure 5. Inside a hobby servo

RC devices that use servos often use more than one. To accommodate controlling multiple servos from a single RC communication channel, a particular signal protocol has emerged. Although not rigidly defined or enforced, a typical servo is driven by a PWM signal that uses only a fraction of the possible channel bandwidth, so that more than one servo can be driven from the same PWM source. A typical servo PWM signal includes one pulse every 20ms, and each pulse than can vary between one and two milliseconds. A 1ms pulse drives the servo fully clockwise (between 45 and 90 degrees from center), a 2ms pulse drives the servo fully counterclockwise (45 to 90 degrees from center), and a 1.5ms pulse centers the servo. To change the servo position by 1 degree requires a PWM step size of 1ms/180, or about 5.5us. Note that different servos may use slightly different pulse times, and may have slightly different maximum rotation angles.

Figure 6. PWM signals for servo control
Figure 6. PWM signals for servo control

The controller circuit inside the servo measures the pulse width, and then rotates the servo shaft accordingly and holds it there. A shaft encoder measures the shaft rotation angle, and feeds that back to the controller. If an external force tries to rotate the servo shaft from its assigned position, the controller adds current as needed to keep the servo at its assigned location.

Using Servomotors on Blackboard

The Blackboard contains four three-pin, 100-mil-spaced headers/connectors that can attach directly to servo motor connectors (pin 1 is ground, pin 2 is motor voltage, and pin 3 is the PWM control signal). The PWM pin is attached to an FPGA pin on ZYNQ, and that pin can be driven from custom IP or from ZYNQs triple timer counter module using the EMIO interface.

The image below shows Blackboard’s servo connectors, two excerpts from the schematic, and the relevant entries from the .xdc file. Perhaps the best way to drive the servos is to configure ZYNQs TTC outputs to create the appropriate PWM waveform (see the Timers reference page for more information). Blackboard’s hardware configuration file routes the waveform outputs of the three counters in TTC0 to the PWM pins on servo connectors J1, J2, and J3.

Figure 6. PWM signals for servo control
Figure 6. PWM signals for servo control