|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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! |
|
#2
|
|||||
|
|||||
|
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. Last edited by Mark McLeod : 29-08-2012 at 13:22. |
|
#3
|
|||
|
|||
|
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.
|
|
#4
|
||||
|
||||
|
Re: Joystick Controls
Quote:
|
|
#5
|
|||||
|
|||||
|
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. Last edited by Mark McLeod : 29-08-2012 at 16:29. |
|
#6
|
|||
|
|||
|
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.
|
|
#7
|
|||||
|
|||||
|
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. |
|
#8
|
||||
|
||||
|
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. ![]() See below Last edited by Dexterium : 01-09-2012 at 11:34. |
|
#9
|
||||
|
||||
|
Re: Joystick Controls
Quote:
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 |
|
#10
|
|||
|
|||
|
Re: Joystick Controls
Thanks!! That really helped. Going to try it as soon as possible.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|