Posts

Arduino USB Host – Peripherals.

USB constructor

USB constructor


The time has come to start using the code to communicate to peripheral devices. There are many devices which work well with microcontrollers. HID devices, such as keyboards, joysticks, and Radio Controller look-a-likes are useful and not too difficult to implement. Another good application of embedded USB host is digital camera control. Communication using Bluetooth and WiFi peripherals are also a possibility.

Today I’m going to show how to communicate with USB keyboard. Standard USB keyboard belongs to a class of devices, called HID (Human Interface Device). The format of data generated by HID device is quite flexible and each device stores it’s data definitions in structures called Report descriptor and Physical descriptor. Generally, to work with the device, report descriptor has to be retrieved and parsed. Because of HID flexibility, a universal HID driver will take many many lines of code. Luckily for us, if all we need is to talk to the keyboard, there is an easier way.


Continue reading Arduino USB Host – Peripherals.

Arduino USB Host Shield build log. Part 4.

Layout closeup

Layout closeup


Release candidate 1 boards has been received, built, tested, and came out green wire free – at last! I placed an order for a small batch with board house and expect PCBs to be available in a couple of weeks. I am making second call for beta testers – if you write code and/or blog, drop me a line with a link to your blog and your voltage preference for the shield – 3.3V or 5V. I have more 3.3V boards left from prototyping so naturally people requesting 3.3V boards will have more chances to get one.

Updated Eagle and Gerbers are available in Downloads section. If you don’t have Eagle, here is the PDF of the schematic. Please make sure you are not using scematic posted in one of the previous articles – there are quite a few changes.

In this article I want to give an overview of the board and it’s features. I’d like to start with most complicated part, which is power configuration. First of all, the USB core part of the shield (MAX3421E) requires 3.3V to function. Second, bus-powered USB peripheral requires 5V on Vbus. However, to use self-powered USB peripheral we only need to connect 3.3V to Vbus to be able to see speed-setting pullup resistors. Consequently, for digital camera control applications, shield can be mated with 3.3V Arduino (like Sparkfun‘s Arduino Pro) with no additional power supplies.


Continue reading Arduino USB Host Shield build log. Part 4.

Vigorius stirring redefined. Part 1 – mechanics.

Tornado in the flask

Tornado in the flask

Magnetic stirrer is a handy tool to help in any household activity, where agitation or mixing of relatively small (under 4L/1Gal) volumes of liquid or suspension are involved – from yeast starter preparation to dissolving fertilizer to chemical experiments. As almost any piece of laboratory equipment, factory-made magnetic stirrers are way overpriced. At the same time, such stirrer is rather easy to make from junk lying around the house. There are plenty of information on the Internet describing building mechanical part of a stirrer. Google for other people’s projects, some of which are much nicer than mine. I started this project mainly to play with motor control piece so mechanical setup was simplified as much as possible. As far a motor control goes, the main difference of mine will be ability to track stirrer bar behaviour. When a bar is spinning close to the maximum speed for given viscosity, it tends to lose strong attraction to the magnet of a motor and stop. Usual remedy is then to slow down the motor until it catches the bar and slowly increase the speed. Since moment of losing attraction is easy to register by monitoring current to the motor, the process of catching the stir bar can be automated. Also, I have a suspicion that a current change will be observed just before the disconnection and can be avoided altogether by corrective action. I will check this possibility during control circuit firmware design. Now, while waiting for Adafruit Motor/Stepper/Servo Shield for Arduino kit to join piles of junk lying around the house, I will describe mechanical implementation of the stirrer.


Continue reading Vigorius stirring redefined. Part 1 – mechanics.

Arduino USB Host Shield build log. Part 3.

USB Host Shield prototypes

USB Host Shield prototypes

Making functional 5V version of a shield proved to be difficult. I was hoping to publish a release after building previous protos. However, it turned out that together with fixing old errors I managed to make several new ones and also missed a couple from previous prototyping cycle. So, in order to produce a proto containing less errors than a previous one, I spent a great amount of time checking everything I could think about, writing test code, running those tests against prototypes, and then repeating them on all possible mixes of available Arduinos and voltages.

Also, I found that USB-B connector on Duemilanove shorts GPIN contacts on a shield. Cover top of the connector with piece of Scotch tape, if you haven’t already.

Today I placed an order with BatchPCB to what I call “Release candidate 1”. I am hoping this is a design which will be released when I get it back in 3 weeks or earlier( BatchPCB is getting faster ). Also, I forked previous repo containing Arduino libraries, the current development is now contained in USB_Host_Shield. I removed Vbus power control support since it’s not implemented on a shield and added functions for GPIO pins read/write. I’m freezing previous repository to support old sketches.

While waiting for PCBs I will continue working on HID code for the shield and also write a library to control LCD/buttons via GPIO pins. Stay tuned.

Oleg.

Building USB Isolator.

USB Isolator

ADuM4160 USB Isolator PCB panel

USB Isolator PCBs has arrived. In this article I will be talking about building and configuring one. The PCB was designed with hobbyist-friendly large size SMD packages and 10mil clearances and I hope it won’t be difficult to made one at home. The layout files are available from downloads section.
Let’s talk about parts procurement. This is a BOM at Mouser sans ADuM4160, LT1376-5, and PCB. This is BOM at Digi-Key, which includes LT1376-5. Last time I checked, Digi-Key was way more expensive. As far as ADuM4160, since no one sells it in single quantities right now (check this using FindChips), the easiest way to get it is to ask Analog Devices for a sample, they are generous folks.


