Author Topic: Convenient USB --> GPIO module?  (Read 8444 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.
 

Online nfmax

  • Super Contributor
  • ***
  • Posts: 1558
  • 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: 9888
  • 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!
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 4749
  • Country: nr
  • 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: 5317
  • 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: 9888
  • 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: 6227
  • 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: 3340
  • 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: 6227
  • 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: 6227
  • 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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf