|
I'm not sure if this is exactly what you want to do, but it sounds like the movement is too sensitive - if you put the joystick suddenly full foward, it just shoot up; the drivers need to be more gentle with it, but it's kinda hard under pressure. Do I have that right?
If thats so, my team solved it not using PIDs (we have no idea what they are), but adding 'lag' to it. Basically our program works like this.
Say during one cycle, the input is 128. The driver gets a bit excited, and shoots up to 254. Our robot would normally just shoot off, and this is damaging to our motors, so we added some lag.
Basically during the first cycle, it saves the pwm output from the joystick to a variable - call it last_pwm. During the next cycle, it gets the difference between last_pwm and the current_input. If this input is greater than a max_move variable (we have it set for 10, but this is the tweaking part), the output to the pwm is the current_input + max_move. Else, the output is the input.
So, back to our scenario. Say during cycle 1, the input is 128. During cycle 2, the input is suddenly 254. The program calculates the difference, sees that delta_input is greater than max_move, so it outputs 128 + max_move to the pwm.
Cycle 1 - input = 128, last_pwm is set to 128
Cycle 2 - input = 254, last_pwm = 128, delta_input = 126, 126 > max_move, so pwm = last_pwm + max_move, or 138 (and last_pwm is set to 138)
Next cycle the output to the pwm would be 148
Then 158
Then 168
...
Then 148
Then delta_input is less than max_move, so output to the pwm = 254.
This makes your motor respond slower to the input by adding a bit of lag to it if the difference is too high. So instead of going right from 128 to 254, it increments by 10 every cycle until it reaches 254 (the 10 part should be adjusted depending how long your code is, and so, how long it takes to execute one cycle) Hope you see what we did - if you decide to do it this way and need some help writing the code, just ask
|