Go to Post Are you saying you want to submerge your circuit board in an open container of liquid nitrogen? - Ether [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 30-01-2008, 20:18
penguain penguain is offline
Registered User
AKA: Barry Preston
FRC #1997 (Stag Robotics)
Team Role: Programmer
 
Join Date: Nov 2006
Rookie Year: 2007
Location: Bishop Miege High School
Posts: 18
penguain is an unknown quantity at this point
1 Joystick Control

The FRC code for 1 joystick control is
Code:
  p1_x = 255 - p1_y;

  p1_y = 255 - pwm05;



  pwm13 = pwm14 = Limit_Mix(2000 + p1_y + p1_x - 127);

  pwm15 = pwm16 = Limit_Mix(2000 + p1_y - p1_x + 127);
how ever when i move the joystick left and right the robot goes forward and backwards

and when in move the joystick up and down the robot moves left and right

should is switch all the axises to the opposite or what

Thanks in advance

Barry Preston
STAG Robotics
Team #1997
Programming and Communications Officer
__________________
2007 Greater Kansas City Regional Champions
2008 Greater Kansas City Regional Finalists
  #2   Spotlight this post!  
Unread 30-01-2008, 20:24
usbcd36's Avatar
usbcd36 usbcd36 is offline
Registered User
AKA: "DOS"
FRC #2399 (The Fighting Unicorns)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Solon, OH
Posts: 151
usbcd36 is a jewel in the roughusbcd36 is a jewel in the roughusbcd36 is a jewel in the rough
Re: 1 Joystick Control

That code assumes that both motors (or sets of motors) move the robot in one direction when they are going forwards. In order to make it work for conventional systems, you need to reverse one of the sides. Simplest way to do that is subtract the value you assign to the PWM outputs from 254:



Code:
  p1_x = 255 - p1_y;

  p1_y = 255 - pwm05;



  pwm13 = pwm14 = 254 - Limit_Mix(2000 + p1_y + p1_x - 127);  // reverse this side

  pwm15 = pwm16 = Limit_Mix(2000 + p1_y - p1_x + 127);
  #3   Spotlight this post!  
Unread 30-01-2008, 20:27
kevin.li.rit's Avatar
kevin.li.rit kevin.li.rit is offline
Imaginary Friend
AKA: Kevin Li
FRC #0596 (SciClones)
Team Role: Student
 
Join Date: Jan 2003
Rookie Year: 2001
Location: Hopkinton, Massachusetts
Posts: 936
kevin.li.rit has a reputation beyond reputekevin.li.rit has a reputation beyond reputekevin.li.rit has a reputation beyond reputekevin.li.rit has a reputation beyond reputekevin.li.rit has a reputation beyond reputekevin.li.rit has a reputation beyond reputekevin.li.rit has a reputation beyond reputekevin.li.rit has a reputation beyond reputekevin.li.rit has a reputation beyond reputekevin.li.rit has a reputation beyond reputekevin.li.rit has a reputation beyond repute
Send a message via Yahoo to kevin.li.rit
Re: 1 Joystick Control

It could be that one side of your motors need to be run backwards. In the standard toughbox, if both motors on both sides are run CCW then it will turn. If one is run CW and one CCW then it will go foward.

So I'm not sure how you have wired your motors, but this could be fixed in code or fixed by reversing the red and black leads on one side of your robot drive motors.
__________________
Kevin Li

596 - Sciclones
1405 - Finney Falcons
2262 - Holliston Panthers
  #4   Spotlight this post!  
Unread 31-01-2008, 00:55
divergentdave divergentdave is offline
Registered User
FRC #1816 (Green Machine)
 
Join Date: Jun 2006
Rookie Year: 2007
Location: MN
Posts: 35
divergentdave is a jewel in the roughdivergentdave is a jewel in the roughdivergentdave is a jewel in the rough
Send a message via AIM to divergentdave
Re: 1 Joystick Control

Quote:
Originally Posted by usbcd36 View Post
...Simplest way to do that is subtract the value you assign to the PWM outputs from 254:
Actually you should subtract from 255 in this case. (if Limit_Mix returns you a 255, then pwm13=254-255=-1, but the -1 wraps over the unsigned char to 255, whereas if you subtract from 255, then you will correctly get 0) So, that line should read
Code:
pwm13 = pwm14 = 255 - Limit_Mix(2000 + p1_y + p1_x - 127);
__________________
Team 1816 - The Green Machine
  #5   Spotlight this post!  
Unread 31-01-2008, 07:19
Roger Roger is offline
Registered User
FRC #1153
 
Join Date: Jan 2006
Rookie Year: 1900
Location: Walpole MA
Posts: 688
Roger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond repute
Re: 1 Joystick Control

See also this thread.

Hmmm... I never thought about putting the subtraction outside of the Limit_Mix() function. I had it inside:

Code:
   //Put modified joystick numbers into the four motors
   //The (256- ) part reverses one side's motors so no reverse wiring is needed!

   pwm13 = pwm14 = Limit_Mix(2000 +        p1_yNew  +        p1_xNew  - 127);
   pwm15 = pwm16 = Limit_Mix(2000 + (256 - p1_yNew) - (256 - p1_xNew) + 127);
You can also create a spreadsheet to check the range.

Reversing motors isn't the only problem us programmers have to go thru. We loaded up code on our brand-spanking new robot that we've been testing on last year's robot for the past -- well, the past year, come to think of it. New robot goes all which-way crazy directions. (Didn't help that one side's motors weren't working.) Shop says "programming error!" (Yeah, right!) Check wiring from last year to this year. Red-to-red, black-to-black. Everything checks out. Turns out (40 minutes later!) new robot has one less set of gears, so motor output to wheels is now opposite from last year. Shop says "oh yeah." Sigh....

