Go to Post Between Andy B. and Andy G. being Andy A. has some unspoken expectations put on it. - Andy A. [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 17-01-2005, 20:17
kshot kshot is offline
Registered User
#0968 (RAWC)
Team Role: Programmer
 
Join Date: Jan 2005
Rookie Year: 2005
Location: West Covina, California
Posts: 5
kshot is an unknown quantity at this point
Send a message via AIM to kshot
Rookie programmer in need of help.

Hello all,

This is pretty much my first year of doing programming in C for purposes other than using it in robots. I was wondering on how to put a line of code in to add a button that would act as a click switch and tell the RC that a button was hit, and then it would proceed onto the next line of programming.

Thanks.
  #2   Spotlight this post!  
Unread 17-01-2005, 20:36
Unsung FIRST Hero
Mike Betts Mike Betts is offline
Electrical Engineer
no team
Team Role: Engineer
 
Join Date: Dec 2001
Rookie Year: 1995
Location: Homosassa, FL
Posts: 1,442
Mike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond repute
Re: Rookie programmer in need of help.

Quote:
Originally Posted by kshot
Hello all,

This is pretty much my first year of doing programming in C for purposes other than using it in robots. I was wondering on how to put a line of code in to add a button that would act as a click switch and tell the RC that a button was hit, and then it would proceed onto the next line of programming.

Thanks.
Kshot,

Do you want the button to be at the operator interface (such as a momentary switch that the driver pushes) or on the robot (such as a micro switch indicating an arm is at the end of its travel)?
__________________
Mike Betts

Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013

As easy as 355/113...
  #3   Spotlight this post!  
Unread 17-01-2005, 20:44
kshot kshot is offline
Registered User
#0968 (RAWC)
Team Role: Programmer
 
Join Date: Jan 2005
Rookie Year: 2005
Location: West Covina, California
Posts: 5
kshot is an unknown quantity at this point
Send a message via AIM to kshot
Re: Rookie programmer in need of help.

Well, I wanted the button to be placed in front of the robot, then as the driver pushes the robot forward, if the button is pressed (vision tetra is being pushed against the robot), then the program would then execute it's next stage.
  #4   Spotlight this post!  
Unread 17-01-2005, 20:55
Unsung FIRST Hero
Mike Betts Mike Betts is offline
Electrical Engineer
no team
Team Role: Engineer
 
Join Date: Dec 2001
Rookie Year: 1995
Location: Homosassa, FL
Posts: 1,442
Mike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond repute
Re: Rookie programmer in need of help.

Quote:
Originally Posted by kshot
Well, I wanted the button to be placed in front of the robot, then as the driver pushes the robot forward, if the button is pressed (vision tetra is being pushed against the robot), then the program would then execute it's next stage.
See page 11 of 2004-programming-reference-guide-12-apr-2004.pdf (at the bottom of Perform Operations Example)for an example of how to reference a digital input. In this case, they use rc_dig_in01 to decide what to do (will the roller stop or go?).

You would need to connect your switch to digital input #1 on the robot controller for this to work.

Does this help?
__________________
Mike Betts

Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013

As easy as 355/113...
  #5   Spotlight this post!  
Unread 17-01-2005, 21:27
gnormhurst's Avatar
gnormhurst gnormhurst is offline
Norm Hurst
AKA: gnorm
#0381 (The Tornadoes)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Trenton, NJ
Posts: 138
gnormhurst will become famous soon enoughgnormhurst will become famous soon enough
Re: Rookie programmer in need of help.

I think you are saying that after the switch is hit, then a new section of code is enabled. Yes? And I think you want the code to remember that the switch had been hit, even after the switch is no longer pressed?

(experienced programmers, please check for errors. I did this off the top of my head!)

In the file user_routines.c...


In the function User_Initialization(), make sure:

Code:
// tell the controller that we want to use io pin 15 as an input:
//
digital_io_15 = INPUT;  // or whichever input you want to use

also, somewhere in user_routines.c, near the top:
Code:
#define  MY_SWITCH rc_dig_in15  // makes the other code easier to read
In the function Default_Routine(void), add your code like this:

near the top
Code:
static unsigned char switchWasHit = 0;
later:
Code:
// when the switch is hit, it closes, and pulls the input low i.e. 0
//
if ( MY_SWITCH == 0 )  
   switchWasHit = 1;   // remember forever

if ( switchWasHit )
{
  /* this is never executed before the switch is hit, and is
      always executed after the switch is hit
  */
}
Remember that Default_Routine(void) is executed over and over again, about 39 times a second.

Does that help?
__________________
Trenton Tornadoes 381
2004 Philadelphia Regional Winners
2006 Xerox Creativity Award
---
My corner of the USPTO.
My favorite error message from gcc: main is usually a function
My favorite error message from Windows: There is not enough disk space available to delete this file.
  #6   Spotlight this post!  
Unread 18-01-2005, 10:25
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: Rookie programmer in need of help.

I think he may want to go even further and basically have a debug switch. When he hits it, then the next line of code is executed, then the robot waits again.

I'm not sure if this is possible on the RC. On a computer, debuggers typically work by hooking into a software interrupt (don't remember which one right now) and stopping execution when it is activated. I'm not sure if a similar thing exists on the RC, but if it does and you get that working, you'd be my hero.
__________________

  #7   Spotlight this post!  
Unread 19-01-2005, 01:59
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: Rookie programmer in need of help.

if what Ryan M. says about kshot's objectives is true, the simplest way would probably be with a finite state machine and a variable to determine if the robot is in a 'wait' state.
__________________
Team 1020, the Indiana Prank Monkeys (www.team1020.org)
  #8   Spotlight this post!  
Unread 20-01-2005, 15:05
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: Rookie programmer in need of help.

Quote:
Originally Posted by Ryan M.
I think he may want to go even further and basically have a debug switch. When he hits it, then the next line of code is executed, then the robot waits again.
If you're refering to every line of C, than yes it would be, because data has to be returned to the master processor in a timely manner.

However, if you're refering to scripting (or any other high-level, multi-cycle sections), than this is entirely possible.
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
A ? about NASA grants computhief263 General Forum 18 29-03-2004 13:35
Rookie Regionals rachakate Regional Competitions 5 24-03-2004 00:01
TEAM 121 and a rookie team on CBS SAT MORNING! Joe Menassa General Forum 7 21-03-2002 00:47
Rookie Programmer has question about the default code DanL Programming 3 26-01-2002 19:59


All times are GMT -5. The time now is 15:44.

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