Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   ERROR (http://www.chiefdelphi.com/forums/showthread.php?t=35526)

ace123 26-02-2005 21:11

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)
{
...
}


amateurrobotguy 26-02-2005 23:24

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

Alex1072 26-02-2005 23:35

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.

amateurrobotguy 26-02-2005 23:56

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

amateurrobotguy 27-02-2005 14:27

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.

Adam Richards 27-02-2005 15:55

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?

amateurrobotguy 28-02-2005 17:20

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.

Alex1072 28-02-2005 17:28

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.


All times are GMT -5. The time now is 17:32.

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