Page 1 of 1

Using the PS/2 Ports as General Ports

Posted: Wed Nov 26, 2014 1:44 am
by Primis
So I was flipping through the 8042 spec.
You can turn the clock off it would seem, and set the data bit from the controller output port.
Does that technically mean that I can bitbang serial data over the two PS/2 Ports?
I know this is not technically standard... but it'd be cool for serial data other than PS/2 usage. (MIDI comes to mind)

Re: Using the PS/2 Ports as General Ports

Posted: Wed Nov 26, 2014 4:05 am
by Nable
Using LPT port (8255) is much simpler for this task and real LPT port is much easily to find than "close-to-real 8042" (PS/2 controller that is emulated by LPC chip or south bridge may lack such "disable clock" feature). Btw, bit-banging often requires very good timekeeping (I mean that you should keep width of pulses with a good accuracy unless you want to play with 1-wire interface devices that are very tolerant to changing pulse width), I'm not sure if you can easily achieve it with such interface.

Btw, using external GPIO board (based on FTDI232, CP21xx or Atmel or Cypress MPU) that is connected via USB would be a much better solution (no usage of legacy ports that are becoming rare, no efforts to implement low-level port manipulations, no wasted CPU time and bus bandwidth to keep synchronization, higher possible data rate).

TL;DR: you can try it but real 8042 can be found only on Pentium1 and older motherboards. On newer boars it's emulated and emulation chip may lack features that are rarely used. I should also notice that it would be rather hard to implement and data rate would be very low.

Re: Using the PS/2 Ports as General Ports

Posted: Wed Nov 26, 2014 11:49 am
by Primis
One thing that struck me that I could do was the Apple Desktop Bus Connector. It'd just take a PS/2 to SVideo Adaptor (I'm not above splicing wires)
The LPT port probably would work better, but the thought was "Lots of computers have unused PS/2 Ports, What's a good use for them?"

Re: Using the PS/2 Ports as General Ports

Posted: Wed Nov 26, 2014 6:36 pm
by Brendan
Hi,
Primis wrote:One thing that struck me that I could do was the Apple Desktop Bus Connector. It'd just take a PS/2 to SVideo Adaptor (I'm not above splicing wires)
The LPT port probably would work better, but the thought was "Lots of computers have unused PS/2 Ports, What's a good use for them?"
For bit banging purposes, the 8042 doesn't give you enough control over clock or data (and the signals on clock and data need to be synchronised - e.g. you can't send without the receiving device providing the clock signal).

The main problem is that "PS/2 serial" is quite different to "RS232 serial". For PS/2 there's one data line that's used for both transmitting and receiving, and one clock line that's used for both transmitting and receiving. For RS232 there's one "data and clock" line for transmitting, and one "data and clock" line for receiving. The other problem is PS/2 has almost nothing else; while RS232 has a bunch of other signals (CTS/RTS, ring indicator, etc).

Finally, there's a speed difference. PS/2 runs at a fixed speed of about 10 Khz, but that's shared for sending and receiving, so it's more like ~5 Khz per direction. Serial is typically faster - e.g. between 9.6 KHz and 115 KHz in both directions. This means that (even with a special electronic "PS/2 to RS232 converter" circuit) PS/2 simply doesn't have the bandwidth to run RS232 devices properly (although by using both PS/2 ports you might get enough bandwidth to do 9600 baud serial without much buffering).

As far as I know, MIDI is very similar to RS232, except MIDI is even faster (about 32 KHz).

The funny part is that for user input devices (e.g. keyboard, mouse, touchpad, joystick, etc) where you rarely need to send data to the device and the amount of data is relatively tiny; it's the latency (and not bandwidth) that matters most. For USB, the controller does polling and the bus is potentially shared by many devices; so the latency suffers. What this means is that for user input devices, PS/2 is typically better than USB.

I guess what I'm saying here is that you can't really use PS/2 for anything other than user input devices; and for user input devices you'd be struggling to find anything better.


Cheers,

Brendan