Thursday, December 8, 2011

Some old notes

I was browsing around some of my files on the clock and figured I'd post some of the notes I took on the drive components.  From my notes on 3/16/2011:

I thought about using stepper motors to drive the hands, but gave up because the Arduino motor shield can only drive 3 steppers.  I need 5.  This is the model of sail winch servo I used:  GWS Sail Winch Servo S125-1T.  Most places have them for $20-30 each.

After the fact, I think that steppers would be possible with the Arduino using some custom mux/demux circuits to select one of multiple steppers to drive and an external driver board like this one:

The mux/demux circuit could use this chip:,652/568-1689-5-ND/763293

I used these two types of gears:  A 1T 2-Y32048 from

drive gear on servo:  48 pitch, 96 teeth, 2" pitch dia
hand shaft gear:  48 pitch, 72 teeth, 1.5" pitch dia

For the concentric hand shaft, the brass tubes nest nicely, but to interface with the 1/4" gear hole I will have to increase the diameter of the smaller shafts to fit.  I can cut small pieces of the larger shafts and glue them together.  The tight fit of the nest shafts should work nicely.

Servo positioning:
The Arduino servo class allows controls of 0 to 180 degrees.  Starting with 90 at the 12 o'clock position, 0 and 180 are approx 3 and 9 o'clock positions anti-clockwise and clockwise, respectively.

10 degrees in the Servo library equates to 30 degrees on the clock, or one out of 12 positions.  The full 360 degree range on the clock translates to 30-150 degrees in the servo library.  It's pretty accurate, but may need some fine tuning per servo.

Saturday, November 26, 2011

Clock Functional!

I've been able to get lots done on the clock over the Thanksgiving weekend.  I haven't been able to work on it for a while.  I needed to make the hands for the clock and wrap it up to finish the top section with the actual functioning clock.  I drew out some hands in AutoCAD that I thought I could cut out by hand, but then I thought about having them laser cut and wanted something more intricate.  I had poked around a bit at having them cut, but couldn't get motivated to redesign the hands.  I opted to go back to my original plan and cut them out by hand.  With some sheet metal I had, an air nibbler, and a hand nibbler I set to work.  I managed to get them all cut out with only a handful of blisters and sore hands.  Here's some photos of the cutout hands:
Hands cut out, but still with the paper templates attached.

The templates have been removed and the hands cleaned up, ready for paint.

With the hands cut out, I had to shorten each of the center shafts to fit behind the glass door.  I had intentionally left them long because I didn't know how long I needed them to be when I built the mechanism. With the shafts shortened, I mounted the mechanism, Arduino, and wireless bridge into the back of the clock body:
Rear of the clock body showing the guts.  This is minus the power supplies.

The front of the clock with a couple hands attached, but no photos in them yet.

I chose some nice photos of each family member, converted them to a sepia look and cut them out to fit.  A little bit of glue and I had a finished clock top.

The finished clock top with all five hands with their appropriate faces!

My next steps are to finish restoring the clock base and waist to complete the grandfather clock.  This should go relatively quickly, but I'll post updates to it.  I also need to post the files and code that I used for the face, hands, etc.

What an awesome project this has been!

Friday, September 23, 2011

A non-clock post

I figure I should post something non-clock related.  One of my other hobbies is collecting firearms and target shooting.  It's a hobby at this point as I'm not shooting competitively yet, but I have wanted to build a target rifle and/or hunting rifle for some time.

I ran into a guy at my last range trip that was praising his Millett TRS scope.  I took a look at it and also liked it.  I also liked the price.  For $300 you get a 4-16x50mm scope with illuminated mil-dot reticle and other nice features.  I ordered one from Cheaper Than Dirt and it arrived very quickly.  I just ordered a mount for it from Wilson Combat.  I got the Accu-Riser scope mount for 30mm scopes.

My plan is to see if this will fit on my current AR15 carbine, and if so I should be able to play with it for a while.  If it won't fit (it's a large scope) I plan to get a new 20" upper and be able to switch out the carbine or rifle uppers at will.  Right now I'm leaning toward this one from Palmetto State Armory.

