As the Wheel Turns

The guide to everything controls for 1675 members.

As the Wheel Turns

Objective

In this lab, we will create our first robot program and make a wheel turn using a motor controller.

Hardware

The hardware required for this lab is:

The setup should be as follows:

You’re in luck! Every past 1675 robot that still has its electronics has all these things. Let’s go a little more in-depth on some of the aspects of the hardware setup.

Driver Station

You will need a computer with Driver Station installed to start the robot. We won’t be using any human input in this lab, so the program is all you need.

RoboRIO

roboRIO

The RoboRIO is the “brain” of the robot. It will run our code, take input signals, and send output signals. One key output is sending commands to motor controllers, over either PWM or CAN.

PD Board and Main Breaker

PD Board Main Breaker

The PD (Power Distribution) board connects to the battery and distributes power to the robot. The electrical team will handle this for the most part, but using CAN we can get some info about power usage of various channels if we need to.

Motor Controller

SparkMax

This is a motor controller. It takes power in from the PD board (+ and -), outputs power to the motor (+ and -), and has signal wires. The output wires going to the motor will apply some voltage to the motor depending on how we command it. In FRC, motor controllers work using the CAN (Controller Area Network) Bus, or using PWM (Pulse-Width Modulation) signals. The two methods use different wiring and different code. Typically, 1675 uses communication over the CAN bus.

CAN Bus

CAN Connection

The CAN Bus is 2 wires that all the CAN Bus devices on the robot chain together and enter the roboRIO at one point. Each CAN Device has its own “CAN ID” used to refer to it in the code.

Motor

Rev Neo Motor

This is a motor. This motor is a Rev Neo, but we use many different kids of motors (determined by the rules and the design team). Most motors we will use work the same way. The two power wires connect to the outputs of the motor controller. When the motor controller applies voltage to the motor, the motor will turn proportional to the voltage given. How fast the motor spins is determined by both the applied voltage and the motor specifications. Each motor requires its own dedicated motor controller.

Wheel

The wheel will turn when the motor turns. How fast it spins depends on how it is conected to the motor. The design team determines what the ratio from the motor to the wheel will be. If you are running on this lab on a test board, no wheel will be connected, which is OK.

Software

To program the robot you will need VSCode with the FRC development plugins installed and vendor library for motor controllers (e.g. CTRE, Rev. Ask a mentor if you are unsure of this). For help, see Setting up your development environment (robot).

What we need to do to accomplish the objective:

Create an Timed Robot template project

To create the template project

If successful you will have a new project in VSCode and in that project will be a Robot.java file with a lot of template code and comments.

Understand How Timed Robot Works

In FRC, if a robot is turned on, it is in one of 3 modes: Disabled, Teleoperated, or Autonomous. In Disabled mode all outputs are disabled. In Autonomous all input from the Driver Station is disabled. In the TimedRobot framework your code can be called in one of 2 ways: init, periodic. Each mode has its own version of a method for these ways. (ex. autonomousInit, disabledPeriodic.

QUESTION TIME!

On 1675 we typically use Command-Based programming to program our competition robots, but it is important to understand how IterativeRobot works first.

Write Code

For this lab, make the wheel spin at 50% speed forward any time the robot is in teleop mode.

What method or methods should our code to do this go in? Think about it or discuss with your group.

What code will you need to add? Here are some tips:

Testing

When you test your code for the first time, always do it “on blocks”. No moving part of the robot should be touching the floor or anything else. For this lab you can leave the robot on blocks as we are only turning one wheel.

Post Lab Questions