Help with PID

I am using vexcode, and I recently made a PID controller. When running my robot, it will slow down to that point that the motors are running at a speed that can’t overcome the force of friction. This makes the robot undershoot its target. When I lift it up the wheels spin the rest of the distance. Is there any way to make the robot not accept certain values around -1 to 1 volts without doing a massive if else statement? Thanks for the help.

Use a PID loop. the I component, the Integral, will slowly increase the power if the motor spends too long away from the target.

also, you can tune the P component a bit better.


The best way to accomplish what you want is to play with the I term of your PID loop. The issue you are experiencing is the exact issue that the I term is designed to solve.

However, if you want to set a minimum voltage allowed by the loop, you could just do a simple if statement like

if(abs(voltage) < minimumVoltage) {
     voltage = WhateverYouWantToSetItTo

where voltage is the voltage that the PID loop computes and minimumVoltage is the lowest voltage that you are okay with.


Recently I was testing how to modify the integral accordingly in PID algorithms, and I was able to come up with a simple solution

if((prevError < 0 && error > 0) || (prevError > 0 && error < 0)){
    totalError = totalError/8;

I didn’t want the integral to magically stop after the position was reached. So I decided I wanted integral to somewhat-naturally flow with momentum.

Edit//: You can see that the Boston Dynamics robot does the same thing with making integral naturally flow with momentum past the set-point, then lowers itself into position