Log in

View Full Version : Joystick Inputs


Jatheon4316
03-02-2005, 18:03
Hello fellow programmers!

Would someone please tell me what the inputs are for the the 2004 and or 2005 FIRST joysticks? Including x and y axis, trigger, top button/HAT (depending on year) etc...

Thanks! :)

Bleric
03-02-2005, 18:16
*cough* documentation *cough* ;)

Anyway, the variables you will be using are

p1_y
p2_y
p3_y
p4_y
p1_x
p2_x
p3_x
p4_x

p# refers to the port you're plugging the joystick into. x / y refer to the x and y axis. Values range from 0 - 255.

For example, if you're looking at the joystick in port one, and it is held in the center, p1_y is 127 and p1_x is 127.

p1_sw_trig
p1_sw_top

p3_sw_trig
p3_sw_top

p2_sw_trig
p2_sw_top

p4_sw_trig
p4_sw_top

These refer to the trigger and top buttons. (If you're using the white kit joysticks, I think the "top" button is actually on the side) They're set to 1 if the button is being pushed, and 0 if it isn't.

I'm pretty sure the "hat" button isn't even wired. So, you can't use it unless you take your joystick apart and wire it up yourself. (I may be wrong on this, though)

Also, I would read all the documentation I could find if I were you. :p Innovation first has a programming guide which I found very useful, and should answer most of your questions.
useful links (http://www.ifirobotics.com/rc.shtml#Programming)
programming guide (http://www.ifirobotics.com/docs/legacy/2004-programming-reference-guide-12-apr-2004.pdf)

Jatheon4316
03-02-2005, 19:00
Thanks...I must've missed that in the documentation *rubs eyes wearily*... :eek:

whakojacko
03-02-2005, 19:28
all the definitions are in ifi_aliases.h . you shouldnt need to change anything there, but that will give you a good idea of the variables. Btw the p_wheel definitions is for the hat. Its wierd how it works, but i messed around with it and it does work

Jatheon4316
03-02-2005, 23:13
Ok, here's another question...

I know that the joystick's y axis value is highest (ideally 254) when it's full forward and lowest (ideally 0) when it's full backward.

However, what about the x_axis? Is highest (ideally 254) at the left or the right? And is the lowest (ideally 0) at the right or the left.

y=254?
full forward
|
x=? full left ----+---- full right x=?
|
full backward
y=254?

Anton
04-02-2005, 06:38
I can't remember it at the moment, but you can easily check it with printf, for example:
printf("Port1 Y %3d, X %3d, Fire %d, Top %d, lm %d, rm%d\n, ,%d , %f",(int)p1_y,(int)p1_x,(int)p1_sw_trig,(int)p1_sw_to p,lm,255-rm,5/3, 5/3 );

Bharat Nain
04-02-2005, 06:42
Ok, here's another question...

I know that the joystick's y axis value is highest (ideally 254) when it's full forward and lowest (ideally 0) when it's full backward.

However, what about the x_axis? Is highest (ideally 254) at the left or the right? And is the lowest (ideally 0) at the right or the left.

y=254?
full forward
|
x=? full left ----+---- full right x=?
|
full backward
y=254?
Yes, it is 0 and 254, if I recall correctly.

Jatheon4316
04-02-2005, 07:35
0=full left (ideally)
-to-
254=full right (ideally)

Right?

Sorry to bug ya'll. But I won't see our bot and joysticks again till Saturday (or would've used a printf statement to find them)...thanks!

Anton
04-02-2005, 16:08
I remember being really surprised to see that the algorithm I developed wouldn't wprk just because x- axis had 255 as the left value, not the right one as I expected, but soon I realised that to invert it I just had to add a line of code p1_x=255-p1_x;
What I'm trying to tell is that even if you don't know the correct axes values you don't need to worry, you can easily map them as you wish-you can even make them -127 to 128, if you think that it's worth the effort. Personally, I htink it would be nice, but I already wrote half my brogramm using the default values, so there's no point giving myself more work than needed. But if you are just beginning the joysticks, I think it's a good thing to do.

Greg Ross
04-02-2005, 16:53
Would someone please tell me what the inputs are for the the 2004 and or 2005 FIRST joysticks? Including ... top button/HAT
This thread (http://www.chiefdelphi.com/forums/showthread.php?t=24315&highlight=hat+pov) from last year covered the"top button/HAT". I don't know if IFI has fixed the "feature" whereby any deflection in the up direction are indistinguishable.

Darkelement
04-02-2005, 17:06
Yes, it is 0 and 254, if I recall correctly.
I thought that the joystick range was 0 to 255. That's what I have been inputting and I haven't had any problems.

The yellowdart
06-02-2005, 12:01
full ahead should be 254
127 is neutral.....
full reverse should be 0

full right should be 254
and full left should be 0
again with neutral being 127

hope that helps :)

Workaphobia
06-02-2005, 17:25
The hobby controller I used for my team's EDUbot fell short of the full analog range by 20-40, robbing us of some control resolution. I don't think the joysticks in the FRC kit had this problem, but you can always test the range, and which side is which, by outputting the contents of p1_y (and the others) to User_Mode_byte and switching to user mode in your operator interface.