Go to Post "You are the lead programmer now, therefore everything that goes wrong is your fault. When anything good happens its the teams fault." "But what if the robot spontaneously combusts?" "Your Fault." ~Borna - CodeTBone [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 15-02-2005, 22:32
TMHStitans TMHStitans is offline
Robot Operator-2005
AKA: Eric
#1474 (Tewksbury Titans)
Team Role: Programmer
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Tewksbury, Massachusetts
Posts: 6
TMHStitans has a little shameless behaviour in the past
Question Programming motors with joystick buttons

I am a relatively new programmer on a second year team. I was wondering if anyone knows if it is possible to program a window motor using the joystick buttons. What our team would like to do is to program our joystick so that when we press one button, the arm motor goes forward. When we press another button, we want the motor to go back. I do not know how to translate the relay outputs to a pwm output which would make the motor move. I tried writing an if statement that makes the pwm produce an output if a button is pressed, however nothing happens. I have performed countless searches for this information. The only threads I found talked about operating pnuematics using the joystick buttons, not motors. I do not know how to wire or program the relays so as to get a pwm output. I would appreciate any help. Thanks.

Lead Programmer, Team 1474
  #2   Spotlight this post!  
Unread 15-02-2005, 23:01
incognito_NICK's Avatar
incognito_NICK incognito_NICK is offline
hidden in the corner
AKA: Nick Ferreira
#0179 (Children of the swamp (swampthing))
Team Role: Programmer
 
Join Date: Nov 2004
Rookie Year: 2002
Location: palm beach gardens
Posts: 15
incognito_NICK will become famous soon enough
Send a message via ICQ to incognito_NICK Send a message via AIM to incognito_NICK
Re: Programming motors with joystick buttons

you have the right idea about using an if statment.

what you can try is something like this:

Code:
if(p1_sw_trig==1)
{
   pwm01=254;
  }
else if(p1_sw_top==1)
{
   pwm01=0;
   }
else
{
 pwm01=127;
 }
  #3   Spotlight this post!  
Unread 15-02-2005, 23:10
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,785
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Programming motors with joystick buttons

Same sort of thing would work if you have the window motor on a spike.
Code:
if (p1_sw_trig==1)
{
	relay2_fwd = 1;
	relay2_rev = 0;
}
else if (p1_sw_top==1)
{
	relay2_fwd = 0;
	relay2_rev = 1;
}
else
{
	relay2_fwd = 0;
	relay2_rev = 0;
}
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
  #4   Spotlight this post!  
Unread 15-02-2005, 23:16
Manoel's Avatar
Manoel Manoel is offline
Registered User
FRC #0383 (Brazilian Machine)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 2000
Location: Porto Alegre, RS, Brazil
Posts: 608
Manoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond repute
Send a message via ICQ to Manoel Send a message via MSN to Manoel
Re: Programming motors with joystick buttons

Or, alternatively:

Code:
pwmxx = (127 + (127*p1_sw_top) - (127*p1_sw_trig));
,

Replace xx with the pwm output you'll be using for the motor. In this case, pressing p1_sw_top will make the motor go full forward, p1_sw_trig will make it full reverse, and pressing both will do nothing.

__________________
Manoel Flores da Cunha
Mentor
Brazilian Machine
Team # 383
  #5   Spotlight this post!  
Unread 15-02-2005, 23:29
stephenthe1 stephenthe1 is offline
Registered User
#1008
 
Join Date: Dec 2004
Location: Ohio
Posts: 113
stephenthe1 is on a distinguished road
Re: Programming motors with joystick buttons

hey,
I always wandered, when you press a button on a joystick (say the top button or trigger), does it "remember" it was pressed and hold a value of 1? I don't really understand this. otherwise, for the guy who posted this forum, he would have to be holding down the trigger, which seems like it would be problematic. do you know what I mean? how does that work.
  #6   Spotlight this post!  
Unread 21-03-2005, 21:07
dm0ney's Avatar
dm0ney dm0ney is offline
Will Code For Food (Food Optional)
AKA: Deepak Mishra
None #0217 (The ThunderChickens)
Team Role: Alumni
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Shelby Twp., MI
Posts: 48
dm0ney will become famous soon enough
Send a message via AIM to dm0ney
Re: Programming motors with joystick buttons

Quote:
Originally Posted by stephenthe1
hey,
I always wandered, when you press a button on a joystick (say the top button or trigger), does it "remember" it was pressed and hold a value of 1? I don't really understand this. otherwise, for the guy who posted this forum, he would have to be holding down the trigger, which seems like it would be problematic. do you know what I mean? how does that work.
When a button is pressed on a joystick, it is not remembered. If the motor was to be driven for some time and the user did not want to hold the button until the desired point, a flag would have to be used.

The flag would be set to one when the button is pressed which would enable code controlling relay ouputs or pwms. Once a desired outcome happens, the flag would have to be reset. The outcome could be a pot position being reached, an encoder count value, a set amount of time from either Kevin's clock or a clock variable incremented every program cycle, or even the ORIGINAL BUTTON pressed on the joystick.
__________________

Alumni
Team #217, The ThunderChickens



Student, Class of 2009
California Institute of Technology


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
Using the extra buttons on the joystick. Code\\Pilot Programming 7 04-12-2004 19:30
problem with joystick buttons (top left one) Richomundo Programming 5 15-02-2004 17:16
Programming the second joystick in PBASIC archiver 2001 2 24-06-2002 00:25
Looking for practice motors & extra tape drive parts? archiver 2000 1 23-06-2002 22:54
"Motors and Drive train edition" of Fresh From the Forum Ken Leung CD Forum Support 6 29-01-2002 12:32


All times are GMT -5. The time now is 00:05.

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