Continue reading Building USB Isolator.

USB Isolator.

USB Isolator

[ Update ] I now have bare PCBs and parts kits of this design for sale in store, as well as assembled and tested boards.

We all love USB. It is well supported across many platforms, easy to work with, and even able to provide a little power to the peripheral. However, the quirk of USB is that peripheral must share ground line with the host. The host is usually a PC and very often a desktop, which means it’s USB ground is electrically connected to earth ground in the wall outlet. With PC-based test instruments, like oscilloscopes, logic analyzers and such, It works fine most of the time, but not always.

There are situations when we prefer our ground separate. It happens when PC/earth ground is too “dirty” and we don’t want our circuit to pick up this dirt. Sometimes our device’s ground is not too good or even dangerous if connected to earth ground. Sometimes we are trying to overcome ground loops. Sometimes, we want our oscilloscope to behave like a multimeter, i.e. being able to show voltage drop between any two arbitrary points of the circuit. In any of this cases we want our USB data and ground isolated from the host.

Isolation improves common-mode voltage, enhances noise rejection, and permits two circuits to operate at different voltage levels. It also tends to save test equipment, as well as PC itself. It is also very useful in industrial setting, that probably why industrial USB isolator devices cost between $200 and $400. While looking for a solution for my lab, I found interesting USB isolator part, recently released by Analog Devices, and decided to give it a try.


Continue reading USB Isolator.

Arduino USB Host Shield build log. Part 2.

USB Host Shield prototypes

USB Host Shield prototypes

I finished building Arduino USB Host Shield prototypes. Functionality has been tested, errors found, fixed, and 1.0rc boards ordered. Title picture shows two prototypes, 3.3V sitting on top of Arduino Pro from Sparkfun and 5V on top of Duemilanove (bought at Sparkfun also).

As you can see, the biggest amount of errors has been made in 5V part of the circuit. To be honest, I’m not quite sure all of them are fixed. At some point I decided to stop messing with temporary fixes and order a board – if anything is still not right, I will find out later.

One of the goals of this build was to test 3.3V to 5V DC-DC converter (schematic). You can see it populated on 3.3V shield. It can be used on 3.3V-only systems to provide power to Vbus. This converter is designed around LTC3426, delivers ~700mA (slightly more than needed for powering Vbus) and runs cold with 90-94% efficiency. Output ripple was measured at 25mV. Note of caution: you should expect stability issues when powering such setup from USB (for example, during development) – in one of my tests Arduino was regularly rebooting during USB drive connect.


Continue reading Arduino USB Host Shield build log. Part 2.

Arduino USB Host Shield build log. Part 1.

5V to 3.3V converter

5V to 3.3V converter


Parts has arrived yesterday and I started test-building my USB Host Shield prototype PCB to check functionality and buildability. Since design is not final, I’m not publishing Eagle files yet – they will be online as soon as I get all errors fixed. In the meantime, the PDF of the schematic diagram is available.

One of the goals of this design is to make it compatible with both 5V and 3.3V Arduinos. Since MAX3421E is 3.3V part, I added some extra circuitry to provide 5V compatibility.

I started my testing by building 5V to 3.3V converter piece to check parts values and circuit layout. The circuit is located in the upper-left corner of the schematic and in the lower-right corner of the board. Please also take a look at the title picture if you haven’t already to see the layout. This converter comes in handy if, for example, you are using 5V Arduino and/or need to provide Vbus power for bus-powered peripheral and want to use this supply to power the shield/Arduino also. Converter is rated for 600ma, enough to power both MAX3421E and Arduino, if necessary.


Continue reading Arduino USB Host Shield build log. Part 1.

USB Host Shield for Arduino – first prototype.

Arduino USB Host Shield PCB

Arduino USB Host Shield PCB


While developing Arduino code for MAX3421E USB Host controller I was thinking about making a shield for it. Sure, breakout board riding on top of protoshield works just fine, however, some people don’t like the wire clutter. Additionally, since many Arduinos are 5V devices, level translation may be necessary. I was playing with different configurations, and routed a draft prototype to build and see how it would look like. I received PCBs today from BatchPCB – just in time before the weekend.

In addition to MAX3421E with accompanying parts, the shield contains level translating logic for all signals and GPIN/GPOUT ports, and 3.3V to 5V step-up and 5V to 3.3V step-down converters. I decided to use DIP packages for level translators – this way if translation is not necessary, the PCB can be simply modified with jumper wires.

I’m going to start building/debugging this board today and produce final version in 2-3 weeks. After that, the plan is to order a batch of boards, build them and send to beta testers. If you want to participate in testing, leave a comment and I’ll put you on a list.

Oleg.

Xbee microcontroller board.

Xbee PCB

Xbee PCB


After playing with Xbee connected to a PIC I decided to transfer the design from the protoboard to make it more pretty and compact. The following board contains Xbee connectors, PIC18F26K20, bypass caps and Vpp limiter to use with old programmers/debuggers. I wrote several articles describing the circuit and it’s capabilities, see “Related posts” for more information.

As usual, Eagle files are available from download section. The PIC code written for Xbee protoboard will work here with very little modification. This board is good as a base for more complex sensors which require MCU on-board.

I am working on several applications for this board and will be posting results here this summer.

Oleg.