Silicon ChipBuild A USB Port Voltage Checker - July 2013 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Nuclear power is the answer
  4. Feature: 100 Years Of AWA by Kevin Poulter
  5. Feature: Cheap & Cheerful Smart TV Conversion by Julian James
  6. Project: DIY Wireless Audio Streaming by Nicholas Vinen
  7. Project: Li'l Pulser Model Train Controller, Mk.2 by John Clarke
  8. Feature: Secure Digital Cards: Clearing Up The Confusion by Nicholas Vinen
  9. Project: Add A UHF Link To A Universal Remote Control by John Clarke
  10. Subscriptions
  11. Project: Build A USB Port Voltage Checker by Nicholas Vinen
  12. Vintage Radio: Restoring an AWA B15 AM broadcast receiver by Rodney Champness
  13. PartShop
  14. Market Centre
  15. Advertising Index
  16. Outer Back Cover

This is only a preview of the July 2013 issue of Silicon Chip.

You can view 19 of the 104 pages in the full issue, including the advertisments.

For full access, purchase the issue for $10.00 or subscribe for access to the latest issues.

Items relevant to "DIY Wireless Audio Streaming":
  • Software for DIY Wireless Audio Streaming (Free)
Items relevant to "Li'l Pulser Model Train Controller, Mk.2":
  • Li'l Pulser Mk2 Revised PCB [09107134] (AUD $15.00)
  • Li'l Pulser Mk2 front & rear panels [09107132/3] (PCB, AUD $20.00)
  • Li'l Pulser Mk2 Revised PCB pattern (PDF download) [09107134] (Free)
  • Li'l Pulser Mk2 panel artwork (PDF download) (Free)
  • Li'l Pulser Mk2 PCB pattern (PDF download) [09107131] (Free)
Articles in this series:
  • Li'l Pulser Model Train Controller, Mk.2 (July 2013)
  • Li'l Pulser Model Train Controller, Mk.2 (July 2013)
  • Li'l Pulser Mk2: Fixing The Switch-Off Lurch (January 2014)
  • Li'l Pulser Mk2: Fixing The Switch-Off Lurch (January 2014)
Items relevant to "Add A UHF Link To A Universal Remote Control":
  • Infrared to UHF Converter PCB [15107131] (AUD $5.00)
  • UHF to Infrared Converter PCB [15107132] (AUD $10.00)
  • Revised 10-Channel Remote Control Receiver PCB [15106133] (AUD $12.50)
  • PIC12F675-I/P programmed for the IR-to-UHF Converter [1510713A.HEX] (Programmed Microcontroller, AUD $10.00)
  • PIC12F675-I/P programmed for the UHF-to-IR Converter [1510713B.HEX] (Programmed Microcontroller, AUD $10.00)
  • PIC16F88-I/P programmed for the revised 10-Channel Remote Control Receiver [1510613B.HEX] (Programmed Microcontroller, AUD $15.00)
  • Firmware (ASM and HEX) files for the IR/UHF Link [1510713A/B.HEX] (Software, Free)
  • Firmware (ASM and HEX) files for the Revised Versatile 10-Channel Remote Control Receiver [1510613B.HEX] (Software, Free)
  • IR/UHF Link PCB patterns (PDF download) [15107131/2] (Free)
  • 10-Channel Remote Control Receiver revised PCB pattern (PDF download) [15106133] (Free)
  • Infrared/UHF Link lid panel artwork (PDF download) (Free)
Items relevant to "Build A USB Port Voltage Checker":
  • USB Port Checker PCB [24107131] (AUD $5.00)
  • USB Port Checker PCB pattern (PDF download) [24107131] (Free)

Purchase a printed copy of this issue for $10.00.

