Go to Post Look guys, I am telling you for the fourth time - you are NEVER going to earn your official "Geek" certificates if you keep spelling "pwned" with an "O" in it! - dlavery [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
  #16   Spotlight this post!  
Unread 09-03-2004, 10:22
10intheCrunch's Avatar
10intheCrunch 10intheCrunch is offline
Who's John V-Neun?
AKA: Alex Baxter
None #0254 (Cheesy Poofs)
Team Role: College Student
 
Join Date: Feb 2004
Rookie Year: 2004
Location: San Jose, CA
Posts: 129
10intheCrunch is a jewel in the rough10intheCrunch is a jewel in the rough10intheCrunch is a jewel in the rough10intheCrunch is a jewel in the rough
Send a message via AIM to 10intheCrunch
Re: Do you write functions for your code?

We have a few more... =)

This list I can recall atm: 254_arm, 254_auton, 254_drive, 254_encoders, 254_utilities, 254_interrupts, 254_timers, 254_recordable (recordable autonomous, work in progress)...hmmm, I think that's it, might be one more somewhere.

We're also working on breaking our pump and gear shifting code to functions for ease of use in autonomous mode.
__________________
~Alex Baxter
Programming, Arms operation, Team 254
  #17   Spotlight this post!  
Unread 09-03-2004, 13:38
Max Lobovsky's Avatar
Max Lobovsky Max Lobovsky is offline
Fold em oval!
FRC #1257 (Parallel Universe)
Team Role: College Student
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Scotch Plains, NJ
Posts: 1,026
Max Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant future
Send a message via AIM to Max Lobovsky
Re: Do you write functions for your code?

Quote:
Originally Posted by KenWittlief
actaully, the SW we are creating for these machines is realtime embedded code

remember that the C compiler will convert your code into assembly code, and from that into machine code

breaking your code up into many little functions makes it look nice, but it actually takes longer for it to run, and takes up more code space, because the function calls are actully jumps in assembly code

its shorter and faster to have sequential code all in one routine that simply falls through to the next statement.

not that we really have to be concerned with optimizing our code for size or speed.

well wait, I have seen some people posting that they have used up all the available code space this year - so maybe some of us got a little carried away with the functions :^)
Im not sure, but don't good compilers make using functions not so ineffecient? If not, can't you just use inline to get the same effect as not using functions?
__________________
Learn, edit, inspire: The FIRSTwiki.
Team 1257


2005 NYC Regional - 2nd seed, Xerox Creativity Award, Autodesk Visualization Award
2005 Chesapeake Regional - Engineering Inspiration Award
2004 Chesapeake Regional - Rookie Inspiration award
2004 NJ Regional - Team Spirit Award
  #18   Spotlight this post!  
Unread 09-03-2004, 13:57
velocipenguin velocipenguin is offline
Registered User
#0246 (Overclocked)
Team Role: Programmer
 
Join Date: Feb 2004
Location: Boston, MA
Posts: 77
velocipenguin is on a distinguished road
Send a message via AIM to velocipenguin
Re: Do you write functions for your code?

I would have suffered greatly if not for the ability to divide everything into functions this year. Even if some of them are only called once, they still make it much easier to keep code organized, readable, and easy to debug. Our (failed) autonomous code has about 8 separate functions, each of which contains 20-30 lines of code. Trying to keep all that organized within Process_Data_From_Local_IO() would have been a nightmare, but dividing all of it into separate functions made coding a breeze. Sure, it might take another CPU cycle or two to jump to the appropriate memory location, but that's not much of a problem when the thing's running at 40 MHz.
  #19   Spotlight this post!  
Unread 09-03-2004, 14:14
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Cool Re: Do you write functions for your code?

I did a lot of the stuff your taliking about. I'll post some of my hardware-driver code. (don't have it on me) It includes #defines for every motor, victor, spike, pot, and whatnot. And to top it of, to move the shoulder to a certain position, you call Shoulder_Check(Target). It also includes macros to scale (and translate) the analogs.
  #20   Spotlight this post!  
Unread 09-03-2004, 19:34
SeanCassidy's Avatar
SeanCassidy SeanCassidy is offline
Antiregistered User
#0263 (Aftershock)
Team Role: Programmer
 
Join Date: Oct 2003
Location: Holtsville, NY
Posts: 37
SeanCassidy is an unknown quantity at this point
Re: Do you write functions for your code?

I used many functions, many just like:

#define square(a) a*a

And also a nice function to turn based on degrees you want to turn. Kickin'.
  #21   Spotlight this post!  
Unread 09-03-2004, 19:42
KenWittlief KenWittlief is offline
.
no team
Team Role: Engineer
 
