![]() |
Re: PID Loops
Quote:
Quote:
|
Re: PID Loops
Quote:
JoyStickYaxis is +1 (operator input) currentPotValue is 550 (min is 300 and max is 600) (m*(currentPotValue+b)) = ( (1/150)*(550-450) ) m is 1/150 and b is -450 so that the number is always between -1 and 1error = 1 - 0.6666; MotorOutput = k * 0.3333 and say k is 0.75 then the output becomes 0.25 of course, k needs to be adjusted so the error is as close to 0 as possible and/or the arm doesn't oscillateGood so far? Or did I make a mistake somewhere? EDIT: I have a feeling I did something wrong |
Re: PID Loops
Quote:
|
Re: PID Loops
Quote:
|
Re: PID Loops
Quote:
What you have implemented is a closed-loop position controller. The arm will move to a position commanded by the joystick, and stay there as long as the joystick continues to command that position. If you let go of the joystick, the joystick will return to its rest position and will be commanding "go to position zero", which corresponds to a reading of 450 on your pot. So that is where the arm will go. If that is not the behavior you want, then you need to articulate more clearly what you are trying to accomplish. For example, if you want the controller to hold the arm in a given position once you have moved it to where you want it to be with the joystick, then you could do something like the following: change the code so that it uses the joystick value for the setpoint only if Button1 is pressed. When Button1 is released, the joystick is ignored and the last joystick value continues to be used for the setpoint. So the driver holds Button1 pressed while he is moving the joystick to put the arm in position, and once the arm is where he wants it, he releases Button1, and the controller will hold the arm at that position, and he can let go of the joystick. When he wants to change the arm position, he holds Button1 pressed and uses the joystick to move the arm to the new position, and then releases Button1. Or perhaps there is a small set of pre-defined positions from among which you would like to be able to select. For example: floor, level1, level2, level3. You could program 4 buttons so that each button changes the setpoint to the necessary value. The closed-loop controller then moves the arm to that setpoint. In this case, you could dispense with the "m" and "b" constants, and just assign a pot-value setpoint to each of the buttons. |
Re: PID Loops
Quote:
I already have the four presets that the operator can use, but the only difference is that I'm only using a P loop to reach that target. It works beautifully and doesn't oscillate. The only drawback is that its only accurate to +-5 pot values. But I compensate by increasing the desired value by 5 pot increments that way it gets as close to the target as possible going one way... I didn't really implement I and D because for one, I didn't really know how to use them and secondly, I didn't really have enough time to learn and implement it on the robot to yield some positive results. Thank you! |
Re: PID Loops
Quote:
|
Re: PID Loops
Quote:
|
| All times are GMT -5. The time now is 23:40. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi