Monday, February 24, 2014

Hastily Assembled Shower

Due to a hastily arranged bathroom renovation my productivity has been a little less than usual this week.  It's hard to do things with tradespeople around.  So I thought I'd cheat on this post and show something I threw together last week.  One of the problems with a bathroom renovation is you have nowhere to shower while it's in progress.  With only a couple of days notice I needed to put together a shower, and because I'm a cheapskate I thought I'd use what I had on hand.

Sprinkler
Sprinkler Shower
I got lucky and found a sprinkler base with two holes drilled though it.  This made it ideal to screw to the beam of the patio outside.  The head on it wasn't ideal, but I did have one that was a lot more like a shower.

Sprinkler
Garden hose attached to the sprinkler
An attachment to connect a garden hose was then added.

Hose
Excess hose wrapped around beam
The hose I found was too long, so instead of cutting it to the right size, the excess was wrapped around a beam.

Water pipes
Shower combination
I was willing to take cold showers, it's summer in Australia at the moment so showering outside in cold water isn't too much of a problem, but by a stroke of luck there was an old hot/cold shower combination nearby.  So a few adapters later I had a nice warm shower running.  It took me about half an hour and cost me nothing except for a bit of thread tape.  By the way, the secret to plumbing is thread tape, know how much to use and what type and you'll never have a leak again.

Thursday, February 13, 2014

Generating a Captcha from the Linux Command Line

I've been playing around with OCR software lately, Tesseract, gOCR, and Ocropus.  I'd like to get all the developers together in a room and lock them in until they come out with something awesome.  Each program has features that I'd like to see in combined package, but for now I'll work with what I have.

Anyway, this post is a bit of a tangent to the whole goal of OCR, recognising text.  Thinking about how to make the job of an OCR program harder can lead to a deeper understanding of the recognition process.  The leading technology to beat OCR is the captcha.  Those annoying little blurred words you have to read to gain access to forums and other sites.  They're there to prove you're a human and not a spam bot.  Through a combination of geometric distortions and filters it makes text hard for computers to read but not humans.

Anyway, for the hell of it I thought it would be nice to be able to generate them from the command line.  So here's what I came up with.  You'll need imagemagick installed as well.

I've put everything together in a script located here.
captcha.sh

Plain text is generated first.

convert -background white -fill black -font FreeSerif-Bold -pointsize 36 label:'all work and\nno play\nmakes Grant\na dull boy' test.png

Captcha Text
Text
A wave is added to the text.  Ideally the magnitude and wavelength of the wave would be randomised per line, but a simple uniform wave will do a reasonable job as well.

convert test.png -background white -wave 4x55 test2.png

Captcha Text
Wave added
A blur is added to text.

convert test2.png -blur 0x1 test3.png

Captcha Text
Blur added
A photocopy filter is then added.  This helps to segment some of the letters.
The photocopy filter was found at www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=14441&start=0

convert test3.png -colorspace gray -contrast-stretch 4%x0% \( +clone -blur 0x3 \) +swap -compose divide -composite -blur 0x1 -unsharp 0x20 test4.png

Captcha Text
Photocopy effect added

Sunday, February 2, 2014

Adding a 200 Amp Range to a Multimeter With a Current Shunt

I'm working on something that requires me to measure high currents.  I don't need to be exact, I just need to know how many Amps are running through a winch so that cabling and relays can be sized.  It wasn't until this project came along that I realised I had no way to measure current over a couple of Amps.  I tried to measure the resistance of a wire and measure the voltage drop across it, but it was too clumsy and error prone.  An old automotive current meter I had should have done the job, but it seems to be dead.  The best and least frustrating solution was to do things properly and build a tool for the job.  A quick trip to Jaycar for a couple of parts and I was on my way.
Current Shunt
Current-Shunt connected to multimeter
The set-up is really simple, it consists of a current shunt and some cabling to connect it to a load and a multimeter.  If you're unfamiliar with the concept of a current shunt here's a quick recap.  When you need to measure a current the easiest way to do it is to run the current through a resistor of known value and then measure the voltage drop across the resistor.  This resistor is called a current sense resistor or a current shunt.  Ohm's law is then used to calculate the current.  When you need to measure large currents however you need a special low value resistor.  That's where specially constructed current shunts come into play.  The one I bought is rated for 200 Amp and at this current has a voltage drop of 50mV across it.  This means it has a resistance of 250 micro Ohms (50 mV / 200 Amp).  It also means that at full current it dissipates 10 Watt, something to keep in mind.

To measure the current of a load, the shunt is inserted in series via the alligator clips and the voltage across the shunt is measured on the multimeter.  Every amp thought the shunt will cause a 250 micro volt drop across the shunt.

Current Shunt
Current Shunt
To connect the shunt to the multimeter, the tips were cut off a cheap set of multimeter probes and eye terminals were crimped onto the leads.  You can make your own, but this way you get a nice set of moulded banana plugs on the ends of the leads.  The size of these leads doesn't matter because no current should flow through them, they are only used to measure the voltage across the current shunt.  To connect the shunt to the load you need some serious cabling.  The current I am trying to measure isn't 200 Amps, but since the shunt is rated for 200 Amp I might as well size all parts for that current in case I need it in the future.  This means that the cabling has to be quite thick.  Trying to find the cable thickness needed for this is difficult.  Everyone has a different answer, the cross sectional area also depends on the the accepted temperature rise, the insulation, and where the cables are located.  For my situation, I bought the largest crimp terminals that would fit on the shunt, and by coincidence these lugs were the exact size of some old welding cable I had.  The cable has a cross sectional area of approximately 25 square mm.  I would've preferred something a little thicker, but this should do the job adequately.

Battery Terminal Clip
Car battery clips
It worked out nicely that the largest battery terminals from Jaycar were also rated for 200 Amps.  They also make things look a little more professional.
Battery Terminal Clip
Battery clip teeth
One side of the teeth in the battery clip can be taken out by removing a screw.  The cable can then be crimped into it.
Soldered cable
Teeth soldered to cable
Although the cable is crimped into the fitting, I wasn't entirely convinced it would hold, so it was soldered into place.  It's not the greatest job in the world, I don't have a soldering iron that could put out that much power, as most of the heat will be drawn down the large copper cable and dissipated into the environment.  What I do have however is a small blow torch for browning Crème brûlée that was just the right size.  It's a balancing act to get the right amount of heat into the copper and not melt the cable insulation, but I think I got the hang of it.

I've tested it by running 4 amps from a power supply though it.  The reading was close to 1 mV.  A better multimeter would make a difference, but this is precise enough to get me in the ball park.  All up I'm quite pleased with the result.  I have a useful tool that will come in handy in the future.  A pre-amplifier across the shunt would be a nice addition, kind of like a big brother to the eevblog ucurrent.