Convenient USB --> GPIO module? - Page 1
Forum section: electronics / general

author: rf-fil
author_rank: Regular Contributor
timestamp: May 24, 2018, 08:33:17 am
content: So, I'm getting tired of always installing the weird "zadig" drivers for the FT232H. (Otherwise, Adafruit has done a great job with the Python library to drive this chip).I've used the Aardvark / Cheetah to do SPI/I2C and those are great, pro-level tools. But, $$$.What's out there that lets me control a few, lets say 4 to 8, simple GPIO pins from a Windows host? Something without weird drivers that I (and my clients!) have to install manually and that I can access from Python.Something perhaps that presents itself as USB CDC on the host side, and that has a simple serial API for controlling the GPIOs. Alternately, something that comes up as USB HID, but where someone has already developed a Python-accessible API? The FT260 is a good looking chip, but no one has wrapped the API yet..Obviously, I've googled around, but would be keen to hear some practical experience / tips / etc.

author: Hypernova
author_rank: Unknown
timestamp: May 24, 2018, 09:45:41 am
content: Bus pirate? It presents itself as a serial port and you interact with it with plain ASCII.

author: nfmax
author_rank: Super Contributor
timestamp: May 24, 2018, 09:46:56 am
content: Those of us of a certain age suddenly come over all nostalgic about the parallel printer port...

author: Scrts
author_rank: Frequent Contributor
timestamp: May 24, 2018, 06:48:27 pm
content: How about FT245 then?

author: funkathustra
author_rank: Regular Contributor
timestamp: May 24, 2018, 10:45:18 pm
content: [Shameless Promotion]I'm actually gearing up to launch a product I built that should fit your requirements nicely. it's called Treehopper — it's a USB peripheral that connects to your computer, smartphone, or tablet and provides 20 analog/digital I/O, along with SPI, I2C, UART, and PWM support. I've built out APIs for C# (.NET), Python, Java, and C++, with support for Windows, macOS, Linux, and Android.Treehopper supports automatic WinUSB installation on Windows 7, 8, 8.1, and 10 — so there are no goofy drivers to install (which means you don't even need to be an administrator of the computer to use the product).You can read more athttps://treehopper.io.I'm still probably a month out from starting to ship units, but I'd be more than happy to send you a beta unit to evaluate for your application! Just send me a PM.[/Shameless Promotion]

author: rf-fil
author_rank: Regular Contributor
timestamp: May 24, 2018, 11:16:57 pm
content: Nice suggestions all around, thanks.

author: rstofer
author_rank: Super Contributor
timestamp: May 24, 2018, 11:56:33 pm
content: The easy way to do this is with USB HID and here is an implementation:https://www.pjrc.com/teensy/rawhid.htmlI used this approach to add switches, knobs and dials to Microsoft Flight Simulator.ETA: Using HID means Windows provides the drivers. There are no custom drivers to install. This is important!

author: westfw
author_rank: Super Contributor
timestamp: May 25, 2018, 07:17:26 am
content: Any USB Arduino-like board, with a bit of firmware? In particular, those with a 32u4 capable of native USB; but they have a serial "protocol" called Firmata that dates back to the ATmega8 days (access to GPIO via serial.)

author: CJay
author_rank: Super Contributor
timestamp: May 25, 2018, 08:09:50 am
content: I'd chime in with Brian Schmalz' Bitwhacker but it seems to have stopped moving forward in 2016...Treehopper looks really nice, do you have an idea of pricepoint?

author: abyrvalg
author_rank: Frequent Contributor
timestamp: May 25, 2018, 09:04:18 am
content: Why Zadig for FT232H? Let me guess - some library is “cross-platform”, so it wants a libusb-compatible driver instead of the ftdi original?

author: funkathustra
author_rank: Regular Contributor
timestamp: May 25, 2018, 04:54:43 pm
content: Quote from: CJay on May 25, 2018, 08:09:50 amInitial retail price is $21, with free Prime Shipping from Amazon. Thanks for your interest!

