Pages: [1] 2   Go Down
Author Topic: Joystick Servo Control... for newbies.  (Read 3652 times)
0 Members and 1 Guest are viewing this topic.
UK
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 200
Posts: 8563
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Does it have to be a USB joystick?  It's generally easier to interface to a raw joystick potentiometer than to go through USB.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

UK
Offline Offline
Shannon Member
****
Karma: 219
Posts: 12374
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

0
Offline Offline
Tesla Member
***
Karma: 140
Posts: 9452
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The servo "knob" code example in the arduino IDE should be of interest for basic joystick learning.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Indiana, US
Offline Offline
Full Member
***
Karma: 12
Posts: 204
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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

Offline Offline
Faraday Member
**
Karma: 79
Posts: 3733
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Although I answer in good faith, remember always: Your Mileage May Vary.
Get me on LinkedIn: za.linkedin.com/in/jimbrownza/

0
Offline Offline
Tesla Member
***
Karma: 140
Posts: 9452
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

UK
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Firstly, thank you so much for all your prompt replies smiley-grin 

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!
Logged

Offline Offline
Faraday Member
**
Karma: 79
Posts: 3733
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well there are these but at e125 they're just a leeeeetle bit pricey look you.
Logged

Although I answer in good faith, remember always: Your Mileage May Vary.
Get me on LinkedIn: za.linkedin.com/in/jimbrownza/

UK
Offline Offline
Shannon Member
****
Karma: 219
Posts: 12374
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Faraday Member
**
Karma: 79
Posts: 3733
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Although I answer in good faith, remember always: Your Mileage May Vary.
Get me on LinkedIn: za.linkedin.com/in/jimbrownza/

UK
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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...

Logged

Offline Offline
Faraday Member
**
Karma: 79
Posts: 3733
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Although I answer in good faith, remember always: Your Mileage May Vary.
Get me on LinkedIn: za.linkedin.com/in/jimbrownza/

Offline Offline
Faraday Member
**
Karma: 79
Posts: 3733
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Although I answer in good faith, remember always: Your Mileage May Vary.
Get me on LinkedIn: za.linkedin.com/in/jimbrownza/

UK
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

Pages: [1] 2   Go Up
Jump to: