Go to Post ...we might be able to take the 'out' out of 'outsourcing' - if we all share a strong cultural set of values, who exactly is 'out'? I think FIRST is a great way to do this, ... - Ian Mackenzie [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 22-11-2003, 12:20
ErichKeane ErichKeane is offline
Registered User
FRC #3210
Team Role: Mentor
 
Join Date: Nov 2003
Rookie Year: 2004
Location: Hillsboro, OR
Posts: 113
ErichKeane is just really niceErichKeane is just really niceErichKeane is just really niceErichKeane is just really niceErichKeane is just really nice
Send a message via AIM to ErichKeane
Space Limit--What is expendable?

My problem is this: it appears that i am reaching the limit on the EDU controller for space. It has gotten to the point where i need to comment out portions of my code to get it to even transfer.

I am able to compile it with no problem using MPlab.

When i transfer, it says opennign port, the "Erasing Device" where it stays for about 10 seconds, then, it says device not connected.

When i comment stuff out, or use less memory by using ints instead of floats, it works fine.

My real problem is that i only have the guidence program created, no autonomous control, no braking, no arms, etc. What in the default code can i get rid of? I need to recover as much space as possible so that i only use the absolute necessary code.

Any help is appreciated.
  #2   Spotlight this post!  
Unread 22-11-2003, 16:51
Sachiel7's Avatar
Sachiel7 Sachiel7 is offline
<Yes I managed to flip it
AKA: Shayne Helms
FRC #1132 (RAPTAR Robotics)
 
Join Date: Sep 2002
Rookie Year: 2002
Location: Richmond, VA
Posts: 541
Sachiel7 is just really niceSachiel7 is just really niceSachiel7 is just really niceSachiel7 is just really niceSachiel7 is just really nice
Send a message via AIM to Sachiel7
Hmm, well yes, you want to stick with as many ints as possible. The math is processed faster for them, and they take up less space.
There are a number of routines you can erase from the default code. Mainly, I would read through the Default_Routine sub and then clear it out.
Depending on your method of executing auto mode, you could be eating lots of memory. If you're doing it case-by-case with lost of IFs, or a switch or something, that needs to change. The method I use is to hold an array of movement data and then have a small piece of code that executes it. It works fine, and you can have some massive arrays too.
It also sounds like something might've gotten modified that shouldn't have...
We had someone do this on our team and we had memory problems too. We had to restart from scratch from that point.
__________________
-=Sachiel7=-

There's no such thing as being too simple!
Look for Team #1132, RAPTAR Robotics at the VCU Regional this year!
  #3   Spotlight this post!  
Unread 22-11-2003, 17:37
Dave Flowerday Dave Flowerday is offline
Software Engineer
VRC #0111 (Wildstang)
Team Role: Engineer
 
Join Date: Feb 2002
Rookie Year: 1995
Location: North Barrington, IL
Posts: 1,366
Dave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond repute
Re: Space Limit--What is expendable?

Quote:
Originally posted by ErichKeane
using ints instead of floats
You should avoid using floats if at all possible. The PIC inside the EDU controller does not support floating point math in hardware, which means that if you use floating point math, then the compiler has to include a bunch of software floating point routines. This undoubtedly takes up a lot of space and is also really slow.

Also, if you haven't done it already, get rid of the printf_lib stuff. It takes up a ton of code space for essentially a debugging function. If you remove printf_lib, you can still output stuff to the serial port, just not as nicely as with printf.
  #4   Spotlight this post!  
Unread 22-11-2003, 22:06
ErichKeane ErichKeane is offline
Registered User
FRC #3210
Team Role: Mentor
 
Join Date: Nov 2003
Rookie Year: 2004
Location: Hillsboro, OR
Posts: 113
ErichKeane is just really niceErichKeane is just really niceErichKeane is just really niceErichKeane is just really niceErichKeane is just really nice
Send a message via AIM to ErichKeane
I did delete all of the Default section as well as a few functions that were not being used. I did keep the printf section, at least for now.

I believe i figured out the problem. I did not realize that floats were not native to the chip archetecture, so, in my one line i did a cast promotion to do : pwm01=pwm02*((float)in1/127.00)

this i guess must have taken up a lot of memory, so instead i made it like this: pwm01=pwm02*in1/127, keeping it entirely integer mathematics. Shoulda thought of this in teh first place!.

I do need to do a lot of if statements for my auto control, because my team plans on using only sensors to direct the bot, instead of some pre set auto control. We feel that this will work best for the Auto at teh end setup.

And another note: which is more efficent in this chipset, the Switch statements, or nested ifs? And how do you do spanned switch cases? I know in Basic you could to Case 127 to 255, is there a similar way to do it in this langauge? And a final note, does using a void function take more processing power than incoded systems? or the same?

ETA 30 seconds later: What can i do to figure out if it takes too much memory? with the pbasic editor i had a memory chart i could pull down to see my % on program and variable memory. Is there a similar way to do this in picc? And what are the hex limits for variable space and program space as reported by IFI loader?
  #5   Spotlight this post!  
Unread 23-11-2003, 22:08
Anthony Kesich's Avatar
Anthony Kesich Anthony Kesich is offline
Programmer Turned Engineer
AKA: SonKenshin
#1097 (Site 3 Engineernig)
Team Role: Leadership
 
Join Date: Jan 2003
Rookie Year: 2003
Location: Sacramento, CA
Posts: 186
Anthony Kesich has a spectacular aura aboutAnthony Kesich has a spectacular aura about
Send a message via AIM to Anthony Kesich
limits for variable and program space are given at the innovations first webiste. As for putting ranges in the switch-case loop, to the extent of my knoledge, it cannot be done like in PBasic; you need to use some if statements. If it is just for one range and everything else is a single value, put it as a comparison in the default: tag, or as just the default tag if the situation permits. The other meathod is to create a char variable just for your switch-case loop and do some comparisons first, so it would look something like this:
Code:
char case_range
if(x<60)
{
   case_range=0;
}
else if(x<127)
{
   case_range=1;
}
else
   case_range=2;

switch(case_range)
{
   case 1:
      statements
   case 2:
      statements
   case 3:
      statements
}
And do that for however many cases you need. If you only need 2, you can even go with the whole ? : operator--case_range=(127<=x && 225>=x) ? 1 : 0.

On that note, does anybody know if you can nest the ?: operator? i.e. x=(condtion 1) ? 1 : (condition 2) ? 2 : (condition 3) ? 3 : ... (condition n) ? n : 0
__________________
C is screwing up my English--I'm ending all my sentences in semi-colons;

Horray for most things! -George Carlin

"Sure, I'll play rugby. Besides, I have a lot of experience running from really big guys who want to cream me." -Me, Freshman year
  #6   Spotlight this post!  
Unread 23-11-2003, 22:17
ErichKeane ErichKeane is offline
Registered User
FRC #3210
Team Role: Mentor
 
Join Date: Nov 2003
Rookie Year: 2004
Location: Hillsboro, OR
Posts: 113
ErichKeane is just really niceErichKeane is just really niceErichKeane is just really niceErichKeane is just really niceErichKeane is just really nice
Send a message via AIM to ErichKeane
really i only have like 4 ifs/ifelse statements, to cover the 4 sections of the stick. (x axis, y axis, left turn, and right turn), so its not too bad. I dont wanna create any more variables, but i think that i am fairly low now after taking out all printf statements(had 8 in there at one point. hehehe..)
  #7   Spotlight this post!  
Unread 24-11-2003, 11:10
Andrew Andrew is offline
Registered User
#0356
 
Join Date: May 2002
Location: Little Rock, AR
Posts: 393
Andrew is a name known to allAndrew is a name known to allAndrew is a name known to allAndrew is a name known to allAndrew is a name known to allAndrew is a name known to all
Quote:
Originally posted by ErichKeane

ETA 30 seconds later: What can i do to figure out if it takes too much memory?
Two comments...
First of all, there is a separate code space and data space. One could be full and the other virtually empty.

If you want to find out all about the program you are down-loading to the controller, the linker generates a file called...

FNAME.LST

where FNAME is the name of your project (for instance: IFI Default Code.LST).

This file contains your C code, with the assembly next to it, with the line numbers of the code addresses where this code is getting dumped. It also contains the machine code translation of your instructions.

If your code is getting too big, you should see addresses above 008000 in this file.

[NOTE: this LST file only contains code which is being compiled. The library code is not disassembled in this file.]

You can also look in the FNAME.map file (if you have the "generate map file" option checked in your MPLAB environment). This will show you the section information.

At the end of the code section there is a little block which says:
"Program Memory Usage"
It gives start and end address.

You will have a little subblock that says:
xxx out of 33816 program addresses used, ...

You get similar information for the data memory. Only, you'll have to look at the "data" section address of the last symbol to figure how close you are to full in the data space.
  #8   Spotlight this post!  
Unread 24-11-2003, 11:43
ErichKeane ErichKeane is offline
Registered User
FRC #3210
Team Role: Mentor
 
Join Date: Nov 2003
Rookie Year: 2004
Location: Hillsboro, OR
Posts: 113
ErichKeane is just really niceErichKeane is just really niceErichKeane is just really niceErichKeane is just really niceErichKeane is just really nice
Send a message via AIM to ErichKeane
Thank you andrew, that is exactly what i was looking for. Just 1 final question, what is the hex Address Limit for the data variables?
I found out that with program memory, im only at 25%(yay!), and i got my data memory down to 000fab or something like that.
  #9   Spotlight this post!  
Unread 24-11-2003, 12:26
InnovationFirst's Avatar
InnovationFirst InnovationFirst is offline
Official FIRST Supplier
no team
 
Join Date: Nov 2002
Location: Greenville, Tx
Posts: 28
InnovationFirst has a reputation beyond reputeInnovationFirst has a reputation beyond reputeInnovationFirst has a reputation beyond reputeInnovationFirst has a reputation beyond reputeInnovationFirst has a reputation beyond reputeInnovationFirst has a reputation beyond reputeInnovationFirst has a reputation beyond reputeInnovationFirst has a reputation beyond reputeInnovationFirst has a reputation beyond reputeInnovationFirst has a reputation beyond reputeInnovationFirst has a reputation beyond repute
Limit is now 32k

A new version of IFI_Loader (1.0.5) is now available for download at: http://innovationfirst.com/FIRSTRobo...umentation.htm

Version 1.0.5 allows you to download the full 32k bytes of code to the User processor. If you are using an older version you will be unable to download any code which is over 16k bytes in size.
  #10   Spotlight this post!  
Unread 24-11-2003, 14:38
ErichKeane ErichKeane is offline
Registered User
FRC #3210
Team Role: Mentor
 
Join Date: Nov 2003
Rookie Year: 2004
Location: Hillsboro, OR
Posts: 113
ErichKeane is just really niceErichKeane is just really niceErichKeane is just really niceErichKeane is just really niceErichKeane is just really nice
Send a message via AIM to ErichKeane
Thank you for letting me know about this! It will be a big help in the future.
  #11   Spotlight this post!  
Unread 24-11-2003, 15:36
Andrew Andrew is offline
Registered User
#0356
 
Join Date: May 2002
Location: Little Rock, AR
Posts: 393
Andrew is a name known to allAndrew is a name known to allAndrew is a name known to allAndrew is a name known to allAndrew is a name known to allAndrew is a name known to all
Quote:
Originally posted by ErichKeane
Thank you andrew, that is exactly what i was looking for. Just 1 final question, what is the hex Address Limit for the data variables?
I found out that with program memory, im only at 25%(yay!), and i got my data memory down to 000fab or something like that.
According to the data sheet for the PIC 18FXX20 family (available from www.microchip.com, look for PIC18F8520), the data space is 0x800 bytes.

This can also be seen in the 18f8f20user.lkr file, which contains the memory map. Although 0x754...0x7ff is allocated to something called "dbgspr" whatever that is and is listed as "PROTECTED."
  #12   Spotlight this post!  
Unread 24-11-2003, 17:02
Rickertsen2 Rickertsen2 is offline
Umm Errr...
None #1139 (Chamblee Gear Grinders)
Team Role: Alumni
 
Join Date: Dec 2002
Rookie Year: 2002
Location: ATL
Posts: 1,421
Rickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant future
Send a message via AIM to Rickertsen2 Send a message via Yahoo to Rickertsen2
Quote:
Originally posted by Sachiel7
Hmm, well yes, you want to stick with as many ints as possible.

I would even stay away from ints wherever possible. Unsigned chars take up the least code space and process the fastest. Also, try turning on the compiler optimizations.
__________________
1139 Alumni
  #13   Spotlight this post!  
Unread 02-12-2003, 00:10
Random Dude Random Dude is offline
Oregon State Head FTA
AKA: Chris
no team (Oregon Robotics Tournament & Outreach Program)
 
Join Date: Aug 2002
Rookie Year: 1998
Location: Oregon
Posts: 142
Random Dude will become famous soon enoughRandom Dude will become famous soon enough
Re: Space Limit--What is expendable?

Quote:
Originally Posted by Rickertsen2
I would even stay away from ints wherever possible. Unsigned chars take up the least code space and process the fastest. Also, try turning on the compiler optimizations.

Whats wrong with signed chars? I've converted all my PWM signals to signed to simplify the math.
  #14   Spotlight this post!  
Unread 02-12-2003, 06:22
ErichKeane ErichKeane is offline
Registered User
FRC #3210
Team Role: Mentor
 
Join Date: Nov 2003
Rookie Year: 2004
Location: Hillsboro, OR
Posts: 113
ErichKeane is just really niceErichKeane is just really niceErichKeane is just really niceErichKeane is just really niceErichKeane is just really nice
Send a message via AIM to ErichKeane
Re: Space Limit--What is expendable?

Quote:
Originally Posted by Random Dude
Whats wrong with signed chars? I've converted all my PWM signals to signed to simplify the math.
If you do it correctly, and dont need to do any extra math on those two values, its no problem. The Conversion should look like this:
signedpwm01=(char)pwm01-127;

That way you dont loose any information. Now, in processing, remmeber that the values for your pwm's can NEVER reach a number higher than 127 or less than -127 without a well planned promotion.
  #15   Spotlight this post!  
Unread 02-12-2003, 11:33
Dave Flowerday Dave Flowerday is offline
Software Engineer
VRC #0111 (Wildstang)
Team Role: Engineer
 
Join Date: Feb 2002
Rookie Year: 1995
Location: North Barrington, IL
Posts: 1,366
Dave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond repute
Re: Space Limit--What is expendable?

Quote:
Originally Posted by ErichKeane
The Conversion should look like this:
signedpwm01=(char)pwm01-127;

That way you dont loose any information.
Actually it'd be better to use this:
Code:
signedpwm01 = (char) pwm01 - 128;
A signed char can range from -128 to 127. Thus, if you subtract 128 it will give you a reasonable value for any value of pwm01. If you subtract 127, then you get into a problem if pwm01 = 255. 255-127 = 128, however a signed char cannot be 128, and will actually end up being -128! (This is a side effect of the way a computer stores a negative number). Realistically, pwm01 isn't supposed to be larger than 254, but in software it's usually better to make something work for all cases rather than assume that certain cases won't occur.
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
St. Louis anyone? Jeremy_Mc Regional Competitions 8 07-02-2003 12:06
Slightly humorous story about global warming & space explor. archiver 2001 3 24-06-2002 04:01
The 'Big Picture' regarding regional space.. archiver 2000 1 23-06-2002 23:58
KSC Results archiver 2000 2 23-06-2002 22:19
CD forum don't have space for more pictures? Ken Leung General Forum 7 10-04-2002 23:41


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

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