author: iMo
author_rank: Super Contributor
timestamp: May 25, 2018, 05:12:49 pm
content: You do not need zadig drivers for FT232H. Install the original FTDI certified driver (VCP or D2XX) and it will work fine..http://www.ftdichip.com/Drivers/VCP.htm

author: Seph.b
author_rank: Regular Contributor
timestamp: May 25, 2018, 05:28:48 pm
content: Quote from: funkathustra on May 24, 2018, 10:45:18 pmTreehopper looks interesting to throw into my travel kit for debugging hardware on site. My suggestion would be an enclose with spring terminals on it. That way it can survive in a bag and is quick to hook up, test and move on to the next task.

author: funkathustra
author_rank: Regular Contributor
timestamp: May 25, 2018, 06:08:47 pm
content: Quote from: Seph.b on May 25, 2018, 05:28:48 pmThat's a cool idea! Treehopper has castellated pads, so you can directly surface-mount-solder it to a carrier board that either contains a project-specific design, or something utilitarian, like a terminal block with screw terminals or — in your example — spring terminals.Obviously, 0.1" terminal blocks will solder directly to the standard-pitch header pads it has, too — so no need for a carrier board in that case.

author: Howardlong
author_rank: Super Contributor
timestamp: May 25, 2018, 06:59:49 pm
content: Quote from: nfmax on May 24, 2018, 09:46:56 amYou’ve hit the nail on the head. And, without all of today’s protected mode nonsense, you could set the pins to your desired state with two assembly language instructions or a simple single C runtime library call.

author: neil555
author_rank: Contributor
timestamp: May 25, 2018, 07:03:27 pm
content: Does treehopper have a C api?, if so then i'm definitely getting one

author: funkathustra
author_rank: Regular Contributor
timestamp: May 25, 2018, 09:49:49 pm
content: Quote from: neil555 on May 25, 2018, 07:03:27 pmTreehopper has a C++ API, but not a pure C API. You could wrap the C++ API with some pure C-style functions that would make the library compatible with your C compiler.Another option is to just write a C API from scratch: Treehopper uses a simple protocol so it would be trivial to get basic functionality up and running by calling into LibUSB (on Linux, Windows, or macOS)... or the native platform libraries (IOKit on macOS, and WinUSB.dll on Windows) — which are actually all C APIs that Treehopper's C++ API uses.Regardless, since the firmware and software are open-source, it should be easy to hack together some C support!

author: rstofer
author_rank: Super Contributor
timestamp: May 26, 2018, 05:19:28 pm
content: Quote from: funkathustra on May 25, 2018, 04:54:43 pmI went to the Buy tab from the Treehopper page and clicked on Amazon - I get "Currently Unavailable"https://www.amazon.com/Treehopper-Black/dp/B073VBVX6Z

author: Nominal Animal
author_rank: Super Contributor
timestamp: May 26, 2018, 07:29:14 pm
content: I'd go for a Teensy too, except if price is an issue, in which case I'd reach for a Pro Micro clone on eBay. I've got a couple, cost about 4€ (5 USD) apiece. They have the Leonardo bootloader, and you can do a native HID device (no drivers needed on any OS); programming is very easy in Arduino environment. You can also do bare metal programming with AVR-GCC and avrdude, at least in Linux. The end result is the same, of course.Just make sure the board is an actual Pro Micro clone (32u4), and not a Pro Mini (328p). Many sellers seem to confuse the two.Because the ATmega32u4 has native USB support, you can also program it to behave exactly like a device that is already supported by some standard USB drivers. (I've used the clones to roughly emulate USB devices, like vinyl cutters, based on USB capture data, that I've written userspace "drivers" for, without access to the actual device.)

author: Doctorandus_P
author_rank: Super Contributor
timestamp: May 26, 2018, 07:59:37 pm
content: V-USB is a software USB (low speed only) stack that runs on an AVR.The USBasp programmer is built around it.In the example projects there are projects to (ab)use standard HID drivers to switch relays, or use that as a start for your own product.https://www.obdev.at/products/vusb/projects.htmlAlternatively:Switch to LinuxNo need to install drivers for such common hardware there. It is already included.And linux does not have the botched FTDI drivers, which demolish your hardware.

