Go to Post No, nothing secret unless you include the following: will it work?, can it be driven and will it release the balls. - twolf [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 03-02-2008, 14:25
Shivang1923 Shivang1923 is offline
I make robot go VROOM VROOM!
FRC #1923 (MidKnight Inventors)
Team Role: Programmer
 
Join Date: Feb 2008
Rookie Year: 2008
Location: West Windsor, NJ
Posts: 38
Shivang1923 has a spectacular aura aboutShivang1923 has a spectacular aura about
Programing joystick buttons

Could someone please help me? I've been trying to figure out how to program the joystick buttons to make the motors move. I looked through the code samples, and the default code and I found nothing that I can understand properly.

My past experience with C is MikroC which is different than programing the FIRST FRC robots.

Thanks in advance!
  #2   Spotlight this post!  
Unread 03-02-2008, 14:30
psy_wombats's Avatar
psy_wombats psy_wombats is offline
Registered User
AKA: A. King
FRC #0467 (Duct Tape Bandits)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Shrewsbury MA
Posts: 95
psy_wombats has a spectacular aura aboutpsy_wombats has a spectacular aura aboutpsy_wombats has a spectacular aura about
Re: Programing joystick buttons

The joystick buttons should follow this sort of naming convention:

Code:
p1_sw_aux1
p1_sw_aux2
p1_sw_trig
p1_sw_top
Then just change the number of the port. You may want to look at ifi_frc.h. Everything's in there.

You should be able to work these with a simple if statement, something like:

Code:
if (p1_sw_aux1){
pwm01=255;
} else {
pwm01=127;
}
  #3   Spotlight this post!  
Unread 03-02-2008, 14:33
paulcd2000's Avatar
paulcd2000 paulcd2000 is offline
Accidentally speaks in C
AKA: Paul Dagnelie
FRC #1719 (The Umbrella Corp.)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Baltimore
Posts: 368
paulcd2000 is a jewel in the roughpaulcd2000 is a jewel in the roughpaulcd2000 is a jewel in the rough
Send a message via AIM to paulcd2000
Re: Programing joystick buttons

there's also of course the joystick values themselves (p1_y, p1_x, p2_y...), and the wheel values (p1_wheel) (look on other threads for the output)
__________________
"People don't say 'It's just a game' when their team is winning!" -- Scott Adams

5.5 students (on average)* $7/h *210 hours/student= $8085 of labor, all volunteered (not counting mentors', who are each that much)

We have blades on our robot?! ***sweeeeeet***

There are 11 types of people in the world. Those who can read binary, those who can't, and those who say this joke is supposed to be, "There are 10 types of people in the world. Those who can read binary and those who have a life."
  #4   Spotlight this post!  
Unread 03-02-2008, 14:37
tseres's Avatar
tseres tseres is offline
obsessed with FIRST...
FRC #1565 (Think Tank Tech)
Team Role: Leadership
 
Join Date: Apr 2007
Rookie Year: 2007
Location: Cambridge, ON
Posts: 305
tseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of light
Re: Programing joystick buttons

ok, i'll assume you're using port 1 on the operator interface (OI). just because i'm not sure what you know up to this point (and who's reading) i'll just give a brief intro.

as you know, the port your joystick is plugged into is referrred to as pX_something, so it will be p1_.....

the analog outputs are

p1_y, the y-axis,
p1_x, the x-axis,
p1_wheel, p1_aux ...these are not used as far as i know on the KOP joysticks (possibly the hat on the top?), but they ARE used with the USB ckicklet if you're using that....

now, the analog buttons are:
p1_sw_trig, the trigger,
p1_sw_top, one of the buttons, i'm not sure which, as with
p1_sw_aux1 and p1_sw_aux2.

that's about it!
__________________


  #5   Spotlight this post!  
Unread 03-02-2008, 19:14
ShotgunNinja's Avatar
ShotgunNinja ShotgunNinja is offline
Programming Mentor, FRC 4247
AKA: Nicholas Iannone
FRC #4247 (CougarBOTS)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2006
Location: Milwaukee, WI
Posts: 160
ShotgunNinja is a jewel in the roughShotgunNinja is a jewel in the roughShotgunNinja is a jewel in the roughShotgunNinja is a jewel in the rough
Re: Programing joystick buttons

Are you using a Robotics IDE (ROBOTC, EasyC, etc.), or are you using a regular C editor? I've found EasyC to be just that, easy. If you are this early on in the programming, you can still switch over to EasyC (or another), and have that much already taken care of for the programming, so you can focus on other things like figuring out the best way to pull off Hybrid Mode.

In EasyC, you could do it in about 6 lines of code.

EDIT: By the way, yes; the p1_wheel does refer to the "hat", and I believe that there is also p1_sw_thumb for the thumb button (or would that be what p1_sw_top goes to?)
__________________
Team #2970 Alum
Team #1652 Alum
2006: School Mascot for Team 1652
2007-2008: Programmer for Team 1652 (Robot Mafia)
2009: Programmer on Team 1652 (Robot Mafia), Programmer on Team 2970 (eSchool eBots)
2010-2016: Volunteer, Wisconsin Regional
2017: Programming Mentor, FRC 4247 (CougarBOTS, Obama SCTE, Milwaukee, WI)

Last edited by ShotgunNinja : 03-02-2008 at 19:17.
  #6   Spotlight this post!  
Unread 03-02-2008, 19:22
lukevanoort lukevanoort is offline
in between teams
AKA: Luke Van Oort
no team
 
Join Date: Oct 2005
Rookie Year: 2005
Location: Waterloo, ON, Canada
Posts: 1,873
lukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond repute
Send a message via AIM to lukevanoort
Re: Programing joystick buttons

Quote:
Originally Posted by ShotgunNinja View Post
In EasyC, you could do it in about 6 lines of code.
I'm surprised it takes that much. In MPLAB, it is just four:
Code:
if(p1_sw_top)
   pwm01 = 254;
else
   pwm01 = 127;
or five:

Code:
if(p1_sw_top){
   pwm01 = 254;
} else {
   pwm01 = 127;
}
depending on your coding styles.

p1_sw_top is the top button on CH flightsticks and, I believe, one of the buttons on the top of the AVB Top Shots. I think the thumb button is either another trigger or top button... the wiring in those AVB sticks is darn confusing.
__________________
Team 1219: 2009 - Mentor
Team 587: 2005 - Animator, 2006-2008 - Team Captain
  #7   Spotlight this post!  
Unread 03-02-2008, 19:47
ShotgunNinja's Avatar
ShotgunNinja ShotgunNinja is offline
Programming Mentor, FRC 4247
AKA: Nicholas Iannone
FRC #4247 (CougarBOTS)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2006
Location: Milwaukee, WI
Posts: 160
ShotgunNinja is a jewel in the roughShotgunNinja is a jewel in the roughShotgunNinja is a jewel in the roughShotgunNinja is a jewel in the rough
Re: Programing joystick buttons

Well, actually, we're using two AVB (or is it ADB? It looks kind of like that ) sticks for our OI, and using EasyC for programming, we don't need to use the p1_sw_(fill in the blanks) variables, as we can just use a single function to bind everything together. It hurts my pride acquired from slaving over the Source Engine code to use such simplified functions, thus limiting my amount of precise control, but it goes a lot faster, and it works.

EDIT: And those six lines set up the entire operator interface. Just a by-the-way.
__________________
Team #2970 Alum
Team #1652 Alum
2006: School Mascot for Team 1652
2007-2008: Programmer for Team 1652 (Robot Mafia)
2009: Programmer on Team 1652 (Robot Mafia), Programmer on Team 2970 (eSchool eBots)
2010-2016: Volunteer, Wisconsin Regional
2017: Programming Mentor, FRC 4247 (CougarBOTS, Obama SCTE, Milwaukee, WI)
  #8   Spotlight this post!  
Unread 03-02-2008, 20:46
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Programing joystick buttons

Quote:
Originally Posted by lukevanoort View Post
I'm surprised it takes that much. In MPLAB, it is just four:
Code:
if(p1_sw_top)
   pwm01 = 254;
else
   pwm01 = 127;
or five:

Code:
if(p1_sw_top){
   pwm01 = 254;
} else {
   pwm01 = 127;
}
depending on your coding styles.
I can name that tune in one note...I mean, I can write that function in one line:
Code:
  pwm01 = p1_sw_top?254:127;
Anyway, Shivang, if you give some more detail about what you want to accomplish, we can give better advice. Which buttons do you want to use, and what do you want the motors to do when you use them?
  #9   Spotlight this post!  
Unread 09-02-2008, 16:21
program1's Avatar
program1 program1 is offline
Registered User
AKA: RJ
FRC #2441
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Maryknoll
Posts: 43
program1 will become famous soon enough
Re: Programing joystick buttons

it mostly depends on which controler you are using, if your using controler 1:

p1_sw_trig
p1_sw_top
p1_sw_aux1
p1_sw_aux2

to program the buttons is acutally very simple

pwm01 = 127

if (p1_sw_trig == 1)
{pwm01 = 150}

this program says "while controler 1's trigger is being pressed, pwm01 will move at 150"

this is the way i was taught anyway, the other ways will work also
__________________
ok, who ate my hot pocket?
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
Buttons to Pins on Joystick yarb65 Electrical 1 24-08-2007 20:39
Programming Extra Joystick Buttons Inverted Programming 2 08-02-2007 11:45
Victors Controlled By Joystick Buttons douglass1371 Electrical 2 17-02-2006 01:57
Programing a joystick Justin_302 Programming 2 21-03-2005 22:45
Assigning Joystick buttons.... archiver 2001 5 24-06-2002 00:59


All times are GMT -5. The time now is 02:58.

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