Author Archives: adam

Steve the Weightlifter

SteveMy kids are heavily into Minecraft at the moment. Since I don’t have much to write about this week, let’s have a look at the thing that impressed me most about this game – the amazing weight-lifting skills of the game’s main character, Steve.

Steve is a pretty strong guy. Not only can he smash through trees and mountains with his bare fists, he’s always strolling around carrying big blocks of stone, whole trees and a small armoury of tools and weapons. Just for laughs, let’s work out the maximum weight he can carry.

Minecraft Inventory ScreenAll the stuff Steve is currently carrying is shown in his personal inventory.

Steve’s personal inventory has 36 slots and each slot can hold up to 64 items, this means he can carry a maximum of 2304 items.

So what is the heaviest item he can carry? Well the heaviest material in the game is gold so how about a cubic metre of gold? How much would that weigh?

Gold has a density of 19.3 grams per cubic centimetre, there are a million cubic centimetres in a cubic metre. So a cubic metre of gold would weigh 19.3 metric tonnes.

Just one of these gold blocks would defeat (and squash flat) the world’s best weightlifters. The current world weight lifting record stands at 263kg.

But Steve can carry 2304 items. If each gold block weighs 19.3 tonnes, that’s a total of 44,467 tonnes!

And even with all that weight in his pockets, it doesn’t even slow him down.

All that gold by the way would be worth about $2.6 trillion at today’s prices, you could probably buy Norway for that amount of cash, and Steve wouldn’t have to worry about anyone stealing it as nobody could possibly lift it.

An Olympic gold medal only contains 6 grams of gold, so you could make 7.4 billion of them by emptying Steve’s pockets. That’s an Olympic gold medal for everyone on the planet.

Hyperlinks for your twitter posts

Here’s a quick Javascript to take a string and automatically add hyperlinks to any twitter tags it sees. This could be useful if you were writing a web page for users to enter tweets. It will take a string such as “I gave @siliconsparrow a hug”, detect the at-tag and wrap it in the appropriate hyperlink.

Here’s a demo page where you can see it in action.

function addTwitterLinks(text) {
 return text.replace(/[\@\#]([a-zA-z0-9_]*)/g,
   function(m,m1) {
     var t = '<a href="http://twitter.com/';
     if(m.charAt(0) == '#')
       t += 'hashtag/';
     return t + encodeURI(m1) + '" target="_blank">' + m + '</a>';
   });
}

 

 

More design refinements to the Baud Rate Converter

The latest batch of RS232 Bit Rate Converters have a few improvements over the previous releases. The new model is called RS004. I’ve actually been selling these for a few months now so anyone who ordered some recently already has these new features:

  • Programmable time-delay in each direction so you can delay your packets.
  • Support for an even wider variety of baud rates from as low as 11bps up to 120,000bps – check the baud rate calculator
  • Improved power efficiency – It now only draws 25mA when idle, a bit more than that when busy but much less than the 120mA consumed by the previous design
  • Reverse polarity protection in case you accidentally wire the power backwards
  • I now outsource the circuit board manufacturing so I don’t have to build them myself. The boards are robot-assembled which results in a much neater build with less mistakes.

New units are now ready for sale, head on over to serialgadget.com for more detail.

New Toy

In the past I’ve written a couple of posts on how to get better magnification out of a digital camera. Well, you can get some pretty reasonably priced digital microscopes these days – and now I have one, the DigiTech QC3247.

It has two modes, a 20X mode which is fairly useful and a 400X mode which is ridiculous.

Here’s a capture from 20X mode. To give you an idea of scale, the brown chip capacitors in the picture are 0603 – ah, that is 1.6mm long and 0.8mm wide. Click on the picture to get the full-res 800×600 image.

Now here’s a capture of one of those same chip capacitors at 400X. It took me ages to position and focus it as the frame is less than 1mm from side to side. This mode is of limited use I think unless I build a mount for the microscope. It is impossible to hand-hold it at this magnification and the supplied stand is too flimsy to hold it in position without wobbling.

All in all, this will be a nice addition to my toolbox.

Class D Amplifier is Working

A few posts ago I mentioned that I was having trouble with my Class-D amplifier design. It’s been sitting on the shelf for a few weeks and I think it’s time to have another look at it.

It’s amazing how you can notice new things when you take a fresh look at something. The problem is obvious now. I was missing a ground trace which introduced some noise into the input. Also the input impedance was way too high which made the amp very sensitive to that noise. The result was some nasty buzzing and it had nothing to do with the power supply as I first thought.

So now it’s working. Yay! I also upgraded it to the Texas Instruments TPA3110 which is completely pin-compatible and has 15 Watts of power. My ears are suitably hurting after running some tests at full volume and it didn’t even get warm.

So next I need to correct the PCB in light of these changes and it is done.

Synchronize two video replays using Javascript

Here’s a quick Javascript I whipped up to make an HTML5 video object track a second HTML5 video object. I needed to do this because I had two videos from a talk – a video of the speaker and a video of his powerpoint presentation, both as MP4 files.

This script will trap events from one video window and pass them on to the other window so they stay in sync with each other. I’m posting it here because it may be useful to someone…





HTML5 Synchronize Video Test




UI Horror Story of the Day

I finally got around to upgrading to Dev Studio 2010 Express. It looks nice so far but I don’t know whether to laugh or cry at the number of fundamental UI mistakes they have made with the documentation system. Have Microsoft learned nothing about user interface and user experience in the 18-odd years they have been developing Windows? I’d like to take this blog post to list some of the issues with this software.

Now in previous versions of Dev Studio, if you wanted to look up the manual for a key word or library function, you placed your cursor on the name and pressed F1. So wanting to know how to create a fixed array in C#, I typed the word ‘fixed’ and pressed F1. Did I see the documentation? Nope.

What I did see was a dialog box asking whether I’d like to look up the documentation on my local machine or on the internet. I wish I’d taken a screen-shot of that dialog box because it was an absolute classic of bad design but I can’t make it appear again. Once I’d chosen, there was no way to go back to it and make a different choice.

UI Lesson #1: Let the user go back. People make mistakes, if it is possible to undo, then allow it.

 

The choices on the dialog were “YES” or “NO”. Um, does that mean yes, look it up on the internet or no, don’t look it up on my local machine? Heads I win, tails you lose. Bad choice of wording for the buttons.

UI Lesson #2: Label your dialog buttons with verbs – SAVE / DON’T SAVE is easier to understand than YES / NO

 

So I took a punt on NO which it turns out meant loading the documentation from the local machine. Well that’s OK, it should be faster loading locally right? But then again, should I care where it gets the documentation from as long as it gets it. Microsoft is interrupting my work flow. I just want to see the documentation, right now.

UI Lesson #3: Don’t interrupt the user’s work flow unless you have a very good reason.

 

So next it goes about setting up a small web server on my PC so it can serve up the documentation in my browser. Takes a few seconds but that’s OK, except – get this – it doesn’t work! I get a 404 error! I did take a screenshot this time:

 

So what this is telling me is that there is no local help! And the software was too brain-dead to realise it.

UI Lessage #4: If you can automatically check something, don’t make the user manually check it!

 

There is no way I am going to spend time installing the local help on my PC. Remember what I want to do is view the help, not dink around with my computer all afternoon. So of course I now choose to look for the help online. So I click the link and…

 

UI Lesson #5: Honestly, just think!

 

I cannot believe how utterly broken this is. I think I’ll go look up my keyword on Google.

 

Incompatible Objective-C types initializing struct

This bizarre iPhone compiler error message had me tearing my hair out this morning. I’ve finally figured it out.

Here’s the scene: You have two classes, each class has an init method with the same name and taking the same parameters. Here’s an example:

@interface myClass1 : NSObject { }

-(myClass1 *)initWithName:(NSString *)name;

@end

@interface myClass2 : NSObject { }

-(myClass2 *)initWithName:(NSString *)name;

@end

Now try to initialize an instance of the first class:

myClass1 *c = [[myClass1 alloc] initWithName:@"Fred"];

You get Incompatible Objective-C types initializing ‘struct myClass2 *’, expected ‘struct myClass1 *’ which doesn’t make any sense because the initializer never even mentions myClass2.

The thing is that the program will run fine, it just gives this warning at compile-time because the compiler can’t tell the difference between two different methods with the same signature. I like my code to compile with no errors and no warnings because I’m very fussy. So even though this warning could be safely ignored, it still bugs me and I have to get rid of it!

So to shut the compiler up, I need to cast the object so it explicitly knows which method to call.

myClass1 *c = [(myClass1 *)[myClass1 alloc] initWithName:@"Fred"];

Casting always looks ugly to me but that’s the way around it.