Sub topic 13
Troubleshooting: resets, jitter, hot parts, and silent motors
This chapter assumes you have wired a servo and a small DC motor from earlier chapters. You should know what a common ground is, how the Servo library works, and how a MOSFET or H-bridge switches a motor. Motor problems are usually power problems. This chapter gives you a method for finding which one you have.
A method that works
Change one thing at a time and watch for one symptom. Most motor faults fall into four groups: the board resets, the motion jitters, a part gets hot, or nothing moves. Each group has a short list of likely causes. Check them from cheapest to most expensive.
- Unplug the motor power and check that the sketch still runs. Add
Serial.printlnmessages if needed. - Check the wiring against the circuit, with the power off.
- Measure with a multimeter before you replace parts.
- Test the motor alone on a bench supply or battery pack, away from the Arduino.
A multimeter is the most useful tool here. Measure the voltage at the motor supply pins while the motor runs. Measure the Arduino 5V pin at the same time. A voltage that drops when the motor starts points to a supply problem.
Resets and brownouts
A brownout is a dip in supply voltage low enough to make the microcontroller restart. The Arduino's brownout detector resets the chip when the supply falls below a threshold, often around 2.7 V on an Uno. You might also see the board freeze or behave oddly before it resets.
Typical signs:
- The board resets when a motor starts, or when a servo begins to move.
- The USB connection drops and reconnects on your computer.
- The
setup()messages repeat in the Serial Monitor. - The power LED flickers.
Causes
A motor draws far more current when it starts or stalls than when it spins freely. A small hobby motor might draw 100 mA free-running and over 1 A at stall. A servo can draw several hundred milliamps while it moves, and more when it pushes against a load. If the motor shares a supply with the Arduino, that surge pulls the voltage down.
Common causes, roughly in order of how often they occur:
- The motor or servo is powered from the Arduino 5V pin or from USB.
- The external supply is too small for the stall current.
- Batteries are nearly flat, or their internal resistance is high.
- Thin or long wires and breadboard contacts add resistance, so the voltage drops along the way.
Fixes
- Power the motor from its own supply, and join its ground to the Arduino ground.
- Choose a supply rated above the stall current of every motor that can run at once.
- Add a bulk capacitor (for example 470 µF to 1000 µF) across the motor supply near the driver or servo. It supplies short surges.
- Add a 0.1 µF ceramic capacitor across the motor terminals to reduce high-frequency noise.
- Use shorter, thicker wires on motor power. Avoid pushing motor current through breadboard rails when you can.
Jitter
Jitter is unwanted twitching or buzzing. For a servo it means the horn shakes around its target angle. For a DC motor it means uneven speed.
Servo jitter
Check these causes in order:
- Weak or noisy supply. The servo's control circuit reacts to supply dips. Fix it with a better supply and a bulk capacitor.
- Missing common ground. Without a shared ground, the signal has no stable reference. The servo may move at random.
- Blocked or irregular signal timing. The servo expects a pulse about every 20 ms. Long calls such as
delay()do not stop the Servo library's pulse generation on AVR boards, because it uses a timer interrupt. But other interrupt-heavy code or libraries can disturb the timing. Check the libraries you use. - Fighting the end stops. Commanding an angle beyond the servo's real travel makes it push against the stop and buzz. Stay inside the range, as the sweep example in this tutorial does with 10 and 170 degrees.
- Load too heavy. A servo holding a load near its torque limit hunts back and forth.
- Cheap servo dead band. Some servos react to a one-microsecond change and some ignore it. If you change the target by tiny amounts constantly, the servo may twitch. Update only when the target changes by a meaningful amount.
A sketch that reads a potentiometer and writes the result to a servo shows a common cause. The analog reading wobbles by a few counts, so the servo moves on every loop. A simple fix is to ignore small changes:
#include <Servo.h>
Servo servo;
const int SERVO_PIN = 9;
const int POT_PIN = A0;
const int DEADBAND = 2; // ignore changes smaller than this many degrees
int lastAngle = -100;
void setup() {
servo.attach(SERVO_PIN);
}
void loop() {
int reading = analogRead(POT_PIN);
int angle = map(reading, 0, 1023, 10, 170);
if (abs(angle - lastAngle) >= DEADBAND) {
servo.write(angle);
lastAngle = angle;
}
delay(20);
}DC motor jitter
PWM speed control at low duty values can make a motor stutter. A small motor needs a minimum voltage to overcome friction, so values near zero may produce a whine or no motion at all. Find the lowest analogWrite value that starts the motor reliably, and use that as a floor for any non-zero speed. Note that a motor that is already spinning can run at a lower value than one starting from rest.
Other causes match the servo list: a sagging supply, a loose connection, or noise from brushes. Loose connections are very common. Wiggle each wire while the motor runs and watch for changes.
Hot parts
Some warmth is normal. Heat that you cannot touch for two seconds is not. Power off first, then find the part.
| Hot part | Likely cause | What to check |
|---|---|---|
| MOSFET | Not fully turned on, so it acts as a resistor | Is it a logic-level part? Measure gate voltage. Check the gate resistor and wiring. |
| MOSFET | Switching too slowly or too often | Check PWM frequency and the gate resistor value. |
| H-bridge driver | Motor current above the rating | Compare stall current with the driver's continuous rating. |
| Motor | Stalled or overloaded | Free the shaft. Reduce the load. |
| Servo | Pushing against an end stop or a load | Command a smaller range. Reduce the load. |
| Arduino regulator | Powering too much from the barrel jack or VIN | Check the input voltage and what is drawing from 5V. |
| Wires or breadboard | Current beyond the contact rating | Use thicker wire and soldered joints for high current. |
The MOSFET that is not logic-level
The most common hot-part fault in this tutorial's circuits is a MOSFET that needs a higher gate voltage than 5 V. A standard power MOSFET may need 10 V at the gate to turn fully on. At 5 V it conducts only partly. It then behaves like a resistor, dissipates heat, and delivers less voltage to the motor. Check the datasheet for the gate threshold and the on-resistance (RDS(on)) at a gate voltage of 4.5 V or lower. If it is not listed at that voltage, choose a different part.
Power dissipated in the MOSFET equals current squared times RDS(on). At 2 A and 0.05 Ω this is 0.2 W, which is fine. At 2 A and 1 Ω this is 4 W, which is enough to burn you.
Stalled motors
A motor that is powered but cannot turn draws its full stall current and converts all of it to heat. The winding can be damaged within seconds to minutes. If a motor hums and does not move, cut power quickly. Then look for a jammed gear, a bound shaft, or too much load.
Silent motors
A silent motor does not move, hum, or click. Work from the power source toward the motor.
- Is there power? Measure the supply at the driver or MOSFET. Check for a switched-off supply, a flat battery, or a loose connector.
- Is the ground shared? Measure between the Arduino GND and the motor supply ground. It should read close to zero volts. If it reads anything else, or the meter shows an open circuit, connect them.
- Does the motor work alone? Connect it straight to the supply for a moment. If it still does not move, the motor or its wiring is at fault.
- Is the signal reaching the driver? Measure the gate or input pin while the sketch runs. For a PWM output, the average voltage rises as the duty value rises.
- Is the pin correct?
analogWriteonly produces PWM on pins marked with a tilde (~) on an Uno. On other pins it gives only on or off, with a threshold at 128. - Is the driver enabled? Many H-bridge boards have a standby or enable pin. In the H-bridge example in this tutorial,
STBYmust be HIGH, and the direction pins must differ for the motor to turn. - Is
pinModeset? An output pin that is never set asOUTPUTdoes not drive a clean signal. - Is the sketch running? Add a serial message in
setup()andloop()to confirm.
Servo specifics
A servo that does not respond to commands may have these faults:
attach()was never called, or it was called with the wrong pin.- The signal wire is on the wrong header pin. Most servos use brown or black for ground, red for power, and orange or yellow or white for signal. Check your servo's datasheet, because colors vary.
- The servo is connected but has no external power.
- On boards using the Servo library, certain pins lose PWM function. On an Uno,
ServodisablesanalogWriteon pins 9 and 10. If your sketch uses PWM on those pins, move it.
A servo that moves to one end and stays there often has a signal-range problem. Try writeMicroseconds() with values between 1000 and 2000, and widen the range slowly if your servo supports it. Do not go far beyond what the servo is rated for.
Direction faults
A motor that spins the wrong way is not broken. Swap the two motor wires, or swap the two direction signals in software.
A motor that spins only one way suggests a wiring problem on the second direction input, or a sketch that never sets that pin.
Using Serial to test in isolation
A short test sketch separates software faults from wiring faults. This one steps through speeds and prints what it sets, so you can match output to what the motor does.
const int MOTOR_PIN = 5; // must be a PWM pin
void setup() {
Serial.begin(9600);
pinMode(MOTOR_PIN, OUTPUT);
Serial.println("Motor test start");
}
void loop() {
for (int speed = 0; speed <= 255; speed += 51) {
analogWrite(MOTOR_PIN, speed);
Serial.print("PWM value: ");
Serial.println(speed);
delay(2000);
}
analogWrite(MOTOR_PIN, 0);
Serial.println("Stopped");
delay(3000);
}Read the result like this:
- The motor never moves, and the messages appear. The fault is in the hardware.
- The messages stop when the motor starts. The board is resetting. Go to the brownout section.
- The messages appear, the motor starts at a high value only, and it is slow. The supply is weak or the MOSFET is not fully on.
- No messages at all. Check the board, the port, and the upload.
Quick reference
| Symptom | First check | Common fix |
|---|---|---|
| Resets when motor starts | Is the motor on the Arduino's supply? | Separate supply, bulk capacitor |
| Servo twitches | Common ground and supply | Join grounds, add a capacitor, add a deadband |
| Motor hums, no motion | Stall or too low a PWM value | Free the shaft, raise the minimum PWM |
| MOSFET hot | Logic-level rating | Replace with a logic-level part |
| Driver hot | Current rating | Lower the load or use a larger driver |
| Nothing at all | Power, ground, enable pin | Measure at each step |
| Wrong direction | Motor wire order | Swap wires or swap signals in code |
Exercise
Your Uno resets every time a hobby servo starts moving. The servo's red wire is connected to the Arduino 5V pin, its ground to Arduino GND, and its signal to pin 9. List the changes you would make and explain why each one helps.
Show answer
Power the servo from a separate supply (for example a 5 V to 6 V battery pack or regulated supply) rated above the servo's stall current, and connect that supply's ground to the Arduino GND so the signal has a shared reference. The servo's start-up surge was pulling the Arduino's 5V rail down and triggering the brownout reset. Add a bulk capacitor of about 470 µF to 1000 µF across the servo supply, close to the servo, to cover short surges. Keep the signal wire on pin 9. Use thicker, shorter wires for the servo power.
Exercise
A motor circuit uses a MOSFET to switch the motor from a 9 V supply. The motor runs slowly and the MOSFET gets very hot. The MOSFET's datasheet lists RDS(on) only at a gate voltage of 10 V. What is the likely cause, and what do you do?
Show answer
The MOSFET is not a logic-level part. The Arduino's 5 V gate signal does not turn it fully on, so it acts as a resistor. It dissipates heat and drops voltage that the motor needs. Replace it with a logic-level MOSFET that lists a low RDS(on) at a gate voltage of 4.5 V or lower. Also confirm the gate resistor is a modest value (100 to 220 ohms) and that the flyback diode is in place.
Exercise
A motor is wired through a TB6612FNG-style driver. The sketch prints its speed values, but the motor stays silent, and the supply and motor are known to be good. Name three things to check.
Show answer
Check that the standby pin (STBY) is HIGH, because the driver is disabled otherwise. Check that the PWM pin is a real PWM pin and that the direction inputs are set to different levels (one HIGH and one LOW), because two LOW values stop the motor. Also check that the motor supply ground is joined to the Arduino GND, and that the motor supply pin on the driver is powered.