Go Down

Topic: Joystick Servo Control... for newbies. (Read 4834 times) previous topic - next topic

Hello.  I have a project whereby a servo needs to be controlled by a joystick, and I'm wondering if an Arduino could be used here.

I saw this guide: http://teamprincipia.wordpress.com/2008/04/08/arduino-python-4-axis-servo-control/ (and the previous 2 articles on the site as well) which explain how to connect a joystick to a PC, and then connect a servo to an Arduino and get some Python code to tie it all together.  This is almost exactly what I need... but with no PC in the loop.

I've seen this forum post: http://arduino.cc/forum/index.php/topic,5080.msg38890.html#msg38890 but the conversation kinda drifted off in other directions.

I'm really really new to this, but can I use a USB host shield to connect the joystick to the Arduino, then store some code on the Arduino that will let me do what I want?

Any tips/suggestions gratefully received!

johnwasser

Does it have to be a USB joystick?  It's generally easier to interface to a raw joystick potentiometer than to go through USB.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

PeterH

I would suggest you connect the joystick potentiometer directly to the Arduino analog input (and the ground and 5V rails) and use analogRead to determine the joystick position, map/convert that to a servo position however you want, and then use the Servo library to putput the corresponding servo PWM pulse.

Of course you could use an ordinary hobby RC system, and control it via radio using perfectly ordinary off-the-shelf systems.
I only provide help via the forum - please do not contact me for private consultancy.

zoomkat

The servo "knob" code example in the arduino IDE should be of interest for basic joystick learning.
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

patduino

Hi WelshGuy,

I agree with the them all.

Most of these would work:  http://www.jameco.com/webapp/wcs/stores/servlet/StoreCatalogDrillDownView?langId=-1&storeId=10001&catalogId=10001&search_type=jamecoall&freeText=Joystick

I wouldn't make the project any more complicated than that.  The USB approach is overkill for what you're trying to do. Besides... You can buy some new components!

Pat.
There are 10 types of people in the world, those that understand binary, and those that don't.

JimboZA

I agree.

We use this one wired exactly as shown on that link. Connect the Y axis to another analog pin, and double up the code in the knob skecth for say potpin2 and attach say servo2 on another pin and you have x and y servo control.

That particular joystick has a switch- push the button in to fire a rocket or whatever: you can attach that using this as a guide.
"Could you do the egg bacon spam and sausage without the spam then? "

No PMs for help please.
DO NOT power servos from Arduino 5V: give them their own power and connect the grounds.

zoomkat

I just ordered some of these for tinkering. They appear to have a switch button on the side also.

http://www.ebay.com/itm/3-X-New-Handle-Joystick-3D-Sony-Playstation2-PS2-PS-2-10V-/230803703512?pt=LH_DefaultDomain_0&hash=item35bcf906d8
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

Firstly, thank you so much for all your prompt replies :D 

I had a look at the thumbsticks you mentioned and I agree that it does seem like a much simpler process.  My only concern is that the system is being designed for use by a large number of children, and having a solid, large, grippable joystick would both a) make it look more impressive and b) be a bit easier for smaller kids to use.

Does anything exist that has the ease of use of the thumbsticks but in a larger design?

Thanks!

JimboZA

Well there are these but at e125 they're just a leeeeetle bit pricey look you.
"Could you do the egg bacon spam and sausage without the spam then? "

No PMs for help please.
DO NOT power servos from Arduino 5V: give them their own power and connect the grounds.

PeterH


Does anything exist that has the ease of use of the thumbsticks but in a larger design?


Perhaps you could attach a larger handle to the input, so that it looked a bit more like the sort of thing you see on a radio control transmitter?
I only provide help via the forum - please do not contact me for private consultancy.

JimboZA


Perhaps you could attach a larger handle to the input, so that it looked a bit more like the sort of thing you see on a radio control transmitter?


That's a good point- if you take the thumb thingy off mine you end up with what zoomkat linked to, and you could fashion a longer handle to slide over the prong.

But I'd be careful of any damage that the extra leverage could cause, especially in the heat of a game. Perhaps that's why the bigger ones are more expensive: they need to withstand higher moments inside.

I also found this but it has limit switches not pots.
"Could you do the egg bacon spam and sausage without the spam then? "

No PMs for help please.
DO NOT power servos from Arduino 5V: give them their own power and connect the grounds.


I also found this but it has limit switches not pots.


Hmm that could work Jimbo, thanks!

I don't need it for a game, it's for a museum-style exhibit that will control the pitch rotation of a wing section in a wind tunnel.  I guess I don't technically need variable control...


JimboZA

Ah ok, so a basic l-r-u-d thing could suffice?

That big joystick from RS looks like a gear-lever from an 18-wheeler tho: there must be something smaller yet robust and not costing over e100 a pop
"Could you do the egg bacon spam and sausage without the spam then? "

No PMs for help please.
DO NOT power servos from Arduino 5V: give them their own power and connect the grounds.

JimboZA

PS... with limit switches I guess you could just read them like in this sketch and when a switch is closed have a servo.write command to one position, and to another when it's open. Eminently doable with an if testing the buttons' states.
"Could you do the egg bacon spam and sausage without the spam then? "

No PMs for help please.
DO NOT power servos from Arduino 5V: give them their own power and connect the grounds.

Thinking it over I do think variable control would be a bonus though...

Essentially I have a wing section with a rod running through it spanwise.  This needs to rotate (ie pitch the wing up, return it to horizontal and then pitch down then return to horizontal).  A servo mechanism currently exists to rotate the rod, but with no control.  If I had variable control I guess I could code something that would let me hold the joystick at a given position in order to command a certain angle of rotation.  If it was limit switches I guess it would be a little more complicated.

I only need a single-axis of control, providing rotation +-60 degrees.


Go Up