Motor not running

I was just testing a motor that is running with a Talon SRX motor controller, and for some reason, the motor is not running. When I press the button on the Xbox controller, the motor controller stays solid orange, so I believe it is not receiving the code. However, I am using the exact same code on the falcon motors, and those are working. I’m guessing that the code for talons is different, but I’m not sure how the code should look.

Also, I have already updated the firmware on the Talons. Any help is greatly appreciated!image

Can you post your constructors?

If you have a way to link to a github repo with the code in question, that would also help.

A set of standard questions I’d ask a student in a similar boat - none which would answer the question directly, but all should help point toward root cause:

  1. How does that code get called? What other code is making sure it’s running once every 20ms?
  2. Is the controller plugged in an on the right USB channel in the driver station?
  3. Try putting print statements inside each block of the if/elseif/else. Do they get printed? Which ones? (Or, do the same thing with a debugger)
  4. (if safe) Delete everything except the contents of the first IF statement. Does the motor start to spin when you run the code?
1 Like

Yes, here is the link to the github repository: Cortex/Robot.cpp at master · FRCTeam5458DigitalMinds/Cortex · GitHub

Also, thanks for all of the suggestions! I tried all of them, but none of them seemed to work. I tested just the first if statement and that didn’t seem to work, and I tried printing the motor value, but it was still outputting 0 instead of 0.1. The controller was also plugged into the correct USB channel in Driver Station.

Any suggestions?

Is your “Code for spitting” which sits AFTER this intake code setting the motor powers back to 0?

Specifically, you have this block of code running immediately after the snippet you posted:

//Code for spitting
if (Xbox.GetPOV() == 0){
FrontIntake.Set(ControlMode::PercentOutput, -0.75);
BackIntake.Set(ControlMode::PercentOutput, 0);
Conveyor(-0.2, 0.2);
} else if (Xbox.GetPOV() == 180){
FrontIntake.Set(ControlMode::PercentOutput, 0);
BackIntake.Set(ControlMode::PercentOutput, -0.75);
Conveyor(0.2, -0.2);
} else {
FrontIntake.Set(ControlMode::PercentOutput, 0);
BackIntake.Set(ControlMode::PercentOutput, 0);
Conveyor(0, 0);

In the case where POV is not pressed, code is falling down into the final else, which sets both intake motors to power 0, overriding any powers set higher up in the code.

You might consider combining these 2 if, else if constructs into one larger if/else if/else block to insure exactly one path through (and 1 set of motor commands) is executed.

1 Like

Yeah, I didn’t even realize the code for spitting was setting the motors back to zero. I just tried combining the intake and spitting code and it worked! Thank you so much!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.