Silicon Bugs In The FTDI FT232R, And A Tidy RF VCO Project

[Scott Harden] wrote in to tell us of some success he’s having using the FT232 chip to speak SPI directly from his laptop to a AD98850 digital signal generator. At least that was his destination. But as so often in life, more than half the fun was getting there, finding some still-unsolved silicon bugs, and (after simply swapping chips for one that works) potting it with hot glue, putting it in a nice box, and putting it up on the shelf.

In principle, the FTDI FT232 series of chips has a bit-bang mode that allows you to control the individual pins from a fairly simple API on your target computer, using their drivers and without installing anything on basically any platform. We wrote this feature up way back in 2009, and [Scott] was asking himself why he doesn’t see more hacks taking advantage of bit-bang mode.

“Square” waves

Then he answered his own question the hard way, by spending hours “debugging” his code until he stumbled on the FTDI errata note (PDF), where they admit that bit-bang mode doesn’t get timings right at all on the FT232R and FT232RL parts. FTDI has made claims that they fixed the bug in subsequent chip revisions, but the community has not been able to confirm it. If you want to use bit-bang mode, which is plenty cool, steer clear of the FT232R chips — the ones found in the ever-popular FTDI cables and many adapter dongles.

The good news here is twofold. First, now you know. Second, bit-bang mode is tremendously useful and it works with other chips from the vendor. Particularly, the FT232H and FT230X chips work just fine, among others. And [Scott] got his command-line controlled digital VCO up and running. All’s well that ends well?

We’ll wrap up with questions for the comment section. Do other manufacturers’ cheap USB-serial chips have an easily accessible bit-bang mode? Are any of you using USB bit-bang anyway? If so, what for?

Bit banging through a USB parallel port adapter

If you’ve ever looked into low-level parallel port access you may have learned that it only works with actual parallel port hardware, and not with USB parallel port adapters. But here’s a solution that will change your thinking. It borrows from the way printers communicate to allow USB to parallel port bit banging without a microcontroller (dead link, try Internet Archive).

Sure, adding a microcontroller would make this dead simple. All you need to do is program the chip to emulate the printer’s end of the communications scheme. But that’s not the approach taken here. Instead the USB to RS232 (serial) converter also pictured above is used as a reset signal. The strobe pin on the parallel port drives an inverter which triggers a thyristor connected to the busy pin. Thyristors are bistable switches so this solution alone will never clear the busy pin. That’s where the serial connection comes into play. By alternating the data transmitted from the computer between the bit-bang values sent to LP0 and 0xF0 sent to the serial connector the eight parallel data bits become fully addressable. See the project in action in the clip after the break.

Gaining low-level SPI access on the Raspberry Pi

Raspberry Pi - rpi

We’ve seen a ton of projects that interface hardware with the Raspberry Pi. But they usually depend on bit-banging. That means they toggle the pins in software to match a specific protocol. The thing is that the beefy Broadcom SoC that anchors the board has a lot of built-in peripherals that are just waiting to be used instead of bit banging. In this case, it’s the hardware SPI peripheral which can be accessed via the bcm2835 library for RPi.

One of the things that would have really complicated this process is the pin mapping between the Broadcom chip and the RPi GPIO header. Since not all pins are broken out, it was either luck or good design forethought that made all of the SPI0 pins from the chip available on the RPi breakout header. The library page (linked above) explains this well. But if you’re looking for more of a working example check out [EngineerByNight’s] project with adds an accelerometer using hardware SPI.

Low-cost, low-bandwidth wireless Arduino to Android communications


[Joe] was experimenting with his Arduino when he started thinking about how he could get it to communicate wirelessly with his Android phone. Bluetooth is an option, but it requires some extra components, and Google’s ADK works as well – just not wirelessly.

Instead, he thought it would be neat to see if he could get the two devices to communicate with a simple magnetic coil. He constructed a small 1cm diameter coil, connecting it to the Arduino via a resistor and diode. Using the Android Tricorder app, he was able to locate his phone’s magnetometer, after which he ran some tests to narrow down the best sample rate and frequency range for communications.

To transfer data between the two devices, he had to bit bang the signal in software, since the Arduino’s UART has a lower limit far faster than the 7 bps data rate he was able to achieve with the magnetometer.

While his wireless Arduino to Android bridge isn’t likely to win any awards for throughput, it is a great proof of concept project. Be sure to check out the video below to see his “poor man’s NFC” in action.

Continue reading “Low-cost, low-bandwidth wireless Arduino to Android communications”

RF control from just about any device

[Mirko] is working on a library that will allow you to add RF control to just about any device. The only requirement is that the device be capable of running a Linux kernel, and that it have a few GPIO pins available. One example is fairly straight forward, a Netgear router. Many, if not most routers run a Linux kernel natively and most have solder points on the board for unused IO pins so patching into the hardware is very straight forward. Less obvious and much more impressive is the hack seen in the image above. [Mirko] built an SD card adapter cable and uses the contacts in the card reader to bit bang four-wire SPI to communicate with that RF module.

Introduction to FTDI bitbang mode

It was an interface that launched a thousand hacks. Near trivial to program, enough I/O lines for useful work, and sufficiently fast for a multitude of applications: homebrew logic analyzers, chip programmers, LCD interfaces and LED light shows, to name a few.

Today the parallel printer port is on the brink of extinction (and good riddance, some would say). Largely rendered obsolete by USB, few (if any) new peripherals even include a parallel connector, and today’s shrinking computers — nettops, netbooks, media center PCs — wouldn’t have space for it anyway. That’s great for tidy desks, but not so good if you enjoyed the dirt-cheap hacks that the legacy parallel port made possible.

Fear not, for there’s a viable USB alternative that can resurrect many of these classic hacks! And if you’ve done much work with Arduino, there’s a good chance it’s already lurking in your parts drawer.

Continue reading “Introduction to FTDI bitbang mode”

C64 USB keyboard


[Maarten] told us about a C64 USB keyboard that was modified to be used as a standard input device. An interesting aspect of the project is the use of V-USB (formerly known as AVR-USB). V-USB is a software only approach to slow speed USB HID. In essence this is a two fold mod, The C64 keyboard is patched to a PC, and an off the shelf AVR is software-hacked to bit bang the USB communications. The author notes an initial problem with multiple key presses that was later corrected in the application. For the other side of the spectrum, we had covered the C64 twittering client, and a commodore 64 laptop.