USB Port Voltage Checker Above: the unit can be used to check for voltage fluctuations when an external USB-powered unit is connected in-line with the voltage checker. By NICHOLAS VINEN If you carry valuable data around on a USB flash drive, it’s not a good idea to plug it into other people’s computers willy-nilly. They could have dead or faulty USB ports and an incorrectly wired USB port can destroy a flash drive. Tragedy! Test it first with this handy USB Port Voltage Checker. U SB DEVICES ARE convenient for many reasons and one of these is that you can walk up to just about any computer anywhere and plug a USB peripheral in. This is most useful for storage devices like flash drives and hard drives but can apply to just about anything. But unless it’s your computer and you know the ports are all working OK, there is the possibility that your treasured USB device will be damaged by a faulty port. This could happen for a few reasons. One is that front-panel USB ports are normally plugged into a USB pin header interface on the computer’s motherboard via a multicore cable and these can be plugged in incorrectly, causing the port supply voltage to be reversed. That could easily damage a connected device. In fact, in this case, damage is likely. There is also the possibility that the computer’s power supply has a poorly regulated 5V rail, giving a port voltage that is too high, too low or fluctuating. This also applies for powered hubs and other devices where a failed 84  Silicon Chip plugpack could easily lead to trouble. Port voltages that are too high could also damage a connected device while voltages that are too low (permanently or only when current is being drawn) could lead to erratic device operation. Well, that’s enough about what could go wrong. This checker will show you when a USB port’s voltage is in the correct range so you can plug in your flash drive or other device with confidence. You can even leave the unit connected and plug the device in piggy-back style, so you can continue to monitor the supply voltage during operation, to ensure it doesn’t fluctuate too much. The USB Port Checker is just 67 x 17 x 10mm – not much longer than flash drive. It’s built on a small doublesided PCB measuring 44 x 17mm and is encapsulated in clear heatshrink tubing for protection. It uses a mixture of through-hole and surface-mount devices to keep it compact. Circuit description Fig.1 shows the full circuit. The USB plug (CON1) and socket (CON2) – both Type-A – are wired straight through so the function of any USB device connected to CON2 is not affected. The D+ and D- signalling lines are run close together down the middle of the PCB so that the digital data signals are not affected, as well. Schottky diode D1 rectifies the USB supply voltage so that if the polarity is reversed, nothing happens – no LEDs light, including the green one, so you know something is wrong with the port. This is a dual diode with a common anode connection but we’re using them both in parallel. Why do this? Simply because we need one elsewhere and it’s easier to use two identical parts than two different ones. If all is OK, LED1 (green) is lit and this simply runs off the rectified voltage of around 4.7V with a 680Ω current-limiting resistor. Typical LED current is around (4.7V - 2V) ÷ 680Ω = 4mA. IC2 is a 2.5V reference “diode” which is actually an integrated circuit siliconchip.com.au D1 BAT54A +4.7V K1 A VOLTS LOW 1 F K2 LED2 100k 3 2.5V IC2 LM285D –2.5 CON1 CON2 1 2 3 4 +V D– D+ GND TYPE A PLUG 1 2 3 4 +V D– D+ GND TYPE A SOCKET IC1a 2 D2 BAT54A 18k 22k* 680 1 IC1: LM393D K1 A A VOLTS OK  LED1 K2 RB# 1 F 5 IC1b 6 # OPTIONAL – SEE TEXT * FOR USB 3.0 VERSION – SEE TEXT 7 4 160k 120k* USB PORT VOLTAGE CHECKER A K1 LEDS IC1, IC2 BAT54A SC K RA# K 2013 VOLTS HIGH  LED3 680 8 8 4 A  K 110k* 160k 680 A 8 4 1 K2 K A Fig.1: complete circuit of the USB Port Checker. It’s based on dual comparator IC1 and voltage reference IC2. If the voltage is OK, green LED1 is lit while yellow LED2 and red LED3 indicate under-voltage and over-voltage respectively. If the supply polarity is reversed or voltage is very low, none of the LEDs light up. with two pins (well, it has eight but six are unconnected). It is effectively a shunt regulator and it runs off the 4.7V supply via a 100kΩ resistor. That gives it a current of about (4.7V - 2.5V) ÷ 100kΩ = 22µA, with its recommended minimum being 10µA. One half of dual low-power comparator IC1a compares this 2.5V reference to a divided-down version of the USB supply voltage. This is achieved with a resistive voltage divider comprising two 160kΩ resistors and an 18kΩ resistor. IC1a’s inverting input (pin 2) is connected to the 2.5V reference while the voltage at the non-inverting input is at V+ x 0.527 where 0.527 is the divider ratio, calculated as (160kΩ + 18kΩ) ÷ (160kΩ x 2 + 18kΩ). For USB 2.0, the minimum supply voltage is specified as 4.75V. If we plug this into the formula above, we get 4.75V x 0.527 = 2.5V which is the same as the 2.5V reference it is being compared against. So when the USB supply drops below 4.75V, pin 3 of IC1a goes below 2.5V and IC1a’s output switches low, turning on LED2, again with a current of about 4mA. At the same time, IC1a also turns off green LED1 by pulling its anode low through half of dual-Schottky diode D2. Thus, if the USB voltage is too siliconchip.com.au low, the yellow LED turns on and the green LED turns off. A 1µF capacitor across LED1 ensures that it is switched off for a minimum period (a few milliseconds) even if there is a brief drop in the USB voltage. That won’t be noticeable in isolation but if the USB voltage is dropping below 4.75V often enough, it means that LED1 will either dim or go off entirely. Note that the PCB has provision for an SMD resistor labelled RA to add hysteresis for comparator IC1a. However, we don’t think it’s necessary. Over-voltage checking The circuit to detect over-voltage is similar. In this case, comparator IC1b is used, as is the same 2.5V reference voltage from IC2. This time, however, the division ratio is different as IC1b’s inverting input is connected to the other end of the 18kΩ resistor. That means the formula to calculate the comparator threshold is V+ x 0.473, which means the upper threshold is a little above 5.25V. Again we can check this by doing the calculation: 5.25V x 0.473 = 2.48V. So red LED3 will turn on if the supply voltage goes much over 5.25V. As with IC1a, IC1b’s output going low also turns off LED1, via the other half of dual-diode D2. Pads for a hysteresis resistor (RB) are supplied but as before, we don’t think it’s necessary. If RB is fitted, its value will need to be chosen carefully – see below. USB 3.0 support The 4.75-5.25V (ie, 5V±5%) USB supply range is from the USB 2.0 specification. The newer USB 3.0 specification allows for more current to be drawn by USB devices and as such, also allows a wider variation in supply voltage, ie, 4.45-5.25V. While we don’t think it will happen very often, this means that with a USB 3.0 port, the under-voltage indication (ie, yellow LED lit) could occur while operating within specifications. If you want to accommodate this, you can do so by changing the divider resistor values, ie, use the values shown in red on the circuit diagram. The divider ratios then become 0.563 and 0.476, giving an upper threshold of 2.5V ÷ 0.476 = 5.25V and a lower threshold of 4.44V. Accuracy The 2.5V version of the LM285 voltage reference has a tolerance of ±1.5% July 2013  85 3 2 D2 BAT54A CON1 4 3 2 1 1 680 160k^ 18k* 1 F CON2 680 4 D1 IC2 LM285 IC1 LM393 1 F 24107131 1 CON2 A G USB Checker 3 2 A Y C 2013 R 100k A 4 680 CON1 160k # BAT54A REAR VIEW FRONT VIEW * 22k USB 3.0 VERSION # 110k USB 3.0 VERSION ^ 120k USB 3.0 VERSION Fig.2: follow these PCB overlay diagrams to assemble the USB Port Checker. The SMD parts (ICs, diodes and capacitors) all go on the top side along with the LEDs and connectors, while the resistors are all fitted on the bottom side. The two empty pads on the bottom are for optional hysteresis setting resistors. These photos show the front & rear of the completed PCB. Take care soldering in the SMDs and check that the diodes & ICs are correctly orientated. You can remove solder bridges across the IC pins using solder wick. which translates into an error of about ±0.08V referenced to the USB supply voltage. Taking into account resistor tolerances and variations in the forward voltage of D1, the maximum error could be more than that. There is also a roughly +5-10mV error due to the input bias current of IC1a and IC2a flowing through the divider network. An error of ±0.1V would be fairly significant compared to the ±0.25V specification for the USB 2.0 supply but this is a worst case figure and without taking any special care, our prototype’s thresholds measured very close to what we calculated above. You would be unlucky to build one of these and find it had more than ±0.05V error. Our (randomly chosen) LM285 measured 2.4946V which is an error of just -0.22%. One easy way to check the accuracy of your voltage reference IC is to use a DMM to measure the voltage across its lower-left and upper-right pins while power is applied. If your reading is much lower than ours, try reducing the value of the 100kΩ resistor feeding it (eg, to 10kΩ) as a higher operating current should (slightly) increase the reference voltage. Construction Fig.2 shows the assembly details. Begin the construction by fitting the The through-hole components can then go in. The resistors go on the other side to the SMDs (check each one with a DMM before fitting it). The three LEDs go on the same side as the SMDs, with their anodes to the edge of the board. Finish up by fitting the two USB connectors – the socket (CON2) is optional but recommended. Ensure that their mounting tabs are fully pushed into the corresponding holes on the PCB before soldering them and then finally the signal pins. You can test it by simply plugging it into a known-good USB port; the green LED should light while the others should remain off. If you have a variable voltage DC supply, you can wire it up across the USB pins (using a spare plug perhaps) and then vary it between 4.5V and 5.5V to check that the yellow and red LEDs come on at the correct voltages. Once you’re satisfied, slide some clear heatshrink tubing over the unit and shrink it down. SMD components to the PCB, which is coded 24107131. Install the two ICs first. Figure out which is which and then locate pin 1 which is normally indicated by a divot or dot in the corner of the plastic package. It could also be indicated by a stripe along the top of the IC (between pins 1 & 8) or by a bevelled edge which will be on the pin 1 side. Put a little solder on one of the IC pads then place the chip in the correct position, with pin 1 at upper-left. While heating that solder, slide it into position. You can re-heat the solder and adjust it if necessary, then solder the rest of the pins. Finally, add a little solder to the first pin you soldered, to refresh it. If any pins are bridged, you can clear them using solder wick although often all that’s required is to slide the soldering iron tip between the pins and then back again (assuming it’s fine enough). Now fit the two SMD dual diodes. Their orientation should be obvious as long as they are not upside-down, ie, solder them with their leads touching the PCB. Then mount the two ceramic capacitors, again using a similar technique but make sure you wait a bit between soldering one pad and the other to ensure the first joint has solidified before making the second. Hysteresis As noted above, you probably don’t need to add resistors for comparator hysteresis. The advantage of hysteresis is that a brief excursion beyond one of the thresholds is more likely to cause Table 1: Resistor Colour Codes o o o o o o o o No.   2   1   1   1   1   1   3 86  Silicon Chip Value 160kΩ 120kΩ 110kΩ 100kΩ 22kΩ 18kΩ 680Ω 4-Band Code (1%) brown blue yellow brown brown red yellow brown brown brown yellow brown brown black yellow brown red red orange brown brown grey orange brown blue grey brown brown 5-Band Code (1%) brown blue black orange brown brown red black orange brown brown brown black orange brown brown black black orange brown red red black red brown brown grey black red brown blue grey black black brown siliconchip.com.au USB Port Polarity: A Simple Approach This project was inspired by reader Bruce Pierson, who sent in details of a simple design to check USB port supply polarity. As you can see, his design consists of just a USB plug (surfacemounting type), a LED and a resistor, all soldered to some Veroboard and housed in the plastic case from a defunct flash drive. If all you want to do is check the supply polarity then this is not a bad idea and it’s certainly much less complicated than our approach. But obviously, it won’t the LED to come on and stay on rather than flicker so briefly that you may not notice it. In practice, what happens as the bus voltage crosses the threshold is that one LED appears to fade in while the other fades out, due to rapid switching between them. If you decide to add hysteresis, choosing a value for RA is fairly simple. With RA = 10MΩ, once the supply voltage drops below the lower voltage of 4.75V, this threshold is changed to about 4.77V by the fact that RA is effectively in parallel with the lower part of the voltage divider. In other words, it will give about 20mV of hysteresis. A lower value resistor will give proportionally more hysteresis. Much more than 100mV of hysteresis is probably not desirable, giving a minimum value of 2.2MΩ or so. Note that fitting RA will also shift the lower threshold needed to turn on LED2 as well, but only very slightly. Choosing a value for RB is more tricky, because when IC1b’s output is low, it is effectively in parallel with IC2 and we must also consider that some or all of IC1b’s input bias current will flow through it. A sensible value would be around 91kΩ. This forms a 220 USB TYPE A PLUG A 1 2 3 LED  K 4 Fig.3: Bruce Peirson’s simple USB Tester. K A give you much clue as to whether the bus voltage is too low or too high unless it is grossly so and you will have no way of monitoring the bus voltage on that port while another device is connected. divider with the 100kΩ resistor supplying current to IC2 such that the reference voltage should be pulled down to about 2.35V when IC1b’s output is low, providing around 0.3V of hysteresis for the lower supply threshold. We haven’t tried this though and obviously, if you change the 100kΩ resistor value you will need to scale RB similarly. The pads for RA and RB are designed to accept metric 3216 or imperial 1206-sized SMD chip resistors. Using it Simply plug it into a USB port. If it shows a green light, it’s OK. You can then either unplug the checker and connect your USB device or you can simply leave it in and plug your device into its socket. It should not affect operation. If no LEDs light, then either the port is dead or its supply polarity is reversed. Either way, we don’t recommend plugging anything else into that port before you check it out. Similarly, if you get a red LED, be careful – the voltage may be just a touch high. Most USB devices won’t be damaged but you will need to measure it to be sure. The completed PCB can be protected using clear heatshrink tubing (so that the LEDs are still visible). Make sure it’s working correctly before shrinking this clear tubing into place. siliconchip.com.au Parts List 1 double-sided PCB with platedthrough holes, code 24107131, 44 x 17mm 1 PCB-mount USB type A plug (CON1) (element14 2067044 or 1696544) 1 PCB-mount USB type A socket (CON2) (element14 1696534, Jaycar PS0916, Altronics P1300) – optional, see text 1 60mm length 16mm-diameter clear heatshrink tubing Semiconductors 1 LM393D dual low-power comparator (IC1) [SOIC8] (element14 4380563 or 2294229) 1 LM285D-2.5 micropower voltage reference (IC2) [SOIC-8] (element14 8389195) 2 BAT54A dual common-anode Schottky diodes (D1-D2) [SOT23] (element14 1081191) 1 green 3mm LED (LED1) 1 yellow 3mm LED (LED2) 1 red 3mm LED (LED3) Capacitors 2 1µF 16V SMD ceramic [3216/1206] (element14 1683655, Altronics R9950) Resistors (0.25W, 1%) 2 160kΩ^ 1 22kΩ* 1 120kΩ* 1 18kΩ^ 1 110kΩ* 3 680Ω 1 100kΩ * for USB 3.0-compatible version ^ for USB 2.0-compatible version Note: a kit for this project is available from Jaycar, Cat. KC-5522. If the yellow LED is lit, the low voltage is unlikely to damage anything but your USB device may not get enough power to operate properly. Note that if the bus voltage is very low, it’s possible that the red LED could also light (dimly). Some chargers which use USB ports can put out as much as 6V. This is most common with high-current chargers in the 2-3A range, such as those for tablet computers. We believe that this is an attempt to get the maximum current through the USB cable. While most devices will tolerate 6V, some could overheat and in theory damage could occur, so take care plugging anything not designed for these chargers into SC them. July 2013  87