Go to Post So take it all with a grain of salt, form your own opinions, lead by example, act responsibly, be graciously professional, and everything will be ok. - LauraN [more]
Home
Go Back   Chief Delphi > ChiefDelphi.com Website > Extra Discussion
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 05-02-2008, 10:31
garyk garyk is offline
Programming Mentor: 668, 972, 2643
FRC #0668 (Apes of Wrath)
Team Role: Mentor
 
Join Date: Dec 2006
Rookie Year: 2005
Location: Santa Clara (Silicon Valley) Calif.
Posts: 91
garyk is a jewel in the roughgaryk is a jewel in the roughgaryk is a jewel in the roughgaryk is a jewel in the rough
paper: A programming template for Autonomous Mode

Thread created automatically to discuss a document in CD-Media.

A programming template for Autonomous Mode by garyk
Reply With Quote
  #2   Spotlight this post!  
Unread 05-02-2008, 10:47
David Bryan David Bryan is offline
Registered User
#0818 (Steel Armadillo)
 
Join Date: Jan 2002
Location: Warren Consolidated Schools
Posts: 8
David Bryan is an unknown quantity at this point
Question Re: paper: A programming template for Autonomous Mode


Dear GaryK or anyone willing to hear.

I took this working section out of user_routines.c and renamed part of it and placed it into user_routines_fast.c. It will not compile. I cannot find my error. The same program will compile back in user_routines.c.

Here is the program:

/************************************************** *****************************
* FUNCTION NAME: Lim_Mix
* PURPOSE: Limits the mixed value for one joystick drive.
* CALLED FROM: Default_Routine, this file
* ARGUMENTS:
* Argument Type IO Description
* -------- ---- -- -----------
* intermediate_value int I
* RETURNS: unsigned char
************************************************** *****************************/
unsigned char Lim_Mix (int intermediate_valu)
{ // < I get a compile error here.
static int limited_valu;

if (intermediate_valu < 2000)
{
limited_valu = 2000;
}
else if (intermediate_valu > 2254)
{
limited_valu = 2254;
}
else
{
limited_valu = intermediate_valu;
}
return (unsigned char) (limited_valu - 2000);
}

// when i place the cursor over the variable, limited_valu
// i get the bubble [limited_valu = Out of Scope].
// please help

// thanks - David Bryan Team 818
Reply With Quote
  #3   Spotlight this post!  
Unread 05-02-2008, 12:04
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,112
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: paper: A programming template for Autonomous Mode

Quote:
Originally Posted by David Bryan View Post
I took this working section out of user_routines.c and renamed part of it and placed it into user_routines_fast.c. It will not compile.
The error you got seems like one that is actually caused by a problem with the code before it not being complete, with a missing semicolon or close brace. It looks like you might have put it in the middle of one of the existing functions, instead of between them. Double-check to make sure the preceding function in user_routines_fast.c didn't get interfered with when you inserted your code.
Reply With Quote
  #4   Spotlight this post!  
Unread 05-02-2008, 12:43
Steve_Alaniz Steve_Alaniz is offline
Registered User
FRC #2848 (All Sparks)
Team Role: Mentor
 
Join Date: Mar 2007
Rookie Year: 1997
Location: Dallas
Posts: 211
Steve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond repute
Re: paper: A programming template for Autonomous Mode

