Twitchy Motors

So we have another problem with the roborio (the connection issue is fixed). I noticed that the motors twitch, regardless if it is a Talon SR or VIctor SP. We have tried another schools Talon SRs and PWMs, it still twitches, so I think it may be an issue with the wiring or the physical roborio. It is not a shortage since the electronics board is mounted on a wooden board and the only wires touching the metal frame are the motor wires and the battery cables, which I am fairly sure is not causing the issue.

What programming language?

Is it possible you’re addressing motors from more than one area in your program? It’s a favorite mistake I find with my students. They forget that somewhere else in the program a motor is set to 0 and in another part they’re trying to run it at some speed. Causes motor twitch.

I am using Java. There are only four lines of codes that tell the motors to do something.


I can determine these are the only lines of code that make the motors move by commenting them out. When I do that, the talons blink orange.

It sounds like it is something wrong with the joystick. What joystick are you using? You should be able to recalibrate your joystick to fix it.

Put the robot up on some blocks of wood, and change your teleop code to this:


That will rule out the joysticks being a problem. I’d also double check all your code, just to be sure.

Check the battery voltage. Sometimes with brownout protection the wheels will be a bit twitchy.

We’ve seen the same behavior from victor sp’s in past years. Our best guess is that they can be sensitive to noise on the PWM wire. Are your PWM wires running along side power wires?

Interesting, with a digital line like PWM, noise shouldn’t be a big deal unless it’s really, REALLY bad. Hopefully OP comes back with a response soon cause I’m genuinely curious. The only thing that hasn’t been mentioned is the faint possibility that both motor controllers are incorrectly calibrated, but it is still feasible.

Need more description of the symptoms.
For all we know the drive motors are wired into 30amp breakers, rather than 40a breakers.

I have tried setting each motor to a value of 0 and it still twitches.

I do not have the robot in front of me to confirm the breakers.

We’ve calibrated the victors and talons multiple times. I don’t think we’re calibrating it incorrectly.

Since you mention different types of motor controllers, are the correct motor controller types being initialized for each of them in the code?

Yes, I had made sure of that.

Perhaps photos of your wiring setup would help identify additional potential problems/solutions.

I do have a rookie team describing motor controller twitching, too, but they always have the robot apart when I’ve been visiting so I haven’t been able to diagnose it yet.

You could also post all of your code, that will help us make sure something isn’t inadvertently happening.

We had a twitching talon SR… we managed to solve this by connecting the talon to another PWM port.
Since we are getting a strange error in the driver station about PWM (something like PWM 0FRC in some WPIlib).

These are the images

Those are 40 Amp breakers

The wiring looks correct to me (except for your lack of CAN). Does not having the roboRIO connected to the PDP cause any watchdog errors? Not sure…

Anyway, you could try 4 different PWM ports to see if maybe those ports are bad.

Also if you post your code we can rule out the code being an issue.

The wiring looks good to me too.

Take a look at the Driver Station Log File after these twitches occur.
To see if the Event List or the graphs show unusual behavior.

The new radio is 12V, the old radio is 5V.

Edit: Weird, I got an email saying a new post said that the voltage should be changed. Ignore this post I guess

Edit2: Also, when youre testing, do you have the robot up on blocks, so the wheels arent touching the ground? Its possible that they are drawing too much current.

We do prop it on blocks when we test it.

I swapped the PWM ports to 4, 5, 6, and 7 and it still twitches.

package org.usfirst.frc.team988.robot;

import edu.wpi.first.wpilibj.SampleRobot;
import edu.wpi.first.wpilibj.Talon;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Victor;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

public class Robot extends SampleRobot {
    Joystick stickL;
    Joystick stickR;
    final String defaultAuto = "Default";
    final String customAuto = "My Auto";
    SendableChooser chooser;
    Talon LF;
    Talon RF;
    Talon LR;
    Talon RR;

    public Robot() {
        stickL = new Joystick(0);
        stickR = new Joystick(1);
        LF = new Talon(4);
        RF = new Talon(5);
        LR = new Talon(6);
        RR = new Talon(7);
    public void robotInit() {
        chooser = new SendableChooser();
        chooser.addDefault("Default Auto", defaultAuto);
        chooser.addObject("My Auto", customAuto);
        SmartDashboard.putData("Auto modes", chooser);

    public void autonomous() {
    	String autoSelected = (String) chooser.getSelected();
//		String autoSelected = SmartDashboard.getString("Auto Selector", defaultAuto);
		System.out.println("Auto selected: " + autoSelected);
    	switch(autoSelected) {
    	case customAuto:
    	case defaultAuto:

    public void operatorControl() {
        while (isOperatorControl() && isEnabled()) {
            Timer.delay(0.005);		// wait for a motor update time

     * Runs during test mode
    public void test() {