Electronics


June 30, 2009: 5:26 pm: DanElectronics, Gadgets

Continuing with my Kill-A-Watt experimentation, I decided to look at the power consumption of my PCs.  Specifically, I wanted to check a few things that I had assumed to be true, but never actually verified:

  1. Putting a computer in sleep (aka standby) mode saves a lot of electricity over leaving it running.
  2. Turning off a computer saves a lot of electricity over putting it in standby mode
  3. Notebook computers use a lot less electricity than desktops

Here are the numbers for my oldest PC, a circa 2005 HP Pavilion a747c with a Pentium 4 CPU, running Windows XP:

HP Pavilion and Windows XP

Total Milliamps
Total Watts
Notes
Powered off
301
Powered on and idle
1340110My least energy efficient PC
Standby
704
Flea power?
Flea power?

Power usage while it is powered on and doing nothing isn’t great, more than a 90W lightbulb.   In contrast, power usage while in standby mode is barely more than a nightlight.  When turned off completely energy consumption  is not quite zero — this is true of most (maybe all?) computers with a wired network connection.  This Microsoft article calls this phenomenon “flea power”, a term that I’d never come across before today.

Here are the numbers for a new desktop PC, which I assembled earlier this year.  The key hardware components when it comes to power usage are the power supply unit, which is an inexpensive 550W unit from ePower, and the CPU, which is an already obsolete AMD Athlon X2.  I would expect most new desktop computers to get similar or better power usage numbers.

Homebrew desktop and Windows 7

Total Milliamps
Total Watts
Notes
Powered off
402-3
Powered on and idle
108080Not bad compared to the older PC with XP
Sleep
1005

The most striking thing here is how much less this PC uses than the older HP above, especially considering how much more powerful it is.  Credit for this likely goes to the new PSU and chip technologies — manufacturers have really focused on driving down power consumption since the HP was made a few years ago.    The other surprising number is that this PC uses significantly more power than the older PC when turned off — some of this would be going to the network connection, but I’m not sure if that accounts for all of it.

Next up is a low budget notebook computer, a Dell Vostro 1000 from late 2007:

Vostro 1000 notebook and Vista

Total Milliamps
Total Watts
Notes
Powered off
00Wireless LAN = no flea power
Powered on and idle
94067Much less than a brand new desktop
Sleep
201

As expected, even a cheap notebook outpaces a brand new desktop when it comes to power consumption.  Manufacturers have been paying attention to notebook power consumption all along, in order to make the battery last longer when unplugged.  Much of this low energy technology also benefits power consumption when plugged in.  The difference between the notebook and desktop numbers is even more stark when you consider that the notebook is powering the LCD screen too — I didn’t include screen power consumption in the desktop numbers.

Incidentally, the Vostro used absolutely zero power when not turned on because it uses a wireless network connection.

The Hummer of notebooks, a Dell XPS M1730 is last and, surprisingly, least:

Dell XPS notebook and XP

Total Milliamps
Total Watts
Notes
Powered off
301
Powered on and idle
5666The winner for energy efficiency
Standby
301
Big, but not bad
Big, but not bad

Considering that this beast dwarfs the Vostro in terms of screen size and CPU speed, the low power consumption was a pleasant surprise.  Perhaps you really do get what you pay for sometimes, or perhaps energy efficiency simply has advanced that quickly in the 18 months between when my 2 notebooks were built.

Incidentally, the XPS comes with some purely gratuitous bling – LEDs on the cover, keyboard and speakers which blink, pulsate, or do whatever else floats your boat.  I was slightly surprised to see absolutely no measurable difference when I turned on the full complement of lights — LEDs are definitely the light source (and bling source) of the future.

So, it would seem that only 2 of my initial 3 beliefs hold true, for my pack of PCs anyway.  I’ll definitely be making sure that I put unused PCs to sleep before walking away, but powering them off entirely simply isn’t worth the hassle.

May 28, 2009: 12:02 pm: Dan.Net, Electronics, Programming

A little while ago I wrote about an electronics kit from kitusrus that interfaces an LCD to a PC through its parallel port. Like all kitsrus stuff it was fun to build, and the instructions included with the kit do a great job of explaining the design of the circuit.

