Author Topic: Convenient USB --> GPIO module?  (Read 8484 times)

0 Members and 1 Guest are viewing this topic.

Offline rf-filTopic starter

  • Contributor
  • Posts: 48
  • Country: au
Convenient USB --> GPIO module?
« on: May 24, 2018, 08:33:17 am »
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.
 

Offline Hypernova

  • Supporter
  • ****
  • Posts: 655
  • Country: tw
Re: Convenient USB --> GPIO module?
« Reply #1 on: May 24, 2018, 09:45:41 am »
Bus pirate? It presents itself as a serial port and you interact with it with plain ASCII.
 

Offline nfmax

  • Super Contributor
  • ***
  • Posts: 1560
  • Country: gb
Re: Convenient USB --> GPIO module?
« Reply #2 on: May 24, 2018, 09:46:56 am »
Those of us of a certain age suddenly come over all nostalgic about the parallel printer port...
 
The following users thanked this post: lapm, Howardlong, agehall

Offline Scrts

  • Frequent Contributor
  • **
  • Posts: 797
  • Country: lt
Re: Convenient USB --> GPIO module?
« Reply #3 on: May 24, 2018, 06:48:27 pm »
How about FT245 then?
 

Offline funkathustra

  • Regular Contributor
  • *
  • Posts: 150
  • Country: us
Re: Convenient USB --> GPIO module?
« Reply #4 on: May 24, 2018, 10:45:18 pm »
[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 at https://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]
« Last Edit: May 24, 2018, 10:48:25 pm by funkathustra »
 

Offline rf-filTopic starter

  • Contributor
  • Posts: 48
  • Country: au
Re: Convenient USB --> GPIO module?
« Reply #5 on: May 24, 2018, 11:16:57 pm »
Nice suggestions all around, thanks.
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9890
  • Country: us
Re: Convenient USB --> GPIO module?
« Reply #6 on: May 24, 2018, 11:56:33 pm »
The easy way to do this is with USB HID and here is an implementation:

https://www.pjrc.com/teensy/rawhid.html

I 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!
« Last Edit: May 24, 2018, 11:59:39 pm by rstofer »
 
The following users thanked this post: agehall, newbrain

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: Convenient USB --> GPIO module?
« Reply #7 on: May 25, 2018, 07:17:26 am »
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.)
 
The following users thanked this post: NiHaoMike, cdev

Offline CJay

  • Super Contributor
  • ***
  • Posts: 4136
  • Country: gb
Re: Convenient USB --> GPIO module?
« Reply #8 on: May 25, 2018, 08:09:50 am »
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?



« Last Edit: May 25, 2018, 08:13:50 am by CJay »
 

Offline abyrvalg

  • Frequent Contributor
  • **
  • Posts: 824
  • Country: es
Re: Convenient USB --> GPIO module?
« Reply #9 on: May 25, 2018, 09:04:18 am »
Why Zadig for FT232H? Let me guess - some library is “cross-platform”, so it wants a libusb-compatible driver instead of the ftdi original?
 

Offline funkathustra

  • Regular Contributor
  • *
  • Posts: 150
  • Country: us
Re: Convenient USB --> GPIO module?
« Reply #10 on: May 25, 2018, 04:54:43 pm »
Treehopper looks really nice, do you have an idea of pricepoint?

Initial retail price is $21, with free Prime Shipping from Amazon. Thanks for your interest!
 

Offline iMo

  • Super Contributor
  • ***
  • Posts: 4780
  • Country: pm
  • It's important to try new things..
Re: Convenient USB --> GPIO module?
« Reply #11 on: May 25, 2018, 05:12:49 pm »
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
« Last Edit: May 25, 2018, 05:15:58 pm by imo »
 

Offline Seph.b

  • Regular Contributor
  • *
  • Posts: 78
  • Country: us
Re: Convenient USB --> GPIO module?
« Reply #12 on: May 25, 2018, 05:28:48 pm »
[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 at https://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]

Treehopper 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.
 

Offline funkathustra

  • Regular Contributor
  • *
  • Posts: 150
  • Country: us
Re: Convenient USB --> GPIO module?
« Reply #13 on: May 25, 2018, 06:08:47 pm »
Treehopper 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.

That'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.
 

Offline Howardlong

  • Super Contributor
  • ***
  • Posts: 5319
  • Country: gb
Re: Convenient USB --> GPIO module?
« Reply #14 on: May 25, 2018, 06:59:49 pm »
Those of us of a certain age suddenly come over all nostalgic about the parallel printer port...

You’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.
 

Offline neil555

  • Contributor
  • Posts: 40
  • Country: gb
Re: Convenient USB --> GPIO module?
« Reply #15 on: May 25, 2018, 07:03:27 pm »
Does treehopper have a C api?, if so then i'm definitely getting one
« Last Edit: May 25, 2018, 07:05:02 pm by neil555 »
 

Offline funkathustra

  • Regular Contributor
  • *
  • Posts: 150
  • Country: us
Re: Convenient USB --> GPIO module?
« Reply #16 on: May 25, 2018, 09:49:49 pm »
Does treehopper have a C api?, if so then i'm definitely getting one

Treehopper 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!
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9890
  • Country: us
Re: Convenient USB --> GPIO module?
« Reply #17 on: May 26, 2018, 05:19:28 pm »
Treehopper looks really nice, do you have an idea of pricepoint?

Initial retail price is $21, with free Prime Shipping from Amazon. Thanks for your interest!

I 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
 

Online Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6255
  • Country: fi
    • My home page and email address
Re: Convenient USB --> GPIO module?
« Reply #18 on: May 26, 2018, 07:29:14 pm »
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.)
 

