Go to Post ...on occasion, just smile and nod in appreciation. - dubious elise [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 15-01-2006, 19:25
amateurrobotguy's Avatar
amateurrobotguy amateurrobotguy is offline
Lead Programmer/Senior Engineer
no team
 
Join Date: Feb 2005
Rookie Year: 2000
Location: ****
Posts: 136
amateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these parts
Need a little help with how to break out of the box

I want to do some automation. I put Automation(); in the user routines fast.c under the 'insert auto in here'. Does this need to be Automation(void);?

I put Automation(); in the userroutines.h. Does this need to be automation(void);?

What would be an example of why the void is used? I know it is something like if the function returns output but do I need to expressly say this function has run?

I put my my automation function in user_routines.c defining it as void automation(void) {

Please tell me if all that I said is o.k.

Now how do I make it so that I can put Automation in its own .c file? Will it need its own .h? Do I have to define the .c file in ht userroutines.h? How will it know to use automation.h? to get to automation.c? to get to automation().

Now, how do I test this auto code without being in a match? Do I just move the call to automation from urf.c to ur.c?
__________________
I quit FRC over 2 years ago (more if you're reading this past 2010).
  #2   Spotlight this post!  
Unread 15-01-2006, 20:36
Mike's Avatar
Mike Mike is offline
has common ground with Matt Krass
AKA: Mike Sorrenti
FRC #0237 (Sie-H2O-Bots (See-Hoe-Bots) [T.R.I.B.E.])
Team Role: Programmer
 
Join Date: Dec 2004
Rookie Year: 2004
Location: Watertown, CT
Posts: 1,003
Mike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond repute
Re: Need a little help with how to break out of the box

Quote:
Originally Posted by amateurrobotguy
I want to do some automation. I put Automation(); in the user routines fast.c under the 'insert auto in here'. Does this need to be Automation(void);?

I put Automation(); in the userroutines.h. Does this need to be automation(void);?

What would be an example of why the void is used? I know it is something like if the function returns output but do I need to expressly say this function has run?

I put my my automation function in user_routines.c defining it as void automation(void) {

Please tell me if all that I said is o.k.

Now how do I make it so that I can put Automation in its own .c file? Will it need its own .h? Do I have to define the .c file in ht userroutines.h? How will it know to use automation.h? to get to automation.c? to get to automation().

Now, how do I test this auto code without being in a match? Do I just move the call to automation from urf.c to ur.c?
I think you need to learn a bit more about C and C function prototyping. A good link repository is on the AVRFreaks Forum.

You could just move the functions from user_routines_fast.c to user_routines.c, or you can create an autonomous jumper. I forget specifically what pins you need to jump on the OI, but a quick search should bring it up.
__________________
http://www.mikesorrenti.com/
  #3   Spotlight this post!  
Unread 15-01-2006, 20:42
6600gt's Avatar
6600gt 6600gt is offline
Registered User
AKA: Lohit
FRC #0226 (Hammerhead)
Team Role: Alumni
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Troy, MI
Posts: 221
6600gt is a jewel in the rough6600gt is a jewel in the rough6600gt is a jewel in the rough
Re: Need a little help with how to break out of the box

user_routines_fast.c is for auton and user_routines.c is for manual driving.

make a .c file and a .h file(make sure when saving)

the header file or .h is for defining variables and the function prototypes such as
void Automation(void);
but when you use the function in the program its just Automation();

look at how the the user_routines.c and user_routines.h are set up.
In the Automation.c put:

#include "user_routines.h"
#include "Automation.h"
put all the includes that you see in user_routines.c

void Automation(void)
{
//put the code here
}

in user_routines_fast.c (and where ever else you call it) put the
#include "Automation.h" with all the others.

for the header file (Automation.h) to work you have to put

#ifndef __user_program_h_
#define __user_program_h_

//Define variables here (this not needed but it is for organization)


//Define function prototypes here(this also is commented out like the line above)

#endif

Sorry for the bad explanation this should help a lot http://www.ifirobotics.com/docs/lega...2-apr-2004.pdf

To test programming create this for the Operator interface competion port
http://www.ifirobotics.com/docs/comp...guide-reva.pdf
CAREFULL!! OR YOU COULD FRY YOUR OPERATOR INFERFACE

look here: http://www.chiefdelphi.com/forums/sh...ad.php?t=41472

Last edited by 6600gt : 15-01-2006 at 20:48.
  #4   Spotlight this post!  
Unread 15-01-2006, 22:55
amateurrobotguy's Avatar
amateurrobotguy amateurrobotguy is offline
Lead Programmer/Senior Engineer
no team
 
Join Date: Feb 2005
Rookie Year: 2000
Location: ****
Posts: 136
amateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these parts
Re: Need a little help with how to break out of the box

Thanks for not sabatoging me *wink* Well, one more question, since I just found out that it take slighly longer to go out to other.c files for 1 single function than to just put in a separate subroutine, I just want to know how to create my own subroutine here is what I did, tell me if I am right please:

void Automation(void)
{
*Code here*
}

Now, do I need to specifically do something like this or does it only run it once unless it has a loop in itself ~[or if it is in a loop, will it get run more than once?]:

void Automation(void)
{
int automationhasrun=0
if automationhasrun=0
{
*Code here*
automationhasrun=1
}
else {}
}
__________________
I quit FRC over 2 years ago (more if you're reading this past 2010).
  #5   Spotlight this post!  
Unread 16-01-2006, 00:28
6600gt's Avatar
6600gt 6600gt is offline
Registered User
AKA: Lohit
FRC #0226 (Hammerhead)
Team Role: Alumni
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Troy, MI
Posts: 221
6600gt is a jewel in the rough6600gt is a jewel in the rough6600gt is a jewel in the rough
Thumbs up Re: Need a little help with how to break out of the box

The subroutine is right but you have to put a function prototype in the user_routines.h
ex. void Automation(void); like the others already there

Now place this subroutine below all others in user_routines.c

Then call it like inside the function, void Process_Data_From_Master_uP(void)
and comment out the Default_Routine()
ex. (to allow you to control when the auton on and off)

if(p1_sw_trig==1)
Autonomous();
else
Default_Routine();
//basicly you have to hold the trigger to execute the auton.

No that wont work because it will only execute the auton once for a fraction of a second (26.2 ms to be exact) because the next time the automationhasrun = 1 so it wont run again;
DON'T DO THIS BECAUSE YOU DON'T HAVE CONTROL OVER IT.

The trigger control above will let you control the running of the auton.
  #6   Spotlight this post!  
Unread 16-01-2006, 12:18
amateurrobotguy's Avatar
amateurrobotguy amateurrobotguy is offline
Lead Programmer/Senior Engineer
no team
 
Join Date: Feb 2005
Rookie Year: 2000
Location: ****
Posts: 136
amateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these parts
Re: Need a little help with how to break out of the box

Again, thank you for the help
Quote:
No that wont work because it will only execute the auton once for a fraction of a second (26.2 ms to be exact) because the next time the automationhasrun = 1 so it wont run again;
DON'T DO THIS BECAUSE YOU DON'T HAVE CONTROL OVER IT.
But if I did use the variable, wouldn't it ensure that the subroutine just runs 1 time and never again until the robot is powered on? If I wanted a subroutine to run just one time in default_routines, would this need be used?

Code:
 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. */

        Generate_Pwms(pwm13,pwm14,pwm15,pwm16);

        Putdata(&txdata);   /* DO NOT DELETE, or you will get no PWM outputs! */
    }
  }
Like here won't it continuously loop the Auto code(An any subroutines in it) until it realizes 'hey, I am not in auto mode anymore'?

And what does the generat_pwms part do? Aren't they already initialized?
__________________
I quit FRC over 2 years ago (more if you're reading this past 2010).
  #7   Spotlight this post!  
Unread 16-01-2006, 12:56
6600gt's Avatar
6600gt 6600gt is offline
Registered User
AKA: Lohit
FRC #0226 (Hammerhead)
Team Role: Alumni
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Troy, MI
Posts: 221
6600gt is a jewel in the rough6600gt is a jewel in the rough6600gt is a jewel in the rough
Re: Need a little help with how to break out of the box

Quote:
But if I did use the variable, wouldn't it ensure that the subroutine just runs 1 time and never again until the robot is powered on? If I wanted a subroutine to run just one time in default_routines, would this need be used?
I don't completely understand your question?
It has to execute more than one cycle because a cycle only runs for a fraction of a second.
Now if you just want to run it once and set a bunch of pwm values then it will work but if you want to adjust these values later then it can't because it is not executing.

Quote:
Like here won't it continuously loop the Auto code(An any subroutines in it) until it realizes 'hey, I am not in auto mode anymore'?
First, yes it will and it is controlled by that switch mechanism you make for the operator interface.

In the real competion that loop autonomous_mode will execute for however long they singnal it to run in autonomous (10 sec for this years game).
If you make that switch mechanism you can run this loop for as long as you want. While the switch is on.

What I gave you before just lets you test auton without haveing to make that switch box. It lets you control how long the auton runs because you don't know when the robot starts acting crazy.
But FOR THE COMPETETION if you want he auton to work you have to put it in this user_routines_fast.c


Second the pwms 13-16 are different as they are generated by the user processor while all the others are generated by the master processor. They referesh faster ever 2ms rather than the 17ms for the 1-12 pwms. They are hardware generated. They are to fast for the servos.

I hope it answeres your questions, but if it doesn't then could you explain your quesiton differently?

Last edited by 6600gt : 16-01-2006 at 13:01.
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
Pre-manufactured control box for FIRST Ben.V.293 Technical Discussion 19 22-08-2005 12:53
Autonomous Camera Integration GregC Programming 2 06-02-2005 14:34
box grabbing matt111 3D Animation and Competition 3 27-01-2003 23:08
project box archiver 2000 2 23-06-2002 23:01
Gray box limitations Tim Skloss Technical Discussion 1 23-01-2002 07:38


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

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