Go to Post CAD is the oxygen for engineering. - Bharat Nain [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 26-02-2005, 14:27
amateurrobotguy's Avatar
amateurrobotguy amateurrobotguy is offline
Lead Programmer/Senior Engineer
no team
 
Join Date: Feb 2005
Rookie Year: 2000
Location: ****
Posts: 136
amateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these parts
ERROR

I define like this

void Default_Routine(void)
{
long reduction;
double para;
long nodecimalpara;
long reduction2;
double para2;
long nodecimalpara2;

and get this:

D:\Robot\MyFiles\user_routines.c:239:Error [1105] symbol 'redeuction' has not been defined
D:\Robot\MyFiles\user_routines.c:246:Warning [2058] call of function without prototype
D:\Robot\MyFiles\user_routines.c:247:Warning [2058] call of function without prototype
D:\Robot\MyFiles\user_routines.c:252:Error [1105] symbol 'redeuction2' has not been defined
D:\Robot\MyFiles\user_routines.c:259:Error [1139] integer types required for bitwise XOR operator
D:\Robot\MyFiles\user_routines.c:260:Warning [2058] call of function without prototype
__________________
I quit FRC over 2 years ago (more if you're reading this past 2010).
  #2   Spotlight this post!  
Unread 26-02-2005, 14:29
Alex1072 Alex1072 is offline
Registered User
AKA: Alex
#1072 (Harker Robotics Team)
Team Role: Leadership
 
Join Date: Jan 2003
Rookie Year: 2003
Location: San Jose
Posts: 110
Alex1072 is an unknown quantity at this point
Send a message via AIM to Alex1072 Send a message via Yahoo to Alex1072
Re: ERROR

There's nothing that I can see in your code that should be causing those errors. It would help if you posted the rest of the function.

EDIT: After looking at it again, it looks like you spelled reduction differently from how you declared it:

D:\Robot\MyFiles\user_routines.c:239:Error [1105] symbol 'redeuction' has not been defined

The symbol 'redeuction' has not been defined, only 'reduction' has been.

Also, for this error:
D:\Robot\MyFiles\user_routines.c:259:Error [1139] integer types required for bitwise XOR operator

the 'a^b' in C/C++/java is not actually a to the power of b. It's the XOR operator.

if you have two binary integers: a = 1011, b= 1101, a^b would be: 0110. XOR compares each binay digit of a with the corresponding digit of b. If the digits are different, a 1 is placed as the corresponding digit of the result, if they are the same, a 0 is placed.

If you need to do something like a^2, you should just do a*a. If you need actual exponentials then you have to use math.h or write your own function. If you use the c math library, pow(a, b) = a to the bth power.

EDIT #2: fixed the name of the power function
__________________
--------------------------------------
Alex
President
Team 1072 Harker Robotics

Last edited by Alex1072 : 26-02-2005 at 14:56.
  #3   Spotlight this post!  
Unread 26-02-2005, 14:36
amateurrobotguy's Avatar
amateurrobotguy amateurrobotguy is offline
Lead Programmer/Senior Engineer
no team
 
Join Date: Feb 2005
Rookie Year: 2000
Location: ****
Posts: 136
amateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these parts
Re: ERROR

Ok, I will post my function...but where you see ???? it means the number has been editied out for secrecy purposes. BTW with the spelling fixed I still get :
D:\Robot\MyFiles\user_routines.c:242:Warning [2058] call of function without prototype
D:\Robot\MyFiles\user_routines.c:243:Warning [2058] call of function without prototype
D:\Robot\MyFiles\user_routines.c:255:Warning [2058] call of function without prototype
D:\Robot\MyFiles\user_routines.c:256:Error [1105] symbol 'nodecimalparatwo' has not been defined
D:\Robot\MyFiles\user_routines.c:256:Warning [2058] call of function without prototype
D:\Robot\MyFiles\user_routines.c:256:Error [1101] lvalue required
D:\Robot\MyFiles\user_routines.c:257:Error [1105] symbol 'nodecimalparatwo' has not been defined

#include "ifi_aliases.h"
#include "ifi_default.h"
#include "ifi_utilities.h"
#include "user_routines.h"
#include "printf_lib.h"
#include "user_Serialdrv.h"
#include <math.h>

...
void Default_Routine(void)
{
long reduction, nodecimalpara, reductiontwo, nodecomal, paratwo;
double para, para2;

/*---------- Analog Inputs (Joysticks) to PWM Outputs-----------------------
*--------------------------------------------------------------------------
* This maps the joystick axes to specific PWM outputs.
*/
reduction=p1_y-?;
if (reduction>=0)
{
}
else
{
reduction=reduction*-1;
}
para=((pow(reduction, ?)/?)+?);
nodecimalpara=ceil(para);
pwm01 = nodecimalpara;


reductiontwo=p2_y-?;
if (reductiontwo<=0)
{
reductiontwo=reductiontwo*-1;
}
else
{
}
paratwo=((pow(reductiontwo, ?/?)+?);
nodecimalparatwo=ceil(paratwo);
pwm02 = nodecimalparatwo;
__________________
I quit FRC over 2 years ago (more if you're reading this past 2010).

Last edited by amateurrobotguy : 26-02-2005 at 15:03.
  #4   Spotlight this post!  
Unread 26-02-2005, 14:55
Alex1072 Alex1072 is offline
Registered User
AKA: Alex
#1072 (Harker Robotics Team)
Team Role: Leadership
 
Join Date: Jan 2003
Rookie Year: 2003
Location: San Jose
Posts: 110
Alex1072 is an unknown quantity at this point
Send a message via AIM to Alex1072 Send a message via Yahoo to Alex1072
Re: ERROR

D:\Robot\MyFiles\user_routines.c:242:Warning [2058] call of function without prototype
D:\Robot\MyFiles\user_routines.c:243:Warning [2058] call of function without prototype
D:\Robot\MyFiles\user_routines.c:255:Error [1139] integer types required for bitwise XOR operator
D:\Robot\MyFiles\user_routines.c:256:Error [1105] symbol 'nodecimalparatwo' has not been defined
D:\Robot\MyFiles\user_routines.c:256:Warning [2058] call of function without prototype
D:\Robot\MyFiles\user_routines.c:256:Error [1101] lvalue required
D:\Robot\MyFiles\user_routines.c:257:Error [1105] symbol 'nodecimalparatwo' has not been defined

If you look at the numbers after the name of the file: 243, 243, 255, 256, etc. The compiler tells you on which line the error is happening. Since I don't know the exact line numbers i'm not sure if this is the actual cause of the errors, but:

nodecimalparatwo is not defined, you should look at the variable declaration at the top of your function and make sure you don't use any variables that you do not declare.

The 'call of function without declaration' errors are happening because of the pow and ceil functions. These functions are provided in math.h, and are the correct names (http://www.opengroup.org/onlinepubs/...sh/math.h.html), but in order to use them you have to let the compiler know that you're going to be using the math.h library. In order to do that you have to put this line at the top of your file next to the other similar ones:
Code:
#include <math.h>
This will tell the compiler about all the functions that are in the math.h library so that it knows that they exist. The #include command tells the compiler to process the file "math.h" as if it were pasted into the begining of your file. The math.h file has all the declarations that the default c math library needs in order to work, including declarations of the pow and ceil functions you are trying to use.
__________________
--------------------------------------
Alex
President
Team 1072 Harker Robotics
  #5   Spotlight this post!  
Unread 26-02-2005, 15:01
amateurrobotguy's Avatar
amateurrobotguy amateurrobotguy is offline
Lead Programmer/Senior Engineer
no team
 
Join Date: Feb 2005
Rookie Year: 2000
Location: ****
Posts: 136
amateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these parts
Re: ERROR

Ok, I fixed my definitions, but I am still getting the w/o prototype error. I did put the math.h here: It gives me the errors, then compiles further, but gives me build failed.

/************************************************** *****************************
* FILE NAME: user_routines.c <FRC VERSION>
*
* DESCRIPTION:
* This file contains the default mappings of inputs
* (like switches, joysticks, and buttons) to outputs on the RC.
*
* USAGE:
* You can either modify this file to fit your needs, or remove it from your
* project and replace it with a modified copy.
*
************************************************** *****************************/

#include "ifi_aliases.h"
#include "ifi_default.h"
#include "ifi_utilities.h"
#include "user_routines.h"
#include "printf_lib.h"
#include "user_Serialdrv.h"
#include <math.h>
__________________
I quit FRC over 2 years ago (more if you're reading this past 2010).
  #6   Spotlight this post!  
Unread 26-02-2005, 15:14
amateurrobotguy's Avatar
amateurrobotguy amateurrobotguy is offline
Lead Programmer/Senior Engineer
no team
 
Join Date: Feb 2005
Rookie Year: 2000
Location: ****
Posts: 136
amateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these parts
Re: ERROR

I think my math.h file might be bad. See the attachment with it. It doesn't have anything in it.
Attached Files
File Type: h math.h (2.2 KB, 47 views)
__________________
I quit FRC over 2 years ago (more if you're reading this past 2010).
  #7   Spotlight this post!  
Unread 26-02-2005, 15:18
Alex1072 Alex1072 is offline
Registered User
AKA: Alex
#1072 (Harker Robotics Team)
Team Role: Leadership
 
Join Date: Jan 2003
Rookie Year: 2003
Location: San Jose
Posts: 110
Alex1072 is an unknown quantity at this point
Send a message via AIM to Alex1072 Send a message via Yahoo to Alex1072
Re: ERROR

I've never actually used math.h in MPLAB, so I can't really say much. My math.h file is exactly the same though. For ceiling you could easilly write your own function; power is harder if you want it to support non-integer exponents. Anyone else have any suggestions? Is there a way to use math.h in mplab?
__________________
--------------------------------------
Alex
President
Team 1072 Harker Robotics
  #8   Spotlight this post!  
Unread 26-02-2005, 15:19
amateurrobotguy's Avatar
amateurrobotguy amateurrobotguy is offline
Lead Programmer/Senior Engineer
no team
 
Join Date: Feb 2005
Rookie Year: 2000
Location: ****
Posts: 136
amateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these parts
Re: ERROR

Anyone have a good copy of math.h with all the math functions?
__________________
I quit FRC over 2 years ago (more if you're reading this past 2010).
  #9   Spotlight this post!  
Unread 26-02-2005, 16:23
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is online now
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,597
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
Re: ERROR

math.h is just a header file. header files typically don't contain any code, they just have compiler directives in case that library needs other includes, etc. The actual code will be in a math.c file in a libraries folder or something. I'm afraid I can't tell you for certain because I'm not at a computer with the compiler at the moment. At any rate, either you're missing math.c or it's corrupted, or someone's fiddled with compiler settings and you aren't pointing the compiler to the proper library folder anymore.

EDIT:
From a brief perusal, I note that the include folder should be c:\mcc18\lib
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter

Last edited by Kevin Sevcik : 26-02-2005 at 16:34.
  #10   Spotlight this post!  
Unread 26-02-2005, 17:08
amateurrobotguy's Avatar
amateurrobotguy amateurrobotguy is offline
Lead Programmer/Senior Engineer
no team
 
Join Date: Feb 2005
Rookie Year: 2000
Location: ****
Posts: 136
amateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these parts
Re: ERROR

First, if the include isn't set to the /h section, it will error with no adc.h found.
Can anyone explain the procedure for getting ceil() and pow() to work. I don't mind if its a header or a c file or manually program it in.
__________________
I quit FRC over 2 years ago (more if you're reading this past 2010).
  #11   Spotlight this post!  
Unread 26-02-2005, 17:26
amateurrobotguy's Avatar
amateurrobotguy amateurrobotguy is offline
Lead Programmer/Senior Engineer
no team
 
Join Date: Feb 2005
Rookie Year: 2000
Location: ****
Posts: 136
amateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these parts
Re: ERROR

I have made some progress. I got rid of all the error right down to the last lines:
MPLINK 3.40, Linker
Copyright (c) 2003 Microchip Technology Inc.
Error - could not find definition of symbol 'ceil' in file 'D:\Robot\MyFiles\user_routines.o'.
Errors : 1

All i did was this:

/************************************************** *****************************
* FILE NAME: user_routines.c <FRC VERSION>
*
* DESCRIPTION:
* This file contains the default mappings of inputs
* (like switches, joysticks, and buttons) to outputs on the RC.
*
* USAGE:
* You can either modify this file to fit your needs, or remove it from your
* project and replace it with a modified copy.
*
************************************************** *****************************/

#include "ifi_aliases.h"
#include "ifi_default.h"
#include "ifi_utilities.h"
#include "user_routines.h"
#include "printf_lib.h"
#include "user_Serialdrv.h"
#include <math.h>

extern unsigned char aBreakerWasTripped;

/*** DEFINE USER VARIABLES AND INITIALIZE tHEM HERE ***/

/* EXAMPLES: (see MPLAB C18 User's Guide, p.9 for all types)
unsigned char wheel_revolutions = 0; (can vary from 0 to 255)
unsigned int delay_count = 7; (can vary from 0 to 65,535)
int angle_deviation = 142; (can vary from -32,768 to 32,767)
unsigned long very_big_counter = 0; (can vary from 0 to 4,294,967,295)
*/
double ceil(double x);
double pow(double x, double y);

See two last lines. Am I going down the right path? If so, what is causing the error then?
__________________
I quit FRC over 2 years ago (more if you're reading this past 2010).
  #12   Spotlight this post!  
Unread 27-02-2005, 15:55
Adam Richards's Avatar
Adam Richards Adam Richards is offline
I'm baaaaaaack.
FRC #1902 (Exploding Bacon)
Team Role: College Student
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Orlando, FL
Posts: 1,062
Adam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond repute
Send a message via AIM to Adam Richards
Re: ERROR

Quote:
Originally Posted by amateurrobotguy
I define like this

void Default_Routine(void)
{
long reduction;
double para;
long nodecimalpara;
long reduction2;
double para2;
long nodecimalpara2;

and get this:

D:\Robot\MyFiles\user_routines.c:239:Error [1105] symbol 'redeuction' has not been defined
D:\Robot\MyFiles\user_routines.c:246:Warning [2058] call of function without prototype
D:\Robot\MyFiles\user_routines.c:247:Warning [2058] call of function without prototype
D:\Robot\MyFiles\user_routines.c:252:Error [1105] symbol 'redeuction2' has not been defined
D:\Robot\MyFiles\user_routines.c:259:Error [1139] integer types required for bitwise XOR operator
D:\Robot\MyFiles\user_routines.c:260:Warning [2058] call of function without prototype
Are you sure you're closing the function?
  #13   Spotlight this post!  
Unread 28-02-2005, 17:20
amateurrobotguy's Avatar
amateurrobotguy amateurrobotguy is offline
Lead Programmer/Senior Engineer
no team
 
Join Date: Feb 2005
Rookie Year: 2000
Location: ****
Posts: 136
amateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these parts
Re: ERROR

I have the definitive response from C18 tech support:

I found the functions that you refer to however they are C30 math function found in the math.h for C30 dsPICŪ Language Tools Libraries

The files you inquire about are defined in the dsPICŪ Language Tools Libraries
http://ww1.microchip.com/downloads/e...Doc/51456b.pdf

see page 332 double ceil(double x);
see page 355 double pow(double x, double y);

The functions you can use in the C18 library under math.h
MPLABŪ C18 C COMPILER LIBRARIES
http://ww1.microchip.com/downloads/e...Lib_51297d.pdf

see page 162 float ceil ( float x);
see page 165 float pow( float x, float y);

Unfortunately you cannot use the functions you refer to with C18. They are used with C30.


Basically FIRST stiffed us on the compiler...Pity...I could have made a kick-*** function if I had math access.
__________________
I quit FRC over 2 years ago (more if you're reading this past 2010).
  #14   Spotlight this post!  
Unread 28-02-2005, 17:28
Alex1072 Alex1072 is offline
Registered User
AKA: Alex
#1072 (Harker Robotics Team)
Team Role: Leadership
 
Join Date: Jan 2003
Rookie Year: 2003
Location: San Jose
Posts: 110
Alex1072 is an unknown quantity at this point
Send a message via AIM to Alex1072 Send a message via Yahoo to Alex1072
Re: ERROR

You could probably still write your own from scratch if you research how the normal computer math library (open source) does it and optimize only to do the operations you need. Also, you might want to consider using a look up table. Searching for look up tables on CD should give you quite a bit of results.
__________________
--------------------------------------
Alex
President
Team 1072 Harker Robotics
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
error with adc.h incognito_NICK Programming 2 05-02-2005 23:27
MPLink Error cloudago Programming 2 01-02-2005 23:00
MPLAB build error cabbagekid2 Programming 7 12-01-2005 13:36
PHP and Wiki Error Venkatesh Website Design/Showcase 2 24-07-2004 15:51
EMERGENCY! EPROM FULL error?!? CHSguard72 Programming 2 05-03-2003 20:51


All times are GMT -5. The time now is 20:06.

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