But this year we had our autonomous working (on last year's robot) before they even built the robot! Woo-hoo!
  #6   Spotlight this post!  
Unread 31-01-2008, 07:56
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: 1 Joystick Control

Quote:
Originally Posted by usbcd36 View Post
Simplest way to do that is subtract the value you assign to the PWM outputs from 254:
Guys, usbcd36 has it right. The correct value is 254.

Quote:
Originally Posted by divergentdave View Post
Actually you should subtract from 255...
You explained that by using a pwm value of 255 as an example. However, valid pwm signals are in the range 0-254, with 127 being neutral.

Quote:
Originally Posted by Roger View Post
//The (256- ) part reverses one side's motors so no reverse wiring is needed!
256 is just plain wrong.



Of course, 254 is only the right value to subtract from in theory. With the Victor's observed "neutral bias", though, it might actually work better to choose 132 as the mirror point instead of 127, and subtract from 264 instead (making sure to limit the result to 254 after the subtraction).
  #7   Spotlight this post!  
Unread 31-01-2008, 17:19
penguain penguain is offline
Registered User
AKA: Barry Preston
FRC #1997 (Stag Robotics)
Team Role: Programmer
 
Join Date: Nov 2006
Rookie Year: 2007
Location: Bishop Miege High School
Posts: 18
penguain is an unknown quantity at this point
Re: 1 Joystick Control

ok..... Forward goes foreward and backwards goes backwards... But left goes right and right goes left
__________________
2007 Greater Kansas City Regional Champions
2008 Greater Kansas City Regional Finalists
  #8   Spotlight this post!  
Unread 31-01-2008, 17:53
kevin.li.rit's Avatar
kevin.li.rit kevin.li.rit is offline
Imaginary Friend
AKA: Kevin Li
FRC #0596 (SciClones)
Team Role: Student
 
Join Date: Jan 2003
Rookie Year: 2001
Location: Hopkinton, Massachusetts
Posts: 936
kevin.li.rit has a reputation beyond reputekevin.li.rit has a reputation beyond reputekevin.li.rit has a reputation beyond reputekevin.li.rit has a reputation beyond reputekevin.li.rit has a reputation beyond reputekevin.li.rit has a reputation beyond reputekevin.li.rit has a reputation beyond reputekevin.li.rit has a reputation beyond reputekevin.li.rit has a reputation beyond reputekevin.li.rit has a reputation beyond reputekevin.li.rit has a reputation beyond repute
Send a message via Yahoo to kevin.li.rit
Re: 1 Joystick Control

Quote:
Originally Posted by penguain View Post
ok..... Forward goes foreward and backwards goes backwards... But left goes right and right goes left
You can fix this by swapping the pwms on the left side with those on the right. (either through code or switching the pwm cables). However this will make what is now the front, the back and the back is now the front. I think if you swap what's inside the limit_mix function with the one below it, then it'll fix it without changing what's front or back.

Maybe post Your code?
__________________
Kevin Li

596 - Sciclones
1405 - Finney Falcons
2262 - Holliston Panthers

Last edited by kevin.li.rit : 31-01-2008 at 17:58.
  #9   Spotlight this post!  
Unread 01-02-2008, 09:02
Roger Roger is offline
Registered User
FRC #1153
 
Join Date: Jan 2006
Rookie Year: 1900
Location: Walpole MA
Posts: 688
Roger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond repute
Re: 1 Joystick Control

Quote:
Originally Posted by Alan Anderson
256 is just plain wrong.
Ouch!

In my defense (meager as can be) I can only say I did put it inside the Limit_Mix() function, so that the function did keep the numbers in range. I'll have to check my spreadsheet numbers again, and try the 132 center point.
  #10   Spotlight this post!  
Unread 01-02-2008, 10:02
Tom Bottiglieri Tom Bottiglieri is offline
Registered User
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Jan 2004
Rookie Year: 2003
Location: San Francisco, CA
Posts: 3,187
Tom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond repute
Re: 1 Joystick Control

This is easier.
Code:
left_motor = speed - turn_rate;
right_motor = speed + turn_rate;
Where speed and turn_rate are signed char's (subtract 127 from a u-char) and left and right motor are limited to (-128,127).
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
Joystick control rotated? silliewillie Control System 6 12-02-2005 21:23
We need help with joystick control Team ICE #1611 Control System 4 24-01-2005 15:57
Single joystick control problem Mr. Van Programming 7 23-11-2004 09:10
One Joystick Control KWalsh Programming 4 24-02-2004 17:53
Control System, Joystick mod? Jordan A. Technical Discussion 16 13-02-2002 02:29


All times are GMT -5. The time now is 22:34.

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