Wednesday, October 31, 2012

Measuring the current drain of a USB device

I've got a evaluation module of the Texas Instruments ADS1292R analog front end (AFE) for electrocardiography (ECG) applications which I'm incorporating into a prototype application. The AFE chip itself doesn't consume much current (10mA while measuring), but it's hard to tell what the entire evaluation board uses considering there is a MCU, LEDs, flash memory and a few other devices on board.

I needed to see what kind of current was being drawn by this board as the intention is to run the application on batteries. The board uses a USB port for both power and communications.

One idea I had was to splice a USB cable and route the 5V line though a multimeter in current mode. However digital loads can be very variable, and it would be difficult to gauge the total charge consumed by an ECG measurement cycle from a multimeter.  I really want a chart of current vs time at a high (millisecond) time resolution.

My solution was to cut a USB cable and add a low value current sense resistor in series on the 5V line. I chose the lowest value I had in my parts drawers: 1.8 ohms. The problem with current sense resistors is that there will be a significant voltage drop at high currents. At the normal USB maximum of 500mA that would be a drop of 0.9V on the 1.8 ohm resistor. Given that the board used 3.3V logic and I expected no where near the 500mA draw I figured 1.8 ohms as an acceptable value.

Sense wires were soldered to both sides of the resistor (orange and white) which were then connected to two probes of an oscilloscope. The scope was then set to display the difference between the two channels. The resulting voltage trace when divided by the resistor value is the current being drawn on the USB bus as a function of time.


In retrospect the choice of 1.8 ohms was too low. It turns out this board does not draw much current.  Due to the resolution limits of the scope the difference between the two voltages is pretty much zero. Yes, I could hook up the sense wires to a differential amplifier... was hoping to avoid any extra electronics. However it did confirm that whatever current was being drawn by the evaluation board is on the low side which is all I need to know right now.

To illustrate this cable in action I connected an Android phone. The host side of the 5V bus is channel 1 (yellow), the device side channel 2 (green) and the difference is in pink. The voltage difference must be divided by the value of the sense resistor (1.8 ohms) to arrive at the current. So that's 400mV peak-to-peak (ie 222mA bursts) and a mean difference voltage of 67mV ie 37mA mean current draw.

Obviously hacking a cable like this isn't going to do wonders for its performance at high speeds. But so far I have not noticed any ill effects.

Philips CFL bulb tear down

I experienced a rare CFL bulb failure last night (I've got about 16 bulbs installed about 12 years ago. This has been the third failure to date). For the past few weeks this bulb was taking longer than normal to ramp up to full brightness, so I suspect a tube failure.

I couldn't resist having a quick peek inside the blown bulb. I opened by prying with a large flat head screwdriver:

This is the electronics board:

Nothing exciting: a transformer, 5.6uF 360V capacitor (the large can on top), 2 x ST 13003A NPN power transistors and a hand full of miscellaneous discretes.

And the tube:

Disclaimer: Don't try this if you don't know what you're doing. There is a trace amount of mercury (toxic!) inside the tube and you can injure yourself on the glass if you break it. Dispose correctly according to local regulations afterwards.

Saturday, October 13, 2012

Searching for old Facebook posts

In the past two weeks two people I know have had difficulty trying to find a link or information from an old Facebook post. It seems that Facebook just can't do search.

Here's a work around:

Select "Account Settings" (down arrow at far top-right of screen). At the bottom of the account settings screen there is a "Download a copy of your Facebook data" link. Click on that and follow the procedure. It takes several hours for Facebook to generate an archive of all your data. Once complete you will be notified by email and a link will be provided where you can download a ZIP archive with all your stuff.

Unpack that ZIP and use your browser to navigate to the unpacked directory. Look for file "wall.html" in directory 'html'. That's a HTML page with all your posts.

Now use the browser's in-page search (usually CTRL-F or use the browser menu) to search for what you're looking for. The browser in-page search is a simple substring search... but hey... it's waaay better than what Facebook can manage.