author: Nominal Animal
author_rank: Super Contributor
timestamp: May 26, 2018, 10:23:44 pm
content: Quote from: Doctorandus_P on May 26, 2018, 07:59:37 pmI do not recommend suggesting Windows programmers or power users to switch to Linux. They find the lack of a centralized authority, and the lack of "the recommended way" to do most things frustrating. It is much easier to help a non-techie adopt Linux, than help a Windows user/dev un-learn windows-isms; the former have an open mind, whereas the latter already believe they know how computers and systems work, and find it annoying that Linux does not work that way. It is more effort than it is worth, for everyone.Obviously, if someonechoosesto switch, or is aware of the fundamental differences in approaches (likethe Unix philosophy, the Linux kernel not having a stable API, and only having a stable userspace-facing ABI, and so on), and is interested nevertheless, the situation is completely different.As to VUSB and very small AVRs, I have a couple of DigiSparks too (ATtiny85, with a bootloader that supports reprogramming via USB). The lack of a crystal in them makes me a doubt the robustness of the USB connection a bit, though; I'd definitely not expect the reliability of the USB comms one gets with proper hardware USB support. But for things like a couple of buttons or very low data rate I/O pins, sure!

author: xaxaxa
author_rank: Regular Contributor
timestamp: May 27, 2018, 01:09:01 pm
content: why mess with v-usb and atmega when stm32f103 dev boards with native usb are available on aliexpress for $2?

author: martinayotte
author_rank: Regular Contributor
timestamp: May 27, 2018, 01:46:49 pm
content: Of course !MapleMini, BluePill, etc., all those STM32 boards are cheap ...

author: Nominal Animal
author_rank: Super Contributor
timestamp: May 27, 2018, 05:36:42 pm
content: Quote from: xaxaxa on May 27, 2018, 01:09:01 pmBecause most of them don't have a bootloader, and you need a 3.3V TTL UART adapter toburn it, before you can program them? Not exactly convenient.In comparison, you only need to connect the Teensies and Pro Micros with an USB cable to your computer to get going. (DigiSparks, using ATtiny85, have a male USB connector directly on board, so you simply stick the DigiSpark to an USB port to get started; even less hassle and moving parts. But also just six (IIRC) I/O pins to use.)That said, I've been looking at the STM32F103C8T6 in particular, just to play with and compare to the others. As I already have several Teensies with 3.3V logic, burning the bootloader would be trivial for me.

author: clee781
author_rank: Newbie
timestamp: May 27, 2018, 06:56:39 pm
content: Quote from: Nominal Animal on May 27, 2018, 05:36:42 pmWhy would you use a UART to develop on an STM32? Most people just throw down the $5 for an ST-Link to get full Serial-Wire debugging. If you were intending on "trivially" burning this bootloader just so you can use it with Arduino, then that is just silly.If you just want to flash the MCU, all STM32 parts with USB already have a USB bootloader in ROM. Just give it the correct boot pin state on reset to enter bootloader mode. Then use the ST software tools to flash your firmware image. It's extremely easy.

author: donotdespisethesnake
author_rank: Super Contributor
timestamp: May 27, 2018, 07:29:14 pm
content: Quote from: clee781 on May 27, 2018, 06:56:39 pmNot true...F103 doesn't.

author: Nominal Animal
author_rank: Super Contributor
timestamp: May 28, 2018, 12:20:51 am
content: Let's recap re STM32F103:Quote from: xaxaxa on May 27, 2018, 01:09:01 pmBecause you need ST-Link or a 3.3V UART adaptor to program it, or to burn the bootloader for USB programming.Quote from: clee781 on May 27, 2018, 06:56:39 pmWell, that puts the development cost for a single ST32F103, that was supposed to be just $2, to $7. (And ST32F013 does not have a bootloader in ROM, so you do need an ST-Link or 3.3V UART to program it.)Pro micro clones are < $5, and DigiSpark clones (ATtiny85) $1.67, on eBay. For the DigiSpark, you don't even need a cable, just stick it into an USB port, and you can program it.Granted, DigiSpark USB (VUSB) is purely software-based, and I don't completely trust it (the timing part, in particular; no crystal). In my testing, it seems to work just fine for HID stuff. Both the Teensies and the Pro Micro clones have been absolutely rock solid wrt. USB comms in my testing on several machines, even at near the theoretical maximum transfer rates (a bit over megabyte per second when using bulk transfers). Teensies also have a very friendly and vibrant forum at PJRC.com where the developer (Paul Stoffregen) frequents.The title of the thread, and topic at hand, isconvenient USB GPIO module. You don't need hardware debugging for that kind of trivial firmware; at least I never have. And needing a separate module to program the device is not exactly the most convenient; especially if something goes wrong. That is the reason I didn't recommend STM32F103's myself, even though I am interested in them (for comparison and exploration purposes if nothing else).

