10
\$\begingroup\$

I'm trying to find the best micro controller package for my computer programs to communicate with the real world. I am hoping for a large number of I/O pins (so far 64 digital is all i need, nothing fancy like analog and PWM) which an I can read and write directly by calling functions from my program running on my CPU.

I don't want to download programs onto the micro controller itself to run, rather i would like something that simply plugs into my USB and gives me a bunch of CPU controlled I/O pins that i can control from my C++ programs.

What would be the best micro controller package for me? I hope for something that is fairly inexpensive but future proof, as in it runs off USB and has 64-bit drivers for modern OS like Windows 7. Being able to interface more than one of these micro controllers with the same computer program would be a great bonus as well (future expansion).

Edit: I don't need high sampling rates (maybe 10 Hz for reading inputs, 1 kHz for output signals) and most of the pins are used for output only. I am working with brand new computers (core i7 860) so even if the sampling is a bit inefficient or slow, it should still be ok (just have one thread dedicated to I/O and have the main program communicate with it).

I also don't need all 64 I/O pins on a single micro controller package. If i can interface many micro controller packages at the same time, that would work too (actually it would be ideal to be able to interface many smaller micro controller packages, that means it's easy to expand).

I've looked at this: http://www.schmalzhaus.com/UBW32/index.html

Has anyone had any experience with something like this? Any idea if it will work or not? The main concern is that it is the micro controller that is running the program, not my CPU.

\$\endgroup\$
  • 1
    \$\begingroup\$ What data rate do you need? \$\endgroup\$ – Kevin Vermeer Jul 14 '10 at 19:58
  • \$\begingroup\$ @reemrevnivek: I estimate i would need about a 10 Hz sampling rate for inputs and 1 kHz for outputs, very slow I/O. \$\endgroup\$ – Faken Jul 14 '10 at 20:22
  • \$\begingroup\$ In your case the project you have found will probably work quite well. It is a system already put together (no soldering needed is always nice) and seems to have very basic firmware to give you access to all the ports you need. Low sampling rates mean that the serial connection will work sufficiently well. 40$ will not bankrupt you, right? If so, just try it before you look at a more expensive solution. \$\endgroup\$ – Wouter Simons Jul 15 '10 at 7:15
4
\$\begingroup\$

Faken,

The UBW32 is a very good way to go, from what I can tell of your requirements. It will support exactly what you need, as long as you're OK with 3.3V I/O (some are 5V tolerant, but not all.) It is inexpensive ($40) and is very easy to talk to using any language that can support serial ports (which is pretty much all of them - Basic, C, C#, Processing, etc.)

You can use any of the 76 I/O pins as inputs or outputs. The stock firmware as shipped will allow you to do what you want to do, no programming required on the embedded side. Getting that data up to the PC over USB (at only 10Hz) will be no problem. Getting outputs to go at 1KHz will probably work just fine as well.

If you have any questions, please let me know. I'm happy to help you out.

*Brian Schmalz UBW32 creator

\$\endgroup\$
  • \$\begingroup\$ Nice board, mr. Schmalz \$\endgroup\$ – Wouter Simons Jul 15 '10 at 7:22
  • \$\begingroup\$ Well this is defiantly comforting. Being a mechanical engineer to begin with and knowing little about programming and even less about electronics; a prebuilt platform that interfaces with C/C++ is exactly what i needed in order to doge the electronics and microcontroller programming aspect. Thanks for your help! \$\endgroup\$ – Faken Jul 15 '10 at 7:44
9
\$\begingroup\$

I recommend a Teensy++ 2.0 (or any other AT90USB1286 development board)

128KB Flash, 8KB RAM, 46 I/O pins, 8 analogue inputs

$24

The Teensy boards are USB powered and can provide a virtual COM port (USB Communications Device Class). You could make use of this serial link for your pin control protocol. This works without any custom drivers on Windows, OSX and Linux.

To create the pin control firmware, there's TeensyDuino or plain old C.

When bit banging, the bottleneck is going to be the microcontroller's USB interface. So you may want to shift protocols such as I2C and SPI down to the microcontroller. For this you could use my Bus Ninja.

Adding additional Teensies to your setup is simple, you just need one USB port per device, presenting one virtual COM port per device.

(Note. This approach will work equally well with a whole range of ARM processors and others, I just don't know of any cheap development boards with available software).

Another way could be to use an Arduino and a Caterpillar Shield to expand the I/O. On a custom board I built around the same I/O expander I was able to update 256 outputs at over 1KHz.

\$\endgroup\$
4
\$\begingroup\$

I think what you want is not a microcontroller, but something like a National Instruments PCI-6509 I/O card. You can get USB versions as well, but they have many fewer I/O than the PCI-6509. National Instruments will sell you C++ drivers as well.

If that looks too expensive, you could try something like the Labjack U3.

\$\endgroup\$
  • \$\begingroup\$ I've used the labjack, it really slows down your computer if you do anything more serious (higher sampling rate), but it is great for slow sample rate simple logic. The NI systems are wonderful, but the software package is too expensive for home use. (At least for my home use.) \$\endgroup\$ – Wouter Simons Jul 14 '10 at 19:25
4
\$\begingroup\$

The solution you describe does not exist for lower prices. The problem is that you want to run the control software on a system that's not designed for it. Serializing 64 ports and pushing it through USB at high sampling rates slows down the host computer immensely.

There are solutions that work for low performance applications like the labjack mentioned. But the real solution you need to handle high IO rates will involve a programmed system. The question is what programming you have to use to implement the system.

LabView is highly expensive software (which works great, don't get me wrong). It uses a graphical language to design software and compiles to code running on an FPGA or ARM system. All components are too expensive for a high volume embedded app, but absolutely wonderful in a testing environment because of the quick development, high performance offered.

A less expensive solution is to find a system that runs linux with many I/O. EmbeddedARM.com is a site that offers many types of products for this. The code you can write may be in shell scripts, java, C, etc.

The Arduino systems provide microcontrollers that can be developed with a simpler development environment. Their open source nature means there are already many projects to learn from.

\$\endgroup\$
3
\$\begingroup\$

i don't know of any with 64 GPIO pins, thats a lot, you may have to build that yourself.

I use this for bench testing serial interfaces but it also has 23 GPIO pins.

If you just google for 'USB to GPIO' there a bunch of projects out there that have done this, i didn't see any in the first couple pages with 64 GPIOs this is the closest i found, with 32 pins.

Building one wouldn't be very hard, i'd probably just use a 100pin pic18 with built in USB PHY (depending on your speed requirements a more powerful cpu may be in order)

you wouldn't have to do too much coding to get it working as long as your uC vendor offers a USB driver skeleton.

You would have to build a PCB for it most likely as chips that are large enough to have 64 GPIO pins generally do not come in through-hole packages. You could also use a smaller microcontroller and use external port expander IC's for your GPIO's but that would be a more complex design and more complex to program.

You could also look at dev boards that route all I/O pins to headers and have USB. These will likely be a lot more expensive as they will likely have a bunch of stuff you don't need.

One final tip, if you find a board with RS232 but with 64 GPIO pins available, you can use an RS232 to USB adapter, i have a few of these that have worked well for me. This does limit you to the speed of the RS232 interface however.

\$\endgroup\$
3
\$\begingroup\$

The NI Labview environment is expensive, but it will do what you need (Over USB, Ethernet, or PCI depending on what you get.)

The Arduino Mega has 54 pins, which gets you close, for $60. However, it's not a logic analyzer out of the box; you'd have to write or find a sketch to do this. There may be one available, I don't know. This should be fairly simple at low bus rates. Each instruction on the Mega happens at 16MHz, so you'll have a fairly slow baud rate, you'll be lucky or very clever if you can get a 115200 baud signal.

In the end, this is a very different project if you're sampling at 9600 baud or at 50MHz. Remember, USB runs at 480 MHz (In theory; your actual data rate will be lower due to latencies and overhead) so you can't do any better than 480/64 = 7.5MHz without buffering. With buffering and obscene amounts of money (More than your car), logic analyzers can get you 68, 102, or 136 channels at gigahertz data rates.

I would suggest that you very seriously try to figure out if you can use a tool that gives you 8 channels or so, and try to analyze them separately.

EDIT: Aargh, what was I thinking? If you're going at slow rates like that, then working over a serial link is definitely the way to go. I use the ADAM 4000 module system from Advantech all the time at work; they're robust, easy to use (easily interfaced with an ASCII protocol over a COM port, or use the included GUI software), expandable, and well supported. Get yourself a 4500 (RS-232, use a USB converter or COM port on your computer (if it's still got one)) or 4501 (Ethernet with embedded webserver) controller, link in a bunch of 4053, 4055, and 4056 modules, and you're good to go.

\$\endgroup\$
  • \$\begingroup\$ Oh. but they are pretty costly....like $100 to $150 for 16 channels. \$\endgroup\$ – Kevin Vermeer Jul 15 '10 at 2:07
  • \$\begingroup\$ I have an intronix 34 port logic analyzer to test my software (i.e. connect the inputs to the outputs of the microcontroller controlled pins). It's about 500$ I think, but it is also not really digital I/O is it? It is not meant to program custom logic with, just to analyze channels. Mine can work at 500Mhz sampling rate, but I don't usually need that speed, unless the peripherials I want the microcontroller to controll support speeds up to 200Mhz or so (which they usually do not). -- Anyway, long story short. I believe that a logic analyzer is not what the person asking the question needs. \$\endgroup\$ – Wouter Simons Jul 15 '10 at 7:20
  • \$\begingroup\$ It's definitely I, but not O. No, I would agree that the logic analyzer is not what the person needs, given the new information. \$\endgroup\$ – Kevin Vermeer Jul 16 '10 at 11:59
2
\$\begingroup\$

This thing's got 70 GPIOs and a USB interface for $50.

\$\endgroup\$
  • \$\begingroup\$ Can you use call functions to read and write pin data directly from C++ programs running on your CPU? \$\endgroup\$ – Faken Jul 15 '10 at 23:53
  • \$\begingroup\$ I was going to suggest that NXP would have something ARM based with some I/O, and if you couldn't get enough of them to just slap on I2C IO expanders. You can't beat the price of that thing, and it's plug 'n play. Excellent work. \$\endgroup\$ – akohlsmith Jul 16 '10 at 5:42
  • \$\begingroup\$ I have no idea. I just saw it on Sparkfun's new products post. \$\endgroup\$ – endolith Jul 16 '10 at 14:52
2
\$\begingroup\$

Yes, it looks like the UBW32 would work fine for you, and the default firmware lets you control the I/O pins from your software on your PC.

According to "how to bit bang SPI and parallel interfaces on an FT232R", you can apparently bit-bang 8 digital pins (possibly more?) on the FT232R controlled by software on your PC.

$15 Breakout Board for FT232RL

It sounds like what you really want is a digital I/O interface; you neither need nor want a programmable microcontroller. If you only wanted 16 bits, I would go with a couple of FT232RL boards. However, it looks like a single $40 UBW32 looks like it will give you the 64 I/O you want for less cost than 8 of the FT232RL boards it would require to get 64 I/O.

I'm finding that's becoming increasingly common -- it sometimes costs less to throw an entire microcontroller at a problem, even though it has a million "extra" transistors I'll never use on it, than to use a hard-wired solution.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.