Arm Control Help

My team is currently working on a pickup arm that needs to hold itself in three distinct positions. We originally tried using pid but were unable to get this to work due to the heavy weight of the arm and lack of knowledge. The arm uses a talon encoder to get its positions and needs to hold steady at -4700, -6000, and -3700 ticks with the press of a button. Our team is currently trying to use if statements and while loops to hold the arm but is struggling to move the arm precisely without it swinging down and slamming into our bumpers.

If anyone has sample code or ideas on how to control the arm please help!!!
We are competing at CVR today and are from team 3859.

Step one: compensate for the arm’s weight mechanically. Add a bungie cord, or a counterweight, or a gas spring, or anything that will take the constant load off the motor.

Then you can proceed to step two, and use the motor just to move the arm from location to location without worrying about gravity.

Absolutely agree with Alan - make a “passive” system that reduces the load on the “active” system.

Another setup we have used for this (off-competition) is a pneumatic cylinder. You don’t even need a solenoid valve, just orient and pressurize it so that it is ALMOST enough to lift the load.

Second option is to just gear the arm down enough that the motor doesn’t see the load much. If you’re driving the arm with a Versaplanetary gearbox or something, adding an extra reduction stage might be easier than counterbalancing.

This can work too. Just be aware of the torque loads you’re going to be putting on the output of the gearing. Make sure whatever you use isn’t going to get sheared off if you bump the arm wrong.

In a game like FIRST Stronghold, “bump the arm wrong” might include heavy bouncing from merely driving from one part of the field to another.

If you are having the issue of the arm slamming into the bumpers than what helped for our team was using a slow voltage ramp rate when the PID is arm level

Additionally, to make your code nicer, I’d carefully tune a feed forward constant. Multiply this by the cosine of the CURRENT (not desired) arm position to get the force required to hold the arm at that position. From there, you may find it easier to use traditional PID tuning methods as you are not fighting the force of gravity

We did programmatic gravity compensation for our arm this year, and all we ended up with were motors without their blue smoke. Don’t do it all by essentially stalling your motors like we did.