Go to Post it was beautifull just beautifull... then i took my earmuffs off. - Tytus Gerrish [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 13-02-2005, 17:09
The yellowdart's Avatar
The yellowdart The yellowdart is offline
Registered User
FRC #1506 (Metal Muscle)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 2004
Location: Oakland County
Posts: 22
The yellowdart has a little shameless behaviour in the past
Autonomous Code trouble

can anyone find whats wrong with this code ?

static unsigned int t;

while (autonomous_mode) /* DO NOT CHANGE! */
{
if (statusflag.NEW_SPI_DATA) /* 26.2ms loop area */
{
Getdata(&rxdata); /* DO NOT DELETE, or you will be stuck here forever! */

/* Add your own autonomous code here. */
t++;
if (t <114)
{
pwm01=160;
pwm02=160;
}

i know this should run indefinitely....and that is the goal right now......but everytime i compile everything and load the code.....it doesnt work

(this is the autonomous code i wrote for the user_routines_fast.c area where it says autonomous code here..)

any help would be much appeciated

please reply or email me at Johnbk14@gmail.com
  #2   Spotlight this post!  
Unread 13-02-2005, 17:33
AIBob's Avatar
AIBob AIBob is offline
AI Programmer
AKA: Bob Frank DOT org
FRC #0358 (Hauppauge Robotic Eagles)
Team Role: Alumni
 
Join Date: Jan 2005
Rookie Year: 2003
Location: Long Island, NY (in Binghamton now)
Posts: 297
AIBob is a splendid one to beholdAIBob is a splendid one to beholdAIBob is a splendid one to beholdAIBob is a splendid one to beholdAIBob is a splendid one to beholdAIBob is a splendid one to beholdAIBob is a splendid one to behold
Send a message via ICQ to AIBob Send a message via AIM to AIBob Send a message via MSN to AIBob Send a message via Yahoo to AIBob
Re: Autonomous Code trouble

one possible problem is that you never set variable t, and you never have it do anything after the 114 loops, like neutralizing them.
Try this:
Code:
static unsigned int t=0;
 
while (autonomous_mode) /* DO NOT CHANGE! */
{
if (statusflag.NEW_SPI_DATA) /* 26.2ms loop area */
{
Getdata(&rxdata); /* DO NOT DELETE, or you will be stuck here forever! */
 
/* Add your own autonomous code here. */
t++;
if (t <114)	//edit(added): runs Forward for 113*26.2ms = 2.9606s
{
pwm01=160;
pwm02=160;
}
else
{
pwm01 = 127;
pwm02 = 127;
}
...etc...
__________________
- from B B frank


Last edited by AIBob : 14-02-2005 at 10:49.
  #3   Spotlight this post!  
Unread 13-02-2005, 18:19
Ryan M. Ryan M. is offline
Programming User
FRC #1317 (Digital Fusion)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Ohio
Posts: 1,508
Ryan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud of
Re: Autonomous Code trouble

It would be helpful if you'd include your entire user_routines_fast.c file. Looking at your code sample, for example, you're missing a closing '}', but I know it must be there, because you code compiles. So... the entire file would be helpful.
__________________

  #4   Spotlight this post!  
Unread 13-02-2005, 20:54
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: Autonomous Code trouble

Quote:
Originally Posted by The yellowdart
i know this should run indefinitely....and that is the goal right now......but everytime i compile everything and load the code.....it doesnt work
Be more specific. What do you want it to do? What does it do instead?
  #5   Spotlight this post!  
Unread 14-02-2005, 08:09
Anton's Avatar
Anton Anton is offline
Anton Povzner
#1581 (Element)
Team Role: Programmer
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Israel
Posts: 51
Anton can only hope to improve
Re: Autonomous Code trouble

you know how to enable autonomous mode, don't you? you have to put a jumper somewhwere- don't remember where.
you could try enabling it manualy:
//////////////////////////////////////////////////////////
autonomous_mode=1;

while (autonomous_mode) /* DO NOT CHANGE! */
{
if (statusflag.NEW_SPI_DATA) /* 26.2ms loop area */


I didn't check that, so it might do something else instead.
__________________
/*
Anton Povzner, head&tail of team 1581 programming team... and that's just one of the many reasons for us to loose seriously
*/
  #6   Spotlight this post!  
Unread 14-02-2005, 16:17
Ssbfalcon's Avatar
Ssbfalcon Ssbfalcon is offline
The beta version
AKA: Arthur
FRC #1546 (Chaos Inc.)
Team Role: Alumni
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Baldwin, New York
Posts: 8
Ssbfalcon is an unknown quantity at this point
Send a message via AIM to Ssbfalcon
Re: Autonomous Code trouble

That looks like the answer. Be sure to trace variables used in loops and if's etc if you find that things aren't working the way you want them to.

Also, for autonomous mode testing and such, having a mock competition port is very useful. Firstly so you can activate autonomous mode with the flick of a switch, and also if that goes crazy, you can disable it by pressing the disable button.
__________________
Don't Lick Dry Ice!
  #7   Spotlight this post!  
Unread 16-02-2005, 21:51
whakojacko's Avatar
whakojacko whakojacko is offline
Registered User
FRC #1072 (hrt)
Team Role: College Student
 
Join Date: Feb 2003
Rookie Year: 2003
Location: San Jose, California
Posts: 137
whakojacko is on a distinguished road
Send a message via AIM to whakojacko Send a message via MSN to whakojacko
Re: Autonomous Code trouble

as people said, make sure that your actually going into autonomous mode. Look at this link:http://www.ifirobotics.com/docs/comp...guide-reva.pdf. if you want to make something to be able to kill your bot or put it in autonomous mode
__________________
Harker Robotics:1072
http://www.harker-robotics.org
  #8   Spotlight this post!  
Unread 21-04-2005, 21:55
The yellowdart's Avatar
The yellowdart The yellowdart is offline
Registered User
FRC #1506 (Metal Muscle)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 2004
Location: Oakland County
Posts: 22
The yellowdart has a little shameless behaviour in the past
Re: Autonomous Code trouble

i figured it all out.....i should have posted a long time ago..... i misplaced the line of code that declared my variable..... int t=0;
t++;
that should have been in a different location.......thanks for all the advice/help/links and such





Thanks again everyone,

John
  #9   Spotlight this post!  
Unread 08-08-2005, 21:08
The yellowdart's Avatar
The yellowdart The yellowdart is offline
Registered User
FRC #1506 (Metal Muscle)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 2004
Location: Oakland County
Posts: 22
The yellowdart has a little shameless behaviour in the past
Re: Autonomous Code trouble

Guys thanks for all the help and advice during the season.
I have become more familiar with C and C++ now. And advice i have for other rookies like myself is to stay away from Global Variables.

  #10   Spotlight this post!  
Unread 09-08-2005, 19:47
EricS-Team180's Avatar
EricS-Team180 EricS-Team180 is offline
SPAM, the lunchmeat of superheroes!
AKA: Eric Schreffler
FRC #0180 (SPAM)
Team Role: Engineer
 
Join Date: Apr 2002
Rookie Year: 2001
Location: Stuart, Florida
Posts: 561
EricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond repute
Re: Autonomous Code trouble

I ask my students to add a 2 letter prefix to variable names in order to keep the different scopes and types of variables sorted out. We don't touch the IFI variables, just the custom code we create...but that helps to identify IFIs code, as well:

First character:
t - type
m -data member of class, struct or
union (non-static)
s - static class scope
g - global scope
a - argument, non-reference
r - reference argument
l - auto local (temporary storage)

Second character:
n - number/scalar, non-enumeration
e - enumeration scalar
s - struct
u - union
a - array
p - pointer

So if we wanted to add a static int "t", it'd be snt and snT. If global, gnt or gnT or if used solely in a function lnt or lnT. It looks a bit awkward, but it really helps me when I'm code reading and debugging.

Eric
__________________

Don't PANIC!
S. P. A. M.
  #11   Spotlight this post!  
Unread 11-08-2005, 01:09
Kyle T Kyle T is offline
waiting for next season...
FRC #0810 (Mechanical Bulls)
Team Role: Programmer
 
Join Date: Feb 2005
Rookie Year: 2004
Location: Smithtown
Posts: 20
Kyle T is an unknown quantity at this point
Re: Autonomous Code trouble

I wish that MPLAB was more like Visual Studio 2005, there'd be much less complaining. If you forget to initialize a variable, it tells you with those nice underline spellcheck uses in MS-office. You forget a semicolon? VS2005 tells you right away at the end of that line, in a way that doesn't make you have to click a button in an alert box. It helps you get into good habits.
__________________
  #12   Spotlight this post!  
Unread 11-08-2005, 13:57
Unsung FIRST Hero
miketwalker miketwalker is offline
Robot Lifeguard
FRC #1902 (Exploding Bacon)
 
Join Date: Dec 2001
Rookie Year: 2002
Location: Orlando, FL
Posts: 878
miketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond repute
Send a message via AIM to miketwalker
Re: Autonomous Code trouble

Quote:
Originally Posted by EricS-Team180
I ask my students to add a 2 letter prefix to variable names in order to keep the different scopes and types of variables sorted out. We don't touch the IFI variables, just the custom code we create...but that helps to identify IFIs code, as well:

First character:
t - type
m -data member of class, struct or
union (non-static)
s - static class scope
g - global scope
a - argument, non-reference
r - reference argument
l - auto local (temporary storage)

Second character:
n - number/scalar, non-enumeration
e - enumeration scalar
s - struct
u - union
a - array
p - pointer

So if we wanted to add a static int "t", it'd be snt and snT. If global, gnt or gnT or if used solely in a function lnt or lnT. It looks a bit awkward, but it really helps me when I'm code reading and debugging.

Eric
You should've told me that 3 years ago Eric, I would've understood your code much more then, I always wondered why you labeled your variables like you did. :-p
__________________
Chopsaw? Chopsaw.
  #13   Spotlight this post!  
Unread 22-09-2005, 18:44
RIgnazio RIgnazio is offline
Registered User
no team
Team Role: Webmaster
 
Join Date: Jan 2005
Rookie Year: 2004
Location: .
Posts: 45
RIgnazio will become famous soon enough
Exclamation Re: Autonomous Code trouble

Even though the comment says that it is a 26.2ms Loop area (I think it was 26.2?) it is in fact 40ms. The autonomous loop runs in 26.2ms space, but your code actually runs in 40ms space.

What I do to keep from getting confused is this:
Quote:
#define second 40
#define tenth_second 4

//IFI code goes here
unsigned int autonomous_clock;

if (autonomous_clock < ((2*second) + (4*tenth_second))
{
pwm01 = 254;
pwm02 = 254;
}
else
{
pwm01 = 127;
pwm02 = 127;
}

++autonomous_clock; //adds 1 to the autonomous_clock count
I forget if the default code uses pwm_max, pwm_min, or pwm_neutral, but my code did. I merely use pwm_max as 254, pwm_neutral as 127, and pwm_min as 0

Hope this helps.
  #14   Spotlight this post!  
Unread 22-09-2005, 20:14
Unsung FIRST Hero
Mike Betts Mike Betts is offline
Electrical Engineer
no team
Team Role: Engineer
 
Join Date: Dec 2001
Rookie Year: 1995
Location: Homosassa, FL
Posts: 1,442
Mike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond repute
Re: Autonomous Code trouble

Quote:
Originally Posted by RIgnazio
Even though the comment says that it is a 26.2ms Loop area (I think it was 26.2?) it is in fact 40ms. The autonomous loop runs in 26.2ms space, but your code actually runs in 40ms space...
Roger,

Your code is correct but your statement about 40 milliseconds is wrong:

40ms * 40 = 1.6 seconds
40ms * 4 = 0.16 seconds

However, if we assume that the loop cycle is 26 ms we get:

26.2 ms * 40 = 1.048 seconds
26.2 ms * 4 = 0.1048 seconds

Trust the math...

Mike
__________________
Mike Betts

Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013

As easy as 355/113...
  #15   Spotlight this post!  
Unread 22-09-2005, 20:17
RIgnazio RIgnazio is offline
Registered User
no team
Team Role: Webmaster
 
Join Date: Jan 2005
Rookie Year: 2004
Location: .
Posts: 45
RIgnazio will become famous soon enough
Re: Autonomous Code trouble

Thanks for the clarification on that, no wonder my autonmous values seemed incorrect
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
Best Way To Insert Autonomous Code Into Default then load help.? :-)? gemccnp Programming 2 05-02-2005 18:58
Team THRUST - Kevin's Code and Camera Code Combine Chris_Elston Programming 3 31-01-2005 22:28
heres the code. y this not working omega Programming 16 31-03-2004 15:18
InfraRed autonomous code ... mtrawls Programming 1 11-01-2004 00:25


All times are GMT -5. The time now is 09:24.

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