Arduino reading digital scale
I am the proud owner of Stamps.com Model 510 5lb digital scale. It is a nice little scale which works very well (much better than Stamps.com service itself) while attached to my workstation. The scale doesn’t have a display making any kind of standalone use difficult. However, since the scale is a USB HID device reading data from it should be as easy as from a joystick and Arduino board should be adequate to provide a display function for it. To test this theory I made a simple setup consisting of Arduino UNO, USB Host shield and HD44780-compatible LCD display. I also wrote a small sketch which polls the scale and outputs the weight. The secondary objective of this project was to demonstrate LCD support in USB Host shield library.
For this project I used the following:
- An Arduino board. Standard size board, such as UNO, Duemilanove or Leonardo, will work
- USB Host Shield
- Toshiba HD44780-compatible LCD display, in 16×1 or 16×2 configuration. If you’re planning to use this sketch for something else, like data logging, the display is optional – all output from the scale is repeated to the serial port
- Stamps.com 5lb digital scale. Scales are standard HID devices with usage table 0x8d, therefore, scales from other brands may work as well with no or minimal modifications to the code
- USB Host library
The example code is also hosted at github, as well as in ‘examples’ section of the library under ‘HID’. It has been tested with Arduino IDE version 1.0.5.
In this project, the LCD is connected to the shield’s GPOUT pins, as documented in max_LCD.h header file. In addition to data lines, 5V and ground must also be connected to the shield’s 5V and GND terminals; the RW pin must be grounded – I do it on the LCD itself. In order to see the characters, the display must be biased – a 5K-10K pot with wiper on Vo and other two pins on 5V and ground will provide contrast adjustment.
Continue reading Adding a display to a digital scale using Arduino and USB Host shield
Power switch populated
About a month ago I started shipping USB host shields built on PCB bearing revision number 2.0.1. On this PCB I added a new feature, suggested by Andrew Kroll – a VBUS power switch. The board comes with power switch unpopulated and if you don’t care about this feature it can simply be ignored. However, if you do care about power control, read on.
The ability to turn VBUS on and off at will can be very beneficial. In battery-powered projects the run time can be significantly increased by powering on USB device only when needed. Some other devices can’t even be initialized reliably without a powercycle. Also, many power switches incorporate current limiting circuitry allowing VBUS overload detection and prevention.
An example of populated power switch is shown in the title picture (click on it to make it larger). A is a power switch IC (in this case, Micrel MIC2004). B is 0.1uF ceramic capacitor in 0603 package. C is a wire from MAX3421E GPX pin to the ENABLE pin of the power switch. Finally, D is VBUS Power jumper which needs to be opened, as pictured. Current revision of USB Host 2.0 library is needed to support power control.
Next picture will be used to explain the details of the power control circuitry.
Arrow A points to the jumper which needs to be cut open
Arrow B shows the position where 0603 0.1uF ceramic capacitor needs to be placed
C and D show the places for the power switches (only one switch is needed). Many switches packaged in SOT23-5 and SOT23-6 use this footprint, use On Semiconductor NCP380 as a reference. Also, some other 5 pin switches, such as Maxim MAX4793 and Micrel MIC20xx, will work while placed on SOT23-6 footprint, as shown on the title picture.
Certain switches, such as 6 pin NCP380, allow for adjustable current limit. The position for current setting 0603 resistor is marked ILIM – for the value of this resistor consult the datasheet for the part you’re planning on using
Many switches provide FAULT pin to signal various fault conditions, like output overload, reverse votage, or over-temperature. The pin is typically active low open drain type. It is broken out to a pad labelled VBUS OVL. The signal can be used in several different ways. A LED with a series resistor can be connected across VBUS OVL and a power rail. Also, it can be connected to a MCU input. In this case, a position labelled 10K should be populated with 0603 resistor, typical value is 10K. The other (upper) end of the resistor is connected to 5V rail with a trace which is placed under the letter K; if 3.3V level signal is desired, cut the trace and solder the upper end of the resistor to the 3.3V rail.
The power control signal is labelled VBUS EN. The library uses GPX pin for
Init() functions. There is also a variant of
Init() function which will hold the VBUS off for the number of milliseconds passed to it as a parameter. See usbhost.h file for details. Also, testusbhostFAT.ino demonstrates usage of powercycling
Continue reading VBUS power control on USB Host shield
TM240A building USB Host Shields
Some time ago I noticed that I’m spending more time building boards and less time developing and needed to increase my manufacturing capabilities. After thorough reading Dangerous Prototypes’ Chinese desktop pick and place machine forum thread I got in contact with a factory and bought TM240A – the big brother of TM220A. Earlier this week a DHL van carrying 70kg crate pulled in my driveway. After a day of hands-on learning I started building boards. This article was written after 2 days of using the machine and contains my first impressions as well as a couple of hints.
First, it is a real Chinese machine – well built, simple, and reasonably priced. At the same time, an owner must be prepared to fix mechanical issues and work around software bugs without relying on manufacturer’s support – the folks at Neoden are helpful but due to a time difference a reply to an e-mail would arrive the next day. Fortunately, the user base for these machines is expanding and the thread linked above as well as videos by Ian@DP and other people provide lots of useful info.
I was ready to face issues like air lines clogged by small pieces of styrofoam, non-functioning vacuum pumps and such; luckily, the only problem out-of-the box was racked gantry causing feeding fault. Thanks to this post in DP thread I was already aware about the symptoms as well as the fix – so I fixed it. While doing this I learned that to implement the fix no tools were necessary – a typical human finger jammed between the front support and the gantry works just as well as originally specified screwdriver.
I loaded some tapes and proceeded to stuffing boards. During test runs double sided removable scotch tape placed over the pads helped keeping parts in place. “Removable” type is preferable since it leaves no residue. Also, since the machine has no vision, accurate board registration is paramount. Here is how I do it.
Continue reading Neoden TM240A Pick and Place machine – first impressions
The product being tested on animals
To make my growing season preparations more high tech I built a grow light with more than 25000 lumens light output while spending less than US$300. During the build I posted pictures/short notes on Makers, Hackers, Artists and Engineers Google+ community and received a lot of questions concerning LED choice, drivers, build of materials and construction details. This article is intended to answer these question and hopefully generate others – please don’t hesitate to ask!
The goal of this project was to produce a decent grow light for personal indoor gardening – mainly starting vegetables for subsequent transplanting outside some time in May and possibly extending the grow season in the autumn. While trying to determine necessary light output I realized that good numbers are impossible to find. By reading numerous indoor gardener’s forums I learned that people are having good results with light sources ranging from household-type compact fluorescent bulbs to high pressure sodium street lights. After analyzing pros and cons of all available light sources I decided to use high-power white LEDs. Here’s why:
- They are low-voltage devices therefore they are much safer to work with than HID/fluorescent light sources. Low-voltage (<60V) LED drivers are also inexpensive
- They are efficient as grow lights. Photosynthesis in plants occurs differently under different wavelengths of light; the “good” light is known as Photosynthetically active radiation (PAR). White LED emits most of its light in PAR – out of all light sources it produces most “PAR lumens” per unit of electricity used to produce these lumens. In addition, LED outputs all its light from one side therefore a light fixture doesn’t need a reflector.
- They can last long time. LED manufacturers specify 50000 hours at some pretty high emitter temperature (75-85C) – it’s 11.4 years if lights are on 12 hours a day. At the end of 500000 hours a LED maintains 70% of its light output. The main factor here is temperature of the LED – if it is kept lower than specified the LED will last longer (and produce more light, see below).
Continue reading High-power LED grow light – a build log
While designing USB Isolator I needed a 5V supply to power the device side. I picked Linear Technology LT1376-5 part which proved to be pretty reliable and mellow converter. I’ve had used this part for 3.5 years now, in a product and also in the kit and I haven’t had any serious issues with it. Some time ago I decided to put together another kit based on the same controller – at this time containing only PTH components to make assembly easier for beginners. This kit is now available at the store for $20 plus shipping and the following is a short overview of the capabilities.
The kit contains a PCB plus all parts necessary to build a DC-DC step-down converter. Voltage setting resistors to make output of 3.3V, 5V and 12V are included. The converter is capable of supplying 1A at any of the output voltages over 6-25V input voltage range ( 23Vmax for 12Vout), and can be pushed up to 1.3A if input and output voltages are close enough. Output voltage ripple is 50mv@1A.
The biggest advantage of switch mode supplies is efficiency. It is possible, for example, to step down from 24V to 3.3V without generating excessive heat even at 1A load. Also, switchers are fascinating circuits, fun to build and play with.
In addition to full kit, a bare PCB is offered for makers who prefer to source parts themselves. Eagle CAD files of the circuit are also available.
Dummy load Jig Complete
Here is a little jig I made to test and characterize the BLDC controller I wrote about a while back. It is a dummy load consisting of two coupled motors: one driven by a controller and another having its windings shorted either directly for maximum load or through series resistors when measured load is desired. Title picture shows finished jig (click on it to make it larger). The construction details follow.
Two brackets made of 2″ aluminum angle profile hold 50-size brushless outrunner Chinese motors rated at 100A. The brackets are bolted to 0.5″ polycarbonate base. The motor shafts are coupled with a flex coupler. Finally, the contact plates are bolted next to each motor – this way if I burn a motor, changing will be easy. The high-current wires are soldered to the female contacts. I’m using double wires to increase current capacity of the wire and also to allow observing half of the flowing current with my little 50A current probe.
I tested the load with my prototype BLDC controller and was very pleased with results. The testing is documented in the short video – check it out.
I got pretty tired of coding recently and had to switch my brain to something as distant from USB protocol as possible. Also, I’ve being planning a quadcopter build for which I need a motor controller less basic than PPM-driven R/C electronic speed controller AKA ESC. I needed something fast, reliable and scalable and at the same time not too hard to understand. After studying several existing open source designs I decided to make my own. This article is a status report of testing the initial prototype of sensorless brushless DC motor controller.
The prototype can be seen in the middle of the title picture (click on it to make it bigger). The green board contains a controller ( Allegro A4960 ) plus power stage – 6 N-type MOSFETS. In addition to performing typical control functions – setting speed and direction of 3-phase brushless sensorless DC motor, this controller also has a tachometer and fault indicator outputs as well as number of configuration registers available via SPI interface. The controller IC consists of 2 main functional blocks – a logical interface and power bridge driver. The former is compatible with 3.3V and 5V logic and the latter is specified in 5.5V-50V range (startup is possible from as low as 6V), making it suitable for projects ranging from 2S LiPo-powered models to electric scooter drives.
Continue reading Advanced brushless DC motor controller
Scanning barcodes using Arduino and USB Host Shield
An addition of Human Input Device Class support to USB Host Shield library 2.0, announced several days ago allows using powerful and inexpensive input devices with USB interface in Arduino projects. Sample sketches demonstrating sending and receiving data to one of the most useful HID device types – boot keyboard/mouse, has been released along with the library. The beauty of boot protocol lies in the simplicity of device report – a data packet containing information about button presses and mouse movements. However, samples were designed to demonstrate all features of the class and because of that, they are somewhat heavy. In real-life applications, it is often not necessary to implement each and every virtual function – only what is needed. In today’s article I will show practical application of HID boot device building a simple gadget.
Originally, HID boot protocol was meant to be used with keyboards and mice. When USB became popular, other keyboard-emulating devices, such as barcode scanners and magnetic card readers have been migrated from PS/2 standard to USB while keeping their keyboard-emulating property. As a result, many modern “not-so-human” input devices behave exactly like a keyboard including boot protocol support. A gadget that I demonstrate today is portable autonomous barcode scanner built using Arduino board, USB Host shield, handheld USB barcode scanner and LCD display (see title picture). The operation is simple – when handheld scanner button is pressed, it scans the barcode and sends it to Arduino symbol by symbol. Arduino then outputs these symbols on LCD display. LCD is erased before outputting each new barcode by tracking time between arrival of two consecutive symbols. To keep the code simple, I intentionally did not implement any data processing, however, since Arduino sketch for the gadget compiles in just a little over 14K, there is plenty of memory space left for expansion.
Continue reading Connecting barcode scanner to Arduino using USB Host Shield
HID r.2.0 released
I pleased to announce that after a long and difficult development period Human Input Device AKA HID class support has been added to USB Host Shield Library r.2.0 and is available on gitHub – I suggest downloading the whole directory, since some modifications has been also made to core files to accommodate a new class. HID devices include popular devices like keyboards, mice, joysticks, game controllers, bar code scanners, RFID and magnetic card readers, digital scales and UPSes, to name a few.
I previously wrote about interfacing to HID devices here, here, and here. The code examples in these articles were written for legacy USB Host Shield library and can’t be compiled with current revision, however, the basic principles are the same – the device is periodically polled by the host and sends back data block called report containing changes in device controls (buttons, switches, jog dials etc.) since the last poll. Even though different devices have different report formats, for a certain device, report format is stored in the device in data structure called report descriptor. Therefore, it is possible to learn about device controls from the device itself by parsing its report descriptor.
There is one special case where report format is known in advance. Almost all HID keyboards and mice support so-called boot protocol intended for communication to very simple systems like PC configuration screen when computer runs from BIOS. Keyboard boot protocol report consists of 8 bytes containing state of modifier keys (CTRL, SHIFT,etc.) in the first byte, second byte being reserved, and up to 6 key scan codes in the rest of the report. Mouse boot protocol report consists of 3 bytes, first of which contains state of left, right and middle buttons and other 2 store X and Y travel since last poll.
In many cases boot protocol capabilities are more than enough for an Arduino project; for this reason, boot protocol class is the first to be released. To demonstrate operations of this class, 2 simple sketches has been developed, one for mouse, another for keyboard.
Continue reading HID support for USB Host Shield Library 2.0 released