Eventually, I would like to get a new lower as well.  I either want to get the Magpul PRS stock or the CAA ARS stock.  Right now I'm leaning toward the CAA stock.

Monday, September 19, 2011

Lots done on the clock this weekend

I was able to get quite a bit done on the Whereabouts Clock this weekend.  I had previously posted that the brass face for the clock has been silk screened and it looks great.  I did put some clear lacquer on the front of it to protect it from tarnishing.  I had also been working on a frame to hold the face in the clock.  The original design of the grandfather clock had the face mounted to the clock internals, and it left a lot of empty space surrounding the face.  It looked really bad, according to my wife.  I purchased some 1" x 6" red oak stock and built a frame to fit inside the cabinet and hold the brass face.

The oak frame and brass face are glued to some 1/4" hardboard and glued inside the case.  In the original design of the grandfather clock, the front face was the only maintenance access to the internals.

With the oak frame and face in place, there's no way to access the clock internals from the front.  I built a door to cover the back plywood and have it closing with some 1/2" round magnets.  With this door on the back the servers, networking gear, Arduino, etc. will all be accessible.  Here's some pictures of the build so far:

Saturday, August 20, 2011

Clock face brass completed

I got the silkscreened brass back from James at Preston Screen Printing this morning. He did a great job with it.

I was able to work quite a bit more on the clock today. I need to clear laquer the brass face to keep it from tarnishing, but I have to do it when it's between 50 and 90 degrees. Our string of 100+ degree days isn't helping on that front. I got a lot done on the frame for the face. The original grandfather clock frame left a big gap around the brass face and looked rather bad, so I'm constructing an oak frame that will fill the gap. This will make the face a permanent fixture of the clock, so the mechanism will have to be accessed from the back instead of the front door of the clock. It's gluing this evening, so hopefully tomorrow I'll be able to get the router out and put a decorative finish to the face frame and start to get it installed.

Tuesday, August 9, 2011

Clock face to be silkscreened

I just dropped off the brass for the clock face and the design to James at Preston Screen Printing. His rate is very reasonable. When I get the piece back in a few days I'll post results pictures.

Sunday, August 7, 2011

Update 8/7, Part 2

Aside from the clock face itself, I started work on the hands. I wanted each hand to be slightly different and hold a photo of each family member. I haven't figured out the photo mounting mechanism yet. I want the photos to be fairly easy to replace since I have young children and their appearance is likely to change over the years (imagine that). I got a tril copy of AutoCAD and drew up the five hands.

I have a couple thicknesses of sheet steel I want to use for these, but I'm not sure yet how well I can cut and drill these out. I think between my drill press and nibbler that I should be able to do pretty well, but I'll have to try out a couple first.

Update 8/7, Part 1

I was able to work a bit on the clock the past couple of weekends. First, an update on the clock face:

I found that ironing the toner to a clean, shiny piece of brass was a non-starter. I found the best technique to be scrubbing the brass with a green Scotch-Brite pad in perpendicular directions improved the toner adhesion quite a bit. The second was to thoroughly clean it with acetone to remove any oils or other dirt that may have accumulated. Regular alcohol was not sufficient. After I did both of these I got what I hoped would be two good sample tries. The first was using laser printed on inkjet photo paper like many online sites recommend, and the second was a glossy laser paper. I liked the second better because I was able to get it printed at tabloid size, whereas the inkjet photo paper was letter size only. I should have grabbed some shots of the two samples. The inkjet paper left only toner behind and it was nice and shiny, the glossy laser paper left quite a bit of paper residue behind. In either case it looked like the transfer was pretty good, so I moved onto the galvanic etching.

I took a bucket of water and dissolved about 2 cups or so of the root killer (Copper Sulfate). It left the water a bright blue color as many other's attempts did. I taped the positive lead from my battery charger to the back of the plate to be etched and submerged it all the way to the bottom. I suspended a scrap piece of brass about 4" above it with some bent coat hanger. The battery charger was set on the 12V/10A setting and I could tell something was happening because the charging indicator was about 1/2 way between "doing nothing" and "full out." Within a couple minutes the scrap plate was starting to turn black on the underside. Here's a pic of the setup:

