Go to Post Gotta love the use of universal technical terms, along with whatchamacallit, doodlespiel, whosiwhatsit... ;) - PaW [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-01-2004, 17:17
NoRemorse's Avatar
NoRemorse NoRemorse is offline
FOCUS Integration, LLC - Owner
AKA: Brian Roberts
FRC #1023 (Bedford Express)
Team Role: Alumni
 
Join Date: Feb 2003
Rookie Year: 2003
Location: Bedford
Posts: 221
NoRemorse has a spectacular aura aboutNoRemorse has a spectacular aura about
Send a message via AIM to NoRemorse Send a message via MSN to NoRemorse
Programming joysticks

On the new joysticks, there is a mini - milt-direction "d-pad" i guess you could call it. How do you prgram this, or can you even. I can't find it anywhere in the code
__________________

http://LSJBuildUp.com -Documenting the build of my LSJ, as well as other influential cars.
  #2   Spotlight this post!  
Unread 24-01-2004, 18:22
Dave Flowerday Dave Flowerday is offline
Software Engineer
VRC #0111 (Wildstang)
Team Role: Engineer
 
Join Date: Feb 2002
Rookie Year: 1995
Location: North Barrington, IL
Posts: 1,366
Dave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond repute
Re: Programming joysticks

Quote:
Originally Posted by NoRemorse
On the new joysticks, there is a mini - milt-direction "d-pad" i guess you could call it. How do you prgram this, or can you even. I can't find it anywhere in the code
It's called a "hat switch" and it'll show up as one of the analog joystick values to the robot controller. I can't remember if it appears as "Joystick Wheel" or "Joystick AUX" off the top of my head, though.
  #3   Spotlight this post!  
Unread 24-01-2004, 18:36
NoRemorse's Avatar
NoRemorse NoRemorse is offline
FOCUS Integration, LLC - Owner
AKA: Brian Roberts
FRC #1023 (Bedford Express)
Team Role: Alumni
 
Join Date: Feb 2003
Rookie Year: 2003
Location: Bedford
Posts: 221
NoRemorse has a spectacular aura aboutNoRemorse has a spectacular aura about
Send a message via AIM to NoRemorse Send a message via MSN to NoRemorse
Re: Programming joysticks

well, the count of buttons on thejoistick does not equal the count of buttons in the program. and it is the odd man out.
__________________

http://LSJBuildUp.com -Documenting the build of my LSJ, as well as other influential cars.
  #4   Spotlight this post!  
Unread 24-01-2004, 19:14
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: Programming joysticks

The joystick's POV hat takes the place of the "pN_wheel", where N is the number of the joystick port you're using. I can only really speak for the joystick which I have right in front of me (the other is at my house, being used to play TIE Fighter ), so YMMV. The two least significant bits of the value change too erratically to be of any use. Here's a listing of the values of the variable when the POV hat is in different positions:
Neutral: 001011xx
Up Left: 111111xx
Up: 111111xx
Up Right: 111111xx
Left: 011000xx
Right: 110010xx
Down Left: 101001xx
Down: 100101xx
Down Right: 110101xx

The x's take the place of the two least significant bits, which, as I said earlier, change randomly (at least with this single joystick).

Basically, if you can understand binary, you can take advantage of the POV hat for controlling your robot.

Hope this helps.
__________________
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 27-01-2004, 21:21
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: Programming joysticks

Quote:
Originally Posted by FotoPlasma
The joystick's POV hat takes the place of the "pN_wheel", where N is the number of the joystick port you're using. I can only really speak for the joystick which I have right in front of me
...
Neutral: 001011xx
Up Left: 111111xx
Up: 111111xx
Up Right: 111111xx
Left: 011000xx
Right: 110010xx
Down Left: 101001xx
Down: 100101xx
Down Right: 110101xx
our values for the joystick concur for the first 6 bits as well. (darn shame there is basically no difference between UL, U, and UR)
__________________
Team 1020, the Indiana Prank Monkeys (www.team1020.org)
  #6   Spotlight this post!  
Unread 28-01-2004, 20:53
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: Programming joysticks

So the bit masks are:
Code:
const unsigned char Hat_None = 0x2C;
const unsigned char Hat_Up = 0xFC;
const unsigned char Hat_Left = 0x60;
const unsigned char Hat_Right = 0xC0;
const unsigned char Hat_Down = 0x94;

//Unless values are off, Combos aren't OR'ed
const unsigned char Hat_Up_Left = 0xFC;
const unsigned char Hat_Up_Right = 0xFC;
const unsigned char Hat_Down_Left = 0xA4;
const unsigned char Hat_Down_Right = 0xD4;
This seems a little stupid, but that's life.
  #7   Spotlight this post!  
Unread 01-02-2004, 23:59
Chris Hleva Chris Hleva is offline
Registered User
#0905 (Razor Burn)
Team Role: Programmer
 
Join Date: Nov 2003
Location: Milford
Posts: 5
Chris Hleva is an unknown quantity at this point
Send a message via Yahoo to Chris Hleva
Question Programming joysticks

I have a question, how could I add the right lines of code to make the POV hats work with the new C language this year? Amonst other things, where would I have to define them and map them to the right IO ports to work with the hex/bin input signal?
  #8   Spotlight this post!  
Unread 02-02-2004, 11:15
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,586
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Programming joysticks

Quote:
Originally Posted by Astronouth7303
So the bit masks are:
Code:
const unsigned char Hat_None = 0x2C;
const unsigned char Hat_Up = 0xFC;
const unsigned char Hat_Left = 0x60;
const unsigned char Hat_Right = 0xC0;
const unsigned char Hat_Down = 0x94;

//Unless values are off, Combos aren't OR'ed
const unsigned char Hat_Up_Left = 0xFC;
const unsigned char Hat_Up_Right = 0xFC;
const unsigned char Hat_Down_Left = 0xA4;
const unsigned char Hat_Down_Right = 0xD4;
Why not #define them, instead of taking up memory?
  #9   Spotlight this post!  
Unread 02-02-2004, 12:45
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: Programming joysticks

Quote:
Originally Posted by Chris Hleva
I have a question, how could I add the right lines of code to make the POV hats work with the new C language this year? Amonst other things, where would I have to define them and map them to the right IO ports to work with the hex/bin input signal?
example:
Code:
if( (p1_wheel & 0xC0) == 0xC0 )
{
     //hat control is pushed right
}
else if( (p1_wheel & 0xA4) == 0xA4 )
{
     //hat control is pushed down-left
}
...
et cetera
...
just use the bitwise AND function (&) to determine if the correct bits are set.
__________________
Team 1020, the Indiana Prank Monkeys (www.team1020.org)

Last edited by deltacoder1020 : 02-02-2004 at 12:49.
  #10   Spotlight this post!  
Unread 02-02-2004, 16:59
Chris Hleva Chris Hleva is offline
Registered User
#0905 (Razor Burn)
Team Role: Programmer
 
Join Date: Nov 2003
Location: Milford
Posts: 5
Chris Hleva is an unknown quantity at this point
Send a message via Yahoo to Chris Hleva
Re: Programming joysticks

Thanks, that helped a lot. I am just starting out with C so i'm still a little sketchy with it.
  #11   Spotlight this post!  
Unread 02-02-2004, 17:21
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: Programming joysticks

no prob. if you want a review on the syntax of C, you could try the various guides in the whitepapers section, or the guide that I'm working on (see the thread in this forum titled "FIRST Programming Tutorial")
__________________
Team 1020, the Indiana Prank Monkeys (www.team1020.org)
  #12   Spotlight this post!  
Unread 14-02-2004, 23:50
Ryan Cumings's Avatar
Ryan Cumings Ryan Cumings is offline
Programmer and University Rejected
#0134 (Team Discovery)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2000
Location: Pembroke, NH
Posts: 65
Ryan Cumings is an unknown quantity at this point
Send a message via AIM to Ryan Cumings
Re: Programming joysticks

Quote:
Originally Posted by deltacoder1020
example:
Code:
if( (p1_wheel & 0xC0) == 0xC0 )
{
     //hat control is pushed right
}
else if( (p1_wheel & 0xA4) == 0xA4 )
{
     //hat control is pushed down-left
}
...
et cetera
...
just use the bitwise AND function (&) to determine if the correct bits are set.
Haven't been on for a while, but here goes (Sorry delta!)
If you push the hat up by your code then it will default to the first conditional statement you put in.

A more correct way might be to do it this way (using constants provided courtesy of Astronouth7303)
Code:
switch (px_wheel & 0xFC) {
	case Hat_Up_Left: {
		// ... Code here
		break;
	}
	case Hat_Up_Right: {
		// ... Code here
		break;
	}
	// etc...
	default: {
		break;
	}
}
  #13   Spotlight this post!  
Unread 15-02-2004, 23:35
Robert Hafner's Avatar
Robert Hafner Robert Hafner is offline
FIRST Alumni
no team
 
Join Date: Mar 2003
Rookie Year: 2000
Location: Springfield. MA
Posts: 34
Robert Hafner is on a distinguished road
Send a message via AIM to Robert Hafner Send a message via MSN to Robert Hafner Send a message via Yahoo to Robert Hafner
Re: Programming joysticks

Could someone help me out?

What I need is for someone to do out the etc. part of the

if( (p1_wheel & 0xC0) == 0xC0 )
{
//hat control is pushed right
}
else if( (p1_wheel & 0xA4) == 0xA4 )
{
//hat control is pushed down-left
}
...
et cetera
...


thing so I can do this right. I'm a tad but slow when it comes to binary and hex
  #14   Spotlight this post!  
Unread 16-02-2004, 00:05
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: Programming joysticks

here they are in binary, decimal, and hex forms...

Neutral: 001011xx 44 0x2C
Up Left: 111111xx 252 0xFC
Up: 111111xx 252 0xFC
Up Right: 111111xx 252 0xFC
Left: 011000xx 96 0x60
Right: 110010xx 200 0xCB
Down Left: 101001xx 164 0xA4
Down: 100101xx 148 0x94
Down Right: 110101xx 212 0xD4
__________________
Team 1020, the Indiana Prank Monkeys (www.team1020.org)

Last edited by deltacoder1020 : 16-02-2004 at 00:08.
  #15   Spotlight this post!  
Unread 16-02-2004, 00:17
Guest
 
Posts: n/a
Re: Programming joysticks

Here's a diagram that gives the full range of values and the value to test with AND is bold.

252-255*252-255*252-255
*96-99***44-47**200-203
164-167*148-151*212-215
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 Compatition Angela06 Programming 30 08-04-2005 23:12
Could use some help with joysticks . . . archiver 2001 5 23-06-2002 23:36
Pneumatics electrical wiring and programming archiver 2001 1 23-06-2002 23:10
Calibrating speed controllers and joysticks thedillybar Technical Discussion 4 11-02-2002 13:24
pbasic programming punarhero Programming 4 21-01-2002 23:32


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

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