View Single Post
  #15   Spotlight this post!  
Unread 14-02-2011, 18:41
umangv620 umangv620 is offline
Programming Captain
AKA: Umang
FRC #1403 (Cougar Robotics)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2008
Location: New Jersey
Posts: 80
umangv620 will become famous soon enoughumangv620 will become famous soon enough
Re: Acceleration based on position

Since I can't really use PIDs to slow down the motor when it reaches either limit, and allow free control of the motor through joystick otherwise, I tried another method that doesnt involve PIDs or case structures.

I made a function f(x) = .2 + .8sin(pi*x/1000) , and am using this to control the motor. X is an input that has the value of the encoder's position, and f(x) is multiplied with the joystick axis value to get the motor speed. When the position is near either limit, it will have a minimum speed of .2, allowing the motor to still move, yet not overshoot too badly that will cause harm. When it is not in the middle, it has a higher motor speed, allowing the motor to move from one side to the other as fast as it can.

I have that code combined with the limit switch code (using encoders) so that the elevator can't keep going up when it hits the top limit, and vice versa for the bottom. This code should technically work, right?
__________________
Team 1403 Cougar Robotics

2009-2011 Programming Captain

2010
NJ-Regional - Chairmans Award
Reply With Quote