Posts

USB Cable of My Dreams

USB A to B connectors back to back

USB A to B connectors back to back

USB isolation is good for you. Isolated DAC makes better sound, isolated oscilloscope produces cleaner trace, and making line voltage measurements with isolated instruments helps us live longer. However, USB isolation often comes with a cost of extra USB cable, which may become excessive if we take into account precious desk space taken by said cable, as well as time spent on finding and untangling it.

I made several attempts to build a short cable which would also be able to bear load of USB isolator. Finally, while searching for a source of PCB mounted USB male B-type connector, I found this little marvel on eBay.

There is not much to say about it. It is short rigid adapter with USB A-type connector on one end and B-type on the other. The following picture shows typical arrangement – USB isolator connected to my Bitscope with USB adapter holding isolator in the air.

Of course, this little adapter can be used for connecting many other devices. Another picture shows our beloved Arduino connected to a USB port of a laptop computer. Here the weak spot of the adapter is clearly seen – since A and B connectors are turned 180 degrees, connected device would be turned upside down. For isolator it doesn’t matter much; however, operating Arduino’s Reset button and connecting shields would be difficult.

Adapter is available from several sources on eBay. Prices vary from $0.90 to $2.00, often with free shipping. The search string is “USB 2.0 Male to Printer Scanner A-B Converter Adapter”. Enjoy!

Oleg.

USB Isolator connected to Bitscope using short cable

USB Isolator connected to Bitscope using short cable

Using USB adapter to connect Arduino to a PC

Using USB adapter to connect Arduino to a PC

PS3 and Wiimote Game Controllers on the Arduino Host Shield: Part 3

Wiimote controller wit USB Host Shield

Wiimote controller wit USB Host Shield

This is the third part of a series of articles written to describe development of interface between Arduino and popular game controllers using USB Host Shield. Previous parts:

Revision 0.4 – 13th January 2010

Part 3. Develop the Bluetooth USB and HCI interface used in the support of the Wiimote and PS3 game controller, and also some utilities needed to analyse and configure these devices.

1. USB Interface
As before, we first look at the descriptors for the USB dongle using the USB_Desc sketch. The result is:


Continue reading PS3 and Wiimote Game Controllers on the Arduino Host Shield: Part 3

PS3 and Wiimote Game Controllers on the Arduino Host Shield: Part 2

Sony PS3 controller

Sony PS3 controller

This is the second part of a series of articles written to describe development of interface between Arduino and popular game controllers using USB Host Shield. Previous parts:

Revision 0.6 – 13th January 2010

Part 2: Develop the USB interface to the PS3 controller

1.       USB Reduced Hosts

Full USB hosts such as Windows and Linux based computers can manage a large variety of different USB devices and load appropriate USB drivers for each device. There is an enumeration or discovery phase where the host gathers information on the attached USB device and uses this information for the driver selection and configuration. In small embedded applications this is not possible or required to support this variety, so the application usually only supports a few devices, often only one. This means the discovery process can be much reduced since the results are already known. This will reduce the memory required for the application by hard coding the device configuration into the application.

Though the configuration will be hard coded, we still need to initially gather the information from the device itself and other sources.

The existing device drivers mentioned above for Windows and Linux are important in our development process. The Windows drivers are usually complete, but not available in source form. Linux drivers are available in source form, though not always as complete. Device manufacturers are usually very reluctant to provide information required to build a driver or embedded application. So we rely on copying Linux code or “sniffing” Windows code to give us guidance.


Continue reading PS3 and Wiimote Game Controllers on the Arduino Host Shield: Part 2

PS3 and Wiimote Game Controllers on the Arduino Host Shield: Part 1

Bluetooth

Bluetooth


Revision 0.9 – 13th January 2010

Part 1: Introduction

1.       Background
These articles describe how to interface PS3 and Wiimote game controllers directly onto the Arduino using the USB Host Shield. These controllers have not previously been directly connected to an Arduino due to the USB and Bluetooth interfaces and protocols used, and their relative complexity. The game controllers are a good match to the capabilities of the Arduino, and to the imagination of Arduino users, they have not only buttons and joysticks, but also motion sensing, and other goodies which deserve to be in the hands and ideas of Arduino users. Also I hope these articles provide some guidance for people to develop other USB host and Bluetooth applications for small embedded processors.
Arduino already comes in versions which have USB and Bluetooth interfaces, but these are not suitable for our chosen game controllers. When used in USB mode, the PS3 controller is a USB device and needs to talk to a USB host. The normal Arduino USB interface is also a device, so not compatible. When in Bluetooth mode, both of these game controllers use the Bluetooth HID protocol and this is not compatible with the commonly used Bluetooth modules which support only the RFCOMM Serial Port Protocol. Arduino users have successfully used a PC as an intermediary between the game controllers and the Arduino, so the PC is host to both devices.

These articles were written by Richard who is new to the Arduino, blogs, github, libraries, etc, so please give me any help and feedback on how I might improve or correct these articles and software.


Continue reading PS3 and Wiimote Game Controllers on the Arduino Host Shield: Part 1

Hook up PS3 controller to USB Host shield

PS3 controller connected to Arduino USB Host Shield

PS3 controller connected to Arduino USB Host Shield

Another HID example has been added to Github repository of USB Host Shield for Arduino (which you can purchase in my store) . Richard Ibbotson sent me this nice piece of code along with some pictures. He also posted a short description of his sketch in comments section:

I wrote a sketch for the interface of the PS3 controller over USB. I have two controllers, one Sony and one Madcatz wireless with a USB dongle. Both of these work fine to the USB host shield. I only made one minor change to the library to increase the NAK count. The sketch tests all the function, buttons, joysticks, accelerometer/gyro, leds and rumble. This is not yet under bluetooth just USB. I can set the host bluetooth adddress on the controller though which is needed for bluetooth pairing.

Did not make much attempt to reduce code or data size, so only have about 4K of program space and 240 bytes of data space left, but sketch is pretty long. The actual PS3 part is very small and could be made to a small library.

Next is to move to the bluetooth part, from what I have found on the direct USB, I am pretty confident this will fit even on the 168.

PS3 controller support opens some very interesting possibilities. Not only can it be used as a normal “joystick plus buttons” type of control, but you can also utilize it’s accelerometer/gyro. With wireless variant of the controller all kinds of very powerful radio control are possible. Who is going to be the first to make a mechanical dog, which follows you around and brings back the controller when you throw it away?

If you want to try the sketch, make sure you have the latest library code as well – there are some small but important changes made recently in NAK handling.

MadCatz wireless controller to USB Host Shield

MadCatz wireless controller to USB Host Shield

Wireless mini keyboard connected to USB Host Shield

Wireless mini keyboard connected to USB Host Shield

USB Host breakout at work

Here is an interesting project which uses MAX3421E breakout board to connect XBox360 wireless controller to old Nintendo Entertainment System. Francois Gervais used Cortex-M3 as an interface between Nintendo and a game controller. There are two other videos showing the details of the setup – check them out as well.


Continue reading USB Host breakout at work

USB Isolator Most Frequently Asked Question

ADuM4160 PIN pin grounding

ADuM4160 PIN pin grounding

Q. I am getting “USB device not recognized” error message – what do I do? Also, since the isolator is soldered into my circuit, “reconnect peripheral” suggestion seems too difficult to follow.

I decided to write this article after receiving several e-mails from people who bought my isolator. While setups described in those e-mails were different, the problem was the same – a PC refusing to recognize the device connected through the isolator. Here I will try to explain what is happening and also share my ideas how to troubleshoot and possibly fix the problem.

When nothing is connected to USB port, the bus is held at ground level with pull down resistors on the host side. USB device, when connected, pulls one of bus lines up, often times also with a resistor connected to Vbus and data line. Host sees it, sends bus reset and tries to query the device. If device is answering, host keeps querying the device and eventually enumerates it. When device is enumerated, application takes over.

If device is not answering (like for example, when self-powered device is turned off), host will give up and post “Device not recognized” message. To get attention from the host, we need to generate bus event, i.e., disconnect the peripheral and connect it back again.


Continue reading USB Isolator Most Frequently Asked Question

Solder stencil for USB Isolator PCB in store

USB Isolator Board Solder Stencil

USB Isolator Board Solder Stencil

I received a batch of solder paste stencils for my USB Isolator PCB. Now those who want to try low-tech reflow soldering technique, can do it. Stencils are laser cut by Ohararp from 0.0035″ Kapton. They are now offered for sale at the store.

How to drive USB keyboard from Arduino

USB Host Shield driving a keyboard

USB Host Shield driving a keyboard


I am continuing on topic of using USB Host shield to drive USB peripherals started in the previous article. The code presented here performs keyboard polls, character translation and management of “LOCK” keys – NumLock, CAPSlock and ScrollLock.

A keyboard is hard to use if results of typing can’t bee seen, so my first step was to add an output device. Even though HD44780-compatible character LCD can be driven with Arduino pins, I wrote a little library which uses GPOUT port of MAX3421E for LCD control. This library is now a part of USB Host Shield repo on github. I used LCD high-level routines from official Arduino distro and developed low-level functions specific to MAX3421E hardware, as well as LCD initialization. Since function syntax and behaviour (and source code ) is identical to official LCD functions, the user manual is already written and can be found in the library reference by title LiquidCrystal. The only difference is in the constructor; since only 4-bit mode is possible and only one pinout is supported, Max_LCD constructor is not accepting any parameters. The pinout of LCD connections to GPOUT is given in the Max_LCD.h file; see also title image of this article.


Continue reading How to drive USB keyboard from Arduino

USB Isolator kits in store

USB Isolator parts

USB Isolator parts

Immediately after announcing USB Isolator circuit I received several suggestions to put together a parts kit. Indeed, users of such devices are usually not afraid of small parts and generally aware of which side of soldering iron is better suited for holding on to. Also, I’m having hard time trying to find a supplier, where one can buy all the parts to build this circuit; usually, you need to buy from 2-3 suppliers, which significantly adds to shipping expenses. Considering this, I’m now offering not one, but two parts kits to build an USB Isolator based on Analog Devices’ ADuM4160.

The kits are added to “ADuM4160 USB Isolator bare PCB and kits” dropdown. One kit contains all the parts necessary to build an isolator – PCB, ADum4160, capacitors, resistors, USB connectors, pin headers, and jumpers and costs $25. Another kits contains all that plus all parts for 5V buck converter – LT1376-5, inductor, caps, etc and costs $33. Enjoy!

I’m not writing a build manual at this time; I’d like to get some feedback from builders first. Any questions you have, please don’t hesitate to ask.

Oleg.