Animated Nativity Book

Having completed the animated blowmold nativity, I decided I needed some text to help tell the nativity story better.  My final solution was to use pieces of corrugated plastic (the kind used for small road-side political signs) to act as pages of a book with abridged bible verses on them.  I have a cover, and 5 pages (all turn except the last page) that are shown at each stage of the nativity’s animation.

The Mechanics
After thinking this over quite a bit and discussing it on a few forums, I ended up going with individual servos to turn each page (I got my servos from All Electronics).  A servo is a digital motor that can be rotated to a particular location by varying a digital pulse-width to it (called pulse-width modulation, or PWM).  By changing the pulse-width, you are able to change the location of the servo’s shaft (the servos I bought have ~180° of motion).

The pages are mounted vertically to a piece of threaded rod from Lowes via hot glue.  If you use a healthy amount of hot glue, it basically welds to the coro and it oozes into the threads on the rod to have a lot of surface area to grip onto.  My first pass was very dainty, so it had a pretty weak hold; after that I globbed it on and now it has s great bond.  The rod extends above and below the pages to act as a pivot point.

After some trial-and-error attempts at getting a nice fluid rotation without too much stress on the servos, I ended up buying some pillow block bearings on eBay (specifically a 2-bolt flange with screw lock and a 15mm shaft).  The pillow block is installed at the top of the book (inside an enclosure so it is out of the elements), and the top of threaded rod is locked into place with a screw lock mechanism.  The rod itself is too small for the 15mm opening in the bearing, so I bought some threaded rod couplers, and wrapped the couplers in some tape.  This made the coupler round, gave the locking screw something to bite into, and made the coupler snug in the bearing.  The bottom of the threaded rod (underneath the bottom of the page) hangs suspended through a hole cut into a piece of wood to keep the page from swaying in the wind.

To mount the rod to the servo horn, I used some 1/4″ fender washers that were roughly the size of the plastic horns that I got with my servo, and I welded a nut onto them. I then drilled two holes into the washer that match some of the many holes in my plastic horn for the servo.  The horn attaches to the servo like normal, then the new nut/washer combo I made gets screwed onto the piece of threaded rod that is extending above the bearing.  I then attached the plastic horn to the mating fender washer via some cotter pins, and snugged a second nut and split washer up onto the nut/washer combo to keep it into place.  Here is a picture of the setup for visual reference.

This setup is used for the cover and the first four pages of the book.  The last page will be fixed in place and will not move.

The Electronics
Digital servos are driven with pulse-width modulation (PWM) to control it (a good visual can be found here), so I went to my handy PIC to use as a controller.  Since this was going to need to be controlled by the animated blowmold project, I just used the same PIC as that project for simplicity’s sake (probably overkill for this project).

The PIC must control 5 individual PWM outputs at all times (the servo must be refreshed with a new signal at least every 20ms [50 times a second], even when not moving), and take commands from the blowmold project’s PIC to turn pages.  In addition, I also added a potentiometer to the circuit board to use to configure the opening/closing positions of all five servos.

The Code
The crux of the PIC code is a small, tight, interrupt driven assembly routine I found here, that can drive up to 32 servos at one time.  I modified it for my PIC speed and to only drive 6 servos (I have a spare for future use).

In this application, the servos basically have an opening position and a closing position for each page (so 10 variables for the 5 motors).  I store the values in non-volatile EEPROM and read them into memory upon boot.  50 times a second the code will read what the requested servo position is and compare it to the current servo position.  If they differ,  I move the servo one step closer to the requested position; if they are the same, I send the current position to the servo anyway to keep it in place.  I could set the value straight to the requested position all at once and be done with it, but that would mean a VERY fast page turn with minimal torque, so I opted for a slower, yet smooth, turn.  My current method takes about a second for the page to turn ~180° and it has a nice dramatic look.

Upon power up, the servos are all reset to their “home” position (which is all of the pages “closed”) so that the book is closed and it sits and waits for commands.  Because I do not know the current position when everything comes alive (wind could have blown a page when it was powered down), I just move the pages to the home position without doing the slow rotation mentioned above, so this happens VERY fast.

There is a serial module attached to the PIC to convert between the PIC’s serial TTL and RS-232 protocol.  This allows the PIC to accept commands from the blowmold display so that it knows what step the animation is on, as well as to offer a simple menuing system for diagnostics/configuration from a laptop.  I went with serial because it is barebones simple (and cheap!), but I could foresee switching to something wireless in the future to get rid of the 25ft serial cable between the book’s PIC and the blowmold’s PIC.

Something that wasn’t part of my original plan, but was rather necessary, was the ability to configure the opening/closing positions of each page individually on the fly.  To accomplish this, the PIC has the ability to receive special commands on the serial port and rotate the respective page to wherever the potentiometer is (as you turn the pot, the page turns with it).  In this way I can turn the pot and when I am happy with the location of the page, save it to memory.  This allowed me to do fine-tune settings when first built as well as make things simpler if I need to make an adjustment to a single page in the middle of the yard (in the dark/cold/snow) while cars are lining up to see it.

A schematic can be found here (**TODO** Add the schematic).

The power requirements for this project are pretty straight forward, but slightly hefty (the servos can draw as much as 2A each when stuck pushing against something).  Both the PIC and the servos run off of 5VDC; but I tried to keep their power separate to keep any power glitches away from the PIC (servos have the potential to cause a lot of noise on the line during movement or if they are struggling against a force).  For this project I used an old ATX PC power supply.  The 5V rail offers more than enough headway to power the servos, as well as extra voltage rails for the PIC.

To keep the PIC’s voltage clean, I used the power supply’s 12V rail, and dropped the voltage to 5V with a 7805 linear voltage regulator.  Now everything is running off of 5V, but the PIC is separated from the (electrically) noisy servos.

Beefy capacitors are added to the design to help with instantaneous servo power draws on startup.