David,
I did a cut and paste of the code and inserted it in My user_routines_fast
If I place the code in the autonomous section of the program I get the compile error.
If I place it above with the other function declarations it compiles fine.
Somebody with a greater knowledge of why C does what it does will have to explain why that happens. (I'm just a hacker..I like to stay on the hardware side of things...Instead of stupid compile errors we get blue smoke or sparks and that makes trouble shooting REAL easy!)
Anyway, I assume you can place the code outside the autonomous area and still call it. I may be wrong but that MIGHT solve the problem.

Steve


PS ...Oh you're placing a function within a function. User_Autonomous_Code . I don't think that's legal.

Steve

Last edited by Steve_Alaniz : 05-02-2008 at 12:52. Reason: grammar
Reply With Quote
  #5   Spotlight this post!  
Unread 05-02-2008, 13:11
garyk garyk is offline
Programming Mentor: 668, 972, 2643
FRC #0668 (Apes of Wrath)
Team Role: Mentor
 
Join Date: Dec 2006
Rookie Year: 2005
Location: Santa Clara (Silicon Valley) Calif.
Posts: 91
garyk is a jewel in the roughgaryk is a jewel in the roughgaryk is a jewel in the roughgaryk is a jewel in the rough
Re: paper: A programming template for Autonomous Mode

Quote:
Originally Posted by David Bryan View Post

Dear GaryK or anyone willing to hear.

I took this working section out of user_routines.c and renamed part of it and placed it into user_routines_fast.c. It will not compile. I cannot find my error. The same program will compile back in user_routines.c.

Here is the program:

/************************************************** *****************************
* FUNCTION NAME: Lim_Mix
* PURPOSE: Limits the mixed value for one joystick drive.
* CALLED FROM: Default_Routine, this file
* ARGUMENTS:
* Argument Type IO Description
* -------- ---- -- -----------
* intermediate_value int I
* RETURNS: unsigned char
************************************************** *****************************/
unsigned char Lim_Mix (int intermediate_valu)
{ // < I get a compile error here.
static int limited_valu;

if (intermediate_valu < 2000)
{
limited_valu = 2000;
}
else if (intermediate_valu > 2254)
{
limited_valu = 2254;
}
else
{
limited_valu = intermediate_valu;
}
return (unsigned char) (limited_valu - 2000);
}

// when i place the cursor over the variable, limited_valu
// i get the bubble [limited_valu = Out of Scope].
// please help

// thanks - David Bryan Team 818
Hi, David:

I wonder also if you put this function inside another function. Did you put it where it says:


/* Add your own autonomous code here. */
?

If I put your code there I get an error on the "unsigned char" line.

Try removing all the code in question, and make sure you get a clean compile. Then, add your code at the very end of the file and I think it will compile.

The code you have is a complete function and it can't be put in the middle of another function (and I apologize if you already know this.) If it works with your code at the end of user_routines_fast.c then you can call it where you need it.

BTW, if you just need a limit_mix function for your autonomous routine, you can call the one in user_routines.c - the significance of the function is determined by where you call it from, not which file it's in. To do so, add this
line with the other function prototypes in user_routines.h:

unsigned char Limit_Mix (int);

Make sure it compiles after you remove your own Lim_Mix(), then you can
call Limit_Mix from your autonomous routine.

Gary

Last edited by garyk : 05-02-2008 at 13:13. Reason: Added emphasis
Reply With Quote
  #6   Spotlight this post!  
Unread 07-02-2008, 10:19
David Bryan David Bryan is offline
Registered User
#0818 (Steel Armadillo)
 
Join Date: Jan 2002
Location: Warren Consolidated Schools
Posts: 8
David Bryan is an unknown quantity at this point
Re: paper: A programming template for Autonomous Mode

Hey Team
Thanks for your answers.
I set down with a C programmer Nathan and we solved the problem:

1) Added to IFI_utilities.h

2) char Limit_Mix (int); // ADDED 2/07/08 active in user_routines.c


Added to user_routines_fast.c and removed from user_routines.c

3)
/******************************** page 2.6 ***************************************
* FUNCTION NAME: Limit_Mix
* PURPOSE: Limits the mixed value for one joystick drive.
* CALLED FROM: Default_Routine, this file
* ARGUMENTS:
* Argument Type IO Description
* -------- ---- -- -----------
* intermediate_value int I
* RETURNS: unsigned char
************************************************** *****************************/

unsigned char Limit_Mix (int intermediate_value)
{
static int limited_value;

if (intermediate_value < 2000)
{
limited_value = 2000;
}
else if (intermediate_value > 2254)
{
limited_value = 2254;
}
else
{
limited_value = intermediate_value;
}
return (unsigned char) (limited_value - 2000);
}


4) pwm2_tiltup = Limit_Mix(2000 + pot_08 - pot_07 + 127);

5) When we do that all of it will compile!

Without lines 1, 2 above I could not make it work, but now it does thanks
to GM programmer Nathan Mackarewicz!

Problem I think is now solved!
Thanks!!
Reply With Quote
Reply


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
A programming template for Autonomous Mode garyk Programming 2 05-02-2008 20:08
Help needed in autonomous programming for hybrid mode Team_STORM Programming 3 21-01-2008 19:11
White Paper Discuss: C Programming and Autonomous Modes for Newbies cbolin Extra Discussion 3 09-01-2008 19:32
Help for finding Autonomous Programming Template vito3693 VEX 2 23-11-2006 19:01
Programming Autonomous mode Jared Stofflett Programming 3 11-11-2003 09:32


All times are GMT -5. The time now is 08:29.

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