WestlakeLEARN
FTC · Java

FIRST Tech Challenge

FTC · Java

  • IMU, Encoders, and Bulk Caching
  • Voltage, Current Awareness, and Safe Test OpModes

Voltage, Current Awareness, and Safe Test OpModes

Avoid damaging robot hardware while testing code.

Module 4: Feedback Devices and Safe TestingCore

In this lesson, you will:

  1. 01Read voltage as context.
  2. 02Design low-power tests.
  3. 03Create disable and stop paths.

Concept narrative

Battery voltage changes robot behavior. A drivetrain that feels gentle at low voltage may be aggressive on a fresh battery, and a mechanism near a hard stop can draw damaging current.

This lesson should be read as a robotics lesson first and a programming lesson second. The code matters because it lets the team create repeatable behavior under match pressure. Students should slow down long enough to name the inputs, outputs, assumptions, and safety limits before they touch the robot.

Robot mental model

Safe test code assumes something might be wrong. It uses low power, short timeouts, telemetry, and an easy stop path so students can learn without turning every bug into a repair job.

A good mental model gives the team a shared language. When a driver, builder, and programmer can point to the same behavior and use the same words, debugging gets calmer and code review becomes useful instead of personal.

Implementation walkthrough

Add voltage telemetry to tests, start with low motor power, clamp outputs, and use timeouts. For mechanisms, begin away from hard stops and verify direction before full travel.

Keep the implementation staged. First create the smallest version that compiles. Then add telemetry that proves it is running. Then connect one hardware device or one decision. Finally, repeat the test from a cold init so the team knows it was not a lucky hot reload.

SafeMotorTest.javaJava

double voltage = hardwareMap.voltageSensor.iterator().next().getVoltage();
runtime.reset();
while (opModeIsActive() && runtime.seconds() < 1.0) {
    motor.setPower(0.2);
    telemetry.addData("voltage", voltage);
    telemetry.update();
}
motor.setPower(0);

Common mistakes and debugging

If a motor stalls, stop and inspect the mechanism before increasing power. If voltage is low, do not tune final constants. If a test has no timeout, add one before running it on the floor.

Use the five-value debugging habit: input, state, target, measurement, output. If one of those values is missing, add it before rewriting logic. The goal is to make the robot tell the truth about what it thinks is happening.

Practice

Write a motor test that runs at 20 percent power for one second, reports voltage, then stops regardless of sensor state.

Checkpoint

  • Power starts low.
  • Voltage is recorded.
  • The test stops on timeout and Stop.

Reflection check

Check your understanding before moving on.

What is the most important habit in Voltage, Current Awareness, and Safe Test OpModes?

0 of 1 answered

References

FIRST FTC DocsOfficial SDK, Robot Controller, and programming reference.Learn Java for FTCFTC-focused Java book and exercises by Alan G. Smith.Game Manual 0FTC community reference for programming, controls, and robot design.

Finished reading?

Mark this lesson complete — “Driver Control” is up next.

IMU, Encoders, and Bulk CachingDriver Control