View Single Post
  #1   Spotlight this post!  
Unread 25-01-2008, 14:16
billbo911's Avatar
billbo911 billbo911 is offline
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,356
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
MPLAB syntax error?? No Way!!

OK, I am no programming Guru, so I am asking for help.
I am coding a simple torque limiting function. I have very carefully checked my work, yet when I "Build All", MPLAB says I made a Syntax error. When I comment out the entire function, the error goes away. Please take a look at it and comment to your hearts content. The error is on line 111, which is where my first "if" takes place.

Code:
 /******************************************************** ****************************
*	Function name: Torque_Limit
*
*	Purpose: Reduce max torque to allow smoother driving transitions
*
*	Called from: autonomous./Autonomous(), and teleop.c/Teleop()
*
*	Arguments:	Target value from code or joystick, Previous value of pwm,
*   Max change (MAXTORQUE). DO NOT FORGET TO STORE FINAL PWM VALUE TO CORRECT 
*   VARIABLE (lastpwmXX) WHEN RETURNED!!!
*
*	Returns:	(int) pwm value
*
*
**************************************************************************************/
int Torque_Limit (int target, int previous)
{
	int setpmw;
	if((target - previous) > MAXTORQUE)
	{
		setpwm = (previous + MAXTORQUE);
	}
	else if((previous - target) > MAXTORQUE)
	{
		setpwm = (previous - MAXTORQUE);
	}
	else
	{
		setpwm = target;
	}
	return setpwm;
}
See the screen shot for the error.
Attached Thumbnails
Click image for larger version

Name:	mplab_error.JPG
Views:	230
Size:	48.9 KB
ID:	6135  
__________________
CalGames 2009 Autonomous Champion Award winner
Sacramento 2010 Creativity in Design winner, Sacramento 2010 Quarter finalist
2011 Sacramento Finalist, 2011 Madtown Engineering Inspiration Award.
2012 Sacramento Semi-Finals, 2012 Sacramento Innovation in Control Award, 2012 SVR Judges Award.
2012 CalGames Autonomous Challenge Award winner ($$$).
2014 2X Rockwell Automation: Innovation in Control Award (CVR and SAC). Curie Division Gracious Professionalism Award.
2014 Capital City Classic Winner AND Runner Up. Madtown Throwdown: Runner up.
2015 Innovation in Control Award, Sacramento.
2016 Chezy Champs Finalist, 2016 MTTD Finalist