author: digsys
author_rank: Unknown
timestamp: May 28, 2018, 01:09:25 am
content: Been using these for years .. simple HID , US$63 .. off the shelf ... plug in and go - sensoriumembedded.com/products.htm- and this small program to send keystrokes direct into programs -https://joytokey.net/en/Edit: definitely interested in the Treejumper though !! :-)

author: donotdespisethesnake
author_rank: Super Contributor
timestamp: May 28, 2018, 06:04:20 am
content: Quote from: Nominal Animal on May 28, 2018, 12:20:51 amYou missed Maple Mini... which is F103 and negates everything you said. But anyway requiring an extra cable for programming is the barest level of inconvenience.

author: cdev
author_rank: Super Contributor
timestamp: August 28, 2021, 11:50:35 pm
content: I just wanted to add in the WCH-341A, seems similar to the FT232H in some ways. Firmata and an USB friendly arduino also works well for interfacing with external HW at very low cost.

author: bingo600
author_rank: Super Contributor
timestamp: August 29, 2021, 05:27:24 am
content: The STM32F401/411 - "Blackpill" has an USB DFU loader - built in , and is supported by the Official STM "Arduino core"Could be an alternative to Teensy or "Bluepill"/Bingo

author: Ian.M
author_rank: Super Contributor
timestamp: August 29, 2021, 05:55:37 am
content: ThepigpioPython module allows full remote control of the GPIO of a Raspberry Pi running the pigpiod daemon, from Python code on your PC, over TCP/IP. It supports general bit-banging, high quality PWM and Futaba servo pulse generation, hardware I2C, SPI and UART, pattern generation and arbitrary scripting for low latency stuff. Depending on your choice of Pi, the physical interface can be USB RNDIS (ethernet gadget), wired ethernet or WiFi. Apparently there's also a Linux C remote access library (libpigpiod_if2), that may be usable cross-platform, but I haven't used that myself.

author: fchk
author_rank: Frequent Contributor
timestamp: August 30, 2021, 06:54:03 am
content: Quote from: rf-fil on May 24, 2018, 08:33:17 amMicrochip MCP2200 and MCP2221A.These are preprogrammed PICs sold as USB-UART/8GPIO and USB-UART/4GPIO/I2C bridges. They use CDC-ACM for the UART part and HID for the rest. You don't need any proprietary kernel drivers. You will get away with only SETUPAPI.DLL and HID.DLL calls in Windows and /dev/hidraw in Linux.fchk

author: ebclr
author_rank: Super Contributor
timestamp: August 31, 2021, 05:24:03 am
content: This works well for me is based on attinyhttps://www.aliexpress.com/item/4000045000234.html?spm=a2g0o.productlist.0.0.17107869SIhp5u&algo_pvid=73cae860-5072-449a-b18e-012bdb768336&algo_exp_id=73cae860-5072-449a-b18e-012bdb768336-0

author: Doctorandus_P
author_rank: Super Contributor
timestamp: September 02, 2021, 02:32:33 am
content: Is this thread still alive after 3 years...I've been tinkering a bit with STM32, and without much trouble I got the serial sathosimn project going.It's open source from github, and it makes the three USART's of the STM32F103 available via CDC on it's USB port.I compiled the thing, flashed it in a Blue Pill (When they were still original) and added some loopback wires on a breadboard and it all seemed to work with different terminal sessions talking to the three CDC ports. I found it quite impressive, and then my attention wavered to other subjects again.