Skip to lesson
Westlake RoboticsLearn
Vault

FIRST Tech Challenge

Loading progress…

  • P Control Basics
  • PD Control and Damping
  • Integral Control and When Not to Use It
  • PIDF and Feedforward
  • Dashboard Tuning Workflow

P Control Basics

The first useful feedback controller.

PID and Feedforward ControlControl

In this lesson, you will:

  • Define error.
  • Scale output by error.
  • Clamp safely.

Concept narrative

Proportional control converts current error into output. It is the simplest way to make a mechanism move toward a target using feedback.

Robot mental model

The robot is repeatedly asking how far away it is and pushing in proportion to that distance. Large error produces larger output; small error produces smaller output.

Your browser does not support embedded video. Use the open-video link below.
0:00 / 0:00
Follow one proportional-control updateOpen video Download captions
Video transcriptRead or search the narration

You already know that proportional control multiplies error by kP. Let's follow one update from target to output and watch the correction shrink as the measurement approaches the target. The target is 1,000 ticks and the measurement is 600 ticks. Target minus measurement gives us an error of 400 ticks. For this calculation, we'll use kP as 0.0005, so the raw output is 0.2. We generally like to keep the units and sign visible. If the target is above the measurement, this convention produces a positive correction. Keep in mind that this gain is only sample data. It is not something to put on your actual robot. This software fixture performs that exact sequence once per loop. It reads the encoder, calculates target minus measurement, multiplies by kP, and keeps that between negative 0.25 and positive 0.25. Then it publishes that and writes every stage to telemetry. At 600 ticks, the error is 400 and the output is 0.2. At 900 ticks, the error is 100 and the output is 0.05. At 990 ticks, the error is 10 and the output is 0.005. That shrinking correction is the basic behavior of P control. It also explains why friction or gravity can leave a small steady error. The correction may become too small to move or actually hold the mechanism. If we accidentally calculate measurement minus target, the same starting point produces negative 400 and negative 0.2. The controller pushes away from the target. Do not try to tune a sign mistake with a smaller gain. Stop and look at the target, measurement, coordinate convention, encoder direction, motor direction, and the actual error equation. Once you have looked at those, use a low-power environment from the current robot and choose a small gain and output limit just to test. Direction errors can be one of the most dangerous things to test, especially with bigger mechanisms, so make sure you are taking all the proper precautions.

Implementation walkthrough

Read position, calculate error, multiply by kP, clamp, command motor, and print all values. Tune slowly with small target changes.

PController.javaJava

double error = targetTicks - lift.getCurrentPosition();
double output = kP * error;
output = Math.max(-1.0, Math.min(1.0, output));
lift.setPower(output);

Common mistakes and debugging

If the mechanism runs away, check encoder sign. If it oscillates, kP may be too high or the mechanism may need damping. If it never moves, output may be too small to overcome friction.

Practice

Tune a proportional-only lift on blocks and graph target, position, error, and output.

Checkpoint

  • Error sign is correct.
  • Output is clamped.
  • Telemetry shows target/position/error/output.
  • The test record includes the setup, prediction, and observed result.
  • A teammate can repeat the check from the saved evidence without guessing.

Reflection check

Check your understanding before moving on.

A mechanism moves away from its target as positive error grows. What should be checked before increasing kP?
Why clamp a P-controller output before calling setPower?

0 of 2 answered

References

Game Manual 0FTC community reference for programming, controls, and robot design.FTC DashboardLive telemetry, graphs, config variables, and camera streaming.
Loading lesson progress
Previous lessonInterfaces, Packages, and Code OrganizationNext lessonPD Control and Damping