|
Re: Acceleration based on position
I would recommend PID to control this. Our team is doing a similar thing, and this is working well.
Quick overview of PID.
P-Proportional Gain-Bases motor output based off of how far away from the target you are. The higher the number, the faster you approach your goal, but it is less accurate at holding that position
I-Integral Change-Look at how error has accumulated over time, and correct for it. The higher the number, the further back it looks, which will slow down your approach as you get closer (but will hold it closer to where you want).
D-Derivative Time- Look at how fast the rate is changing and compensate so it does not overshoot your goal. The higher the number, the further ahead it looks, which will slow down your approach
Most likely, you will only need the P part, which should hold it close enough to where you want. I would increase the number until the elevator has a visible shake to it. (from the P part over-correcting)
If this is confusing, try messing with the "General Auto PID Simulator" in the FRC examples. Its a good way to figure out the relationship between P,I, and D
Once you start actually testing your elevator, be sure to have preprogrammed upper and lower limits so you dont break your elevator as well as a few setpoints to move to. If the elevator does not seem to slow down as it approaches a setpoint, you may have the motor wired inversely with the encoder output. Either reverse the motor, or change the P value to be negative instead of positive.
|