|
|
|
| My love spiders out in a web of emotions when I think of you. |
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Problem With Math.h
Hi all, was wondering if anyone could help me out with a problem I'm having:
I am trying to use Math.h for a few trig functions to be processed in the controller, and my program compiles perfectly fine, but immediately upon completing the upload to the RC, an ERROR text pops up with just hex symbols, and I get a code error led. This only happens when I try to use trig functions from Math.h such as tan(), asin(), etc. I thought at first it was a memory overflow of some sort but I seem to have plenty of memory left (I think). Note that this happens immediately after I upload the code, before its run (aka doesnt occur due to a runtime error from an invalid input value). Any help would be appreciated... |
|
#2
|
|||||
|
|||||
|
Re: Problem With Math.h
http://www.chiefdelphi.com/forums/sh...ad.php?t=42790
Your program is too big for last years' IFI_Loader to handle. Update it to v1.1.0 here: http://www.ifirobotics.com/rc.shtml#Programming |
|
#3
|
|||||
|
|||||
|
Re: Problem With Math.h
I usually see this when the data memory gets too full.
You can test by temporarily commenting out any large array declarations you might have just to see if it loads into the RC. |
|
#4
|
||||
|
||||
|
Re: Problem With Math.h
I am using the latest version of IFI_Loader and have been connecting great with it, except for this one error when using trig functions. Also, I have tried commenting out just this single line and the code uploads perfectly, even when I add a bunch of extra memory-wasting arrays
|
|
#5
|
|||||
|
|||||
|
Re: Problem With Math.h
Look in the ChiefDelphi whitepapers for something about CORDIC - it's an integer-valued trig library that not only will solve your code size woes, but is faster too (since the PIC doesn't have a hardware FPU).
|
|
#6
|
||||
|
||||
|
Re: Problem With Math.h
Thanks, I found the CORDIC library and will test it tonight, but it appears that the function doesnt handle asin(). Do you know of any library extensions based on this library that would handle this?
|
|
#7
|
|||||
|
|||||
|
Re: Problem With Math.h
Well my first comment (question actually) would be, why could you possibly need asin()??? I'm assuming this is for range estimation, in which case atan() makes more sense, to me at least.
Secondly, CORDIC can by design do asin() - you need to slightly modify the code to get it to work, however. Use the identity: asin(x) = atan(x/sqrt(1-x*x)) |
|
#8
|
|||||
|
|||||
|
Re: Problem With Math.h
One other thing - if you look at the CORDIC implementation in the white papers, you can actually improve its performance twofold if you need both the sin() and cos() of an angle.
It actually calculates both simultaneously, but in the current design it discards whichever you don't need. Pass arguments by pointers into the function and you can get both at once. |
|
#9
|
|||||
|
|||||
|
Re: Problem With Math.h
Quote:
|
|
#10
|
||||
|
||||
|
Re: Problem With Math.h
All of the math.h functions need a huge code space, because there are a bunch of long floating point #defines.
|
|
#11
|
||||
|
||||
|
Re: Problem With Math.h
Oops, sorry about that everyone. I was using what I THOUGHT was the new 2006 version, because I installed v1.0.10 to learn the controls on last year's bot, but downloaded v1.0.12 to connect to this year's. Anyway I installed v1.1 and it seems to work fine now.
By the way, for anyone else who is using tan(CameraAngle) to determine horizontal distance to the target using the stock camera mount, do you get decently accurate results? When the light is decently far away, 1 change in servo tilt value obviously equals a much greater change in reported distance. I am thinking of using a different servo with more steps... |
|
#12
|
||||
|
||||
|
Re: Problem With Math.h
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need a realistic Statics Problem | sanddrag | Technical Discussion | 10 | 05-12-2005 15:07 |
| Strange Encoder Problem | AIBob | Electrical | 3 | 20-02-2005 22:20 |
| Programming Problem: Extremely Frustrating | chantilly_team | Programming | 19 | 12-02-2005 23:00 |
| The problem with scouting... | archiver | 2001 | 10 | 23-06-2002 23:49 |
| Major problem with chipphua motors | aka Scott White | Motors | 18 | 19-03-2002 19:44 |