Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   Joystick Controls (http://www.chiefdelphi.com/forums/showthread.php?t=108068)

996rookie 29-08-2012 11:28

Joystick Controls
 
Hi,
This yeara to prep for FRC, our team is building a model airplane from scratch to fly. The problem I am facing as a programmer is to set the rudders and such to the joystick so that if i move it partially to the left and hold it, the rudders will only turn that much, stay there, and nothing more.
Right now, if I set them to the joystick, they continue to turn, and damage the servo's.
Can anyone help?
Thanks!

Mark McLeod 29-08-2012 12:03

Re: Joystick Controls
 
The servos controlling the flight surfaces could just be set to the angle of the joystick.

Convert the joystick value to be in the same range as the servo, e.g., (joy+1)/2 = servo position
This is assuming you use 0 to 1 as the servo Set Position. If you use Set Angle instead, then convert the joystick to the angle range you defined or defaulted to in your Servo Open instead.

P.S.
Probably need to set max/min limits to the servo motion as well, so they don't try to move past mechanical limits.

996rookie 29-08-2012 15:56

Re: Joystick Controls
 
So I think a more difinitive explanation of my problem is that when I lean the Joystick to the left, the motor continues to turn past the angle I want. The more I lean it, the faster it turns. I want to set it so that it only turns to the angle that the Joystick is.

Ether 29-08-2012 16:11

Re: Joystick Controls
 
Quote:

Originally Posted by 996rookie (Post 1183539)
So I think a more difinitive explanation of my problem is that when I lean the Joystick to the left, the motor continues to turn past the angle I want. The more I lean it, the faster it turns. I want to set it so that it only turns to the angle that the Joystick is.

Tell us what part number servo you are using.



Mark McLeod 29-08-2012 16:25

Re: Joystick Controls
 
Are you sure that it's really a servo?
Is it a continuous rotation or is it limited in it's rotation?

The servo model will tell us what we want to know.

If you think it's a code problem, then post a snippet of the code reading the joystick and setting the servo.

996rookie 01-09-2012 01:20

Re: Joystick Controls
 
No, it's not the servo, its the code. I honestly just don't know how to set the angle of the rudder to the angle of the joystick.

Alan Anderson 01-09-2012 02:13

Re: Joystick Controls
 
When you say "servo", what exactly are you referring to? Your first post suggests that you might be using it to mean something other than what I think of.

Also, what are you using as your control system? A cRIO and its supporting electronics are rather heavy to be using in a model airplane.

Dexterium 01-09-2012 11:10

Re: Joystick Controls
 
your problem is the code. Whenever you move the joystick you are sending a constant value to the motor/servo/whatever. That constant value is causing the whatever to constantly turn. What you need to do is use the servo set position this takes a value from 0 to 1 from an input and matches it to the servo's position. use this along with some math and the joystick to make it work. Lets say that your servo range (the range of possible/wanted motion) is 90 degrees. You would specify this in the begin vi with servo open. For this to work right you would want is set up like this:

0 degree position(all the way in one direction)=0 servo position=(-1) Joystick position

45 degree position(straight/level)=.5 servo position=0 Joystick Position

90 degree position (all the way the other direction)=1 servo position=1 Joystick position

The degree refrences don't really matter for the sake of the programming they are just there for refrence. What you really need to do is find some math(i have no clue what) to put between the joystick output value and the servo input value that makes 0=-1, .5=0, and 1=1. Once you do this your home free. :D

See below

Dexterium 01-09-2012 11:33

Re: Joystick Controls
 
Quote:

Originally Posted by Dexterium (Post 1183936)
\What you really need to do is find some math(i have no clue what) to put between the joystick output value and the servo input value that makes 0=-1, .5=0, and 1=1. Once you do this your home free. :D

Found the math:
x=Value from the joystick
y=Value to the servo position

x(1/2)+1/2=y

Examples:

-1(1/2)+1/2=0
-.5(1/2)+1/2=.25
0(1/2)+1/2=.5
.5(1/2)+1/2=.75
1(1/2)+1/2=1

996rookie 01-09-2012 22:30

Re: Joystick Controls
 
Thanks!! That really helped. Going to try it as soon as possible.


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

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