However, I was a little surprised that they didn’t include the source code for the Windows program that communicates with the board. Sending a “hello world” message to the LCD is fine for verifying that the kit works, but an LCD connecting to a PC could be used for so much more.

When Googling for some .Net code that I could use as a starting point for writing my own interface, I was delighted to find that somebody had already done most of the work for me. An article on The Code Project site describes the construction of a homebrew parallel port LCD connection, and includes the C# .Net code that the creator used to send data to the LCD. Out of curiosity I downloaded the code and ran the .exe to see what happened, and I was astounded to see it successfully writing The Code Project’s RSS feed to the kitsrus LCD, under Vista no less. “Hello World”, indeed.

The Code Project article’s creator wasn’t using the kitrsrus kit, but because his LCD is based on a similar controller chip, and by a lucky coincidence in the selection of parallel port pins, the code mostly worked. The only problem was that the data wasn’t scrolling across the LCD as intended, but was stuck in the last column of the display, writing only to that one position. The data was getting across, it just wasn’t being positioned correctly. This is a pretty common and easily solved problem when writing data to an LCD, as I’ll explain below.

(In order to preserve your sanity and mine, I’ll refrain some referring to “the Code Project project” and the “kitsrus kit”, and call them the “CP project” and “the kit”. Apologies to their respective trademark owners.)

Although there is no “standard interface” for connecting an LCD to a parallel port, there is a fairly close correspondence between the parallel port’s pins and the pins used by all LCDs that use an HD44780-compatible controller chip. (Most LCDs intended for use by hobbyists are compatible with this standard, dating back to the late 90s. The Wikipedia entry for HD44780 links to an Everyday Practical Electronics article from 1997.)

The CP project used an LCD based on an old Samsung KS0066 chip, and the kit contains an LCD based on the KS0070 and manufactured in 1999, and both of those are HD44780-compatible.

The Code Project author wrote 2 articles that contain all the technical information you need to know in order to understand his .Net source code: this article covers the parallel port’s pins, and this one covers the LCD’s. The illustration below is linked to his second article.

Both the parallel port and the LCD use 8 data pins, D0 through D7. Not surprisingly, both the CP project and the kit wire the 2 sets of pins in a one-to-one correspondence, D0 to D0, D1 to D1, etc. The data sent by the .Net code arrives just fine at the LCD, then.

LCDs based on the HD44780 interface also have 3 control pins: RS (register select), R/W (read/write) and E (enable). Since LCDs don’t have much to say, both the CP project and the kit do the same thing with the R/W pin – wire it to ground, putting it in a permanent write state.

By a happy coincidence, both the CP project and the kit happened to wire parallel port pin C0 to the E pin of the LCD – without pin C0 turning things off and on, nothing would have made it to the LCD. There is a non-intuitive pattern of setting the enable pin low then high then low again that is necessary to write data to the LCDs — this seems to be the thing that trips up most novice LCD programmers, but the CP project’s source code does a nice job of commenting this code so that you can understand what’s going on.

The only area where the 2 approaches differ is in the selection of the RS pin: the CodeProject board uses pin C2 while the kitsrus board uses C1. (See the CP project’s pinout diagram below). Since this pin is used to tell the LCD whether it is receiving data or instructions, and the pin needs to be high for data, this difference should have caused everything being sent to the LCD to the treated as instructions, resulting in a jumpy cursor but no characters on the screen. However, by another lucky coincidence, the parallel port pin used by the kit, C1, is reversed – it is normally high and is set to low by sending it a “1″. This results in everything sent to the LCD being treated as data — characters with no cursor control, exactly what we got.

Parallel port connections to the LCD, by Levent Saltuklaroglu, courtesy of The Code Project
Parallel port connections to the LCD, by Levent Saltuklaroglu, courtesy of The Code Project

To adapt the CP project’s code to the kit, the only change required is to redirect all signals intended for C2 to C1, and flip the bit from allow for the fact that kit’s pin is reversed.

I decided to implement this change by adding a go-between method that would convert the instructions sent by the CodeProject code to the ones required by the kitsrus board:

        private void writeToControl(int intValue)
        {
            int intModifiedValue = intValue;
            if ((intValue & 4) > 0)
				// if C2 is being set  high, set C1 high by sending it a 0
                intModifiedValue = intModifiedValue & 253;
            else
				// else, if C2 is being set low, set C1 low by sending it a 1
                intModifiedValue = intModifiedValue | 2;

            PortAccess.Output(intControl, intModifiedValue);
        }

And that’s it — the kit can now be fully controlled by the CP project’s code.

This is quite cool, since it breathes new life into a 10-year old kit. When originally introduced the kit had only a command line interface that would only run in DOS – real DOS, not the command line in Windows XP. However, the .Net code works just fine under Vista and Windows 7. By tinkering with the code you can now use the LCD as a remote display for whatever you like: RSS feeds, e-mail, twitter. A poor geek’s Chumby!

April 18, 2009: 4:29 pm: DanElectronics

Do you like to build electronics kits, but wish that more of them came with step-by-step instructions and pictures?

No?  Then, um, don’t read this article.  Do you like cats, but wish that more of them made amusing, oddly spelled comments?  Look at this!

As for electronics kits, it’s a shame that the most widely-distributed line of kits come with just Ikea-like pictograms for instructions, and don’t even try to teach you anything about the design of the electronic circuit.  Some kits, like those from Adafruit and Evil Mad Scientist Labs, get the balance just right, providing instructions that are easy to follow and educational.  Many of the best kits, though, are skimpy on the assembly details.

The kit designers are, I imagine, old hands at electronics who can solder components together as effortlessly as a kid building something out of Lego.  Things are not so intuitive to beginners, though, and even experienced kit builders will sometimes be thrown off by misleading labels on a circuit board, or 2 seemingly identical components that aren’t actually interchangeable.

So, I thought it might be useful to someone to post step-by-step assembly descriptions of kits that I build.  I also like the idea of giving my blog’s admittedly modest exposure to kits that I admire and think others might enjoy building too.

First up, kitsrus’s K134: Introduction to LCDs.

I’m a big fan of kitsrus.  Their kits tend to be geniuinely useful electronic devices, with some flexibility in how they are powered, connected to their input and output devices, and adjusted for performance.  They also include quite detailed  descriptions of the design of the circuits.  I’ve yet to be disappointed with one of their kits.

Kit 134 is, at first glance, somewhat outdated since it drives the LCD from a parallel port rather than a USB port or a microcontroller.  However, since parallel connections to LCDs are the cheapest and simplest to understand, the theory behind the circuit is well worth learning.   In addition to the relatively detailed instruction sheets included with all kitsrus kits (and also available as a PDF on their web site), kitsrus has also made available a more detailed technical writeup from an electronics magazine, Silicon Chip, and the datasheet for the somewhat obscure LCD model.  Providing the datasheet is the kind of gesture that I really appreciate from kitsrus — most kit vendors don’t even bother to give you the manufacturer’s part number.

As mentioned later in this artcle, I was also somewhat surprised to find a recent piece of open source .Net  software that is, by a happy coincidence, compatible with the kit, breathing new life into it.  All things considered, this kit is an excellent educational project as well as a useful platform for additional experimentation.

Like all of kitsrus’s kits, K134’s circuit board, shown below, is well laid out.  All of the parts are clearly labeled, the circuit connections on the back of the board are clear to the eye , and there is a reasonable amount of space between components, making the soldering less frustrating for beginners.

Who needs instructions with a board like this?  You do!
Who needs instructions with a board like this? You do!

Back of the board - excuse my flash!
Back of the board - excuse my flash!
Insert Borg joke here
Insert Borg joke here

As with any kit, it’s a good idea to start with the smallest components.   Resistors are the salad of kits building – a nice warmup to the main course.  In this case, all 4 resistors are exactly the same, 1K, so it’s hard to go wrong.

Next up are the diodes.  Unlike the resistors, these have polarity, so they must be positioned as shown.  The gray stripe on the left of the 1N4004 is obvious, but I remember being somewhat unsure when I first started building kits about whether that blank mark on the Zener diode was the stripe.  It is, so make sure that it is facing towards the top of the board, as shown in the photo below.

Diodes - right side up!
Diodes - right side up!

Diodes - right side up!

Incidentally, the thick leads on the 1N4004 diode make them a little tougher to solder, so don’t be shy about holding the solder iron next to the lead until the solder starts to flow.  As far as I know, it’s pretty much impossible to overheat one of those suckers — taking the heat is their job, after all.

The Capacitors
The Capacitors

There are 3 different capacitors in this kit.  The beige tantalum capacitor can go in either way, but the black electrolytic capacitors, like the diodes, have polarity.  The white stripes of these 2 capacitors must face towards the bottom of the board, as shown in the photo below.  This side of the capacitor, the negative, is also indicated by a shorter lead.

Electrolytic capacitors even have their size printed right on the side – 10 uF and 100 uF.  Such a helpful young component!  Unlike that stupid little tantalum capacitor.  104, you say?  Yeah, right, good to know.

The Capacitors In Profile
The Capacitors In Profile

The potentiometer is up next.  This part of the assembly is a little tricky because the kit appears to have been designed to handle 2 different sizes of potentiometers.  As a result, there are 2 different circles with 2 different pin positions on the circuit board.  My kit came with a smaller potentiometer, so the hole at the right of the larger circle is unused.

Potentiometer Junior - Size Doesn't Matter
Potentiometer Junior - Size Doesn't Matter

The potentiometer is also the first component in this build to have a gravity problem — when you flip the board over to solder the potentiometer’s leads, you’re likely to find that it pops out.  Most kit instructions, when they bother to mention this type of problem at all, will tell you to hold down the component with a finger while you solder.  Personally, I think that’s bad advice.  Unless you’re an experienced kit builder or an orangutan, you’re likely to find that this results in a) a clumsy solder joint, b) a burnt finger and/or c) a lopsided component.

Take it from me, there is no shame in using masking tape to hold down the component.  While the tape will leave a slight bit of adhesive residue, I’ve yet to have that affect a kit.  I have, on the other hand, found that clumsy solder joints and burnt fingers have a considerable effect on the kit and my piece of mind.

Five Pin Connector
Five Pin Connector

If soldering the potentiometer didn’t convince you of the merits of masking tape, the 5-pin connector at the top of the board might do the trick.  Even veteran solderers are hard-pressed to get these connectors in straight.  A guy working at SparkFun recently wrote about a clever solution to this problem — slightly offsetting every other hole so that friction holds the connector in place — but his idea won’t help you here.

Note that the small pins on the connector face down, into the board.    Don’t worry if your connector ends up crooked, or even if it is more seriously maimed, since you probably won’t be using this connector anyway.  It is used to optionally connect the thermostat chip on the board to another project — for example, if you had a heater that you wanted to control with this kit.  For the purpose of learning to program an LCD you can safely ignore the 5-pin connector.

Pins and Pot Connectors
Pins and Pot Connectors
Sorry Link, Zelda's not here
Sorry Link, Zelda's not here

Next up is the mysterious “link” connector.  There isn’t a separate part in the kit for this: you can just use the lead clipped from one of the other parts, such a a resistor.  Just fold the two ends down to form a staple-like shape, insert it into the board, and solder the two ends to underside of the board.  I have no idea what the purpose of this part is.  I’d suspect it was used to correct an error in the circuit board if  there wasn’t a silkscreened “LINK” label on the board.  If you can set me straight on the purpose of this part of the design, please add a comment below.

DC Power Jack
DC Power Jack

It’s time for one of the bigger components, the DC power jack.  This is another instance where a strip of masking tape might come in handy.  This is the first component in this build where the solder needs to do more than make an electrical connection – it also needs to hold the DC connector in place.  Unlike most of the components on the board, the DC connector will pushed and pulled as you use the board, and the only thing that will keep it in place is a big blob of solder.  So, as shown in the image below, you’ll want to be generous with the solder for each of the 3 blades of the plug.

The Blobs of Power
The Blobs of Power

Incidentally, the blade that is at right-angles to the other 2 isn’t actually part of the circuit – you can see that on the underside of the board, since the circuit etchings don’t touch that connector.  That part is there simply for ballast, so be sure to smother it in solder.  Also incidentally, the orientation of the other 2 blades is what determines whether the tip is negative or positive.   In this case it is positive, as noted on the circuit board, so if make sure that you use an AC adapter that has a positive tip.  If the board designer had switched the circuit connections to the blades of the power jack, then it would be a negative tip.  If you’re laying out your own circuit on a breadboard or prototype board you get to match the jack to the adapter type that you want to use, but in this case you’re stuck with a positive tip.

Next up is the thermometer chip.  More correctly, this is a combination thermometer and thermostat, a Dallas Semiconductor DS1620.  You can get the full datasheet for this chip from the kitsrus web site, if you’re interested.   While you could just solder chips like this directly to the circuit board, using a chip socket has 2 advantages — you can reuse the chip on another circuit, and the heat from the soldering iron won’t damage the chip.    In this case, both the socket and chip were embedded in styrofoam, as shown on the right.

Thermometer Chip and Socket
Thermometer Chip and Socket

Remove the socket and place it onto board, below the 5-pin connector.  As shown below in the photo to the lower left, the notch on the socket should face left, towards the resistors.

You shouldn’t need to press too hard on the socket to get it into place.  If you’re finding it difficult to insert, then the problem is likely with one of the socket’s pins being out of place. Make sure that each pin fits into a hole on the circuit board, rather than being bent underneath the socket.  It’s possible that one of the pins was bent during shipping despite its styrofoam armour – if the socket doesn’t easily fit into the holes of the circuit board, gently bend the offending pin(s) with your fingers. Try not to wiggle the socket’s pins too much, though, since they can snap off.     If that happens, you have 2 choices: buy another socket (they are only a buck or two) or, in this case, leave the chip out of the circuit entirely.  As explained later in the follow-on to this article, I found the LCD part of this circuit far more useful than the temperature monitoring, so the chip isn’t a must-have.

Chip Socket on Board
Chip Socket on Board

Now for the two stars of the show: the parallel port connector and the LCD.  Both of these involve a lot of soldering of small pins, so you’ll want to make sure that you keep your soldering iron tip clean and use small amounts of solder.  Note the relatively small size of the solder joints in the photo below, compared to the joints seen in other photos. If you drop a huge blob on any of the pins, there’s a chance that you’ll short the connection to the next pin.  Since most of the parallel port pins and all of the LCD pins are used in this circuit, shorting 2 pins is almost certainly going to ruin the party.

The parallel port connector needs to be anchored down well, since connecting and disconnecting the heavy parallel port cable head is going to put some strain on it.  That’s what the 2 big pins on either end of the circuit board connection are for.  Be sure to dump a lot of solder on those 2 suckers.

Parallel Port Pins
Parallel Port Pins
Pin Connector on Board
Pin Connector on Board

The LCD is connected to the circuit board using a 16-pin connector.  The pin connector actually has 2 parts — male and female — and in my kit they were already connected together.  Get a room, you two!  You’ll have to pull them apart in order to solder them into the circuit.

As shown on the left, the female connector goes goes on the top of the circuit board (held in place for soldering by my faithful strip of masking tape).  The male connector goes on the underside of the LCD.   This arrangement is quite handy, since using the pin connectors makes it possible to reuse the LCD in other circuits.  Since the LCD uses a standard chipset that is supported by a lot of software, you’ll probably find a lot of other uses for the LCD.

The “standard chipset” part may come as a surprise to you if you Googled the LCD’s manufacturer and model (a defunct MCC162 made by Truly Semiconductor Ltd.). There’s  not much information about it on the web.  The reusability of the LCD may come as a surprise even if you looked at the spec sheet (which kitsrus helpfully provides on their website, since you aren’t likely to find the MCC162’s specs anywhere else).  The spec sheet states that this board uses a Samsung KS0070 chipset, and the industry (and hobbyist) standard is the Hitachi HD44780.  However, I came across an intriguing article on The Code Project website which shows how to program a KS0066-based LCD through the parallel port using Microsoft’s .Net Framework.  As stated in the article, the KS0066 (and, it appears, the KS0070) are compatible wit the HD44780.  This is great news — you’ll be able to use this kit’s LCD with most of the LCD-based projects you find on web sites.

Top Side of LCD - Solder Here!
Top Side of LCD - Solder Here!

Note that solder which holds the male pins to the LCD actually goes on the top side of the LCD board — having got into the habit of turning the main circuit board upside-down to do the soldering, it’s easy to get mixed up and solder the male connector pins to the wrong side of the LCD board.

Pin connector on LCD
Pin connector on LCD

This completes the assembly part of the project — sort of.  As wisely suggested in the Silicon Chip article about this kit, you should test the voltage being supplied to the temperature chip’s socket before plugging in the chip.  This type of precaution is a good idea for any project that involves sensitive semiconductors, but unfortunately many kit makers don’t teach this practice.  To test the voltage, plug a positive-tip 12V power supply into the CD jack. Then, as shown in the photo below, set a multimeter to the DC voltage setting and put the negative probe on the socket for pin 4, and the positive probe on the socket for pin 8.  (Pins are always numbered counterclockwise, starting from the end of the chip with the notch. So, when the board is oriented as shown in the photo, pin 4 is the bottom right socket, and pin 8 is the upper left).  The voltage should show somewhere between 4.9 and 5.1 volts — if not, check your power supply, then check the solder connections in the components between the DC jack and the chip socket for bridges.

Checking the Voltage
Checking the Voltage

When checking the voltage, you can also check that the LCD is working correctly.  You should see a series of black rectangles, as shown in the photo.  (As mentioned earlier, the LCD works without involving the temperature chip.  In order to see something other than black rectangles, though, you will need a PC and some software).  If the LCD is blank, you hopefully just need to adjust the contrast.  After I assembled the kit I found that the contrast was turned all the way down, so I had to turn the potentiometer clockwise, as shown in the photo below, before the black rectangles appeared.

Please Adjust Your Set
Please Adjust Your Set

If the voltage and LCD look fine, then you can unplug the power jack, then insert the temperature chip.  These chips generally are shipped with the pins spread a little too far out for the socket, so you’ll need to bend the pins on each side inward by gently pushing them against a table.  They should point in just a bit, as shown in the photo below, before they are ready for the socket.

Nice Legs, Baby!
Nice Legs, Baby!

Now you’re ready for the hardest part of this project — finding a parallel port cable.  The cable that you need is a parallel port extension — 25 pins female on one end (for the kit) and 25 pins male on the other (for the PC).  Back in the day, these were used to extend the distance between the printer and the PC.  Note that all 25 pins need to be wired up, unlike a 25-pin serial port cable.  As a result, the cable you want is thick - mine is about half an inch.  If you found a cable that is thin and cheap, it almost certainly is a serial port cable, and it isn’t going to work with this kit.

Finding a PC with a parallel port may prove to be just as difficult. You may need to purchase an IDE parallel port card just for this project.  They aren’t expensive but are somewhat hard to find — this one from DealExtreme worked for me .  You may come across a USB-based parallel port connector — unfortunately, that isn’t going to work this kit or any parallel-based electronics project, since the USB driver is intended to work with a printer only.

Having scrounged up an outdated parallel port and cable, it’s time to deal with the outdated software.  When this kit was originally released back in 2000, it came with DOS-based software.  This software works fine with Windows Me and earlier, but Windows XP rendered it obsolete, since XP doesn’t let DOS programs interface directly with the parallel port.   Fortunately, the kitsrus website now provides a Windows version of the software, which comes with a DLL that is needed to communicate with the parallel port.  This software is intended for Windows XP, but I found that it worked on Windows Vista too if you run it as an Administrator (that is, right-click on the .exe and select “Run as administrator” from the pop-up menu).

If all of that went well, you should find some scrolling text on the LCD.  Switch the software over to Temperature mode, and you should see a display like the one below.

Now For the Traffic...
Now For the Traffic...

Finding out the temperature in your computer room (rounded to the nearest half degree, actually) may seem a little anticlimactic considering the amount of work needed to get this puppy to run.  However, this project has 2 big advantages over your average electronics kit.  Firstly, the excellent Silicon Chip magazine article will explain how it works, something which few kit makers share with their customers.  Secondly, the fact that the kit uses a standard interface (the parallel port) and a standard LCD chipset (HD44780-compatible) means that you can use this kit with other software that you’ll find on the web.  I’ll explore one such program in the follow-on to this article