2
\$\begingroup\$

Trying to connect as many usb mice to my arduino and just got informed of usb to rs232 converters.

Can anyone tell me if it is possible to simply connect a usb mouse to a usb to rs232 converter, connect some wires from the rs232 output plug to the microcontroller and then read the data for all mouse events?

\$\endgroup\$
11
  • \$\begingroup\$ USB rs232 adapters are not bi-directional. \$\endgroup\$
    – JustJeff
    Jun 16, 2011 at 8:57
  • 1
    \$\begingroup\$ Why do you want to do that? Maybe there is a simpler solution? \$\endgroup\$
    – starblue
    Jun 16, 2011 at 9:45
  • \$\begingroup\$ @starblue PC software that I'm working on would benefit from multi mice inputs. \$\endgroup\$
    – zaf
    Jun 16, 2011 at 10:20
  • 1
    \$\begingroup\$ @zaf - JustJeff's comment is really the answer to your question, but have you tried connecting multiple mice to your computer? The result (on Mac and Ubuntu, at least) is that each mouse's relative movement controls the single cursor. Move mouse 1 to the right, and mouse 2 upward, and the result is that the cursor moves up and to the right. Do you need multiple cursors? If so, you're going to have to use custom hardware and write your own cursor engine, and you're going in the right direction. \$\endgroup\$ Jun 16, 2011 at 11:44
  • 1
    \$\begingroup\$ @Kellenjb - I think he means that you can't plug the USB mouse into the USB-RS232 adapter (through a hypothetical female-female adapter or cable modifications) and get mouse coordinates in RS232 out the other side. So, yes, they aren't bi-directional because they can't act as a host. \$\endgroup\$ Jun 16, 2011 at 13:38

6 Answers 6

6
\$\begingroup\$

No, but you could plug the mouse into a USB to PS/2 converter which will make the mouse switch into synchronous serial mode. You would need a matching mini-DIN socket fed with 5V but decoding the data should be fairly straightforward. See here for the wiring.

USB to PS2 converter

UPDATE

I just tried this with a couple of new mice and they worked OK. As an afterthought - remembering that PS/2 mice work in asynchronous mode with a PS/2 to DA9 adapter - I tried cascading USB => PS2 => Serial adapters (with external power grafted-in). Needless to say, USB mice don't support legacy async serial mode (well it was worth a shot!).

\$\endgroup\$
9
  • 2
    \$\begingroup\$ @MikeJ-UK do all mice switch to this mode when ps2 connected? \$\endgroup\$
    – zaf
    Jun 16, 2011 at 10:29
  • \$\begingroup\$ @stevenvh Are you saying that the passive device is able to convert USB signals to PS/2 signals? \$\endgroup\$
    – Kellenjb
    Jun 16, 2011 at 11:56
  • \$\begingroup\$ @stevenvh see electronics.stackexchange.com/questions/13399/… \$\endgroup\$
    – Kellenjb
    Jun 16, 2011 at 11:58
  • 1
    \$\begingroup\$ I would be surprised if newer mice have this feature. \$\endgroup\$
    – joeforker
    Jun 16, 2011 at 13:30
  • 1
    \$\begingroup\$ Those things were originally shipped with mice that had enough logic to detect whether they were connected to USB or PS2, and appeared in the 90's when there were still people whose computers had no USB ports. Seems like it would be pretty hit-or-miss whether any given modern mouse would support a PS2 mode. That said, while PS2 would be easier for a micro to deal with than USB, it'd still be more complicated than rs232, since PS2 uses separate clock and data lines, and there's an exact protocol for using it. \$\endgroup\$
    – JustJeff
    Jun 16, 2011 at 23:40
6
\$\begingroup\$

No. The USB mouse needs to be plugged into a USB host. The USB to RS232 controller is not a USB host. It is a USB device, like the mouse, and relies on the host to perform various USB bus management functions.

\$\endgroup\$
2
  • \$\begingroup\$ Some high end ARMs can act as USB hosts. \$\endgroup\$
    – stevenvh
    Jun 16, 2011 at 8:25
  • \$\begingroup\$ Yes, but off-the-shelf USB/RS-232 converters won't work in that fashion. \$\endgroup\$
    – Toybuilder
    Jun 17, 2011 at 18:45
4
\$\begingroup\$

Ditch the Arduino and use an MCU with host mode or USB OTG (On The Go). It won't cost much (I'd use a PIC24FJ256GB110 with USB OTG), but developing the software will be a lot of work, although Microchip has a free USB software stack:

http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en531089

\$\endgroup\$
5
  • \$\begingroup\$ Isnt it possible to program an arduino to act as a USB host? \$\endgroup\$
    – 0xakhil
    Jun 16, 2011 at 8:55
  • \$\begingroup\$ It might just be possible with some clever code written in assembler, but it wouldn't be able to do anything else, like doing anything with the data. \$\endgroup\$ Jun 16, 2011 at 9:59
  • \$\begingroup\$ I presume that oxakhil was referring to the host shield, which has a MAX3421E USB host IC. With the original USB-B port, yeah, you're going to have a hard time. \$\endgroup\$ Jun 16, 2011 at 11:43
  • \$\begingroup\$ The problem with using a PIC by itself and the Microchip stack is they don't support hubs, so they are not a good solution for multiple USB mice connected to one microcontroller. However one can use an external USB host chip and a hub -- e.g. Maxim 3421E and TI TUSB2046B, which I have successfully used together. \$\endgroup\$
    – tcrosley
    Jun 16, 2011 at 20:29
  • \$\begingroup\$ the avrusb did a usb host bit it only worked for low speed devices, \$\endgroup\$ Jan 12, 2016 at 8:28
3
\$\begingroup\$

You should pick up the USB host shield. It has a USB host controller chip and comes with supporting software that will let you talk to your mouse.

\$\endgroup\$
0
\$\begingroup\$

If you are looking to interface a USB mouse, keyboard, or other HID, look at this website: https://www.circuitsathome.com/communicating-arduino-with-hid-devices-part-1

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Usually its a good idea to give a summary of a link if you want to create an answer (because the linked content can vanish, making the answer pretty useless). If you just want to dump the link you can always do it in a comment! \$\endgroup\$
    – 0x6d64
    Jan 12, 2016 at 8:08
0
\$\begingroup\$

If you can find a USB to rs232 converter that converts USB device input to rs232 output then yes! unfortunatly that sort of devuce costs $100 or more not including the time spent searching for it. you're better off with a cheap 32 bit micro-controller running s USB stack, or a full OS.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.