Go to Post "It's not a weapon, it's an active bumper system." - Ameya [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 24-02-2004, 16:22
FormatteD_C's Avatar
FormatteD_C FormatteD_C is offline
owned?
AKA: Matt Kerr
#1206 (Wrench Warriors)
Team Role: Programmer
 
Join Date: Feb 2004
Location: Ohio
Posts: 4
FormatteD_C is an unknown quantity at this point
Send a message via AIM to FormatteD_C
Inverting Y axis on joystick

Hey,
We need to invert the Y axis and I don't know how I would code it, any input on this would be great.
  #2   Spotlight this post!  
Unread 24-02-2004, 16:25
JoshJ JoshJ is offline
Registered User
#0316 (LuNaTeCs)
Team Role: College Student
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Salem County
Posts: 44
JoshJ is on a distinguished road
Send a message via AIM to JoshJ
Re: Inverting Y axis on joystick

All you have to do is subtract your current value from 254. I think you can just do p1_y=254-p1_y; but just to be safe I would use a temp variable. Sooo, temp=254-p1_y; then just use temp instead of p1_y (or whatever joystick port) in your program.
  #3   Spotlight this post!  
Unread 24-02-2004, 16:40
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: Inverting Y axis on joystick

Woulden't it be temp = 255 - p1_y? Because other wise you can have negative numbers.
  #4   Spotlight this post!  
Unread 24-02-2004, 16:42
FotoPlasma FotoPlasma is offline
\: |
no team
 
Join Date: Jul 2001
Rookie Year: 2001
Location: San Jose
Posts: 1,900
FotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond reputeFotoPlasma has a reputation beyond repute
Send a message via AIM to FotoPlasma
Re: Inverting Y axis on joystick

Quote:
Originally Posted by Astronouth7303
Woulden't it be temp = 255 - p1_y? Because other wise you can have negative numbers.
If p1_y == 0, then that would evaluate to 255, which is an invalid PWM output. If you're using an unsigned data type, it can't be negative, anyway.
__________________
I played hacky sack with Andy Baker.

2001-2004: Team 258, The Sea Dawgs
2005: Team 1693, The Robo Lobos
  #5   Spotlight this post!  
Unread 24-02-2004, 16:47
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: Inverting Y axis on joystick

Oh, right. But I think the joystick vals go up to 255.
  #6   Spotlight this post!  
Unread 24-02-2004, 16:51
deltacoder1020's Avatar
deltacoder1020 deltacoder1020 is offline
Computer Guy
AKA: Dav
#1020 (The Indiana Prank Monkeys)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Muncie, Indiana
Posts: 340
deltacoder1020 has a spectacular aura aboutdeltacoder1020 has a spectacular aura about
Send a message via AIM to deltacoder1020
Re: Inverting Y axis on joystick

Code:
temp = (p1_y == 255) ? 0 : (254 - p1_y);
__________________
Team 1020, the Indiana Prank Monkeys (www.team1020.org)
  #7   Spotlight this post!  
Unread 24-02-2004, 16:52
jeremy562 jeremy562 is offline
Engineer
#0562 (SPARK 562)
 
Join Date: Feb 2002
Location: Fitchburg, MA
Posts: 74
jeremy562 is an unknown quantity at this point
Send a message via AIM to jeremy562
Re: Inverting Y axis on joystick

255 is not a valid output on a PWM. I think 3 consecutive 255's result in a reset or something.

The range is 0-254, so you want:

p1_y = 254 - p1_y;

No need for a temp variable, the compiler will handle that just fine.
__________________
SPARK 562: Students Pursuing Applied Robotics Knowledge

2006 BAE Granite State Regional: Finalists with 319 and 176
2006 BAE Granite State Regional: Winners of Motorola Quality Award
2004 BAE Granite State Regional: 7th Seed
2004 Mayhem on the Merrimack Champions! Thanks, 61 and 1289!
  #8   Spotlight this post!  
Unread 24-02-2004, 16:56
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: Inverting Y axis on joystick

Ok, thank you for correcting me. Though I could've sworn I saw 255 on dashboard... Oh, well :shrug:
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
Changing 1 joystick code to 2 (rookie team) Brawler006 Programming 5 20-02-2004 17:00
Fried program slots? Jeff Waegelin Programming 18 19-03-2003 18:08
robot goes haywire with the one joystick default code Miles Programming 7 24-01-2003 14:58
joystick problem archiver 2000 12 23-06-2002 23:08
switching joystick axis????? team222badbrad Technical Discussion 9 16-01-2002 23:07


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

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