Go to Post I remember eating dinner once. Long before Build season. Now, we only eat aluminum swarf and disappointment. - BeardyMentor [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 10-02-2007, 15:55
EOC's Avatar
EOC EOC is offline
Registered User
AKA: Eric Curry
None #1208 (Metool Brigade)
Team Role: Coach
 
Join Date: Jan 2005
Rookie Year: 2003
Location: Illinois
Posts: 200
EOC has a brilliant futureEOC has a brilliant futureEOC has a brilliant futureEOC has a brilliant futureEOC has a brilliant futureEOC has a brilliant futureEOC has a brilliant futureEOC has a brilliant futureEOC has a brilliant futureEOC has a brilliant futureEOC has a brilliant future
Smile Re: Programming a Joystick

joystick related code is delt with in user_routines.c. Each button has it's own variable. Joystick positions have two variables, 1 for the x directions and one for the y directions. The values for these positions are mapped like pwm values: 0 is full one direction, 127 means the joystick is in it's neutral position, and 255 means the joystick is being pushed as far as it goes in the other direction. Because of the nature of the values, putting the line of code:

pwm01 = p1_y;

... would be legit, because when the joystick is just sitting there, it doesn't move, and when the joystick is pushed forward/backward all the way, the motor goes as fast as it goes in the appropriate direction. This setup is a bit twitchy, because slight movements in the joystick gets responses from the motor.

Variable names are in the format *joystick_port_name*_*button/axis*.
This means p2_x is the variable dealing with the joystick plugged into the second control port, and the has to do with the x axis directions.

As for unplugging the joystick in the middle of a competion; don't. It confuses the robot, and bad things happen .
  #2   Spotlight this post!  
Unread 10-02-2007, 15:59
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: Programming a Joystick

Quote:
Originally Posted by EOC View Post
This setup is a bit twitchy, because slight movements in the joystick gets responses from the motor.
you can write a function to cancel out values near the middle range. we call ours, "DEADZONE":
Code:
unsigned char Deadzone(unsigned char x){
	if ( (x <= (127 + DEADZONE)) && (x >= (127 - DEADZONE)) ) // if variable is within DEADZONE, stop motor 
		return STOP;
	else
		return x;
}
you need to #define deadzone as something, around 15-20
just implement it:
Code:
p1_y = Deadzone(p1_y);
  p1_x = Deadzone(p1_x);
  p2_y = Deadzone(p2_y);
  p2_x = Deadzone(p2_x);
  p3_y = Deadzone(p3_y);
__________________
"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."
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
Programming Extra Joystick Buttons Inverted Programming 2 08-02-2007 11:45
Joystick Programming team 803 Programming 6 21-02-2006 11:49
Joystick Button programming Bharat Nain Programming 5 18-02-2005 11:48
single joystick programming Bill Bonsky OCCRA 2 04-10-2003 09:47
Programming the second joystick in PBASIC archiver 2001 2 24-06-2002 00:25


All times are GMT -5. The time now is 04:53.

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