Go to Post ...remember RAID 0 is a trap. - Sperkowsky [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 19-02-2004, 14:04
Paul Jr. Paul Jr. is offline
Registered User
#1390
 
Join Date: Feb 2004
Location: St. Cloud, FLA
Posts: 1
Paul Jr. is an unknown quantity at this point
programs and timeing.

I am writing a autonomous function and I need to know if
there is a function or command that returns the time.
elapsed time or just the current time is ok. I will call this
command from with in the fast.c program. In C there is the function clock() but it requires the <time.h> file as an include file. This file is not with our software for this robot.

Also I need a function to pause the program. In assembly I beleive the command "pause" does this but I need to do it
in C.

Thanks;
  #2   Spotlight this post!  
Unread 19-02-2004, 14:34
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: programs and timeing.

There are library timers included with the compiler. Look in the attched file to find out how to use them. (Look for the timers section)

I'm not sure of how you are thinking of doing the pause, but you'll have to make sure that get/putdata() is called at least every 26.2ms or the master processor on the RC will halt the program.

--EDIT--
Oh, yeah, since you at least konw what asembly is: to do asembly instructions in C do something like:
Code:
asm asmembly instruction;
--EDIT--
The file is too large to upload, but it can be found on the microchip website. (Don't remember where exactly)
__________________


Last edited by Ryan M. : 19-02-2004 at 14:42.
  #3   Spotlight this post!  
Unread 19-02-2004, 15:23
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: programs and timeing.

Quote:
Originally Posted by Paul Jr.
I am writing a autonomous function and I need to know if
there is a function or command that returns the time.
There is example code here that shows how to do what you want. It's written for the EDU-RC, but can be easilly ported to the FRC-RC.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #4   Spotlight this post!  
Unread 19-02-2004, 17:31
Phil_Lutz's Avatar
Phil_Lutz Phil_Lutz is offline
Phil Lutz
#0851 (Froggers)
Team Role: Mentor
 
Join Date: Jan 2004
Location: El Segundo, CA
Posts: 67
Phil_Lutz is on a distinguished road
Send a message via Yahoo to Phil_Lutz
Re: programs and timeing.

Why do you need to pause the program?
For testing purposes?

If so, you can code a switch, when closed allows the code to execute, when released if stops.

Code:
if ((autonomous_mode = 0) || (AUTON_SWITCH = 1))
{
  execute auton code 
}
Or something like that. (I don't have my code in front of me.
AUTO_SWITCH - is an alias to one of the O/I joystick triggers for testing only. Make sure to remove it before comp.


Phil
  #5   Spotlight this post!  
Unread 20-02-2004, 16:27
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: programs and timeing.

Quote:
Originally Posted by Phil_Lutz
Why do you need to pause the program?
For testing purposes?

If so, you can code a switch, when closed allows the code to execute, when released if stops.

Code:
if ((autonomous_mode = 0) || (AUTON_SWITCH = 1))
{
  execute auton code 
}
Or something like that. (I don't have my code in front of me.
AUTO_SWITCH - is an alias to one of the O/I joystick triggers for testing only. Make sure to remove it before comp.
First of all, that's a logical OR. You want AND (&&).

How about this? In main.c:
Code:
  while (1)   /* This loop will repeat indefinitely. */
  {
#ifdef _SIMULATOR
    statusflag.NEW_SPI_DATA = 1;
#endif
if (!PAUSE_SWITCH)
{
    if (statusflag.NEW_SPI_DATA)      /* 26.2ms loop area */
    {                                 /* I'm slow!  I only execute every 26.2ms because */
                                      /* that's how fast the Master uP gives me data. */
      Process_Data_From_Master_uP();  /* You edit this in user_routines.c */

      if (autonomous_mode)            /* DO NOT CHANGE! */
      {
        User_Autonomous_Code();        /* You edit this in user_routines_fast.c */
      }
    }
    Process_Data_From_Local_IO();     /* You edit this in user_routines_fast.c */
                                      /* I'm fast!  I execute during every loop.*/
}
  } /* while (1) */
Basically, if you flip the switch, the robot will finish, and then go into a really fast loop: it does nothing until you turn it off. Be sure to but something similar in the auto.mode code: it has its own loop.
  #6   Spotlight this post!  
Unread 20-02-2004, 17:30
mtrawls's Avatar
mtrawls mtrawls is offline
I am JVN! (John von Neumann)
#0122 (NASA Knights)
Team Role: Programmer
 
Join Date: Mar 2003
Location: Hampton, VA
Posts: 295
mtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to behold
Send a message via AIM to mtrawls
Re: programs and timeing.

Quote:
Originally Posted by Astronouth7303
First of all, that's a logical OR. You want AND (&&).
Code:
if ((autonomous_mode = 0) || (AUTON_SWITCH = 1))
{
  execute auton code 
}
Well, I believe the idea is so that the auto code executes if the team's AUTON_SWITCH is activated OR if the IFI controller inidicates via the competition port that the robot is in autonomous mode. However, you want to be careful that you use the equivalene test, not the assignment operator--it probably was a copying error, but for those who might use it, make sure you put == not =. Also, why the 0? Do you mean 1? (Hrm, or do you mean 0, in which case you would need AND, no?) Also, see below.


Quote:
Originally Posted by Astronouth7303
How about this? In main.c:
Code:
  while (1)   /* This loop will repeat indefinitely. */
  {
#ifdef _SIMULATOR
    statusflag.NEW_SPI_DATA = 1;
#endif
if (!PAUSE_SWITCH)
{
    if (statusflag.NEW_SPI_DATA)      /* 26.2ms loop area */
    {                                 /* I'm slow!  I only execute every 26.2ms because */
                                      /* that's how fast the Master uP gives me data. */
      Process_Data_From_Master_uP();  /* You edit this in user_routines.c */

      if (autonomous_mode)            /* DO NOT CHANGE! */
      {
        User_Autonomous_Code();        /* You edit this in user_routines_fast.c */
      }
    }
    Process_Data_From_Local_IO();     /* You edit this in user_routines_fast.c */
                                      /* I'm fast!  I execute during every loop.*/
}
  } /* while (1) */
Basically, if you flip the switch, the robot will finish, and then go into a really fast loop: it does nothing until you turn it off. Be sure to but something similar in the auto.mode code: it has its own loop.
Well, if you're going to all the trouble of creating a disable switch, why add extra code when you can just use the competition port to create a disable button as the program is? And while you're there, you can create your auton switch too, and won't need extra code. It will simulate the competition. competition pin-out guide [pdf file].

I'd carefully analyze why you want to pause. But there are several ways to go about it -- you have a timer interrupt, so you can program a pause function easily enough to pause for a given amount of time. A quick solution, if that's all you need it for, is just to have an empty for loop that executes some pre-determined amount. e.g.,
Code:
for (waste_time = 0; waste_time < TIME_TO_WASTE; waste_time++) ;
// remember: declare waste_time elsewhere, and define TIME_TO_WASTE
  #7   Spotlight this post!  
Unread 21-02-2004, 18:56
deltacoder1020's Avatar
deltacoder1020 deltacoder1020 is offline
Computer Guy
AKA: Dav
#1020 (The Indiana Prank Monkeys)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Muncie, Indiana
Posts: 340
deltacoder1020 has a spectacular aura aboutdeltacoder1020 has a spectacular aura about
Send a message via AIM to deltacoder1020
Re: programs and timeing.

note that if you pause the robot, you should still be calling putdata every 26.2ms, otherwise the frc will shut down.
__________________
Team 1020, the Indiana Prank Monkeys (www.team1020.org)
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


All times are GMT -5. The time now is 00:03.

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