2

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?

Kortuk
  • 13,362
  • 8
  • 60
  • 85
zaf
  • 453
  • 6
  • 10
  • USB rs232 adapters are not bi-directional. – JustJeff Jun 16 '11 at 08:57
  • 1
    Why do you want to do that? Maybe there is a simpler solution? – starblue Jun 16 '11 at 09:45
  • @starblue PC software that I'm working on would benefit from multi mice inputs. – zaf Jun 16 '11 at 10:20
  • 1
    @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. – Kevin Vermeer Jun 16 '11 at 11:44
  • @JustJeff How are they not bi-directional? Do you mean to say that they aren't both a host and a slave – Kellenjb Jun 16 '11 at 11:45
  • I am surprised no one has pointed this out yet, makes me wonder if I am misunderstanding what he wants to do... You can't connect RS232 directly to your Micro, you have to do some level shifting on it first. The simplest method would be something like a FT232, but you can't connect a mouse to the FT232 because of all of the reasons people have already addressed. – Kellenjb Jun 16 '11 at 11:54
  • 1
    @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. – Kevin Vermeer Jun 16 '11 at 13:38
  • @kevin Vermeer the problem with wording it as "bi-directional" implies that a USB to RS232 converter is not capable of TXing and RXing. – Kellenjb Jun 16 '11 at 14:06
  • @Kellenjb - It never occurred to me to read it that way! I understood a non-bi-directional converter as incapable of converting in both directions, not as incapable of sending information in both directions. Makes sense, though. Unfortunate that the best answer was to use a USB-PS/2 converter, and had nothing to do with USB host -> RS232. – Kevin Vermeer Jun 16 '11 at 14:09
  • @Kellenjb - what Kevin said. By no means did I want to say rs232 by itself is not bidirectional; that rs232 by itself is bidirectional I would assume (!) as given. I meant only that you can't operate a USB device by trying to 'host' the adapter from the rs232 side, as Kevin inferred. – JustJeff Jun 16 '11 at 23:33
  • Looks like it's been in X for several years. Article also references similar products for other systems: http://en.wikipedia.org/wiki/Multi-Pointer_X – markrages Oct 19 '11 at 21:55

6 Answers6

6

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.

Toybuilder
  • 2,018
  • 1
  • 11
  • 12
6

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

MikeJ-UK
  • 5,348
  • 15
  • 20
  • 2
    @MikeJ-UK do all mice switch to this mode when ps2 connected? – zaf Jun 16 '11 at 10:29
  • @stevenvh Are you saying that the passive device is able to convert USB signals to PS/2 signals? – Kellenjb Jun 16 '11 at 11:56
  • @stevenvh see http://electronics.stackexchange.com/questions/13399/is-there-an-easy-way-to-test-if-my-ps-2-usb-adapter-is-passive – Kellenjb Jun 16 '11 at 11:58
  • @Kellenjb - okay, my bad. I must admit that it looks too small to have the required electronics inside. – stevenvh Jun 16 '11 at 13:01
  • See http://www.computer-engineering.org/ps2protocol/ for decoding the protocol. – AndreKR Jun 16 '11 at 13:19
  • 1
    I would be surprised if newer mice have this feature. – joeforker Jun 16 '11 at 13:30
  • 1
    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. – JustJeff Jun 16 '11 at 23:40
  • clock and data - perhaps you can connect it to a SPI port. you'd stil need to implement the protocol. – Jasen Слава Україні Jan 12 '16 at 08:25
  • Those adaptors only change the shape of the connector, there's no electronics inside. if the mouse supports "8042" (AKA PS/2) mode then a suitably wired USB socket could be used. – Jasen Слава Україні Jan 12 '16 at 08:33
4

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

Leon Heller
  • 38,774
  • 2
  • 60
  • 96
  • Isnt it possible to program an arduino to act as a USB host? – 0xakhil Jun 16 '11 at 08:55
  • 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. – Leon Heller Jun 16 '11 at 09:59
  • 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. – Kevin Vermeer Jun 16 '11 at 11:43
  • 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. – tcrosley Jun 16 '11 at 20:29
  • the avrusb did a usb host bit it only worked for low speed devices, – Jasen Слава Україні Jan 12 '16 at 08:28
3

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.

joeforker
  • 5,596
  • 10
  • 38
  • 59
0

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

Helper
  • 1
  • 1
    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! – 0x6d64 Jan 12 '16 at 08:08
0

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.