Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Require help programming a Z-Axis on a Logitech joystick (http://www.chiefdelphi.com/forums/showthread.php?t=112079)

LOHS3868 26-01-2013 11:24

Require help programming a Z-Axis on a Logitech joystick
 
Our programming team wants to use the Z-axis on a Logitech joystick as the throttle for our shooter motor. Our problem is that we want the negative portion to be zero and the positive to represent full throttle. Sorry for not being clear - it's hard to convey what I mean over text. If you need any more details, feel free to ask.

Thanks
-3868
:]

agartner01 26-01-2013 11:55

Re: Require help programming a Z-Axis on a Logitech joystick
 
Quote:

Originally Posted by LOHS3868 (Post 1222119)
Our programming team wants to use the Z-axis on a Logitech joystick as the throttle for our shooter motor. Our problem is that we want the negative portion to be zero and the positive to represent full throttle. Sorry for not being clear - it's hard to convey what I mean over text. If you need any more details, feel free to ask.

Thanks
-3868
:]

What language are you programming in? If the most positive value is 1 and the most negative value is -1, what I've done in the past is added 1 and divided by 2 (to the joystick value). Also, an exception needs to be put in place when is the value is -1 because -1+1=0/.5 results in potentially undefined behavior (at least in c++).

Teamcodeorange 26-01-2013 12:00

Re: Require help programming a Z-Axis on a Logitech joystick
 
If you are using Labview you could just add one, divide by 2 and if it goes the wrong way, multiply by -1.

Ether 26-01-2013 12:23

Re: Require help programming a Z-Axis on a Logitech joystick
 
Quote:

Originally Posted by agartner01 (Post 1222141)
If the most positive value is 1 and the most negative value is -1, what I've done in the past is added 1 and divided by 2 (to the joystick value). Also, an exception needs to be put in place when is the value is -1 because -1+1=0/.5 results in potentially undefined behavior (at least in c++).

There are 2 things wrong with the last sentence above.

1) Dividing zero by something does not result in undefined behavior. Dividing something by zero does.

2) 0/.5 is not dividing by 2. It is dividing by 1/2, which is multiplying by 2.




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

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi