View Single Post
  #15   Spotlight this post!  
Unread 14-02-2011, 13:15
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,563
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Acceleration based on position

Quote:
Originally Posted by umangv620 View Post
I tried implementing Mark's example and my encoder into the code, and got this: http://img687.imageshack.us/img687/4504/photodtz.jpg (sorry for the bad screenshot).

There is a (-x) on Joystick 2 axis 2 because going forward gives -1 for some reason, and we have no clue how to calibrate the logitech attack 3 joysticks. It shouldn't change anything in the code, right?

When I deployed this and clicked enable on DS, the elevator suddenly started moving up, and about halfway, it started jerking down and up. By then I rushed to click disable, but no one was moving the joystick during the deployment. Why did the elevator start moving on its own? Since the joystick wasn't moving, its value was 0, and the encoder reset its value to 0 when I clicked enable, so it shouldnt move, right?

Or did I miss something while coding the PID? (Wasn't really sure what the 3,0,0 for PID meant in mark's code, so I just tried using 1 and keeping it simple).
It sounds like you have two separate issues. The first is defining the setpoint, which other people have addressed.

The second problem is the tuning of the PID constants. I recommend that you read PID without a PHD. Your problem is that your P constant is too high. With a P constant of 1, if your encoder is 1 tick away from your setpoint, the motor would be going full speed and blow right past the setpoint. When it gets 1 tick away the other direction, it would reverse direction full speed. This causes the oscillation that you see. If instead you made the P constant be 0.1, then 10 ticks away it would be full speed, but 5 ticks away it would be half speed. Think about how far away you think the elevator should start to slow down, and you can figure out an approximate value for P. From there, you will probably need to experimentally change the value so that it behaves the way you want.
Reply With Quote