TTL Serial Port and PS2 Mouse Interface

Hi,
Was tinkering with a PS2 mouse in the garage the other day. Noted the two digital encoders, 3 digital inputs and the analog input (roller). Noted that four wires connected it to the PC (pins Vcc, 0, CLK, Signal).

Been reading today about the TTL Serial Port on the RC.

Any possibility that these two things can be electrical tied together (simply)? With some of the code samples I have seen it could then be possible to add some more capability to the robots.

Let me know what you think!

Regards,
ChuckB

Just took apart a PS2 keyboard…curious if these devices can be used with very little modifications on the circuit side.
Regards,
ChuckB

Don’t think so. I believe he mouse input on a computer interprets the input data through the mouse driver.(software) Each mouse can have it’s own protocol for data as polled by the mouse driver. I will ask around for more info and get someone to respond.

the serial TTL port isn’t supported by the programming framework in the FIRST controller, so you’d have to build up new framework. The PS/2 port is also directed by a protocol, one developed by IBM, and you’d have to make the controller recognize that protocol. Also, the PS/2 Port needs a clock signal, probably one of a specific frequency, so you’d have to get the return line in the serial port to put out a clock cycle. I don’t know how easy or hard that is, but it’s just something to look at.

Sparks

There are two important differences between the PS/2 protocol and RS-232: first is that PS/2 is synchronous, which means there is a separate clock line which keeps the transmitter and receiver synchronized. In RS-232 (like a normal serial port), the transmissions are asynchronous, meaning there is no clock so the transmitter and receiver each have to know the baud rate ahead of time. The second important difference is that PS/2 uses the same pin for both Transmit and Receive. This is an electrical “trick” of sorts called open-collector, meaning the transmitter only ever actively drives the line to ground and otherwise leaves it unconnected (and a pullup somewhere else on the line makes sure the line stays at Vcc). RS-232 uses separate transmit and receive lines. So right off the bat there’s some electrical incompatibilities. However, most microcontrollers with serial interfaces are very configurable and can often be configured for either synchronous or asynchronous mode, and the electrical problems could be fixed with a few external components. I haven’t looked at the Microchip document in a while, but it might be possible to set up the TTL serial port to do PS/2. There’d still be a good amount of software necessary to do the higher-level PS/2 protocol, though.

The PIC can be configured for synchronous operation.

Got any more details? Example code? If you could show how to interface to a PS/2 mouse or keyboard, this would be huge!

Keep in mind, your looking at a body of code like Kevin Watson’s new serial driver, but more complicated. :ahh:

Most of this has probably been said already, but here goes anyway.

RS-232 (Standard serial, what the COM port on your computer uses) is full duplex with an assumed frequency (though it varies between devices). there are 3 pins needed–Tx, Rx, Gnd. (the other 6 are status indicators). TTL is very similar, just uses 0v and 5v instead of -3v to -25v and 3v to 25v of RS-232. (Beyond Logic has some great RS-232 resources)

The PS/2 format is also serial, but is half-duplex and requires a clock. While it can connect to a standard serial setup (either TTL or RS-232), if the clock speed varies a little, you’re screwed. A better solution may be to take a cheap PIC/Stamp/etc. and wire the clock to an interupt and the data to a digital IO, and have it convert to/from TTL/RS-232 and PS/2.

The actual data format of PS/2 devices has long been standardized (at least for basics). Beyond Logic has an article on the AT Keyboard. Here’s a list of Mouse format articles I found via Google:

There is, of course, plenty more to find online. :wink: