PDA

View Full Version : Help using xy digital joystick in all 8 directions

mk
01-14-2009, 11:58 PM
This is my first time with joysticks, and am bit confused in using same joystick in X-Y as well as diagonal positions simultaneously.

What is wanted:

Ive to control two motors in both polarities using a single joystick. My joystick is an X-Y joystick. Its not analog, and it functions by mere contact at the pin. (There is no potentiometer inside).

Im expecting that when I move the joystick knob to the...

top, Motor 1 rotates clockwise
bottom, Motor 1 rotates anticlockwise
left, Motor 2 rotates clockwise
right, Motor 2 rotates anticlockwise
top-right, Motor 1 rotates clockwise, and Motor 2 rotates anticlockwise
top-left, Motor 1 rotates clockwise, and Motor 2 rotates clockwise
bottom-left, Motor 1 rotates anticlockwise, and Motor 2 rotates clockwise
bottom-right, Motor 1 rotates anticlockwise, and motor 2 rotates anticlockwise

Joystick pins are somewhat like this. On moving knob on top, 1 and 2 get short. on moving left, 3 and 5 get short, on moving top-left, 1 and 3 get short. Similarly the others

......|1|..... |2|

3=....................=4

5=................... =6

......|7|.......|8|

Problem:

I intend to connect the motors via a relay. So Im connecting the relay enable pin to the joystick pin. Im using two relays for 1 motor, one for each polarity. At any time, only one relay is active for the same motor..

If I simply connect the relays to the corosponding pins of the joystick, then I am able to run only 1 motor at a time, and not 2 motors simultaneously.

i.e., if I connect pins 1,4,8,5 to Vcc, and pin 2,,7,3 to corosponding relay, then only one relay is active at any time. Now even if I move the joystick to the top-left, then also, instead of Motor 1 moving clockwise, and Motor 2 clockwise, current flows from pin 1 to pin 3 making only motor 2 rotating, and not motor 1.

I tried using an AND gate between the diagonal pins (1 & 3) so that both motor rotate simultaneously at the top-left position of joystick, but now at any position of joystict both motors rotate simultaneously. (I cant explain its connections as Im not able to upload the image)

Querry:

Is there any way to use all the directions of the joystick simultaneously?
Im sorry for the length of the message, but I had to explain what ive been upto till now.