
Re: Problem holding motor in fixed position for jointed arm
If you need to hold the arm stationary, you need PID control. Not just simple position PID control because like you said, as soon as it reaches target height, power gets cut off and the arm drops. Then PID kicks in again and lift the arm again and the cycle repeats. In other words, the RobotC built-in PID control doesn't work in that situation. You need to write your own PID control which integrates the output power. It's almost similar to speed PID control instead of position PID control where PID will cumulate the output power according to the error. When error goes to zero, the integrated power level is maintained. A simplified version will look something like this:
In theory, as long as you tune Kp correctly, it should work. However, you may still have issues in reality. Note that you have gravity that will help the arm to come down but fights you on the way up. So ideally, you need to do speed control as well. But that makes the algorithm really complicated. Also, this simple algorithm suffers a downside because it will keep integrating the power till it hits the max. The power will not come down unless error is negative which means it will overshoot back and forth before it will hold the position. In theory, you really need full PID control where the D (differential term) will allow the output power to come down when it approaches to target. You may want to try the above and see how well you can make it before thinking of improving it.