Join Date: Mar 2003
Location: Rochester, NY
Posts: 4,213
KenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond repute
Re: Do you write functions for your code?

dont get me wrong- there is nothing wrong with using functions for your code on this project - I was only pointing out in a reply to a post on the 1st page that using functions is not more effecient from a performance perspective, and if the function is only called from one place in your code, its takes up more code space after being compiled than simply putting the same code inline.

there is a balance somewhere, between breaking up every 3 or 4 lines of code into a separate function, and writing one long monolithic block of SW with no functions.
  #22   Spotlight this post!  
Unread 09-03-2004, 20:01
Pat Fairbank's Avatar
Pat Fairbank Pat Fairbank is offline
Circuit Breaker
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2001
Location: San Jose, CA
Posts: 2,132
Pat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond repute
Send a message via MSN to Pat Fairbank
Re: Do you write functions for your code?

Functions? We wrote a whole math library worth of functions! Actually, it was the other programmer who did, not me, because he actually can understand CORDIC.

Otherwise, we only used functions in such situations where they would be called in more than one different place, such as our joystick auto-calibration function.
__________________
Patrick Fairbank
Team 254 | Mentor (2012-)
Team 1503 | Mentor (2007-2011)
Team 296 | Alumnus (2001-2004) | Mentor (2005-2006)

patfairbank.com
  #23   Spotlight this post!  
Unread 09-03-2004, 20:09
jacob_dilles's Avatar
jacob_dilles jacob_dilles is offline
Registered User
AKA: theshadow
FRC #0620 (WarBots)
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2003
Location: Vienna, VA
Posts: 245
jacob_dilles will become famous soon enough
Send a message via AIM to jacob_dilles
Re: Do you write functions for your code?

Quote:
Originally Posted by Pat Fairbank
Functions? We wrote a whole math library worth of functions! Actually, it was the other programmer who did, not me, because he actually can understand CORDIC.
you mind sharing some math libs? a bunch of people are looking for some good ones, if you dont want to write a white paper i could.
__________________
--------------------------
"You're not a real programmer until all your sentences end with semicolons;"
  #24   Spotlight this post!  
Unread 09-03-2004, 20:41
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Do you write functions for your code?

Quote:
Originally Posted by Pat Fairbank
Functions? We wrote a whole math library worth of functions! Actually, it was the other programmer who did, not me, because he actually can understand CORDIC.
If I get my CORDIC implementation functional, I'll put it somewhere for others to read. In the meantime, maybe your "other programmer" would like to post his work?
  #25   Spotlight this post!  
Unread 09-03-2004, 21:31
Pat Fairbank's Avatar
Pat Fairbank Pat Fairbank is offline
Circuit Breaker
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2001
Location: San Jose, CA
Posts: 2,132
Pat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond repute
Send a message via MSN to Pat Fairbank
Re: Do you write functions for your code?

We should be posting a white paper containing our math library in the next week EDIT: day or so, keep an eye out for it. It should be good enough for any team's use; I believe we managed to get our CORDIC trig functions accurate to within 6 decimal places.
__________________
Patrick Fairbank
Team 254 | Mentor (2012-)
Team 1503 | Mentor (2007-2011)
Team 296 | Alumnus (2001-2004) | Mentor (2005-2006)

patfairbank.com

Last edited by Pat Fairbank : 10-03-2004 at 19:39.
  #26   Spotlight this post!  
Unread 10-03-2004, 07:34
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: Do you write functions for your code?

Here's SOME of my code.
Attached Files
File Type: zip TG_Bot_Code.zip (3.6 KB, 30 views)
  #27   Spotlight this post!  
Unread 11-03-2004, 07:04
Pat Fairbank's Avatar
Pat Fairbank Pat Fairbank is offline
Circuit Breaker
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2001
Location: San Jose, CA
Posts: 2,132
Pat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond repute
Send a message via MSN to Pat Fairbank
Re: Do you write functions for your code?

You can now find 296's math library here.
__________________
Patrick Fairbank
Team 254 | Mentor (2012-)
Team 1503 | Mentor (2007-2011)
Team 296 | Alumnus (2001-2004) | Mentor (2005-2006)

patfairbank.com
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
What is your most prefered programming language? Hailfire Programming 156 19-01-2005 21:42
Interrupt timer, executing code asap? SeanCassidy Programming 10 07-03-2004 01:47
Inserting Naviagation code into Default code? actorindp Programming 3 28-01-2004 18:12
RC bootup sequence Venkatesh Programming 17 18-11-2003 20:56
Does your team use the Default code. Jeff McCune General Forum 2 09-01-2003 14:46


All times are GMT -5. The time now is 07:27.

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