Go to Post There can be a fine line between intimidation and inspiration when it come to the elite in FIRST. Those teams who have committed to setting the bar for excellence in ways that change the culture, help to draw that line and deepen it. - JaneYoung [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 09-12-2006, 11:04
itsme itsme is offline
Registered User
FRC #2217 (FOMH)
Team Role: Programmer
 
Join Date: Dec 2006
Rookie Year: 2007
Location: Israel
Posts: 86
itsme is an unknown quantity at this point
Question about programing the bumper sensors

Hello everyone!
Recently I was appointed to be one of the programers in our team. This is my first time I'm in FIRST. I have been learning a bit how to use EasyC and for now it's easier than I thought. Our school got first the Vex robot to practice on it till the larger robot comes. But I have one question: does the bumper sensor have an option to make it as an interrupt?
I'm asking this because I want to do a simple task for the robot: the robot has 2 bumper sensors, one on the front and one on the back. I want to program it to do the following: if the front bumper is pressed, then go backwards for 500 miliseconds and then turn for 500 miliseconds (about 90 degrees). But if the back bumper is pressed while doing so, I want it to drive back forward. For now, I didn't know if the bumper sensor has the option to be an interrupt, so I programed it in the following, inelegant way:

Code:
void Bumper(void)
{
       int counter;
       Get_Bumper_Data(Front_Bumper_Port) /*puts the data from the front bumper into a global varaible named Front_Bumper_Data*/

       if(Front_Bumper_Data==0) //if front bumper is pressed
       {
                    Drive(255,0); /*this function makes the motors run, in this case it drives back*/

                    counter=0;
                    while(counter<=50) //while the robot is driving backwards
                     {
                            Get_Bumper_Data(Back_Bumper_Port) /*puts the data from the back bumper into a global varaible named Back_Bumper_Data*/

                             if(Back_Bumper_Data==0) //if back bumper is pressed
                              {
                                     break;
                              }
                         wait(10);
                         counter=counter+10;
                      }
                        Get_Bumper_Data(Back_Bumper_Port)
                         if(Back_Bumper_Data==1) //if back bumper is not pressed
                            {
                                 Drive(255,127)//turns
                                 counter=0;
                                 while(counter<=50)
                                 {
                                   Get_Bumper_Data(Back_Bumper_Port)
                                       if(Back_Bumper_Data==0)
                                               {
                                                    break;
                                               }
                                         wait(10);
                                         counter=counter+10;
                                  }      
       }
}
And now I put the function in the main in this way:

Code:
void main(void)
{
     while(1) //infinitive loop
     {
        Drive(0,255) //drives forwoard (it is a function I made)
        Bumper();
     }  
}
My question is: isn't there any other more elegant way to do this? I mean, I did the while loop because thats the only way I found how to check every little part of time if the back bumper was pressed. If the back bumper has the interrupt option then it could be a lot easier. So if it does, can someone tell me how to do it?

p.s. sorry about my English.

Last edited by itsme : 09-12-2006 at 11:18.
 


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
Bumper sensors jbill30 Programming 1 01-05-2006 18:49
Quick question about sensors..plz help thnx pheNIX637 Technical Discussion 6 30-10-2005 02:52
Bumper sensors jeffmorris FIRST Tech Challenge 1 02-10-2005 16:20
question on the pressure pad sensors Simon Strauss Rules/Strategy 5 08-01-2005 23:42
question about one joystick drive programing james700 Programming 13 29-01-2003 14:49


All times are GMT -5. The time now is 01:27.

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