|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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? |
|
#2
|
|||||
|
|||||
|
Re: Need a little help with how to break out of the box
Quote:
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. |
|
#3
|
||||
|
||||
|
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
|
||||
|
||||
|
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 {} } |
|
#5
|
||||
|
||||
|
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
|
||||
|
||||
|
Re: Need a little help with how to break out of the box
Again, thank you for the help
Quote:
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! */
}
}
And what does the generat_pwms part do? Aren't they already initialized? |
|
#7
|
||||
|
||||
|
Re: Need a little help with how to break out of the box
Quote:
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:
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. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |