Tuesday, 26 August 2014

Can buying a new Hoover really save the planet?


The EU have been busying themselves with the important issues again.  According to regulations, the maximum power of a domestic vacuum cleaner will be capped at 1600W from September 2014 and 900W from 2017 (http://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=OJ:L:2013:192:0024:0034:EN:PDF).  We're told that this will save 19TWh (that's 19,000,000,000,000 units of electricity) by 2020.  That's an awful lot: so much, in fact, that it sounds a little fishy to me.  Let's check their maths.

First, a few assumptions:-

  • There are 213,839,200 households in the EU (this isn't really an assumption...I looked it up: http://appsso.eurostat.ec.europa.eu/nui/show.do?dataset=lfst_hhnhtych&lang=en)

  • Each of these households spends an hour a week vacuuming, on average (don't we all ?!).  This figure isn't pulled completely out of the air: the 2014-2017 part of the new regulation states that the total annual power consumption of a new vacuum cleaner should be no more than 62.5KWh and that the rated input power should be no more than 1600W.  Divide the first by the second and you find that our EU masters expect us to spend 39 hours per year - equivalent to 0.75 hours per week.  vacuuming.  Interestingly, after 2017 the total annual consumption cap drops to 43KWh and the maximum rated input power drops to 900W.  Do the same maths and you'll find that we will be vacuuming for 47.7 hours per year (almost an hour a week) from 2017.  That's progress, I guess.  Anyway, an hour per week per household is a nice conservative figure for our purposes here.

  • The average vacuum cleaner currently in use uses 1800W of power.  Again, I didn't make this figure up: it is taken from a post on the European Commission blog

  • The expected life of a vacuum cleaner is 10 years.  Once again, I didn't pull this figure out of thin-air.  The regulation states "operational motor lifetime shall be greater than or equal to 500 hours".  At an hour a week (see earlier assumption), that's about 10 years.  That feels about right to me.  So we can expect that 10% of the households in Europe will purchase a new vacuum cleaner each year, swapping their power-hungry 1800W unit for a more eco-friendly 1600W unit up until 2017 and for a positively tree-hugging 900W unit thereafter

So how much power will all these neat-freaks with their vacuum cleaners wind up using and how much will be saved with the new regulations ?






With No Change (MW)





Under New Regulations (MW)





Saving (MW)






So by my calculations, by 2020 the new regulations will result in a saving 4.7TWh per year (at most).  That's an awful lot less than the claimed figure of 19TWh.  Actually, 19TWh is only slightly less than the total power that we use vacuuming each year using our current cleaners, so its difficult to see how any change to regulations - short of banning vacuum cleaners completely - could result in a 19TWh saving.

Am I missing something?  If I am, I just can't see it.

Tuesday, 9 October 2012

Relay Bounce

I was using an oscilloscope to do a little troubleshooting on a project that involved having a microcontroller flip a relay and I stumbled across something interesting.  I was graphing the voltage across the relay contacts (there was a good reason for this !) and I spotted this:-

When the relay snaps shut the voltage is supposed to suddenly drop to 0 as the contacts short.  As you can see that's not exactly what happened.  Instead it bounces between open and shut 4 times before finally settling on closed.  This all happens over 16ms so you might never know about it if you weren't looking at it on an oscilloscope.  I figure what is happening here is that the moving relay contact is quite literally bouncing off the fixed one.  Note how the closed period (0v) of each successive bounce becomes longer until it finally settles.

Monday, 6 August 2012

Arduino-based Audio Cable Tester

I love the Arduino platform - it makes it so quick and easy to get things done.

The local music school had a need to test a bunch of audio cables (1/4" and XLR) in a hurry in preparation for the annual students' concert.  Yes, it can be done with a multimeter but if you have lots of them to do this becomes very tedious very quickly.  Sounds like a job for an Arduino

It does XLRs also...

The work is all done by an Atmel Atmega mircocontroller

All of the development work is done in the Arduino environment.  Once it was all working I just transferred the microcontroller onto a piece of perfboard (so that I could reuse the Arduino board for my next project).  The connectors on the far-left of the board (connected to pins 1,2,3,7 and 8 ) allow the Arduino board to be used as a programmer (see http://arduino.cc/en/Tutorial/ArduinoToBreadboard). That link explains how to configure the Arduino to use the built-in 8MHz RC clock in the Atmega so no external crystal is required (neither accuracy nor flat-out CPU speed are remotely important in this application).

I also stuck a normal ICSP connector on it so that it can be programmed using a normal programmer (bottom-left corner).  This is handy:  once the code was complete I was able to blow the Arduino boot-loader away so that the sketch starts immediately rather than after a pause.  The downside is that if I want to use an Arduino to program it again I need to reinstall the boot-loader (for which that ICSP header will be very useful !)

The source-code is posted here.  The comments in the code list the required connections.  I haven't bothered to draw a circuit-diagram but if anyone wants one just leave a note in the comments below and I will post it here.




Laptop Transport

I needed a better way to carry my laptop on my folding bike.  I used a backpack for a long time which works fine except on hot days (sweaty-back syndrome !).  I tried a handlebar mount (the excellent but expensive  Klickfix system) which also works well but it adversely affects the stability of a bike which is already a little on the twitchy side.  The bike has a carrier but it is so low down that my heel clips anything that overhangs its perimeter.  There had to be a better way.

My simple solution is to make an attachment for the carrier which will allow the laptop case to be mounted vertically without moving around.

The band around the laptop back is a strip of 40mm x 2mm aluminium which is attached to carrier

It works so well I did the same thing for the folding bike's big brother...

I worry a little about the laptop having the guts shaken out of it (its a very nice laptop !) so I use a folded-up and partially inflated tube to give it a little "suspension":

I hope someone finds this useful.  If you have thought of a better way to solve the same problem I'd love to hear from you.


Wednesday, 25 April 2012

The Sound of Music

Oscilloscopes and guitars are a wonderful combination :-)

This is what an open-E played on the 6th string of my Stratocaster knock-off looks like:-

The two vertical dashed lines measure that time between two consecutive peaks (12.19ms) and from this we can work out that the fundamental frequency is 82Hz (as it should be...E on the 6th string is supposed to be 82.4Hz).

The scope can also do spectrum analysis (showing the harmonic content).  Here's the same open-6th string:-

Unsurprisingly, you see a strong peak at 82.4Hz (the fundamental) with 1st harmonic (164Hz, one octave above), 2nd (247Hz, which is B on the 2nd string, nicely illustrating the relationship to the 5th note in a chord) and 3rd (329Hz, which is the E on the 1st string, two octaves above the fundamental) all strongly present.  Although there isn't much of it, 4th harmonic occurs at 412Hz (you can just barely see it).  This is G# played on the 1st string which illustrates the role of the major 3rd note in a chord.  I think its interesting to see how the notes of a major chord all occur as harmonics of the fundamental.

Another interesting thing to look at is how tuning using harmonics works.  This is the 6th string with me barely touching the string just above the 12th fret to damp the first harmonic:-

Two interesting things:  the strongest peak is at 164Hz (one octave above that open E, just as you would expect).  The fundamental frequency of that string is almost completely gone (because my finger prevents the string from moving at its centre point).  Also, there is very little other harmonic content.  Sure enough, if I graph the signal it is much closer to being a pure sine wave at 164Hz:-

If you play that with another (nearly) pure sine wave which is only slightly different (i.e. fractionally out of tune) they will interfere with each other, creating that "fading in and out" effect that we listen for when tuning using harmonics.  They will fade in and out at a rate equal to the frequency difference (which is why you can only hear it when you are very close...tuned to within a few Hz)

These graphs illustrate this pretty well.  Here are harmonics on two strings (6th string 5th fret and 5th string 7th fret) which are slightly out of tune:-

The "waviness" in the signal shows the interference between the two (at ~3Hz, measured with the vertical dashed lines) which I can hear as the characteristic fading in and out.  When I correct the tuning and repeat the test...

...the "waviness" is gone.  This video illustrates what is going on:-


Finally, it is interesting to see the harmonic content of the same note played on two different strings.  Here's the open 5th:-

And here's the same A played on the 5th fret of the 6th string:-

Note the much stronger fundamental (110Hz) compared to the 1st harmonic.

Saorview on the cheap

Irish readers who aren't living under a rock should know by now that the analogue terrestrial TV service will be switched off in October of this year (i.e. 2012).  If you haven't make some arrangements to receive digital TV by then you will be enjoying uninterrupted views of cosmic noise, left over from the big bang (otherwise known as "snow" or "static").

I came across plans for a homebrew antenna at www.tvantennaplans.com.  I just had to tried it and it worked beyond my wildest expectations.  Here it is, mounted in my attic, facing roughly in the direction of the Kippure transmitter:-

Signal strength...100%, bit-error rate...0%:-

The only part I had to buy was the 300Ω <-> 75Ω balun (part number FD78K from Maplin, about €3.50)


I have been running with this for over a year now and it works perfectly.  I have made a few more of them for family and friends with equal success, even in locations where analogue RTE service was poor.

If you really really can't pick up the Saorview terrestrial service, there is also the Saorsat satellite service.  You will need a Ka-band LNB (which is different to the normal type of LNB you would use for picking up Sky/Freesat etc. from Astra 2) and a dish aligned on 9oE.  I tried it with an ordinary cheap-and-cheerful satellite receiver and a dinky 40cm dish mounted in a bicycle-repair stand...

Saorsat dish

...and it works a treat.  You don't get TV3 or 3e at the moment but hopefully that will change.  I haven't tried it, but I understand that it is possible to use a slightly bigger dish and mount a normal LNB off-centre and you can pick up both Saorsat and Sky/Freesat etc. using a single dish.  www.tvtrade.ie (where I bought the Ka-band LNB among other goodies) sell a mounting bracket sized for exactly this purpose (the positioning of the LNB is critical for this trick to work).  Its a great site with a great range of well-priced products.  They also make their own excellent tutorial videos.  Highly recommended.


Tuesday, 6 January 2009

Diary of a Hard Disk Upgrade

I recently found myself needing to upgrade the hard disks in a few PCs to bigger and and faster ones. The thought of having to reinstall Windows from scratch an all of them made my heart sink into the pit of my stomach so I set about seeing what would be involved in "cloning" the contents of the existing disks onto the new replacements. I could have just paid for Acronis Migrate Easy (which seems to be generally well-regarded), but where's the fun in that ?! In the end, I successfully migrated a number of PCs using free software. This article describes how.

The usual disclaimers apply...this is what worked for me - if you try it and it goes wrong and you haven't taken the normal sensible precautions before embarking on an endeavour like this then please don't come crying to me.

Step 1 - Partition the new hard disk

I found it easiest to do this from Windows. I connected the new hard disk to the PC and created the partitions using the normal Disk Management tool. You will save yourself some trouble if you "match up" the partition numbers on the old and new disks (i.e. if your Windows partition is on partition #1 on the old disk, make sure it is on partition #1 on the new disk also). On some of the PCs there was a Dell diagnostics partition present (so the Windows partition was actually the second partition). More about this below.

Step 2 - Delete (or rename) the HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices key in the registry

Doing this now will save you a world of pain later on. The problem is that Windows maintains a mapping of volume IDs to drive letters under this registry key

MountedDevices registry key

Here, my new drive was mounted as drive N: when I partitioned it. If I do nothing now, Windows will remount it as drive N: (instead of C:) when I later boot from it, which won't end well. If I just zap this registry key, Windows will recreate it when it next boots (although it will have forgotten about what drive letters you liked for your USB keys etc.) I guess you could just delete the entries for C: and N:...I didn't try this.

Step 3 - Reboot into Linux

I variously used Fedora Core 8 and Knoppix 5.1.1...both contained the required NTFS tools and both worked perfectly. At this stage, I have both the old and the new drives attached to the PC. I did this with various combinations to attachment from direct PATA to USB-to-PATA or USB-to-SATA converters and they all worked perfectly.

Step 4 - Dell Diagnostics Partition

One of the candidates was a Dell PC and I wanted to preserve the Dell Diagnostics partition, partly because it is a good thing to have and partly - as I mentioned above - to keep my partition numbering consistent between the old and the new drives (which saves a bunch of trouble). I did this by using the gparted utility to create a new partition on the new disk, similar in size to the original (but rounded up to an even cylinder boundary) with a system ID of 'de' (copied from the original). Then I simply did a "dump" sector-by-sector copy of the diagnostics partition from the old to the new:-

# dd if=/dev/sda1 of=/dev/sdb1 bs=32768

This worked a treat. I could then recreate my NTFS partition (again using gparted) as the second partition on the drive. It may seem that this rather wastes the effort of partitioning the disk in Step 1 above, but by doing it this way the standard Microsoft boot code is installed in the MBR. Of course, there are lots of other ways the same thing could be achieved, such as copying the MBR from the original disk to the new disk using the command

# dd if=/dev/sda of=/dev/sdb bs=512 count=1

...and then using gparted to resize the partitions accordingly. Either way, be very careful. If you manage to zap the partition table on your original disk at this stage you are going to have a seriously bad day !

The fun isn't over yet...see below !

Step 5 - Clone the NTFS parition

The next step is to clone the contents of the old NTFS partition into the new one. This is done using the aptly-named ntflsclone command:-

# ntfsclone -O /dev/sdb2 /dev/sda2

In this form, the command clones /dev/sda2 to /dev/sdb2. Once again, be careful. This command doesn't ask for any confirmation and if you get your partitions mixed up (e.g. specify them the wrong way around) it will hurt.

Step 6 - Resize the partition

At this point, all of the data is copied from the old disk to the new disk, but the filesystem on the new disk still "thinks" it is the same size as it was on the old disk. If you just reboot at this point you will find - to your dismay - that the new filesystem is no bigger than the old one, even though the partition containing the filesystem is bigger.

To fix this, we run ntfsresize on the new partition

# ntfsresize /dev/sdb2

Step 7 - Fix the number of "hidden sectors" in the NTFS Boot Sector

If the new NTFS partition doesn't start on the same sector number as the old one, you will need to adjust the number of "hidden sectors" recorded at offset 0x1C in the NTFS boot sector.

TODO: Describe using "hexedit" to complete this job

I did it a different way (kind of by accident). I wound up booting from the Windows Vista installation DVD and selecting "Repair". This located and repaired the incorrect boot sector for me automatically.

Step 8 - Insert the new disk and reboot

All going well, it will boot up exactly as before - except possibly faster - and you will miraculously have lots of available space

Step 9 - Defragment

If your original disk was heavily fragmented (which it probably was if you were running close to capacity for a good while), then the copy is still heavily fragmented. Now would be an excellent time to defragment the new partition.

Other Alternatives

In the course of my research I came across a promising tool called XXCLONE. This works a different way, being file-oriented rather than sector/block-oriented. Apparently, it copies individual files from the old to the new. As an experiment, I cloned one of the PCs using this tool rather than using the procedure described above. Initially all seemed well...I could boot from it and everything appeared to work OK. However, a few days later I was trying to install Microsoft.NET Framework 3.5 and found that it simply would not install. I can't be certain that the problem was with the method used to clone the disk, but when I went back and recloned using the Linux tools I could then install the same .NET Framework without any problems. If the problem was caused by XXCLONE it is a pity...it is very elegant and simple to use. I have sent some feedback to the developers...hopefully it will be helpful to them.


I can't claim to have worked all of this out from scratch by myself. The most useful online guide I found was Michael Dominok's at http://www.dominok.net/en/it/en.it.clonexp.html.