Online Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3358
  • Country: nl
Re: Convenient USB --> GPIO module?
« Reply #19 on: May 26, 2018, 07:59:37 pm »
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.html

Alternatively:
Switch to Linux :)
No 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.
 

Online Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6255
  • Country: fi
    • My home page and email address
Re: Convenient USB --> GPIO module?
« Reply #20 on: May 26, 2018, 10:23:44 pm »
Switch to Linux :)
I 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 someone chooses to switch, or is aware of the fundamental differences in approaches (like the 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!
 

Offline xaxaxa

  • Regular Contributor
  • *
  • Posts: 248
  • Country: ca
Re: Convenient USB --> GPIO module?
« Reply #21 on: May 27, 2018, 01:09:01 pm »
why mess with v-usb and atmega when stm32f103 dev boards with native usb are available on aliexpress for $2?
 

Offline martinayotte

  • Regular Contributor
  • *
  • Posts: 64
Re: Convenient USB --> GPIO module?
« Reply #22 on: May 27, 2018, 01:46:49 pm »
Of course !
MapleMini, BluePill, etc., all those STM32 boards are cheap ...
 

Online Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6255
  • Country: fi
    • My home page and email address
Re: Convenient USB --> GPIO module?
« Reply #23 on: May 27, 2018, 05:36:42 pm »
why mess with v-usb and atmega when stm32f103 dev boards with native usb are available on aliexpress for $2?
Because most of them don't have a bootloader, and you need a 3.3V TTL UART adapter to burn 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.
 

Offline clee781

  • Newbie
  • Posts: 2
  • Country: us
Re: Convenient USB --> GPIO module?
« Reply #24 on: May 27, 2018, 06:56:39 pm »
why mess with v-usb and atmega when stm32f103 dev boards with native usb are available on aliexpress for $2?
Because most of them don't have a bootloader, and you need a 3.3V TTL UART adapter to burn 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.

Why 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.
 

Offline donotdespisethesnake

  • Super Contributor
  • ***
  • Posts: 1093
  • Country: gb
  • Embedded stuff
Re: Convenient USB --> GPIO module?
« Reply #25 on: May 27, 2018, 07:29:14 pm »
all STM32 parts with USB already have a USB bootloader in ROM.

Not true...F103 doesn't.
Bob
"All you said is just a bunch of opinions."
 
The following users thanked this post: Nominal Animal

Online Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6255
  • Country: fi
    • My home page and email address
Re: Convenient USB --> GPIO module?
« Reply #26 on: May 28, 2018, 12:20:51 am »
Let's recap re STM32F103:
why mess with v-usb and atmega when stm32f103 dev boards with native usb are available on aliexpress for $2?
Because you need ST-Link or a 3.3V UART adaptor to program it, or to burn the bootloader for USB programming.

Why 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.
Well, 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, is convenient 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).
 

Offline digsys

  • Supporter
  • ****
  • Posts: 2209
  • Country: au
    • DIGSYS
Re: Convenient USB --> GPIO module?
« Reply #27 on: May 28, 2018, 01:09:25 am »
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 !! :-)
« Last Edit: May 28, 2018, 01:14:08 am by digsys »
Hello <tap> <tap> .. is this thing on?
 

Offline donotdespisethesnake

  • Super Contributor
  • ***
  • Posts: 1093
  • Country: gb
  • Embedded stuff
Re: Convenient USB --> GPIO module?
« Reply #28 on: May 28, 2018, 06:04:20 am »
Let's recap re STM32F103:


You 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.
Bob
"All you said is just a bunch of opinions."
 

Offline cdev

  • Super Contributor
  • ***
  • !
  • Posts: 7350
  • Country: 00
Re: Convenient USB --> GPIO module?
« Reply #29 on: August 28, 2021, 11:50:35 pm »
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.
"What the large print giveth, the small print taketh away."
 

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 1988
  • Country: dk
Re: Convenient USB --> GPIO module?
« Reply #30 on: August 29, 2021, 05:27:24 am »
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
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12856
Re: Convenient USB --> GPIO module?
« Reply #31 on: August 29, 2021, 05:55:37 am »
The pigpio Python 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.
 

Offline fchk

  • Regular Contributor
  • *
  • Posts: 244
  • Country: de
Re: Convenient USB --> GPIO module?
« Reply #32 on: August 30, 2021, 06:54:03 am »
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).

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.

Microchip 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
 


Online Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3358
  • Country: nl
Re: Convenient USB --> GPIO module?
« Reply #34 on: September 02, 2021, 02:32:33 am »
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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf