My team can successfully stack 7 cubes into a tower, but they can get very unstable. Has anyone found a way to keep the tower stable while pushing it off of the tray? Thank you in advance!
Try using a P loop for your tray so it slows down as it stacks
1 Like
daivik
January 21, 2020, 7:17am
#3
P loop? can you provide more details?
weilin
January 21, 2020, 7:30am
#4
What @33691A-Gold_Dusk meant was to use “P” part of the custom PID control loop compared to V5 motor built-in PID feature.
@Connor recently created PID tutorial video for V5 that you may find helpful: VEXCode PID Tutorial
Also if you search for tray PID there will be some good results and discussion.
P-control is only one, more simple, part of PID. PID control involves three unique variables that allow a subsystem of the robot to reach a target or maintain a target position extremely accurately. The integrated PID is best for maintaining a position but it is not designed for moving systems as one would think. This is because you can’t tune it and physics will work against you.
What this means for a tray is that you would need your own PID control loop to deposit stacks smoothly. You do not …
A proportional loop is a control method that uses the idea of ‘error’. You take your setpoint (your target position), and subtract it by the motor’s current position. As you move away from your target, your error will grow larger. And as you get closer, your error gets smaller. If you set the motor’s speed to the value of your error, you would see your motor speed up and slow down depending on its positon.
The problem is that this error doesn’t work very well with the voltages/speeds the motor …
I recently learned about PIDs and have implemented them for our tray, allowing it to slow down as it reaches the target. However, I do not know how to tune the Proportional, Integral, and Derivative. Is there a technique to know your PID has been tuned “perfectly”? Any help would be appreciated!
That is not a P control, thats a bunch of if statements that also use VEX’s internal PID due to “setVelocity”.
If you want a P control do something along the lines of
double kP = 0.001;
int error = 0;
int targetValue = 900;
while(1==1){
error = TrayPusher.rotation(degrees) - targetValue;
TrayPusher.spin( directionType::fwd, error * kP, voltageUnits::volt );
vex::task::sleep();
}
Using voltage would be better, so you have more control of how you operate the motor. You may need to switch …
Are you sure writing your own P loop is necessary in this case? The built-in motor commands should work fine. Assuming that the tray has a one motor lift, then the C++ code would look something like this:
if(con.ButtonDown.pressing())
trayMotor.startRotateTo(0,deg,40,vex::velocityUnits::pct); // 0 is down position
if(con.ButtonUp.pressing())
trayMotor.startRotateTo(100,deg,40,vex::velocityUnits::pct); // 100 is up
3 Likes