WANTED: USB Interface Chip to Support Reading of Mouse and Keyboard
AwesomeCronk
Posts: 1,055
in Accessories
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.
Comments
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).
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:
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 ?
The cable will cost about $5.00.
Mike
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.
https://github.com/scanlime/propeller-usb-host
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 )
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?
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
Google does find this https://github.com/zhuhuijia0001/ch559-usb-host
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/
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.
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.
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.
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.
The object runs at 80MHz so a 5MHz crystal is fine.
BTW: The FTDI Vinculum is another way to interface with USB...
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:
@macca
Can you identify this error code please?
@Rayman
Looks like you were right!
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 ?
Thank you!
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.
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.