Robot does not work

I wrote code to connect Spark and Talon SRX to the robot and set the motor speed to 1.0.
However, when executed, the motor moves for a moment and roboRIO falls.
Spark alone, TalonSRX alone did not understand.
Firmware updated to 2020.
Why?

If you post your code, that’ll help figure out if it’s a code issue or not

This is the code.

package frc.robot;

import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj.PWMTalonSRX;
import edu.wpi.first.wpilibj.Spark;

public class Robot extends TimedRobot {
  private PWMTalonSRX talon = new PWMTalonSRX(1);
  private Spark spark = new Spark(0);

  @Override
  public void robotInit() {
  }

  @Override
  public void robotPeriodic() {
  }

  @Override
  public void autonomousInit() {
  }

  @Override
  public void autonomousPeriodic() {

  }

  @Override
  public void teleopInit(){

  }

  @Override
  public void teleopPeriodic() {
   spark.setSpeed(1.0);
   talon.setSpeed(1.0);
  }

  @Override
  public void testPeriodic() {
  }
  @Override
  public void disabledInit(){

  }
}

In the future, consider a more descriptive thread. Users need to know what posts to click on, based on their areas of knowledge. Nobody can tell if you need help with mechanical, code, or something else from the homepage.

2 Likes

By falls,
do you mean that the the driver station says ‘no robot code’ or do you mean loses power (no communication)?

The connection between roboRIO and the PC has been lost, and the connection between the PDP and roboRIO has also been lost.
If you wait for a while, it will spread.

  1. The team I helped at quick build had a lose wire from PDP to RoboRIO causing intermittent power outages (similar to what might be happening to you). So check that.

  2. You could be browning out if the batteries are particularly low, which can cause the same behavior. What is your voltage?

On first glance, the code looks good. If I can suggest anything, I might recommend initializing the Talon and Spark in the robotInit() method.

The Rio failing, it could mean a lot of things. The best way to figure out how code is failing is by watching the logs, however, that’s not always the issue that you’re dealing with.

You can do this in VSCode by using the WPILib: Debug Robot Code option.

Screenshot from 2020-01-05 20-58-38

When 0.3 was added to the value of setspees, it worked normally. However, entering a number greater than 0.5 did not work.

Okay, that sounds like a battery issue.

What’s your battery voltage?

2 Likes

When it is 0.3, it is 11.8 to 12.4V, and when it is 0.4 or more, it is 11.2V intermittently.
The PDP receives 15V, 5A power from the power supply.

15V 5A? Yeah, you’re browning out your power supply.

Try it with a robot battery, I guarantee you’ll have better results.

2 Likes

What should I input what V and what A?

You’ll need 12-13v and at least 80A.

The Spark and Talon are 40A motor controllers. Each of them are designed to draw 40A at 12v. I’ve seen them draw up to 50A under certain circumstances.

1 Like

Solved using the battery.
Thank you very much.

1 Like

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