View Single Post
  #5   Spotlight this post!  
Unread 12-02-2007, 14:33
benhulett benhulett is offline
Registered User
FRC #1895
 
Join Date: Feb 2007
Location: Manassas
Posts: 28
benhulett is on a distinguished road
Re: Incrementation Code not working

Quote:
Originally Posted by Joe Ross
You don't set RetVal in all branches of your function.
Quote:
Originally Posted by EHaskins
Joe Ross is right.
Code:
//Accelerate
	if (change > max_step)
    {
      RetVal = motor_prev + max_step;
      printf("Motor accelerated by MAX = %d.  ", max_step);
	}
    else
    {
      printf("Motor accelerated by %d.  ", change);
      RetVal = motor_prev + change;
    }
.....

    //Decelerate
    if (change < -max_step)
    {
      RetVal = motor_prev - max_step;
      printf("Motor decelerated by MAX = %d.  ", max_step);
    }
    else
    {
      printf("Motor decelerated by %d.  ", change);
      RetVal = motor_prev - change;
    }

I can't believe we didn't notice that Thanks for the help! I'll be sure to test that when I get the chance tonight.