|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
IR board code
I'm am the programmer for team 1691 and I'm am currently working on programming the ir board. I think that the sort of thing that i want to do is have one button coorespond with just going around the track, one for knocking the trackball off of the left spot, one for knocking it off of the middle, and the last for knocking it off of the right spot. i was wondering if any one out that has done something along these lines could send me a sample of their program?
as you know the ship date is on tuesday, so the sooner you can respond the better off i will be. Thank you for any help you can bring to the table. |
|
#2
|
||||
|
||||
|
Re: IR board code
just do
if((pick the digital io you want)==1) { // add code here } |
|
#3
|
||||
|
||||
|
Re: IR board code
Actually, that will always run as the IR returns 1 unless the signal matches. You will need to have an equivalency check with 0, and probably code to avoid running without the IR connected. I'll post an example once I get back to my code...
As for the actual autonomous mode... Are you basically looking for a complete code to base yours off or something specific you need an example of? If you're looking for something in general, I can post an example of our team's state machine stuff... Once again when I get the laptop back. |
|
#4
|
|||
|
|||
|
Re: IR board code
That is pretty much what i was thinking. we are short on time and we have one way or another fried our ir board, so we are making a code in hopes of getting it fixed with the help of other teams at our regional.
|
|
#5
|
||||
|
||||
|
Re: IR board code
If the IR board's gone, then that would significantly change the strategy... Maybe you'll be able to purchase another before the actual regional, so in case you get one working, this is what we used for the IR board:
Code:
// IR Inputs #define IR_DIG_1 rc_dig_in04 #define IR_DIG_2 rc_dig_in05 #define IR_DIG_3 rc_dig_in06 #define IR_DIG_4 rc_dig_in07 #define IR_DISCONNECTED (IR_DIG_1 && IR_DIG_2 && IR_DIG_3 && IR_DIG_4) #define IR_1 (IR_DIG_1 && !IR_DISCONNECTED) #define IR_2 (IR_DIG_2 && !IR_DISCONNECTED) #define IR_3 (IR_DIG_3 && !IR_DISCONNECTED) #define IR_4 (IR_DIG_4 && !IR_DISCONNECTED) Code:
static int routine = 0;
if(IR_1){
routine=1;
}
if(IR_2){
routine=2;
}
if(IR_3){
routine=3;
}
if(IR_4){
routine=4;
}
switch (routine){
case (1):
routine_1();
break;
case (2):
routine_2();
break;
case (3):
routine_3();
break;
case (4):
routine_4();
break;
default:
routine_0();
break;
}
Code:
typedef enum{
AUTO_DRIVE_1
AUTO_TURN
AUTO_DRIVE_2
AUTO_COMPLETE
} auto_state;
Code:
usigned char do_half_lap (void){
static unsigned char current_state = 0; //This is the current progress
switch (current_state){
case (AUTO_DRIVE_1):
current_state += drive_x_dist(100);
break;
case (AUTO_TURN):
current_state += turn_90_degrees();
break;
case (AUTO_DRIVE_2):
current_state += drive_x_dist(50);
break;
case (AUTO_COMPLETE):
return 1;
break;
}
}
return 0;
I'll leave the subfunction implementation code up to you; but it should be pretty easy. Let me know if any of this is too complicated. Keep in mind these are all samples and haven't been tested. I advise not copy/pasting anything and writing your own with this as a reference. Last edited by psy_wombats : 17-02-2008 at 19:30. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problems integrating CMUCAM code and IFI Default Code | Windward | Programming | 2 | 06-02-2007 16:48 |
| problems using gyro/adc code with camera default code | tanstaafl | Programming | 7 | 22-01-2006 23:09 |
| Lights in Joystick board or control board | rcubes85 | Control System | 15 | 26-02-2005 23:40 |
| Team THRUST - Kevin's Code and Camera Code Combine | Chris_Elston | Programming | 3 | 31-01-2005 22:28 |
| Perf Board = BS2-IC Carrier Board? | indieFan | Electrical | 2 | 16-09-2004 08:28 |