View Single Post
  #11   Spotlight this post!  
Unread 05-03-2015, 22:38
nighterfighter nighterfighter is offline
1771 Alum, 1771 Mentor
AKA: Matt B
FRC #1771 (1771)
Team Role: Mentor
 
Join Date: Sep 2009
Rookie Year: 2007
Location: Suwanee/Kennesaw, GA
Posts: 835
nighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant future
Re: Limit speed of 4 chassis CIM motors

Quote:
Originally Posted by GeeTwo View Post
Limiting acceleration using encoders would require writing some code to calculate the acceleration from the speed (just the change in speed divided by the elapsed time). I don't know of any libraries to do this, so unless you have some experienced programmers, you probably wouldn't want to attempt it at this late date.
I know what we used in previous years, on the cRIO using C++, we had a 2-speed transmission with automatic shifting, based on the speed, but we also used the timer class to prevent us from rapidly shifting from high to low gear within a certain period of time.

Code:
double time = GetTime();
double left_dist = leftSide.GetDistance();
double right_dist = -rightSide.GetDistance();
double left_rate = (left_dist - leftPrevDist) / (time- leftPrevTime);
double right_rate = (right_dist - rightPrevDist) / (time - rightPrevTime);
leftPrevDist = left_dist;
rightPrevDist = right_dist;
leftPrevTime = time;
rightPrevTime = time;
//printf("left: %f, right: %f, Speed! %f\n", left_rate, right_rate, absd((left_rate + right_rate) / 2));
if (!HighGear && absd((left_rate + right_rate) / 2) > 3.7) {
shift.Set(true);
HighGear = true;
} else if (HighGear && absd((left_rate + right_rate) / 2) < 2) {
shift.Set(false);
HighGear = false;
}
That's the relevant portion of what we did in 2011, and 2012. It was placed inside of our main tele-op loop.
The "shift" object was a solenoid, that shifted the pnuematic shifter in the gearbox.


While there probably isn't a library to do that, writing the code for it shouldn't be too difficult. (You could probably just modify that to do what you need it to...)
__________________
1771- Programmer, Captain, Drive Team (2009-2012)
4509- Mentor (2013-2015)
1771- Mentor (2015)