Motor Question..

So our team is looking to add a motor separate from RobotDrive.
After looking through the java API for this year over and over and over again, I cant seem to find a motor function separate from the driving mechanisms.
I could just be missing something, but at this point we’re stuck to an extent. I know there must be a way (we’re using the a speed controller on the motor to power a wheel).
So if anyone has any advice, it would be appreciated :slight_smile:

You control the motors through the motor controller, so there are three classes to choose from in wpilib. Choose the one for the motor controller you are going to wire up to.

Talon
Victor
Jaguar

Example Code:


Talon shooterWheel = new Talon(3); //talon on PWM channel 3 on digital sidecar

shooterWheel.set(1.0); //spin the motor at full voltage in one direction
shooterWheel.set(-1.0); //spin the motor at full voltage in the other direction

Would it be possible for you to elaborate a little bit more at all? How do you know which motor of the three you’re wiring it up too?

It sounds like you don’t have a large amount of experience so I’m going to start from the beginning; please don’t take this as an insult, I’m just trying to cover all bases in case you’re completely new to this.

Just a clarification: Talons, Victors, and Jaguars are not the motor itself, they are the motor controller–the hardware on the robot that takes power from the distribution board and sends it to the motor.

The controller will be connected to one of the outputs on the digital I/O board via a PWM cable; the number output on the I/O board will be used when you construct the object for it in Java.

What setup are you guys using? Are you using just the IterativeRobot base, or are you using a CommandBase pattern with/without RobotBuilder?

Essentially, the only code you need was in the first response from otherguy, you just need to construct an object of whatever kind of hardware is on the robot with the PWM output as the parameter and then you call .set(double speed) on the object.

Look through this page for pictures of the Jagaur, Talon, and Victor Motor controllers. These are the devices you wire your motor up to. They are what the cRIO communicates with to control the speed and direction of the motor.

You will have to decide which component you are using. All three are capable of driving motors. Depending on what you choose, you will need to use the corresponding class that I linked above.