Shop OBEX P1 Docs P2 Docs Learn Events
WANTED: USB Interface Chip to Support Reading of Mouse and Keyboard — Parallax Forums

WANTED: USB Interface Chip to Support Reading of Mouse and Keyboard

I am looking to find a chip to allow serial comms between a USB keyboard and the Propeller 1. I would like to stay in the lower end cost range(no more than $10 per module). These are intended for a custom PCB.
«1

Comments

  • There aren't really a lot of cheap, non-tiny-BGA chips with USB host functionality out there.
    However, many(most?) simple USB keyboards can be controlled over PS/2 (even if they don't ship with the appropriate adapter. The common USB keyboard controller chips just have that feature. Some expensive keyboards also have it, since USB doesn't really do NKRO).
  • jmgjmg Posts: 15,175
    I am looking to find a chip to allow serial comms between a USB keyboard and the Propeller 1. I would like to stay in the lower end cost range(no more than $10 per module). These are intended for a custom PCB.

    So you need a USB-Host to master to a slave (device) Kbd and or Mouse, and report to P1 in serial ? (or even PS/2? or is that 2 x PS/2 ? )

    Maybe this ? $2.20 ?
    https://www.electrodragon.com/product/ch552-ch554-mini-dev-board-ch55x-series/

    I've not run code on these, but there are examples like
    https://github.com/ole00/ch554_sdcc_usb_blinky

    https://bitbucket.org/e_dragon/wch/src
    includes this
    WCH / CH55x / demo code / CH554 serial2keyboard

    and one item shows via translate as
    -- Host
    USB HostHUB_KM.C: USB host application example, initialize and enumerate USB port connected devices, support Level 1 external HUB, can operate USB mouse and keyboard, HUB, printer, including HID class command processing
    USBHostHUB_KM.hex:
  • Hmm, not really what I was looking for, what search criteria did you use to find these?
  • AwesomeCronkAwesomeCronk Posts: 1,055
    edited 2019-03-29 01:52
    Found this on that same site. Maybe it will work?

    EDIT: revisiting electro dragon, I found this. I think my problems may be sort of solved.
  • jmgjmg Posts: 15,175
    edited 2019-03-29 19:08
    Found this on that same site. Maybe it will work?

    EDIT: revisiting electro dragon, I found this. I think my problems may be sort of solved.

    CH340 is a USB-UART bridge, so no, that's not what you need.
    CH375 is a parallel-bus, USB Host capable, and docs say this ". The CH375 also has firmware built into the dedicated communication protocol for Mass-Storage mass storage devices. External microcontrollers can read and write commonly used USB storage devices (including USB hard drives/USB flash drives/U disks) directly in sector-based units."
    so that's also not what you need, as it is Mass-Storage Hosting, & you asked for USB keyboard to P1

    If you do not want to use a low cost MCU (which needs some code downloaded) I see they also have this
    http://www.wch.cn/products/CH9350.html

    but that costs more, and does not seem to have a readily available PCB module ?
  • So can't you use the CH375 as USB C device and connect a keyboard/mouse/mass storage device to it and read it from the parallel pins on the other side. It looks to me is that all you need is an On The Go adapter to plug in the Keyboard or mouse. OTG cable

    The cable will cost about $5.00.

    Mike

  • Ok
    I think I will use some CH935s for my mouse/keyboard.

    That is, once I get time with my laptop, which can translate webpages, unlike my phone.

    A CH375 will do nicely for a disk drive or flash drive, which could be used for potential software changes to the product, using esp8266 over the air firmware style Propeller EEPROM programming.
  • If you accept some compromises, the Propeller can do USB host on its own:

    https://github.com/scanlime/propeller-usb-host
  • The CH9350 looks like a decent solution.

    macca's VT-100 Terminal uses the Propeller as a USB host to support a keyboard. https://github.com/maccasoft/propeller-vt100-terminal

    Note that the Propeller USB host software has not been thoroughly tested. Due to time constraints the amount of support I can provide for it is limited. (without payment ;) )
  • (without payment ;) )
    Ouch!!😋
  • Sorry to revive old threads...

    I have decided to go with a Prop-based USB host, as I cannot find any internet documentation for the CH3950.
    Can anyone walk me through the selection of the right .spin files to obtain to do the USB host on a P1? from @macca 's post?
    macca wrote: »
    If you accept some compromises, the Propeller can do USB host on its own:

    https://github.com/scanlime/propeller-usb-host
  • jmgjmg Posts: 15,175
    edited 2019-05-03 02:23
    Sorry to revive old threads...

    I have decided to go with a Prop-based USB host, as I cannot find any internet documentation for the CH3950.

    There is a PDF here, (in Chinese)
    https://lcsc.com/product-detail/USB_CH9350L_C109472.html
    It's an interesting looking part, their web page says used in pairs, and the SEL pin seems to define master/slave operations.
    It looks to have ability to manage PS2 or USB mouse/keyboard combinations, and sends info at 115200/57600/38400 baud (2 pins select)
    That means it has two host ports, which is less common in MCUs. It may be based on the CH559L Flash MCU (TQFP48), which appears to have 2 USB Host ports.

    From that, if you connect a pair, you can likely reverse engineer the serial link, and implement that in a P1 ?
    Or, maybe find Source for CH559 that does USB/Keyboard 2 x host example.

    Web- page
    Characteristics
    > Supports 12Mbps full-speed USB transmission and 1.5Mbps low-speed USB transmission, compatible with USB V2.0.
    >The host computer's USB port conforms to the standard HID class protocol, and does not require additional driver installation. It supports Windows, Linux, MAC and other operating systems with built-in HID device drivers.
    >The same chip can be configured as the host computer mode and the lower computer mode, respectively connected to the USB-Host host and USB keyboard and mouse.
    > Support USB keyboard and mouse in the BIOS interface, support multimedia function keys, support different resolution USB mouse.
    > Support various brands of USB keyboard and mouse, USB wireless keyboard and mouse, USB to PS2 line and so on.
    >The upper and lower terminals support hot swapping.
    > Provides a transmit status pin that supports 485 communication.
    >The serial port supports the 115200/57600/38400 serial communication baud rate.
    > Built-in crystal oscillator and power-on reset circuit, the peripheral circuit is simple.
    > Support 5V, 3.3V power supply voltage.
    > LQFP-48 lead-free package is available, RoHS compatible.
    

    Google does find this https://github.com/zhuhuijia0001/ch559-usb-host
    @zhuhuijia0001   Zhuhuijia0001 1. Increase the PS2 mouse and keyboard function of the IP port.  Latest commit f976b11 on Aug 23, 2018
    Type Name Latest commit message Commit time
    .gitignore 1. Completes the enumeration of common mouse and keyboard, compound mouse and mouse, and compound mouse with hub. a year ago
    CH559.c 1. Complete the enumeration of common mouse and keyboard, compound mouse and mouse, and compound mouse with hub. a year ago
    CH559.h 1. Increase the PS2 mouse and keyboard function of the IP port. 8 months ago
    GPIO.c 1. Increase the PS2 mouse and keyboard function of the IP port. 8 months ago
    GPIO.h 1. Complete the enumeration of common mouse and keyboard, compound mouse and mouse, and compound mouse with hub. a year ago
    Gpio_map.h 1. Increase the PS2 mouse and keyboard function of the IP port. 8 months ago
    IpPs2Keyboard.c 1. Increase the PS2 mouse and keyboard function of the IP port. 8 months ago
    IpPs2Keyboard.h 1. Add the PS2 mouse and keyboard function of the IP port. 8 months ago
    IpPs2Mouse.c 1. Increase the PS2 mouse and keyboard function of the IP port. 8 months ago
    IpPs2Mouse.h 1. Increase the PS2 mouse and keyboard function of the IP port. 8 months ago
    KeyboardLed.c 1. Changed the program structure. a year ago
    KeyboardLed.h 1. Changed the program structure. a year ago
    Main.c 1. Increase the PS2 mouse and keyboard function of the IP port. 8 months ago
    Packet.c 1. Complete the enumeration of common mouse and keyboard, compound mouse and mouse, and compound mouse with hub. a year ago
    Packet.h 1. Complete the enumeration of common mouse and keyboard, compound mouse and mouse, and compound mouse with hub. a year ago
    ParseHidData.c 1. Determine the data format of the keyboard by parsing the report descriptor of the keyboard. 9 months ago
    ParseHidData.h 1. Determine the data format of the keyboard by parsing the report descriptor of the keyboard. 9 months ago
    PinDefine.h 1. Increase the PS2 mouse and keyboard function of the IP port. 8 months ago
    Protocol.h 1. Complete the enumeration of common mouse and keyboard, compound mouse and mouse, and compound mouse with hub. a year ago
    Ps2Keyboard.c 1. Fixed the problem of port initialization. 11 months ago
    Ps2Keyboard.h 1. Complete the enumeration of common mouse and keyboard, compound mouse and mouse, and compound mouse with hub. a year ago
    Ps2Mouse.c 1. Fixed the problem of port initialization. 11 months ago
    Ps2Mouse.h 1. Fixed the problem of port initialization. 11 months ago
    README.md Create README.md a year ago
    RecvBuffer.c 1. Fixed the problem of port initialization. 11 months ago
    RecvBuffer.h 1. Fixed the problem of port initialization. 11 months ago
    System.c 1. Complete the enumeration of common mouse and keyboard, compound mouse and mouse, and compound mouse with hub. a year ago
    System.h 1. Fixed the problem of port initialization. 11 months ago
    Task.c 1. Increase the PS2 mouse and keyboard function of the IP port. 8 months ago
    Task.h 1. Increase the PS2 mouse and keyboard function of the IP port. 8 months ago
    Timer2.c 1. Completes the enumeration of common mouse and keyboard, compound mouse and mouse, and compound mouse with hub. a year ago
    Timer2.h 1. Completes the enumeration of common mouse and keyboard, compound mouse and mouse, and compound mouse with hub. a year ago
    Trace.h 1. Complete the enumeration of common mouse and keyboard, compound mouse and mouse, and compound mouse with hub. a year ago
    Type.h 1. Fixed the problem of port initialization. 11 months ago
    Uart.c 1. Fixed the problem of port initialization. 11 months ago
    Uart.h 1. Complete the enumeration of common mouse and keyboard, compound mouse and mouse, and compound mouse with hub. a year ago
    UsbDef.h 1. Complete the enumeration of common mouse and keyboard, compound mouse and mouse, and compound mouse with hub. a year ago
    UsbHid.c 1. Determine the data format of the keyboard by parsing the report descriptor of the keyboard. 9 months ago
    UsbHid.h 1. Changed the program structure. a year ago
    UsbHost.c 1. Increase the PS2 mouse and keyboard function of the IP port. 8 months ago
    UsbHost.h 1. Determine the data format of the keyboard by parsing the report descriptor of the keyboard. 9 months ago
    Mcu.h 1. Complete the enumeration of common mouse and keyboard, compound mouse and mouse, and compound mouse with hub. a year ago
    Usb_host_ch559.uvopt 1. Increase the PS2 mouse and keyboard function of the IP port. 8 months ago
    Usb_host_ch559.uvproj 1. Increase the PS2 mouse and keyboard function of the IP port.
    

    and the md docs say
    flash the generated hex file into ch559, you can observe with a serial port tool.

    Possible test board could be https://www.electrodragon.com/product/ch559-mini-dev-board-ch55x-series/
  • I have less than $5 dollars for research and development, so anything that is prop-based is perfect. I have no scope, so reverse engineering this would be difficult.

    On the other hand, PICs are better documented(English-wise) and are known to be sorta-reliable. I heard through my wild goose chase internet search of PICs being usable for USB protocol.
  • Sorry to revive old threads...

    I have decided to go with a Prop-based USB host, as I cannot find any internet documentation for the CH3950.
    Can anyone walk me through the selection of the right .spin files to obtain to do the USB host on a P1? from @macca 's post?
    macca wrote: »
    If you accept some compromises, the Propeller can do USB host on its own:

    https://github.com/scanlime/propeller-usb-host

    Pick one of the test-* sources to see how things are implemented, test-hid.spin is what you need for keyboards. You can also look at my implementation for the RC2014 serial board here https://github.com/maccasoft/propeller-vt100-terminal.

    Read carefully all the documentation and use the circuit as indicated in the source files. You need to experiment a lot to see if there are drawbacks with the devices you want to use.

    Remember that it supports one device only (no hubs) so if you want keyboard and mouse you need two instances running (4 cogs) on different pins.
  • Thank you, Macca. I appreciate the help. Can I run my experimentation on a PropBOE? Or does the breadboard cause problems?
  • Thank you, Macca. I appreciate the help. Can I run my experimentation on a PropBOE? Or does the breadboard cause problems?

    Never tried with a breadboard, the USB needs short connections, if you manage to keep them as short as possible you should not have problems. In my early tests I soldered the USB connector and resistors on a small piece of perf board, then used a couple of short cables to connect it to the propeller, never had problems. I'm not sure the USB connector can be safely placed on a breadboard so a small breakout may be needed.
  • Ok, thanks.

    Also, can I use a USB flash/disk drive with one of these?
  • Ok, thanks.

    Also, can I use a USB flash/disk drive with one of these?

    Yes, test-storage.spin and test-fsrw-usb.spin should allow to use a USB flash drive.
  • AwesomeCronkAwesomeCronk Posts: 1,055
    edited 2019-05-29 18:30
    Thank you!
  • @macca is 6Mhz crystal the minimum for the USB object? I was wanting to test it with the 5Mhz crystal included on the Propeller Project Board.
  • @macca is 6Mhz crystal the minimum for the USB object? I was wanting to test it with the 5Mhz crystal included on the Propeller Project Board.

    The object runs at 80MHz so a 5MHz crystal is fine.
  • Thanks!
  • RaymanRayman Posts: 14,761
    Hmm.. I always thought you needed the 6 MHz crystal for this. Guess I was wrong.

    BTW: The FTDI Vinculum is another way to interface with USB...
  • OK, then.

    I finally found time for the Propeller after school today. So, I fired it up and ran the test-storage.spin object. I had soldered a USB female port onto my Propeller Project Board, then connected Dat- to p0 and Dat+ to p1(with 47ohm series and 47k pulldown each). I loaded the object to EEPROM, open the terminal, and what do I get?
    GARBAGE

    I had Xin set to 6_000_000 with a 5Mhz crystal onboard. (insert facepalm here). So I dialed Xin down to 5_000_000 and reloaded the Prop. I now receive non-garbage info in the terminal:
    Can't enumerate device (Error -150)
    

    @macca
    Can you identify this error code please?

    @Rayman
    Looks like you were right! :tongue:
  • I had Xin set to 6_000_000 with a 5Mhz crystal onboard. (insert facepalm here). So I dialed Xin down to 5_000_000 and reloaded the Prop. I now receive non-garbage info in the terminal:
    Can't enumerate device (Error -150)
    

    @macca
    Can you identify this error code please?

    It can't recognize the USB device (btw, the error codes are all listed in the source files, -150 = E_NO_DEVICE).
    It is correct if you haven't connected anything to the USB port, otherwise what device are you using ?
  • All wired up properly. I should check and see if the port maybe isn’t powered.

    Thank you!
    3024 x 4032 - 2M
  • Found the issue. I was powering the project board from my PropBOE’s servo headers, set to vin. The battery pack(6v, four AA’s) is nearly dead. I will get a proper power supply on here tonight and try again.
  • Thank you, Macca. I appreciate the help. Can I run my experimentation on a PropBOE? Or does the breadboard cause problems?
    I don't remember an instance where using a breadboard caused problems. If it was causing problems it should be a CRC error or something. There's a picture of a bluetooth stick on on the PropBOE breadboard without resistors.

    Remember that the keyboard has an attached cable that is probably more capacitance than the breadboard.
    But if you are building a board, definitely add those resistors. They could be replaced by zero ohms later.

    There are mechanical issues with using a USB connector on the breadboard. I had to solder the connector onto a header for longer pins. The wide mounting pins don't fit, so the metal housing likes to slid off the plastic inner part.
  • I realize it's a bit late to reply to this, but I have had some luck using the CH559 ship for this exact thing (USB host to read keyboard/mouse/gamepad). I got them for less than $1.50 each. It only requires a couple of passives, and the coding wasn't too bad - let me know if you want more info, and I can send a few things your way.
  • MattMatz wrote: »
    I realize it's a bit late to reply to this, but I have had some luck using the CH559 ship for this exact thing (USB host to read keyboard/mouse/gamepad). I got them for less than $1.50 each. It only requires a couple of passives, and the coding wasn't too bad - let me know if you want more info, and I can send a few things your way.

    would you mind to give me some references? I'm currently working with max3421e to read keyboard keys but I want a chipper and simpler solution.
Sign In or Register to comment.