Tuesday, December 31, 2013

Using a Spacetime Diagram to Understand the Frequency Shift of Doppler Radar

I recently did a tear down of a cheap doppler radar module that I'd bought on ebay.  It's used to sense the speed of an object by measuring the frequency shift of a radar signal that bounces off it.  When it came time to work out the speed, I found out that my initial understanding of the problem was wrong.  I had trouble getting a intuitive picture of how the signal was changed until I drew a few diagrams.  They helped me a lot and I thought they might be able to help someone else visualise Doppler radar frequency shift.

Doppler Radar Frequency Shift
Page1

Doppler Radar Frequency Shift
Page 2


Friday, December 20, 2013

Command Line Mail Merge For Wedding Invitations With Perl

Recently I've been occupied making wedding invitations, so I haven't really done anything too technical, but during this task I did come across a nice little command line trick that could come in handy.

I like to lay out documents like wedding invitations in Libre Impress, it's basically the open source answer to PowerPoint.  You might think it's weird to do layout like this in a presentation program, but it's simple and it allows me to exactly control text and graphics and how they're positioned on the page.  The one drawback this method has is that I can't find a way to import a guest list into a template and generate a final document, basically a mail merge, but there is a pretty easy work around using the command line.

The invitations I want are really basic.  They're text only and approximately one third the size of an A4 page.  They do however need to be personalised, which makes things a little harder but not impossible.  The first step is to complete one invitation and use a generic place holder for the name of the guest.  Use something that won't appear somewhere else in the file.  I'm using the string GuestName. This invitation is then copied to fit 3 onto the page.  You then duplicate this page as many times as you need to so that there are enough invitations in the file.

For this process to work the file needs to be saved in the flat open document format, fodp.  The format is xml based and is easily read, but you need to use the flat version that's uncompressed.  That way the place holder string, GuestName, is in the file in plain text.

Wedding Invitation
Template Invitation
I've mocked up a quick invitation to demonstrate the process.  I've put a few Easter eggs in the invitation mainly just to amuse myself.

Wedding Invitation
Template Invitation

The next thing you need is a guest list.  A simple text file will suffice.  For this I've created a file that contains three people.  Each person is on a separate line.

guests.txt

Alice
Bob
Eve

What's needed now is a way to replace the place holder string GuestName with names from the guests file.  Each time a string GuestName is found it needs to be replaced with a different guest from the guests file.  It turns out that following perl command is ideal for this.

perl -pe 's/GuestName/chomp($r=<STDIN>);$r/ge' Template.fodp < Guests.txt > Invitations.fodp

I'm still learning how it all works but I'll try and explain the command.

the e option allows the command to be entered on the command line
the p option loops over the command and prints the result
the s command is used to replace the string GuestName with chomp($r=<STDIN>);$r
chomp($r=<STDIN>);$r reads a line from the standard input, the Guest.txt file, and removes the newline character at the end.
the g option means do a global search and replace
the e option indicates to evaluate the replace expression

This is the result.  The place holder has been replaced with the name of the guest.

Wedding Invitation
Final Invitation
I can then use the Invitations.fodp file to generate a pdf and then print out the invitations.  There's one thing to point out though.  Just because a GuestName string is first on the page it doesn't mean it's first in the file.  So the input order may not be maintained exactly, it can be done, but you just need to be aware of it.  For me the order doesn't matter so I'm not concerned about it.

Monday, December 9, 2013

Onga JM100 Pump Teardown

The pressure pump connected to our rainwater tank failed the other day.  It didn't stop working, it just sounded really wrong and got too hot for the short amount of time it was running.  I'd previously replaced the motor run capacitor on this particular pump and was reasonably familiar with its operation.  As a first step I checked the things I know best, the electrical components.  The 10 uF motor run capacitor was fine, it was reading a perfectly acceptable 9.8 uF.  The winding resistances were however way out of whack.  When I last repaired the pump I took note of the readings, and they had changed significantly since then.  They were now about one sixth of what they used to be.  If some of the windings are shorted it pretty much means it's beyond repair, but I decided to pull it apart for fun, and to see if there was something obvious that could be causing the problem.  So even if the pump can't be repaired there's at least a guide that others can use if they need to pull their pump apart.

Warning - This article describes equipment and circuits that operate at high voltages.  Don't attempt to repair any high voltage circuits if you're not trained to safely work with electricity.  You may be seriously injured or even killed.  For further information read the blog's Terms Of Use.

I hadn't done anything like this before so I tried to find some sort of service manual.  Although not an exact match but the parts diagram in this manual was a fairly accurate representation of how the pump was constructed.

I started by removing the pump head and taking off the fan cover.

Fan cover removed

Pump head removed
At this point I took a moment to inspect the impeller on the motor and the diffuser in the pump head for any signs of wear.  Everything looked fine.

Brown diffuser in the pump head
The next step is to remove the pump stand from the bottom and disconnect all the electrical wiring.  If your not sure how to reconnect everything take lots of photos for reference.  Removing the fan at this stage is a good idea.  It may take some doing, but it can be pried off with a flat bladed screw driver.

With the fan removed, a screwdriver can be used to lock the shaft in place while the nut holding the impeller on to the shaft is removed.

Pump stand removed
Removing the impeller seemed to disturb a colony of ants inside the motor.

Ants inside the motor
After removing the impeller you'll be faced with the layout in the image below.  To remove the black plastic plate the seal on the shaft needs to be removed.  Once again it may take a while to figure it out, but it can be pried off with a flat bladed screwdriver.

Seal on the shaft
Ignoring the ants for the moment, all that's left to do now is to remove the end plate of the motor.  There's another rubber seal on the shaft that can be removed easily.  Once this is done the bolts holding the plate on can be undone.  To remove the plate, gently tap the other end of the shaft where the fan used to be attached, this will push the plate off.

Motor end plate
You now have access to the rotor, bearings, and stator coils.  Apart from the ants, I couldn't see anything out of the ordinary here.  The bearings seemed to turn freely and there was no obvious damage to the motor windings.

Disassembled motor
I used a compressor to clear all the ants out and then reassembled the motor.  It didn't sound any worse, so I'll take that as a win.  I'm still not entirely sure what caused it to fail though.  It could have just been a random breakdown of the winding insulation, that caused part of the motor to heat up causing the insulation on other windings to break down.  Maybe the ants damaged the winding.  Who knows.  One thing is for certain, this motor has reached the end of its life.