Go to Post By inviting engineers and mentors to be a part of your team and partnering with them...brings added value, depth, strength, expertise, and wisdom to the team and to the overall experience. - JaneYoung [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #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,381
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:	231
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
  #2   Spotlight this post!  
Unread 25-01-2008, 14:23
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,586
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: MPLAB syntax error?? No Way!!

what is MAXTORQUE defined to?
  #3   Spotlight this post!  
Unread 25-01-2008, 14:24
mgurgol mgurgol is offline
Registered User
FRC #1094
 
Join Date: Jan 2006
Location: St Louis MO
Posts: 76
mgurgol is just really nicemgurgol is just really nicemgurgol is just really nicemgurgol is just really nicemgurgol is just really nice
Re: MPLAB syntax error?? No Way!!

you are defining setpmw, but using setpwm after the if statements
  #4   Spotlight this post!  
Unread 25-01-2008, 14:26
Tom Line's Avatar
Tom Line Tom Line is offline
Raptors can't turn doorknobs.
FRC #1718 (The Fighting Pi)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 1999
Location: Armada, Michigan
Posts: 2,534
Tom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond repute
Re: MPLAB syntax error?? No Way!!

Yep.

Is that a valid return statement? I thought it should be return(variable);
  #5   Spotlight this post!  
Unread 25-01-2008, 14:27
Roger Roger is offline
Registered User
FRC #1153
 
Join Date: Jan 2006
Rookie Year: 1900
Location: Walpole MA
Posts: 688
Roger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond repute
Re: MPLAB syntax error?? No Way!!

Silly question, but MAXTORQUE is defined globally somewhere? Hmm... is that a syntax error or something else?

If you comment out the first if thru to the else /*if .... else*/ so the else if is now an if, does the error drop down to that if or does it go away?
  #6   Spotlight this post!  
Unread 25-01-2008, 14:33
Roger Roger is offline
Registered User
FRC #1153
 
Join Date: Jan 2006
Rookie Year: 1900
Location: Walpole MA
Posts: 688
Roger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond repute
Re: MPLAB syntax error?? No Way!!

The setpwm / setpmw error will crop up after this error is fixed.

Heh. I feel like I'm on a game show, with all these answers coming back.
  #7   Spotlight this post!  
Unread 25-01-2008, 14:33
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,381
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
Re: MPLAB syntax error?? No Way!!

Quote:
Originally Posted by Joe Ross View Post
what is MAXTORQUE defined to?
Currently MAXTORQUE is defined to a value of 100 in the bob.h file. It will be modified once we experiment a little.

Quote:
Originally Posted by mgurgol View Post
you are defining setpmw, but using septum after the if statements
OK, I corrected my spelling error (thank you), but am still getting the same error for the same line of code.
__________________
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
  #8   Spotlight this post!  
Unread 25-01-2008, 14:37
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,586
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: MPLAB syntax error?? No Way!!

Quote:
Originally Posted by billbo911 View Post
Currently MAXTORQUE is defined to a value of 100 in the bob.h file. It will be modified once we experiment a little.

OK, I corrected my spelling error (thank you), but am still getting the same error for the same line of code.
Is there an include statement for bob.h in this file?

Did you put a semicolon or anything after #define MAXTORQUE 100
  #9   Spotlight this post!  
Unread 25-01-2008, 14:38
Roger Roger is offline
Registered User
FRC #1153
 
Join Date: Jan 2006
Rookie Year: 1900
Location: Walpole MA
Posts: 688
Roger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond repute
Re: MPLAB syntax error?? No Way!!

Does this c file #include the bob.h file? Or is this file bob.c? If you (temporarily) define MAXTORQUE in this file does the error go away?
  #10   Spotlight this post!  
Unread 25-01-2008, 14:39
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,381
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
Re: MPLAB syntax error?? No Way!!

Quote:
Originally Posted by Roger View Post
Silly question, but MAXTORQUE is defined globally somewhere? Hmm... is that a syntax error or something else?

If you comment out the first if thru to the else /*if .... else*/ so the else if is now an if, does the error drop down to that if or does it go away?
Yep, MAXTORQUE is defined in bob.h.

I tried the comment out as you suggested before posting the question. The error moves to the new "if" statement.
__________________
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
  #11   Spotlight this post!  
Unread 25-01-2008, 14:48
Roger Roger is offline
Registered User
FRC #1153
 
Join Date: Jan 2006
Rookie Year: 1900
Location: Walpole MA
Posts: 688
Roger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond repute
Re: MPLAB syntax error?? No Way!!

Quote:
I tried the comment out ... The error moves to the new "if" statement.
That shows that both those if statements have the same error. Probably not an imbalanced { } from above. (You can remove the /* comment */). I'm still thinking the #define MAXTORQUE isn't being seen by this file.

If you change MAXTORQUE to 100 does the error go away?

(I'm also imagining poor billbo911 running from the computer with mplab all the way across the room to the computer with internet access.)

Last edited by Roger : 25-01-2008 at 14:49. Reason: Added an idea
  #12   Spotlight this post!  
Unread 25-01-2008, 14:49
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,381
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
Re: MPLAB syntax error?? No Way!!

Quote:
Originally Posted by Roger View Post
Does this c file #include the bob.h file? Or is this file bob.c? If you (temporarily) define MAXTORQUE in this file does the error go away?
Yes, bob.h included.
No, it doesn't go away when defined locally.


Quote:
Originally Posted by Joe Ross View Post
Is there an include statement for bob.h in this file?

Did you put a semicolon or anything after #define MAXTORQUE 100
Yes, bob.h is included.
No semi-colon on definition. BUT!!!
We have a winner!!! The line looked like this "#define MAXTORQUE = 100" The equal sign killed it.

Quote:
Originally Posted by Tom Line View Post
Yep.

Is that a valid return statement? I thought it should be return(variable);
Not the problem. Tried both ways. Problem solved above!

THANK YOU EVERYONE for helping me find this problem.!!

Note to self: "=" good in variable declaration, bad in definition.
__________________
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
  #13   Spotlight this post!  
Unread 25-01-2008, 14:51
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,381
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
Re: MPLAB syntax error?? No Way!!

Quote:
Originally Posted by Roger View Post

(I'm also imagining poor billbo911 running from the computer with mplab all the way across the room to the computer with internet access.)
Luckily, I have access on 2 side by side computers. It makes this much easier!
__________________
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
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
180:Error: syntax error help! seanl Programming 8 04-02-2007 11:31
MPLAB syntax problem dpick1055 Programming 6 23-01-2007 13:28
C18 v2.4 -- Syntax error where there is no syntax error Joel J Programming 7 12-01-2007 17:27
Syntax Error! Denz Programming 15 04-02-2006 23:57


All times are GMT -5. The time now is 19:15.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi