Go to Post Of course, the banana might mean nothing. It could just mean that Dave needs more potassium in his diet. :) - KathieK [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, 16:23
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is offline
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,673
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.
  #2   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).
  #3   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).
  #4   Spotlight this post!  
Unread 26-02-2005, 17:36
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is offline
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,673
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

the new error is because ceil and pow aren't really defined as anything, I'm sure.

and my mistake, it's been a while since I've really programmed. I meant the library path should be set to c:\mcc18\lib and look in that folder and make sure there's a math.c file and it has the proper functions.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
  #5   Spotlight this post!  
Unread 26-02-2005, 17:36
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

Quote:
Originally Posted by amateurrobotguy
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?

Those two lines that you added are exactly what would have been in math.h. Unfortunatly you also need the actual code of the functions. The way libraries usually work in c is that you have a .h file that tells the compiler all the functions and variables defined in the library, and you have a .o file which contains the compiled code. The way a compiler works is that it takes code and then terns each file into a .o file. The .o file contains "object code". The oject code is an intermediary step between the source code and the actual .hex file. The linker then combines all the .o files into one .hex file. The error that you're getting now is because the compiler does sees all the definitions and compiles the user_routines file assuming that the ceil and pow functions exist. When the linker tries to link the object files though, it doesn't find the actual code for the ceil and pow functions. In order for this to work you have to make it so that MPLAB uses math.o as part of the project and links it in along with your code. Alternativly, you can find the source code to math.o, which would be math.c, and compile it as part of your project. Then the compiler would first compile math.c into a new math.o, and then the linker coud use that to create the .hex file.
__________________
--------------------------------------
Alex
President
Team 1072 Harker Robotics
  #6   Spotlight this post!  
Unread 26-02-2005, 17:42
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

What do I need to put in math.c to get my 2 functions to work?
__________________
I quit FRC over 2 years ago (more if you're reading this past 2010).

Last edited by amateurrobotguy : 26-02-2005 at 19:17.
  #7   Spotlight this post!  
Unread 26-02-2005, 19:31
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 I made a tiny bit of progress in finding a math.c Only problem is, I get this error.

Make: The target "D:\Robot\MyFiles\main.o" is up to date.
Make: The target "D:\Robot\MyFiles\user_SerialDrv.o" is up to date.
Make: The target "D:\Robot\MyFiles\user_routines.o" is up to date.
Make: The target "D:\Robot\MyFiles\user_routines_fast.o" is up to date.
Make: The target "D:\Robot\MyFiles\printf_lib.o" is up to date.
Make: The target "D:\Robot\MyFiles\ifi_utilities.o" is up to date.
Make: The target "D:\Robot\MyFiles\ifi_startup.o" is up to date.
Make: The target "D:\Robot\MyFiles\math.o" is out of date.
Executing: "D:\Robot\mcc18\bin\mcc18.exe" -p=18F8520 "math.c" -fo="math.o" /i"D:\Robot\mcc18\h" -D_FRC_BOARD -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
D:\Robot\MyFiles\math.c:65:Error [1302] old style function declarations not supported
Halting build on first failure as requested.
BUILD FAILED: Sat Feb 26 16:30:19 2005
Attached Files
File Type: c math.c (1.9 KB, 45 views)
__________________
I quit FRC over 2 years ago (more if you're reading this past 2010).
  #8   Spotlight this post!  
Unread 26-02-2005, 21:11
ace123's Avatar
ace123 ace123 is offline
Registered User
AKA: Patrick Horn
FRC #0008 (Paly Robotics - http://robotics.paly.net/)
Team Role: Programmer
 
Join Date: Feb 2005
Rookie Year: 2004
Location: Palo Alto, CA
Posts: 50
ace123 has a spectacular aura aboutace123 has a spectacular aura about
Send a message via AIM to ace123
Re: ERROR

First of all, I would HIGHLY recommend writing and using your own functions.

Are you using floating point powers (6^2.5) or only integers(6^3).

If you are using integer powers then it would be very easy to write your own function:
Code:
long powl(long y, int x) {
    long result=1;
    int i;
    for (i=0;i<x;++i) {
        result*=y;
    }
    return result;
}
(make sure to call a different name like powl instead of pow to avoid conflicts.)

That is much faster and better than using a function with floating point numbers (doubles), which are bad to use on these microprocessors and which one has little reason to use.

------------------------
Now, to answer your question about the hard way to do this:
The "old style" functions are when you do:
Code:
double pow(y,x)
double y, x;
{
    ...
}
The way to fix it is to change math.c:
Code:
double pow(double y,double x)
{
...
}
Do the same thing with ceil at line 71:
Code:
double ceil(double x)
{
...
}
__________________
-Patrick Horn, Paly Robotics

Check out the space simulator called Vega Strike, modelled after the space simulator games Elite and Wing Commander. It's Open Source too!
If you have ever played Wing Commander, or especially Privateer, and had a feeling of nostalga derived from the you will enjoy these two Vega Strike mods: Privateer Gemini Gold and Privateer Remake!
I'm working on adding multiplayer support this year...
  #9   Spotlight this post!  
Unread 26-02-2005, 23:24
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

Unfortunately, I have to use floating point ^??. If I don't, my accuracy goes WAY WAY down. Even with 4 decimal place accuracy I am still .5 off from my target.
Ok, I figured the cause of the error(unposted .h problem) was the same thing with the .h file. I just got rid of the file because the .c should do everything that the .h would. Here is the new error:

Make: The target "D:\Robot\MyFiles\main.o" is up to date.
Make: The target "D:\Robot\MyFiles\user_SerialDrv.o" is up to date.
Make: The target "D:\Robot\MyFiles\user_routines.o" is out of date.
Executing: "D:\Robot\mcc18\bin\mcc18.exe" -p=18F8520 "user_routines.c" -fo="user_routines.o" /i"D:\Robot\mcc18\h" -D_FRC_BOARD -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
Make: The target "D:\Robot\MyFiles\user_routines_fast.o" is up to date.
Make: The target "D:\Robot\MyFiles\printf_lib.o" is up to date.
Make: The target "D:\Robot\MyFiles\ifi_utilities.o" is up to date.
Make: The target "D:\Robot\MyFiles\ifi_startup.o" is up to date.
Make: The target "D:\Robot\MyFiles\MATH.o" is out of date.
Executing: "D:\Robot\mcc18\bin\mcc18.exe" -p=18F8520 "MATH.C" -fo="MATH.o" /i"D:\Robot\mcc18\h" -D_FRC_BOARD -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
90: I_PSTINCFRAM
90: I_IND32RAM16
90: I_MEMBERRAM16
90: I_INDXRAM16
90: I_IND16RAM16
90: I_IDSTK(zp)
D:\Robot\MyFiles\MATH.C:126:Fatal [100] -internal- unable to reduce tree:
Halting build on first failure as requested.
BUILD FAILED: Sat Feb 26 20:22:05 2005
__________________
I quit FRC over 2 years ago (more if you're reading this past 2010).

Last edited by amateurrobotguy : 26-02-2005 at 23:26.
  #10   Spotlight this post!  
Unread 26-02-2005, 23:35
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

Quote:
Originally Posted by amateurrobotguy
I think I made a tiny bit of progress in finding a math.c Only problem is, I get this error.

Make: The target "D:\Robot\MyFiles\main.o" is up to date.
Make: The target "D:\Robot\MyFiles\user_SerialDrv.o" is up to date.
Make: The target "D:\Robot\MyFiles\user_routines.o" is up to date.
Make: The target "D:\Robot\MyFiles\user_routines_fast.o" is up to date.
Make: The target "D:\Robot\MyFiles\printf_lib.o" is up to date.
Make: The target "D:\Robot\MyFiles\ifi_utilities.o" is up to date.
Make: The target "D:\Robot\MyFiles\ifi_startup.o" is up to date.
Make: The target "D:\Robot\MyFiles\math.o" is out of date.
Executing: "D:\Robot\mcc18\bin\mcc18.exe" -p=18F8520 "math.c" -fo="math.o" /i"D:\Robot\mcc18\h" -D_FRC_BOARD -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
D:\Robot\MyFiles\math.c:65:Error [1302] old style function declarations not supported
Halting build on first failure as requested.
BUILD FAILED: Sat Feb 26 16:30:19 2005


The error is on line 65 ("return(zp->d);"), so I would guess the mplab compiler doesn't support return(a). Try changing the return statement to "return zp->d;"


As is implied above though, using this function may not be a good idea. The pow function is not intended for small imbedded microprocessors and relies heavilly on floating point operations. It is designed for a full size computer. Running this function on the robot controller will slow it down a lot. You can try it and see if anything weird happens, but I would try and find another way to solve the problem, if possible. When you try it, watch out for weird behavior of the robot, that is a good indication that you are putting too many operations into the 26ms loop.
__________________
--------------------------------------
Alex
President
Team 1072 Harker Robotics
  #11   Spotlight this post!  
Unread 26-02-2005, 23:56
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 don't think that that is my problem. When I follow your suggestion at the end of the two functions I get this error:. (See my latest post) The line error is the last line of math.c. In the previous and this error, Line 126 is the problem

Make: The target "D:\Robot\MyFiles\main.o" is up to date.
Make: The target "D:\Robot\MyFiles\user_SerialDrv.o" is up to date.
Make: The target "D:\Robot\MyFiles\user_routines.o" is up to date.
Make: The target "D:\Robot\MyFiles\user_routines_fast.o" is up to date.
Make: The target "D:\Robot\MyFiles\printf_lib.o" is up to date.
Make: The target "D:\Robot\MyFiles\ifi_utilities.o" is up to date.
Make: The target "D:\Robot\MyFiles\ifi_startup.o" is up to date.
Make: The target "D:\Robot\MyFiles\MATH.o" is out of date.
Executing: "D:\Robot\mcc18\bin\mcc18.exe" -p=18F8520 "MATH.C" -fo="MATH.o" /i"D:\Robot\mcc18\h" -D_FRC_BOARD -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
D:\Robot\MyFiles\MATH.C:126:Warning [2054] suspicious pointer conversion
Assertion failed: 0, file trn18.c, line 2783

abnormal program termination
Halting build on first failure as requested.
BUILD FAILED: Sat Feb 26 20:54:17 2005
__________________
I quit FRC over 2 years ago (more if you're reading this past 2010).
  #12   Spotlight this post!  
Unread 27-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
Re: ERROR

Hasn't anyone used ceil() or floor or pow()? I just need a math.c with the definitions for C18 compiler or a header or something.
__________________
I quit FRC over 2 years ago (more if you're reading this past 2010).
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 04:38.

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