Nubsio GPIO API – A Windows USB interface for controlling external devices
madeintheusb.blogspot.com
madeintheusb.blogspot.com
I have a device which controls an antique Teletype machine from a USB port. It uses the request to send signal on a USB-simulated serial port to start the Teletype motor. This works fine on Linux. On Windows, the motor starts and stops several times when the USB device is plugged in or Windows starts up. That's because an old Windows feature is probing the serial port for a serial mouse. Annoying.
An output state valid bit can be used to suppress all activation of external actuators until the software has been initialized and the state of the outputs can be safely exposed.
---
Edit: some I have used or heard of that may or may not have .net support:
USB Bit Whacker - http://www.schmalzhaus.com/UBW/
Ultimarc control interfaces (haven't tried them) - http://www.ultimarc.com/
Tutorials, etc, here: https://learn.adafruit.com/adafruit-ft232h-breakout Includes some python code that works on Windows, Linux, etc.
A couple of sources:
http://www.ftdichip.com/Support/SoftwareExamples/MPSSE/FTCSP...
Used these for some simple automation needs in the past. Simple .net library available on the site. Not nearly as cheap as the one in the post (which I did have to google 3 different sites to find the price of)
Sometimes you do want to add GPIO to an existing Windows machine, but if you just want to mess around with .Net and some simple electronics, the parent's suggestion is cheap and simple (and e.g. https://github.com/raspberry-sharp/raspberry-sharp-io claims to support this use case.)
you're also more likely to get more than you want, and have to debounce on the processor side.
I'd go for a small fpga->ftdi usb controller. do a low pass filter on each pin, and when it goes above your threshold, throw it in a fifo that feeds the USB chip. your latency goes up with the number of changes that happen at once, but you're still using raw USB and not miss events that you're interested in.
But yes, might very well want some configurable low-pass/debouncing logic.
Is there any specific product you can recommend for a hobbyist's project?
If you look at real hardware (or FPGAs) they will basically do polling: The input gets sampled at each clock cycle and will then get processed. And hardware is definitely realtime :)
The downside of polling is that you burn CPU resources when actually nothing happens. Interrupt driven designs help there.
Smiley noted; I think we can agree that "polling at 10s of MHz on an input pin" becomes something quite different than "polling at 10s of kHz on the other side of a USB link".
If you don't do that you risk your machinery not responding to critical inputs resulting in machine damage or worse.
If all you want to do is play around with lights and switches then this is fine.
There are Ethernet to Serial adapters [1] [2], I wonder if it could go further. There is also dvi, hdmi, displayport with lots of wires and a chip behind them. Displayport even has " A bi-directional, half-duplex auxiliary channel" [3] , though I'd want to look at the spec to see how that could be used, or if it could be contorted to a GPIO purpose.
[1] https://en.wikipedia.org/wiki/PHY_%28chip%29
[2] https://electronics.stackexchange.com/questions/24588/is-the...
Joking aside, having one of these for a kid to play with is a good way to introduce them to world of controls. They are some areas to work through (polled inputs, default pin configuration etc) but it is a good start. Hoping that v2.0 will be more bespoked.
It has some limitations in terms of IO default state, IO polling or speed of transfer (I2C:15Kbyte/S, SPI:15KBytes/S To 28KBytes/S). Samples in C#, VB.NET or Powershell codes are available on github.
Regarding the IO polling issue, I do not think this can be address with a Windows PC or Linux on the Raspberry PI. I tested the USB interrupt for the FTDI FT4222 and this is not very impressive.
Nusbio v2 coming sometime this year will address some of these issues, IO default state as input, increase in speed transfer (I2C:Up to 128Kbyte/S, SPI:Up to 2.4 Mbyte/S), 10 bit ADC. But unfortunately will be more expensive. Therefore not a device for beginner or small project.
see https://twitter.com/MadeInTheUSB/status/848013033335029761
> Regarding the IO polling issue, I do not think this can be address with a Windows PC or Linux on the Raspberry PI. I tested the USB interrupt for the FTDI FT4222 and this is not very impressive.
Yeah, that's not the right approach. As a controls engineer who builds PC-based test and manufacturing equipment, this is your competition:
http://www.ni.com/pdf/manuals/374369a.pdf
http://www.ni.com/pdf/manuals/374566d.pdf
These can be programmed with .NET languages and C/C++ using Measurement Studio, or graphically through LabView.
I think the critical differences are (1) using USB directly, rather than a serial emulator, enabling much higher data rates - you don't necessarily need this yet, low-speed is probably fine and (2) using internal FIFOs and Tasks to control IO instead of handling each bit over the connection.
Essentially, what you want to do is push all the real-time stuff off to the microcontroller on the peripheral, and only synchronize every couple hundred milliseconds with the PC, which will essentially take in a large buffer with the history of the inputs at 1 kHz or more, and output a similarly sized buffer with the data to be encoded on the outputs until the next synchronization. Anything that needs to happen faster than that needs to be set up before hand.
If the former, then why should anyone choose this over Netduino? If the latter: why have you chosen this product?
edit: by browsing the page I saw it is the former.
With an Arduino specially Chinese Arduino compatible CH340 or with .NET languages you may be limited to 115200 bauds (about 11Kbyte/S) and you need to write and maintain a firmware. As a plus you get PWM and ADC. Nusbio1 can do between 15 and 28 Kbytes/S in SPI and there is no firmware. But there is no PWM. ADC or DAC are available as SPI extensions.
it is not a black and white answer.
But with the knowledge I acquired creating Nusbio 1 hardware and software, I am now working on Nusbio 2.
Nusbio v2 coming sometime this year will address some of these issues, IO default state as input, increase in speed transfer (I2C:Up to 128 Kbyte/S, SPI:Up to 2.4 Mbyte/S), 10 bit ADC, PWM. But unfortunately will be more expensive.
see https://twitter.com/MadeInTheUSB/status/848013033335029761
What I am currently achieving is
- 100Kbytes/S in I2C with a 10Mhz I2C EEPROM and - 2.4 Mbytes/S in SPI with a NOR FLASH at 103Mhz
using the FTDI FT4222 and the FT232H should the same or better.
But the FT232H breakout from Adafruit is great and the cheapest. But they do not offer .NET support on Windows and FTDI does not either.
Here is one of my experiment with Adafruit FT232H breakout in C. https://twitter.com/MadeInTheUSB/status/848799047632773120
all just for hobby and my attempt to understand. have beadboard exprience and follow a course that use windows xp and M3 and a propeiority tool from TI.