Interfacing a USB joystick to AVR

Go To Last Post
15 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

I want to interface my USB joystick to AVR Atmega16, so was looking for some starter tips. I want to be able to read the joystick positions and the button states using the AVR, so as to control some servo motors etc. Any tips or suggestions as to how to get started would be very helpful.

Thanks,
Sumair

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do you really want to use the USB interface of the joystick? If so, you would probably be much better off with a device with hardware USB support.

OTOH, if you don't require the USB interface but just want the joystick position and button states, you could gut the joystick of electronics and hook up the signals to the AVR directly.

/Jakob Selbing

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Forget using the mega16 for this. To interface to a USB device you need to have a USB master and the mega16 is not capable of this. As Jakob said, you need one of the AVRs with USB hardware built in.

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ok thanks for the tip guys...i'll probably think of using a regular joystick without USB to interface with the mega16.

Just on a curious note though, how easy is it to interface USB devices using an AVR with built-in USB hardware support? Could you please specify the AVR with such support?

Thanks,
Sumair

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Try the Atmel web site.

Leon Heller G1HSM

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Just on a curious note though, how easy is it to interface USB devices using an AVR with built-in USB hardware support? Could you please specify the AVR with such support?

All the 8bit AVRs with USB support are DEVICE type themselves. Which makes them great for use inside joysticks and keyboards and so on but no use for acting as a host to one.

There are just two exceptions to this - the AT90USB647 and the AT90USB1287 which, as well as "device" do a limited form of host mode called "On The Go" (OTG) and they may be able to host simple devices such as joysticks or keyboards.

So it would depend on what device you want to host - o0ne of those two might work or you may need to look higher up the foodchain at MCUs that have full host facilities (and a software stack such as OHCI/EHCI/UHCI to match).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

if you intend to provide USB host support, you would probably be better off using an AVR32 (eg. UC3A3) or even a SAM :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Great answers guys....thanks a lot :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

See the link by Johan .
https://www.avrfreaks.net/index.p...

Good to know this code exist, although it may not be useful for this OP's app.

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Hi.

I want to read usb joystick game controller with any mcu like avr - xmega - or lpc1768

i want an example code ? 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

Well, ideas for (?not?) writing example codes can de found in this very thread (and, if they had been false, after 6 years, it would have been detected...)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

electron113 wrote:
I want to read usb joystick game controller with any mcu like avr - xmega - or lpc1768
As dbrion says, read the thread. I already explained in post #6 that in all the models of 8bit AVR (including Xmega) there are only actually 2 models of AVR that could possibly (using internal electronics) act as host for a USB joystick device- 647 and 1287. So forget about using Xmega - none of them have any form of host mode.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

And, clearly, any Atmel forum - let alone the AVR forum - is not the place to ask about LPC1768 !

 

electron113 wrote:
i want an example code ?  

http://www.lmgtfy.com?q=USB+Joystick+Microcontroller+example

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I want to read data from a USB joystick.
Communication protocol between the microcontroller and the joystick is USB Port.
I can not find any code examples or similar!

 

THANK FOR ANSWERS.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Have you READ this thread? You need a 647 or a 1287 and with that you would then use LUFA.