The results were impressive. I did the first one for about 20-25 minutes to get a nice etch. I think it took so long because I didn't mask off the edges and it really had to remove a lot of material. The second went about 15 minutes and got a real good etch. This method of etching really does work, but the toner didn't stick as well as I would like and left a lot of pitting and not a very clean look. I would be ok with a little bit of pitting -- it would add to the antique look of the piece, but this was overkill. See my sample results 1 and 2:

At this point I'm tired of wasting time trying to find the "perfect" paper to do a toner transfer and etch. I'm investigating now having the image screen printed to the brass in black ink. I'll probably laquer over the paint to help protect it.

Saturday, July 23, 2011

Starting to work on the clock face

I haven't touched the whereabouts clock in quite a while. A few weeks back I did complete the woodwork on the upper third of the grandfather clock that I'm using to house the project. I think it looks pretty slick. I also was able to mount the mechanism inside, so now it's on to creating the clock face.

I studied up on how previous folks have etched brass. Mostly here and here. I took my design down to Office Depot to print since I don't have a laser printer. They didn't have ledger size inkjet photo paper, but they guy did say he had some glossy ledger paper. I gave it a try on a sample piece of brass.

I ironed on the paper like the instructions said and soaked it in water to dissolve the paper. What a failure! I think that 1) I didn't have him print it with enough toner, and 2) the paper is not quite right. Large chunks of toner stuck to the paper and came off instead of sticking to the brass. Fortunately, the prints from Office Depot cost me less than $2, so I'm not worried about it. I'll try to use some real inkjet photo paper and create some tests on a borrowed laser printer before I try to track down some ledger size inkjet photo paper.

Trial and error!

Tuesday, May 31, 2011

Slow Progress on the Clock

