Shop OBEX P1 Docs P2 Docs Learn Events
USB mice and keyboads on the Propeller and other micro-controllers. — Parallax Forums

USB mice and keyboads on the Propeller and other micro-controllers.

LoopyBytelooseLoopyByteloose Posts: 12,537
edited 2013-07-13 13:59 in General Discussion
I have a mouse and keyboard set aside with DIN connectors... just to use with my dearly beloved Propellers.

But I also have a gadget with two DIN plugs on one end and a USB connector on the other that will make both the DIN mouse and DIN keyboard interface via one USB port.

For the life of me, I can't quite figure out if the the mouse and the keyboard are internally USB enabled, or if the USB port just has code that reverts to a serial mode that is really much simpler.

I suspect that the latter is the case. After all, the splitter words with mice and keyboards that were around long before USB ports.

And that leads to a second and more dire question.

How does the USB port know that there are two devices and which device is presenting data?

If we could sort this all out, I suspect I could get rid of the DIN mouse, the DIN keyboard, and the splitter and just use USB mice and USB keyboards with the Propeller.

The USB port has 4 wires.. right Or are the extra unused pin in play with the mouse and the keyboard?

If only 4 wires are in play... they are +5, ground, Sio and Sclk. Could it be that the roles of the Sio and the Sckl are reversed on the mouse and the keyboard.

Or if it is 5 wires, do they share the clock and have separate io lines, or do they share the i/o lines and have separate clk lines?

