Go to Post Some of the best team captains I've seen have been from rookie teams. - Conor Ryan [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 02-02-2005, 15:36
willie837's Avatar
willie837 willie837 is offline
Registered User
#0837 (Webbinators)
Team Role: Programmer
 
Join Date: Jan 2005
Location: Oxford, NC
Posts: 9
willie837 is an unknown quantity at this point
Send a message via AIM to willie837
need help w/ joystick code

I have a single joystick code for my robot, but I don't want it to do anything when i tilt the joystick left and right. I can't figure out how to stop the robot from doing anything when i move the joystick left and right. Please help!
__________________
Freshman

Please, I need your help with programming. It is my first year with Robotics and I have been chosen as programmer. If possible can anyone IM or PM me with some codings to help with the prgramming? I need especially a code to change our robot's control to two jostick tank drive from one jostick drive. I also need autonomous help. Thank you so much.



"Don't Die Worrying..." Alicia Molik
  #2   Spotlight this post!  
Unread 02-02-2005, 15:46
kjohnson's Avatar
kjohnson kjohnson is offline
Insert Clever Title Here
AKA: Kyle J.
FRC #1610 (BOT)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Virginia
Posts: 575
kjohnson has a reputation beyond reputekjohnson has a reputation beyond reputekjohnson has a reputation beyond reputekjohnson has a reputation beyond reputekjohnson has a reputation beyond reputekjohnson has a reputation beyond reputekjohnson has a reputation beyond reputekjohnson has a reputation beyond reputekjohnson has a reputation beyond reputekjohnson has a reputation beyond reputekjohnson has a reputation beyond repute
Re: need help w/ joystick code

Just comment out anything that has to do with the x-axis on the joystick and leave everything with the y-axis.

This may not work correctly but we have never used a one joystick drive so I don't really know if it will work or not. It may be more complicated than just commenting out the x-axis. Taking out the x-axis may actually disturb the mixing function of the code but its worth a try.
  #3   Spotlight this post!  
Unread 02-02-2005, 15:54
Chris Hibner's Avatar Unsung FIRST Hero
Chris Hibner Chris Hibner is offline
Eschewing Obfuscation Since 1990
AKA: Lars Kamen's Roadie
FRC #0051 (Wings of Fire)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1997
Location: Canton, MI
Posts: 1,488
Chris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond repute
Re: need help w/ joystick code

Add a joystick deadzone in the code. For example:

Code:
#define JOY_DEADZONE 10
if (xJ_raw < 127-JOY_DEADZONE)
{
    xJ_raw = xJ_raw + JOY_DEADZONE;
}
else if (xJ_raw > 127+JOY_DEADZONE)
{
    xJ_raw = xJ_raw - JOY_DEADZONE;
}
else
{
    xJ_raw = 0;
}

if (yJ_raw < 127-JOY_DEADZONE)
{
    yJ_raw = yJ_raw + JOY_DEADZONE;
}
else if (yJ_raw > 127+JOY_DEADZONE)
{
    yJ_raw = yJ_raw - JOY_DEADZONE;
}
else
{
    yJ_raw = 0;
}
Of course, the above assumes that the joystick is biased at 127 and you are using unsigned variables for your joystick axes.
__________________
-
An ounce of perception is worth a pound of obscure.
  #4   Spotlight this post!  
Unread 02-02-2005, 21:22
JoelP JoelP is offline
whats the P for? Pazhayampallil
FRC #1155 (Bronx Science Sciborgs)
Team Role: Leadership
 
Join Date: Dec 2004
Rookie Year: 2005
Location: bronx, new york
Posts: 62
JoelP is a jewel in the roughJoelP is a jewel in the roughJoelP is a jewel in the rough
Send a message via AIM to JoelP
Re: need help w/ joystick code

dont even bother with setting up a deadzone.
this is assuming your using the default FRC codes
in user_routines.c go to the void Process_Data_From_Master_uP(void) function
then find the printf statement and change it from this
Code:
printf("Port1 Y %3d, X %3d, Fire %d, Top %d\r",(int)p1_y,(int)p1_x,(int)p1_sw_trig,(int)p1_sw_top);
to this
Code:
printf("Port1 Y %3d, Fire %d, Top %d\r",(int)p1_y,(int)p1_sw_trig,(int)p1_sw_top);
poof, no more x-axis

then to avoid any problems with the mixer, just remove it and replace it with another code to set pwm values to the y-axis
ex.
Code:
pwm01=p1_y
pwm02=254 - p2_y /*to reverse the pwm signals if you want,
                            instead of reversing the motor polarity*/

Last edited by JoelP : 02-02-2005 at 21:30.
  #5   Spotlight this post!  
Unread 02-02-2005, 22:47
devicenull devicenull is offline
Robot? We need a robot?
no team
 
Join Date: Sep 2004
Rookie Year: 1234
Location: n/a
Posts: 359
devicenull is just really nicedevicenull is just really nicedevicenull is just really nicedevicenull is just really nicedevicenull is just really nice
Re: need help w/ joystick code

Taking out the x axis on single joystick is a bad idea. AFAIK, its just going to go only forward or backward, because theres nothing there telling it to turn.

JoelP's code is going to give you forward and reverse only... which would be fine for tank drive (2 joysticks), but not single
  #6   Spotlight this post!  
Unread 02-02-2005, 23:12
JoelP JoelP is offline
whats the P for? Pazhayampallil
FRC #1155 (Bronx Science Sciborgs)
Team Role: Leadership
 
Join Date: Dec 2004
Rookie Year: 2005
Location: bronx, new york
Posts: 62
JoelP is a jewel in the roughJoelP is a jewel in the roughJoelP is a jewel in the rough
Send a message via AIM to JoelP
Re: need help w/ joystick code

Perhaps their design uses the joystick buttons or auxillary switches to control turning. I don't see the advantages of that design, but hey, its their robot.
  #7   Spotlight this post!  
Unread 02-02-2005, 23:17
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,112
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: need help w/ joystick code

Quote:
Originally Posted by willie837
I have a single joystick code for my robot, but I don't want it to do anything when i tilt the joystick left and right.
A single joystick with no left/right action will give you only one axis of control. At first glance, it looks like you're asking for a robot which will only go forward and backward, and never turn. The easiest way to do that is to replace every occurrence of p1_x in the user_routines.c file with the constant 127.

But that can't be what you want. Are you perhaps asking how to keep the robot from turning in place when you aren't also moving forward or backward? That's conceptually easy, and I could probably change the code myself to do it in about 30 seconds, but it's not easy to describe to a novice programmer. Try changing every occurrence of p1_x to the following:
Code:
(((p1_y<137)&&(p1_y>117))?127:p1_x)
Basically, this keeps the x-axis value at neutral when the y-axis value is within 10 of neutral.

Last edited by Alan Anderson : 02-02-2005 at 23:21.
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
Team THRUST - Kevin's Code and Camera Code Combine Chris_Elston Programming 3 31-01-2005 22:28
Help with code single joystick JamesBrown Programming 9 19-01-2005 00:42
heres the code. y this not working omega Programming 16 31-03-2004 15:18
Changing 1 joystick code to 2 (rookie team) Brawler006 Programming 5 20-02-2004 17:00
robot goes haywire with the one joystick default code Miles Programming 7 24-01-2003 14:58


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

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