I've been working on the whereabouts clock in fits and starts since I got the grandfather clock body. I've disassembled the top third of the clock (since that's the part that I really care about at the moment) and started stripping off the old stain and making some small repairs as needed. I've polished up some of the hardware to make it a little shinier, but still retain some antiqued look to it.

I bought some glass to insert into the door, but it might be too thin. I may need to have Heather get some from a stained glass shop or custom glass shop to get it to fit right. We'll see what happens when we get there.

I finally found a decent supply of brass for the face. I tried all the big-box stores first (since I was there anyway) and got nothing. The hobby shop had some, but only tiny pieces. I ended up going to Metals4U up the road and got a pretty big piece for about $30. I hope it's thick enough to etch. I will have to glue it onto some thin ply or other wood to reinforce it. Hey, that's what the grandfather clock did, so it can't be that bad of an idea.

I'm getting close to finishing the design of the face. Since my clock face isn't square or round, but square with a half-round at the top I'm having to be a bit creative in the big empty spaces. First I thought that the Hogwarts crest would be cool to put there, but this is my clock not Hogwarts or Harry Potter. I'm leaning toward using some or all of the Jones family crest. It has to be only in black and white, so that's a challenge. I think I like the rampant lion above the surname in the half-round section of the face. I'll post the image once I've completed it.

Tuesday, May 17, 2011

Clock body

I've been looking the past several weeks for a suitable clock body to install the whereabouts clock. I tried calling around to a few clock shops to see if they had any busted clocks with intact frames, but I didn't have any luck with that. Seems that most people have busted clock mechanisms in pretty frames that they want fixed. I pretty much left my search up to Craigslist after that.

I found a guy in
Austin selling a broken wall clock that
I thought would work. $50 later and I have a clock that is too shallow for my parts. It's a beautiful clock, so for a few more bucks at Hobby Lobby I replaced the movement. Of course, after doing that the old movement works again. Oh well.

I kept looking through old posts and found someone selling a "Baby Grandfather Clock." It's design is more like a mantle clock, but it was real
ly about the size I was looking for. However, it too was too shallow. If I left it as a table top clock (as it could be) the depth wouldn't be a problem, but servos would be hanging out of the back. The couple selling the clock told me that they did have a broken grandfather clock also, so I asked to check it out. The clock was a mess. The movement was missing a bunch of pieces, but that was no problem. The glass in the front was completely missing, and the wood needed some TLC. A few wood pieces broke off getting it loaded in the van, but for $60 I think it'll clean up ok.

I started to take it apart last night to get it ready for stripping and restaining. Here's a pic of the top piece with the movement and door removed:

There's also a little label on the back, but I can't make out much of it. It'll probably get removed and tossed. I hate losing any history from what could be a great piece, but this old clock has definitely seen better days.

Tuesday, May 3, 2011

Improved Location Code

Tonight I worked quite a bit on the location code. I had started just to expand the list of known locations in the script, but that proved to be very long and probably not very efficient. I figured that adding the known location data into the MySQL database would provide an easier way to search for that data.

I also added a couple tables to the database. One is a simple username and location table for storing override data. When a user is not set to "GPS" it will turn the clock to the specified location instead of using the GPS data. This will be used quite a bit for testing and also in the iPhone App I want to write.

I also added a scheduling table for the kids. When the script runs it will check to see if there is a defined schedule for "now" and set the location according to the schedule.

The next thing I want to do with the code is to utilize the override table to attach the kids (who don't have phones) to a specific user. Now it's just hardcoded to my wife. I should be able to switch them back and forth as required.

Now that I have a functioning prototype I need to acquire a clock frame to put it all in and build the face and hands.

Saturday, April 30, 2011

Functioning Clock

I got the clock together and functioning today. It gets the data wirelessly over the Arduino Ethernet shield and wireless AP that I bought. The servos have been calibrated and it checks every minute for any new updates on the server and moves the hands to the proper location. There's still a long list of stuff to do before I consider it completed, but today really marks a milestone in the project.

Servo calibration

I'm working some more with the servos and with the gearing I have the servos will move the hands 540 degrees (1-1/2 turns). The Arduino servo class takes inputs between 0 and 180. On my clock, this translates to 3 o'clock position being 0, 12 o'clock as 90 and 9 o'clock as 180 going around clockwise.

I needed a method to make sure that each of the 5 servos:
  • start and end at the same positions
  • can reliably hit each of the 12 clock positions reliably
The first one is pretty easy. When attaching a Servo object to a pin you specify the minimum and maximum time (in us) that the servo will use. Most servos use 900us as a minimum and 2100us as a maximum. By altering this slightly for each servo I could get all the servos to start and end at the same position.

The second one was a little tougher. It turns out that a 10 degree Arduino input corresponds to one clock face position (30 degrees) for all the servos, but one servo would not reliably move to a position if the movement was too small (10 Arduino degrees). I wrote a subroutine in the Arduino code to take an offset factor defined for each servo (the first 4 are zero; servo5 uses an offset of 4) and the code causes the input value and goes a little farther to help push the servo to the desired position.

Here's an example of how it works: If the current position is 20, and we need to move to 30 the subroutine will actually move the servo to 34 for a couple seconds and then back to 30. If it's at 60 and we want to move to 50 the subroutine moves it to 46 for 2 seconds then to 50. It does this even for larger moves, and seems to work pretty well for this stubborn servo.

Friday, April 29, 2011

Wireless Bridge

I picked up a 3Com Wireless b/g access point off of Amazon for $20 used. I want the clock to get its data over the home wireless network and not have to run one more cable for this thing.

It took a bit of messing around with the access point to get it into a working bridge mode, but I did finally get it to work. Hooray! I can move the clock around the house now.

Wednesday, April 27, 2011

Alternative Drive Idea

Before I embarked on the build of the project I was torn between using servo motors or using stepper motors. I had originally opted for the servos because an Arduino can only control 2 steppers with the motor shield, and up to 3 with the EasyDriver Stepper controller. I need 5 motors, so each of these options were out and I went with servos instead.

After some frustration with the servos, I started to reconsider how I might control more steppers with the Arduino. I remembered back to my college days of basic circuit design and remembered a device called a demuxer that could control multiple output lines with fewer input lines triggered by a binary pattern. I checked out the EasyDriver again, and it has an "enable" pin that "enables" the board and the motor. If I could take 3 digital lines from the Arduino through a demux I should be able to control up to 8 stepper motors (each with their own EasyDriver).

I took down some notes (which I will add later) to detail more of this design, but unless my servo version complete craps itself I'm not going to ditch the current design. I've already sunk too much money in it to switch now. Maybe a version 2.0 later one will use steppers (or someone else can use this idea!)

Edit (5/2/2011): I found this chip (DM74LS138 8way demux) that could be used to switch up to 8 stepper motors with one Arduino. You could only control one motor at a time, but that should be fine for a clock. A counterpart 8-1 mux could also be incorporated to receive a location switch closure to make sure that the hands are where you think they are.

Some Servo Problems

I ran into some servo problems a while back that I haven't had time to try to fix. The first one turned out to be a programming error where I was using a byte data type to hold too much data. I'm finding that the C-like programming of the Arduino is very limited, and it's taking some getting used to from my experience with more fully featured Perl/PHP languages that I'm used to.

The second thing was that one of the servo motor brass gear shafts kept popping off the plastic servo output shaft. I fit the 1/4" o.d. brass tubing over the slightly less than 1/4" servo drive shaft by expanding the brass tubing slightly. The problem was that the alignment between the servo and the end of the brass tubing was off slightly causing the tube to "walk" off of the plastic shaft as it rotated. I took my micrometer and measured the vertical and horizontal variations from back to front on all the servos. Most of them were off my .02" at most (which is about the size of a mechanical pencil lead) and shouldn't be a problem, but the one in particular was off by .06" and was causing problems. I removed some rubber mounting bushings which allowed a little more wiggle on the servo mounting and now it's within the .02" variance as the others. So far, so good.

I also found that for large movements the servos did well, but for small adjustments (10 degrees in Arduino) it didn't always do well in repositioning. I thought that there might be too much friction in the gear shafts for the servo torque to overcome, so I tore everything apart again and applied a little oil to all the brass. It helped a bit, but still didn't solve the problem. Then I remembered that these servos are rated something like 5-7 volts, and I had been running them on 5 volts. After bumping up the power supply to 6 volts, everything seems to be in order.

I wrote a quick program to help me calibrate the servo motors to the various clock positions. I plan to do this initially with altering the low and high PWM values for the servos. The factory recommendation is between 900 and 2100 milliseconds, but each servo is a little different (gotta love analog!) By altering these values slightly I can get the servo start and end positions very close to each other. The next step will be to validate the intermediate positions and see if additional adjustment factors are needed to get each servo to reliable move to each of the 12 clock positions.

Wednesday, April 13, 2011

Adding some error checking

I figured that it would be nice for the Arduino to be able to indicate that there was a problem without having to have it connected to a PC. I added a single LED to an unused pin and created a routine to blink it on and off based on an error condition. Works pretty well.

Well enough to tell me that for some reason the Arduino w/ Ethernet shield doesn't like to work without being plugged into USB as well as the external power. It could be that my power supply isn't clean enough or enough voltage to operate everything at once. More investigation is needed. I was hoping to only have a single power cord for this clock.

Tuesday, April 12, 2011

Positioning Code and First Breakage

Tonight I was able to work on some of the positioning code for the clock. Yesterday I was able to get all 12 positions working, but the servos allow for up to 540 degrees of movement in the configuration I have. I want the hands to randomly move to the location if more than one direction is possible. I was able to do just that right before one of the drive shafts came off the servo. I'll have to repair it to get back on track. It does concern me that these may come off fairly easy. I don't want to glue them to the servo, but I may have to find an alternative to pressure fitting them.

Monday, April 11, 2011

First Arduino Clock Code

Tonight I hooked up the possibly completed clock movement to the Arduino and started to assemble the network fetching code with the servo movement code to actually make the clock be a clock.

I think I have the twelve locations that I want the clock to have. I chose all of the locations mentioned in the book along with a few of my own to round out twelve.

It turns out that the 30 degrees between clock points is almost exactly 10 degrees in the Arduino servo code when using these sail-winch servos. With the gearing I have in the clock I get a little more than 540 degrees out of each servo. I will eventually add some code that will make the servo move in the most optimum direction to get to the location. That'll have to be part of LOTS of other optimizing I will need to do to polish this thing up.

For now, I have a paper dial with the 12 locations and small zip ties for each of the five hands. Here's a sample pic:

Sunday, April 10, 2011

Movement Almost Finished

I was able to run by the hobby shop after church today to pick up more servo mounting screws, and I was able to get the last of the servos mounted on the backplane.

I also was able to complete the nested shafts for the hands of the clock. I had 5 sizes of brass tubing that all nested nicely into each other, but all my gears have 1/4" holes. I had to cut small spacers of each of the necessary sizes to make the small diameter shafts fit snugly with each drive gear. Here's a pick of the finished hand shafts:

I used 5 min epoxy to glue the brass tubing together. I know that most glues won't work on metal (it's non-porous). Epoxy should do the trick. It's not like any part of this clock requires lots of torque or has lots of pressure on it.

I was able to attach the brass drive shafts to the servos by expanding the tubing slightly and pressing them onto the plastic shaft of the servo. So far, it's holding well and aligns perfectly.

Here's some more pics of the finished mechanism:

Saturday, April 9, 2011

Build Started

I stopped by the hobby shop on Friday and picked up some more hardware to work on the Whereabouts clock. I've been working with Sketchup to model the clock in 3D before I start cutting brass tubing and plywood. I was able to model the servos and gears and got a good top-view of the mechanism. I printed it out in full scale and was able to use my drill press to drill the 6 holes for each servo shaft and the center shaft. I then used the scroll saw to open up the holes in one piece of plywood to make the holes where the servos mount.

For the brass tubing I was planning on using a regular tubing cutter, as the guy at had used, but I must say it was a dismal failure. I knew that the cutter would leave a bit of a lip on the inside of the tubing that would need to be filed off, but it actually resized the end of the tube slightly smaller where the next smaller tube would no longer fit. I quickly abandoned the tubing cutter and went with a Dremel tool fitted with a cutting wheel and griding stone. I was able to make quick cuts through the tubing without having to resize it after each cut.

After a full day's work on it I have 4 of the 5 servos mounted to the back piece of plywood. I have all the brass bushings for the axles on the front plywood, but these will need to be glued in later. I don't have the nested center tube completed for the hands yet, but I was able to successfully stack all 5 center gears and the individual servo gear on their own axle. I even plugged them into the Arduino running the same little servo test from a previous post and they all work just fine!

Here's a picture of the progress I've made so far:

Thursday, March 31, 2011

Arduino Servo Shield

I bought a piece of breadboard and was able to solder up a shield for the Arduino to power the 5 servos. I'm taking the direct supply power from the 'Vin' pin and the ground to a bus connecting all 5 servos, and pins 2, 3, 5, 6, and 7 to each signal pin of the servo. Each servo gets its own 3-pin header. It looks really nice and give a solid connection to everything. If I ever need to add other small components it'll be really easy because I left plenty of space.

Here's a small video of all 5 servos cycling back and forth for a little while.

Monday, March 28, 2011

Power Options

I discovered earlier, that I would need an external power supply to drive the servos and that it would need to power the Arduino as well so that the grounds are common. This is no problem as I don't plan on having my clock plugged into the USB port on the computer all the time. I bought some stuff to build my own "Servo shield" to plug in the servos. It's a piece of breadboard and some header pins to connect it all. I was thinking that I would need to split the 5V power leads to provide separate (but equal) power to the servo board and to the Arduino, but I was wrong.

On the Arduino boards, there's a pin marked "Vin" on the Arduino UNO (or 9V on older models) that provides pass-through power when using external power. This is not the limited 5V regulated power to the Arduino, this is the unmodified power from the external supply. (The same pin can be used to power the board, if desired.)

My servo board just got really simple. I bring the power and ground from the external supply and provide them as a bus for the 5 servos. I plan on connecting servos to digital pins 2, 3, 5, 6 & 7. Pin 4 is used to switch on the SD card slot on the Ethernet Shield, and pins 10-13 are used to control the Ethernet port. If I need to add other stuff later (perhaps a chime) I still have all my analog pins and a couple digital pins leftover.

Arduino Data Parsing

Tonight I started looking at having the Arduino parse the location output stored on the server. With the Ethernet shield on the Arduino I call a PHP script that fetches the last locations of each of the family members. That's great and all, but I need to get it down to a person and a location.

The Arduino is not Perl and has no regular expression capability or split functions, but it does have some string functions that might be useful. After poking around for the best solution, I found this forum where a guy was using an Arduino to parse NOAA XML weather data. His code worked like a champ, so I'm using it with some modification. I had to go back and alter my PHP script to output some XML formatted data, but that's a piece of cake.

Now I have two arrays in the Arduino. One for people, and one for locations that have been parsed from the data off the webserver.

Next up: how to translate that location data into physical servo locations.

Sunday, March 27, 2011


I decided recently that I would design my mechanism similar to the guy over at, so I ordered 5 of the GWS S125 1T 2BB servos online. They arrived on Friday so I hooked one up to my Arduino with an external power supply, loaded the sample servo sweep sketch, and watched in horror as the servo spinned continuously clockwise.

I browsed all over the web looking for the source of the problem. I read that some people had servos where the pinion gear that drives the potentiometer inside the servo was not firmly attached to the drive shaft and a little lock-tite was the solution. I tried that, but had no luck. I think it actually stripped out the little plastic gear attached to the potentiometer. Metal pinion gear vs. plastic potentiometer gear is not a good recipe for success.

I tried using different pins on the Arduino. No good. I tried running the servo off the Arduino power. It made the Arduino croak due to the load. I tried manually setting the PWM frequency of the servo output, but without an oscilloscope I couldn't see what it was actually doing. Same as before.

After nearly pulling my hair out and abandoning servos for steppers (not sure how I was going to do that since most Arduino projects are limited to 2 or 3 steppers, not 5), it struck me this morning that I was powering the servo off an external 5V supply, and powering the Arduino off the USB port on my Mac. There was nothing tying the ground of the power supply to the ground of the Arduino, and this might be the cause of my problems.

It was! After connecting the power supply to the external power pins on the Arduino, my server happily returned to center. I did have to take apart one of the other servos to get it off the end of the potentiometer travel that was stripped out, but it's functional.

Also, using a frequency range from 0.9 ms to 2.1 ms gave me about 400+ degrees travel from end to end. I only need one full turn, so this is great. I suspect that this servo is capable of more total travel, but I don't want to push it any more in case I hit the ends where the gear is stripped out.

I've modeled the servo in Sketchup, so I should be able to plan out pretty accurately how to mount these things. I don't have any extremely precise cutting tools, but my scroll saw and bench press should be up to the task.

Thursday, March 24, 2011

Ethernet Shield Added

I've been working on my own Whereabouts clock for a while now. For the most part I've just been thinking through some things, but now I'm actually trying to make it a reality.

I got my Arduino Ethernet Shield in the mail today. I revamped the fetch locations script on the web server to update a MySQL database instead of a flat file. Now I have a table for each family member instead of a group of flat files. I also created a fetch script that's used by the Arduino to fetch the latest entry in the database. I plan to parse the results to have the Arduino move the servo motors to the correct location.

My servo motors should be on their way here, but I've still got plenty to work on until they arrive. I'll have to fill in more on this project as I have time.

Wednesday, March 23, 2011

The Location Data

So after looking at a couple examples of a working "Whereabouts Clock" I decided that I wanted to try to make my own. After all, it's really cool! Before I spent any money buying parts and diving into the mechanics of it all, I really wanted to nail down the location data. Other examples use a Twitter feed and keyword searching to grab the locations, but I wanted mine to be fully automatic requiring nothing from me.

My wife and I both have iPhones, so I figured "how hard could it be?"

I started thinking about this project over 5 months ago, and wanted to start with the location data. I browsed around the App Store looking for some way to grab the location data off my phone periodically and upload it to my home server. I found a couple examples that I purchased and found that the folks over at had a really cool product. I downloaded the App and configured it on my phone along with their server. Ta Da! I now had a way to get the location data from my phone periodically.

I messed around with the device-locater app for a while. I hooked it into my Google Latitude account, and with their API was able to collect my location data pretty reliably. Then, Google released their own Latitude App for free that did the same thing as the device-locater App. I tried Latitude for a while, and it was nice, but periodically it would say I was a good 5 miles from where I actually was, so I gave up on it.

The device-locater app actually has a way to call out to your own server to push the data to, so with a little PHP script I was able to get data from my phone, through the device-locater site, into my server. Great!

There was only one little problem. I have an iPhone 4, which has some semblance of multi-tasking. My wife has my old iPhone 3G (not 3Gs), so she has NO multi-tasking. The Latitude and device-locater apps worked fine, as long as she clicked on the app and manually had it update with her location. This was not going to work.

Then, with the release of iOS4, Apple made the "Find My iPhone" feature of MobileMe free to everyone with an iPhone and an iTunes account. Hurrah! I quickly downloaded the app onto our phones and added them to my account. Now I could see my phone and my wife's just by going to the MobileMe site. to get that data to my server??

It turns out that this is not a unique problem, and for the time being has been solved by Tyler Hall. Essentially he's created a PHP object that is an API for the MobileMe find my iphone. With a little PHP scripting I was able to pull the data from MobileMe onto my home server. I setup my script as a cronjob to run every 1/2 hour and grab our locations. I could do it more frequently, but the more often you check the worse the battery life on the phones are.

Hooray! I've been collecting our locations every 1/2 hour for almost 4 months now without a problem. Here's hoping that Apple doesn't shutdown the sosumi project.

The Whereabouts Clock -- Background

I've been a fan of the Harry Potter series since the movies first hit the big screen in 2001. Since then I've read all the books, and I can't wait until the final movie is out. In a couple of the booksand in the movies there are a few references to a magical clock at the Weasley's house:

The first specific description of the family clock is from Goblet of Fire (pages. 151-153):
Mrs. Weasley glanced at the grandfather clock in the corner. Harry liked this clock. It was completely useless if you wanted to know the time, but otherwise very informative. It had nine golden hands, and each of them was engraved with one of the Weasley family’s names. There were no numerals around the face, but descriptions of where each family member might be. “Home,” “school,” and “work” were there, but there was also “traveling,” “lost,” “hospital,” “prison,” and, in the position where the number twelve would be on a normal clock, “mortal peril.”

Eight of the hands were currently pointing to the “home” position, but Mr. Weasley’s, which was the longest, was still pointing to “work.”
. . .

“Oh your father’s coming!” she said suddenly, looking up at the clock again.

Mr. Weasley’s hand had suddenly spun from “work” to “traveling”; a second later it had shuddered to a halt on “home” with the others, and they heard him calling from the kitchen.
It appears again in Order of the Phoenix (pages 471-472):
”And Dumbledore – what about Molly?” said Professor McGonagall, pausing at the door.

“That will be a job for Fawkes when he has finished keeping a lookout for anybody approaching,” said Dumbledore. “But she may already know . . . that excellent clock of hers . . .”

Harry knew Dumbledore was referring to the clock that told, not the time, but the whereabouts and conditions of the various Weasley family members, and with a pang he thought that Mr. Weasley’s hand must, even now, be pointing at “mortal peril.”
And in the Half-Blood Prince (pages. 85-88):
She turned to look at a large clock that was perched awkwardly on top of a pile of sheets in the washing basket at the end of the table. Harry recognized it at once: It had nine hands, each inscribed with the name of a family member, and usually hung on the Weasley’s sitting room wall, though its current position suggested that Mrs. Weasley had taken to carrying it around the house with her. Every single one of the nine hands was now pointing at “mortal peril.”

“It’s been like that for a while now,” said Mrs. Weasley, in an unconvincingly casual voice, “ever since You-Know-Who came back into the open. I suppose everybody’s in mortal danger now . . . . I don’t think it can be just our family . . . but I don’t know anyone else who’s got a clock like this, so I can’t check. Oh!”

With a sudden exclamation she pointed at the clock’s face. Mr. Weasley’s hand had switched to “traveling.”
. . .
Harry saw Mrs. Weasley glance at the clock in the washing basket as they left the kitchen. All the hands were once again at “mortal peril.”
I've seen a few attempts to recreate this clock in a real and physical sense. This person created a very good looking clock that updates the locations via keywords in Twitter feeds. Microsoft apparently is making an attempt as well, but theirs doesn't look much like a clock.

I wanted a nice looking clock that would automatically track my family without having to update locations manually. My wife and I both have iPhones, so this should be easy, right? It turns out that what I thought was hard (the location data) is actually pretty easy.