Comments

  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-07-12 00:04
    This link below provides the wiring solution for one PS2 to USB device.
    I still wonder about two devices on one USB port and if there is an exploit of the extra USB pin.

    I suppose that just providing two special use USB ports for a Propeller - one for keyboard and one for mouse is the optimal way forward. The software should be the same synchronous serial that was used with PS2 devices.

    http://technix.free-message-board.com/t49-ps-2-to-usb-wiring-diagram
  • RDL2004RDL2004 Posts: 2,554
    edited 2013-07-12 02:45
    The PS/2 mode is built in to the chip used in these devices. If the chip doesn't detect that it's plugged into a USB port it automatically switches to PS/2 mode.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-07-12 03:08
    I can understand that the USB port in the PC either recognizes a valid USB device or switches to synchronous serial. That is certainly sensible.
    What you are saying is that all mice and keyboards are essentially synchronous serial with USB connectors instead of PS/2 connectors.


    But if I use a splitter, it seems to also manage recognizing whether the mouse or the keyboard is active. Hows does that happen? And could I do the same with a Propeller?

    It would certainly be handy to have the i/o for keyboard and mouse share pins with all the code using one Cog.
  • RDL2004RDL2004 Posts: 2,554
    edited 2013-07-12 03:44
    The "splitters" (I think combiner is more correct) can connect two devices to a certain type of PS/2 port, usually referred to as an "IBM Thinkpad" PS/2 port. The mouse data and clock are moved to the normally unused #2 and #6 pins. Power and ground are shared. These ports are usually 1/2 purple and 1/2 green colored to distinguish them from the normal types. The Gigabyte motherboard I bought back in October has this type of PS/2 port.

    A note about the backward PS/2 compatibility in USB devices, I've read that some newer USB mouse and keyboard devices may no longer support the PS/2 connection (HP and Dell?).
  • BeanBean Posts: 8,129
    edited 2013-07-12 04:05
    Rick,
    Yeah, I have a bunch of tiny keyboards that are USB only.
    I have not seen any code for the propeller that will work with USB only keyboards.
    I've read that there is some kind of simple USB protocol that USB keyboards use (for example when you go into the bios setup) but I don't know enough about USB to figure it out.

    If anyone has done this, or knows how to do it, please let me know.

    Bean
  • homosapienhomosapien Posts: 147
    edited 2013-07-12 05:59
    I may be wrong, this is from what I 'remember' from engineering school many moons ago -

    The the USB uses differential signaling ( 4 pins: 5v, gnd, V+, V-), PS2 uses synchronous seral (TTL?) (4 pins: 5v, gnd, ser, clk).
    I can understand that the USB port in the PC either recognizes a valid USB device or switches to synchronous serial. That is certainly sensible.

    I believe this is opposite of what happens. The controller in the KB or MOUSE figures out if it attached to a USB port or serial port, and sends its signals according to what it sees. Really old kb/mice will ONLY operate in serial mode. Medium old devices know to look to see if they are attached to USB or serial ports and use the appropriate communication protocol (USB or serial). Apparently some devices never even look to see if they are attached to a serial port, will only communicate via differential signaling (USB).

    If it was the computer USB port deciding on whether to use serial or USB, then the marketing guys at FTDI are geniuses....



    So to answer your original question, the USB is a communication bus. Whenever a device is plugged in, there is a enumeration process where the device is (hopefully) recognized by the USB bus controller. When any device on the USB bus communicates with the computer, the data packets are labeled as from a certain device.
  • RDL2004RDL2004 Posts: 2,554
    edited 2013-07-12 06:25
    The controller in the KB or MOUSE figures out if it attached to a USB port or serial port, and sends its signals according to what it sees.

    Yes, this is how it works. The decision (if any) is made by the keyboard/mouse. It was done this way in order to ease the transition to USB devices. Consumers could buy a newer USB device and plug it into their older computer's PS/2 port using a simple pass-thru adapter and it would still work.
  • kwinnkwinn Posts: 8,697
    edited 2013-07-12 06:55
    As for combining the keyboard and mouse on one connection, the keyboard sends 3 bytes for each keypress, and the mouse does something similar for each button press or x/y step. The bytes sent are different for the keyboards and mice so software on the receiving end can tell what device it came from.
  • prof_brainoprof_braino Posts: 4,313
    edited 2013-07-12 08:02
    So is it possible to have the prop directly deal the USB enumeraton as either host or client? What's stopping us?
  • homosapienhomosapien Posts: 147
    edited 2013-07-12 08:11
    Hardware to create/receive high-speed differential signals.

    FTDI chips (and others, I believe) have this + ability to do enumeration for pretty low cost....

    Not saying the prop couldn't do it with some circuitry, but I think you get into the 're-inventing the wheel' thing when there is already a cost-effective solution out there. I thought about it for awhile long ago, but then read 'USB Complete' by Axelson and decided perhaps my time would be more profitably spent on other projects. Would be thrilled to see if someone from here could prove me wrong....
  • tonyp12tonyp12 Posts: 1,951
    edited 2013-07-12 08:19
    >USB enumeraton as either host or client? What's stopping us?
    The complexity of the enumeration process and understating pipes and endpoints.
    Someone that understand it on a PC should be able to port it, but this person is probably already to busy in the corporate IT world.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-07-12 08:29
    Here is the device that made me start this thread. I have been wondering about this for ages and somewhat expected someone to have solved it by now.

    http://setcomp.pl/akcesoria-do-produktow-sieciowych/34061-planet-adapter-dla-kabli-do-kvm-usb-to-ps-2.html

    I seems to me that you don't need to have USB protocol to have two PS/2 devices on one set of clk and data pins via synchronous serial. And it does seem that USB mice and keyboards are NOT using USB, but legacy synchronous serial. D- as Data and D+ as Clock, while V+ and GND remain the same.

    So why bother with USB overhead if it can be done with less code? As far as replicating USB in any form, I suspect that there are proprietary problems with doing so. Bean said a USB to PS/2 doesn't work for him, but there are also one to one adapters in both directions available.

    I have used the 2 PS/2 to USB with a netbook. And I even have a few PS/2 to USB adapters that came with PS/2 mice. So why wouldn't the USB to PS/2 interface work if you got the right clock and data lines?

    http://www.5kw.dk/Hobby/electronics/connectors/usb.htm

    http://shop.acquirepc.com/product/path/66/product_id/125

    And here is someone that recommends 10K pullups to avoid problems.

    http://pinouts.ru/InputCables/usb_ps2_mouse_pinout.shtml
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-07-12 08:59
    This document seems to indicate that there are non-USB and USB compliant keyboards. see page 75
    I am not sure where reality lies. non-USB keyboards are likely less costly to manufacture due to older chip sets.... even if you put a USB plug on end of the cord.

    http://www.usb.org/developers/devclass_docs/HID1_11.pdf
  • homosapienhomosapien Posts: 147
    edited 2013-07-12 09:08
    Rest assured, if you connect ANYTHING to a USB port on a computer and have successful communication, then the connected device is sending/receiving USB signals - ie differential voltage signals. USB data is serial, one bit at a time, the data being a 0 or 1 depending on the state of the D+ and D- lines. There is no 'clock' line. There is no 1-to-1 correlation between synchronous serial and differential signaling, meaning there is no way to 'wire' a USB signal to a ser/clk serial port without conversion hardware.

    Anytime you connect a PS/2 plugged device to a USB port (and have successful communication), either the device IS sending USB signals, or the conversion plug has an internal conversion device that is acting as a bridge between the 2 protocols/signaling voltages.

    USB was designed as an 'open' standard, pretty much anyone can come and play. It was brought into being mostly to solve speed bottlenecks (differential signaling can be VERY fast and has high noise immunity), which in turn allowed for 'plug n play' as enumeration was possible/fast.


    And that is about the extent of my knowledge of USB :blank:
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-07-12 09:18
    @homosapien
    Well there is a clock line and an synchronous serial mode. And, I believe the clock originates from the PC via the USB port. Read the pdf link in #14 above. The conversion plug seems to have bupkis. nada. zilch.....

    What seems to happen is the BIOS will survey the PC's serial plug, determine if there is a USB device or a PS/2 device with adapter, and then the PC will either provide a USB host or a synchronous serial service via alternative chips on the motherboard.

    But thanks... I wasn't aware that it was supposed to be an open standard.

    "Appendix F: Legacy Keyboard Implementation

    The boot and legacy protocols for keyboards in USB allow a system which is not
    USB-aware (such as PC BIOS or IEEE 1275 boot firmware) to support a USB
    HID class keyboard without fully supporting all required elements of USB. The
    Boot/Legacy Protocol does not limit keyboards to this behavior. Instead, it is
    anticipated that keyboards will support full HID-compatible item-based protocols
    , as well as boot and legacy protocols.

    F.1 Purpose
    This specification provides information to guide keyboard designers in making a
    USB Boot/Legacy keyboard. It provides information for developers of the system
    ROM so that they can use such a keyboard without fully parsing the HID Report
    descriptor. The motivation is that while the full HID class capability is
    enormously rich and complex, it is not feasible to implement the required HID
    class adjustable device driver in ROM. But, operator input may still be required
    for either boot or legacy support."

    See what is really going on with legacy devices... try here ====> http://www.computer-engineering.org/ps2protocol/


  • RoadsterRoadster Posts: 209
    edited 2013-07-12 09:46
    I was looking at this board at hobbytronics to use usb devices for the propeller.

    http://www.hobbytronics.co.uk/usb-host-board-v2
  • homosapienhomosapien Posts: 147
    edited 2013-07-12 09:52
    @Loopy,

    Well, I'm an engineer, not lawyer, but I think your quote is saying there may be some USB keyboards that do not follow the complete USB standard? As Tonyp12 implied earlier, the enumeration protocol will make your head spin....

    To be clear, in your post #2, where you show someone's idea of converting a PS2 plug to a USB plug, this will only work if the device is one that does both serial and differential signaling (ie the chip in the device knows how to determine if it is on a USB or serial port). That wiring is exactly what happens when you put a PS/2-to-USB adaptor on a PS/2 plug. If you simply stick a USB plug on a device that only talks serial, it's not going to function when you plug it into a computer USB port.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-07-12 20:02
    Here is the device that made me start this thread. I have been wondering about this for ages and somewhat expected someone to have solved it by now.

    http://setcomp.pl/akcesoria-do-produktow-sieciowych/34061-planet-adapter-dla-kabli-do-kvm-usb-to-ps-2.html

    The above adaptor has brains in the little box to convert between the USB signal to PS/2. It's not a pass through adaptor that comes with many keyboard capable of using either PS/2 or USB.

    You can have a USB to PS/2 adapter as long as the PS/2 side connects to the PC. In this case, it's as homosapien has been explaining, the keyboard or mouse with the USB plug on it can detect if it's plugged in to a USB port or a PS/2 port and tailors the signal appropriately. This will only work with keyboards and mice which look for a possible PS/2 signal.

    If you have a USB only keyboard or mouse, there's nothing to be done without some sort of intelligent convertor. The convertor would need to be more intelligent than the adaptor in the link quoted above since it would require the adaptor to be a USB host device.

    (BTW, I'm pretty much saying the same thing as homosapien as others are saying.)
  • tonyp12tonyp12 Posts: 1,951
    edited 2013-07-12 21:16
    I attached a zip file with a project done by Matthias trying to bitbang USB on a msp430.
    Done in asm so porting(getting ideas) to pasm should be possible.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-07-13 02:01
    Yeah, the languge is a bit opague... but they mention Legacy keyboards, Legacy mice, Non-USB keyboards, and Non-USB mice and how all are accomodated. My impression is that the USB standard provided for legacy sychronous with an eventual migration to USB mice and keyboards.

    The USB may officially be an open-standard, but if this is open source documentation ... it seems as if it is trying to make it as difficult as possible to read. I have similar problems trying to interpret info on SDcards.

    The MAIN idea was that I was hoping that there were keyboards and mice that had a USB plug, but were really able to support PS/2 protocol.

    This would make my life simpler. If that were true as I wouldn't have to save a PS/2 mouse and keyboard for use with the Propeller. And I wouldn't have to hang onto Propeller Proto Boards for the PS/2 plugs.
    I have no ambitions of making a Propeller work as a USB Host. I think that has been discussed before and has been abandoned. It would just be easier to have an FTDI chip provide the USB Host services.

    The muddle is that there are all sorts of USB to PS/2 and PS/2 to USB adapters floating around in the after-market. Some, such as the USB to PS/2 appear to be a useless deception.
    homosapien wrote: »
    @Loopy,

    Well, I'm an engineer, not lawyer, but I think your quote is saying there may be some USB keyboards that do not follow the complete USB standard? As Tonyp12 implied earlier, the enumeration protocol will make your head spin....

    To be clear, in your post #2, where you show someone's idea of converting a PS2 plug to a USB plug, this will only work if the device is one that does both serial and differential signaling (ie the chip in the device knows how to determine if it is on a USB or serial port). That wiring is exactly what happens when you put a PS/2-to-USB adaptor on a PS/2 plug. If you simply stick a USB plug on a device that only talks serial, it's not going to function when you plug it into a computer USB port.
  • RDL2004RDL2004 Posts: 2,554
    edited 2013-07-13 05:55
    The MAIN idea was that I was hoping that there were keyboards and mice that had a USB plug, but were really able to support PS/2 protocol.

    Yes, the vast majority of keyboards and mice made work this way. It has been stated as such several times in this thread. When they are connected to a computer, if they do not get queried by the computer's USB controller they automatically fall back to PS/2 compatibility mode.

    These devices need a simple pass-thru USB to PS/2 adapter to work correctly on a computer PS/2 port, but only to fit mechanically. The adapter has no effect on the electrical functioning. Bear in mind that they are all actually USB devices, not just PS/2 device with a USB plug. It would not make sense to have a USB plug on something that wouldn't work if plugged into a USB port.

    There is no simple pass-thru adapter to go the other way, from PS/2 to USB. Something with active electronics, like an FTDI chip, is required for that.

    Note that it is certainly possible to use a USB type plug on a PS/2 device (or anything that needs 4 wire or less to connect), but that would be very non-standard and does not make it a real USB device. The potential for end user confusion would be considerable.

    You may find this post at Quinn Dunki's Blondihacks blog interesting.

    http://quinndunki.com/blondihacks/?p=1347
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-07-13 06:28
    Unless I buy a mouse or keyboard with a PS/2 plug on the end of the cable... there is absolutely no clarity that it will also support PS/2 protocol.

    And I find it a real pity that the mouse and the keyboard appear to be migrating over to USB only interface. If the splitter does indeed have a PS/2 to USB converter chip within, that won't save the day when the stores no longer sell PS/2 mice and keyboards.

    Both the mouse and the keyboard are important and extremely useful to the Propeller via the PS/2 protocol. A USB solution will likely cost more in either Propeller resources to support or a USB host chip between the Propeller and the mouse or keyboard.

    If you think you don't need PS/2, consider the fact that the optical mouse can also be set up on a rotating disk as a rotation encoder that works very well, and the disk can be an old standard CD or a smaller 3.5" CD.

    Also having a bar code reader that provides data via PS/2 makes the Propeller a powerful data accumulator.

    Forgive me, but I was hoping for something that is not meant to be... preserving a legacy protocol for the sake of its usefulness to students and hobbyist.
  • RDL2004RDL2004 Posts: 2,554
    edited 2013-07-13 07:29
    Unless I buy a mouse or keyboard with a PS/2 plug on the end of the cable... there is absolutely no clarity that it will also support PS/2 protocol.

    So buy some with the PS/2 plug and stop worrying about it. Newegg currently sells dozens of different PS/2 keyboards and mice, in addition to those that work with either PS/2 or USB. I'm sure they're available almost everywhere.

    There have been millions and millions of PS/2 devices built in the last 20 years and it looks like they'll be around for quite a bit longer. It's not much of a gamble to buy a USB version and hope it works as PS/2 also, odds are highly in your favor that it will. Honestly, I fail to see any reason to go on and on about this. As far as I can tell it's a non-issue.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-07-13 10:28
    Yeah forget it. I can always pay 200% to have it shipped from the USA.... maybe a mere 500% for cheap items. These items don't hang around in Taiwan's retail... maybe not in a lot of other countries.
  • HumanoidoHumanoido Posts: 5,770
    edited 2013-07-13 10:52
    Well, NewEgg doesn't take orders from Taiwan. I can't even reach their web page anymore.

    What you may not realize is that in Taiwan the PS/2 keyboard and mouse are likely to sudden disappear from retail shelves and to never be seen again. It has happened with a lot of other legacy computer gear. I wanted to get a small cheap video card for my XP computer due to the motherboard sharing video with 512M ram, but I can't find one in any local stores.. only big fancy Nvidia power hogs and I need low power for the 250 watt supply.

    I see that in the USA, one can buy ancient CPUs, motherboards, and RAM with ease.. but it just is not the same here.
    This country doesn't want old technology on its retail shelves. They take orders, export, and move on to the next generation. Local sales are from what is currently in vogue.. Windows 8.

    Maybe in Hong Kong this stuff hangs around as it sells to a lot of visitors from all over the world.

    But for a lot of the world, once the older stuff is being phased out... it disappears immediately from the local retail. I can't locally get a stylus for my Palm Zire 72 or a replacement battery. And parts for the early Asus EEE notebooks are all gone.

    I will definitely vouch for that happening in Taiwan. I've seen dozens of stores with those older GPU cards going for about $20. When I decided which ones I wanted and which ones had the proper bus and which ones I could program, and went back with cash to buy a truckload to build a bigger supercomputer, none could be found. They were all replaced with just one thing, the newest GPU cards to hit the market at up to $1,200 bucks a wack. If you need PS/2 keyboards and you see one at the store, you better grab it while it's there. Yes there are visitors from all over the world in HK but I never saw $20 GPU cards at their computer parts stores. I think they were phased out when prime before Taiwan's.
  • Peter KG6LSEPeter KG6LSE Posts: 1,383
    edited 2013-07-13 13:59
    Two words TRISRTATE BUFFER !!!!( and there cousin the analog switch )


    how else is Mini display port able to break out to VGA DVI/HDMI


    Depending on the port that is used .... the Pins are Digitally routed to the correct side of the chip and its Line drivers .
Sign In or Register to comment.