Wednesday, February 12, 2020

Animation and Sound With an Arduino



I plan to have several areas around the layout that have sound and animation.  There will be a 20 stamp ore mill with a detailed interior.  While I don't have plans to animate it I do have a sound track of the mill in operation.  In town there will be a saloon with a dedicated sound track and at the roundhouse there will also be sounds of work being done.  The main focus of animation with sound will be at the engine service facility.  I've been using this as a learning module to develop scratch building  modeling techniques, learn about Arduino programming and create sound files from scratch.

The engine service facility consists of a water tank, coaling tower, sand house and ash pit.  I'm using an Arduino Mega 2560 with a motor control board and a WAV Player from Sparkfun for sound and one single sketch to control everything in seven different scenes.  Both sound and animation are initiated by a pushbutton mounted on the fascia of the layout.  I'll use the animation for the water tank as an example of what was involved.

The water tank scene was first designed by making a timeline of what I wanted to happen.

T0 - Depress fascia mounted button - initiates sequence

T0 to T+4 - Open tenders water hatch (sound only) - On the WAV Player track #1 is initiated and enters a 4 second sound of the water hatch being opened on the tender.

T+4 to T+14 - Lower Spout (sound and animation) - trigger is sent to the motor control board to begin spout being lowered.  Sound track enters 10 seconds of sound of cables running through pulleys while spout is lowered.

T+14 to T+126 - Pause - sound track enters 5 seconds of silence.  Motor drive stops spout motion and begins 112 second delay while sound track plays water flowing through spout into tender’s water box.

T+126 to T+136 - Raise Spout (sound and animation) - Sound track 1 enters sound of spout being raised.  MS sequence completes 112 second count and triggers spout being raised (10 second animation).

T+136 to T+144 - Pause - Sound track 1 enters 3 second silence then enters 5 second sound of tender's water hatch being closed.  Motor drive completes sequence.  End of Wave Player sound track 1.  End of Water Tank scene.

The sketch I built combines 7 different operations: sand house, ash pit, water tank, coaling tower spout, coaling tower bucket and coaling tower pit.  Separate buttons mounted on the fascia panel initiate different parts of the sketch.  In the sketch I used the “delay” command because it works with milliseconds and this allows tiny corrections with the Audacity program for perfect coordination with the animations.  The portion of the sketch for the water tank follows the timeline and goes like this:

void waterSpout() {

  // play sounds of water filling operation
  // run motor to animate water tank spout

  musicPlayer.startPlayingFile("Track006.wav"); // play sounds for water tank

  delay(4000);  // allow 4 seconds before motor operation

  waterSpoutMotor ->run(FORWARD);  // start motor forward

  delay(10000);  // allow 10 seconds to lower spout

  waterSpoutMotor ->run(RELEASE);  // stop motor

  delay(112000);  // allow 112 seconds for sound of water flowing

  waterSpoutMotor ->run(BACKWARD);  // start motor backward

  delay(10000);  // allow 10 seconds while spout raises to stored position

  waterSpoutMotor ->run(RELEASE);  // stop motor

  delay(8000);  // allow 8 seconds for sound track to complete

  musicPlayer.stopPlaying();  // stop playing sound file since animation is complete


  }


Sounds were developed using an ap called Streaming Audio Recorder that captures sounds from from the internet through your computer.  Using it you can make course changes to start and stop of the file and choose to make it a WAV file (my preferred ).  Once you have a usable sound you can modify it using Audacity, an ap used for developing sound files.  For the sound of water I combined 7 different WAV files to get the sound I wanted.   Then I took that small file and copied it and pasted end to end to make a seamless sound of water falling into the tender's tank for 112 seconds with it tapering in at the begining and out at the end.  The sounds of individual drops and echoes inside a metal chamber played an important part in all of this.

Each section of the sketch has it's own sound track and for me, making the sound tracks was the most fun.  There are a ton of sound files on the internet but you have to careful about sound quality and maybe most importantly, about background sounds.  You can use Audacity to clean up these files and even eliminate those background sounds but it's always easier to start with a clean sound file.

Audacity (https://www.audacityteam.org/) is an excellent program for editing sound tracks and it’s free.  It allows zooming into a graphic display of your track so you can work in milliseconds to clean up and modify files.  You can eliminate individual sound spikes that create “ticks” or other annoying anomalies.  You can stitch together multiple files to get the length of time you need and blend multiple files using separate tracks to layer sounds together.  It’s a very cool program and doesn’t take long to become familiar with.  Take the time to read the manual first.

Adding sound and animation to the layout adds a whole new level of “realism” and can add to your modeling skills too.  You can keep it simple and buy ready-made packages or take it to a whole new level and build your own.  Sound and animation made from scratch have the advantage of being higher quality (usually, you have total control) and exactly what you need for your specific scene.  I found the learning curve for building sound files to be fairly easy.

Learning the programming (modified C++) for the Arduino was more difficult for me.  It’s well worth investing the time though.  Arduino hardware is inexpensive and the software is encouraged to be “freeware”.  There are numerous forums available for learning and people seem anxious to help.  As an example, I wanted to write a sketch (program) to run my turntable.  I knew I wanted to use a keypad, LCD display, Arduino Mega and a Sparkfun stepper motor controller called Easydriver.  I had no idea how to make it all work.  I did find a sketch using these components that was written to control a feed table for a cutoff saw.  I copied that thinking I could make it work but had no idea what to do.  I found a forum for Arduino with model railroading and explained what I wanted to do.  A group of members participated but two very knowledgeable folks from opposite ends of the planet spent two months helping me write the sketch and explained in detail all their recommendations.  By the time the sketch was complete I had over 500 lines of code and what is probably the most complete turntable sketch in existence.  Plus I understood every bit of it.

For me, Arduino controlled animation and sound make the hobby way more fun and take it to a level never before possible and all at a reasonable cost.  The biggest expense is my time.  Just like developing every other skill needed for this hobby.







Coaling Tower



I eventually wanted to build a layout with a full engine service facility.  A coaling tower was an essential part of that but since my railroad is going to be a narrow gauge short line size was important.  There are some O scale kits out there but they are either too big for what I'm doing or too expensive.  The Durango tower from Raggs to Riches is really nice but the price of the kit is out of my league.  I don't think it's even available anymore.  I did some hunting around on the net and found a coaling tower that was used by the DSS&A RR up in Marquette, Michigan.  It was rated at about 25 tons which is plenty big enough for my short line.  Best of all, Wayne Wesolowski wrote an extensive four part article starting in the May 1988 issue of Model Railroad Craftsman about modeling this coaling tower.  My wife got me all four issues for my birthday and even contacted Wayne about the tower.  I had everything I needed to get started.  I read through the articles and decided I needed a full size drawing.  Just as I got started on that I found some photos of a coaling tower at the Henry Ford Museum that looked very similar.  This one was recently built in 2014 and designed by an architect using Wayne's article for inspiration.  What he designed uses the same basic design but is much beefier looking.  I contacted the architect and asked if he would share his drawings.  Not the design drawings but he said I could use the line drawings showing all four sides and I could get dimensions from there.



I compared the line drawings of the Ford tower to the drawings of the DSS&A tower and was able to work out dimensions.  I made a full set of drawings of my own, mostly based on the Ford design but modified for narrow gauge.


Actual construction was tedious but fairly straightforward.  I started with the front and rear frames, added the side framing to tie them together and then boxed in the coal bin board by board.  That was the tedious part.  For the steel cage around the ladder I used scale sizes of styrene.  I also used styrene for the fully operational coal chute.  The coal bucket in the back of the tower started out as a kit from Grandt Line for the Durango tower.  I cut it down to the proper size, eliminated the wheels and made a hoisting frame based on the DSS&A tower.  The coal pit behind the tower is based on the ones used in Durango and Chama with a raised service track.  The grating for the pit is another Grandt Line product.



 


The styrene parts were painted with a rattle can and then weathered with Bragdon powders (click here).  The coal chute and bucket were animated with stepper motors mounted beneath the layout and controlled by an Arduino.  The Arduino provides three separate sound tracks for the coaling tower.

The coal chute track starts with the sound of the chute being lowered and the gate opening.  The sound of coal falling down the chute lasts for 45 seconds, then the gate closes and the chute is raised.

The coal bucket track starts with the sound of a hit and miss engine starting up in the shack beside the tower.  The coal pit gate is opened and coal falls into the bucket for 10 seconds.  The gate closes and the bucket raises to the top of the tower, dumps and then lowers back to the pit.  This animation repeats 4 more times.

The third sound track has no animation.  It was made to provide the sound of a hopper dumping coal into the coal pit behind the tower.

Making sound tracks is another form of scratch building that takes the model to a whole new level of realism.


Building the Roundhouse and Shops, Part 3



With the roundhouse space closed in I moved on to detailing the interior.  I found a drawing of standard roundhouse designs for the Central Pacific RR and another of the roundhouse for the East Broad Top RR.  These showed dimensions for inspection pits and a drop pit for removing the driver wheels from a locomotive.  Cool!  That would be a nice feature to add.  The drop table uses a hydraulic lift placed under the locomotive.  After the drive wheels are unbolted the table is lowered and rolled to the side on a pair of tracks where the wheels can be removed from the pit and taken to the shop for machining.  The drop pit is just wide enough to take one or two pairs of drivers and the locomotive is still supported at each end by the other driver and maybe a pair of jacks under the cab.




I belong to a forum called FreeRails (Click here) and it was there that I was introduced to an inexpensive 3D printer (Ender 3, $200), the perfect thing for making my own parts.  You design the parts on a CAD program (I use TinkerCAD) then transfer your design to a slicer program (Cura) that creates the commands for the 3D printer to make your part.  It’s a lot easier than it sounds.  The cool thing is that you can make parts that aren’t available commercially like the drop table.  That was my first 3D project.  I designed the drop table itself from photos and the hydraulic system for it from an old drawing I came across.


I made the inspection pits from MDF and added sugar cube speakers at the far end of the floor for pits #1 and #2.  I disguised the speakers to look like floor drains using HO scale grating from Grandt Line.  The speakers will add sound effects for the roundhouse interior that will be activated from a button mounted on the layout facia.   The photos below show the inspection pits and parts used for the speakers and on the right is the CAD design for the sugar cube speaker baffle mounted below the pit floor.

 

It was about this time that my wife and I took a break and went to Savannah, Georgia for a long weekend.  The idea was to tour the old city section but it just turned out that there's a railroad museum about three blocks from where we stayed.  Hmmm.  The museum includes the roundhouse and shops of the Georgia Central RR and provided many details that I’ve tried to incorporate into my model.  These include ventilators in the skylights, wood block flooring, smoke jacks for the locomotive smoke stacks and interior lighting.


I made skylight ventilators from parts I got from Grandt Line before they went out of business.  The smoke jacks were also a kit from Grandt Line but I modified the hoods to resemble the smoke jacks I saw in Savannah and printed those out on the 3D printer.


The wood block floor took some investigation.  I found that industries used wood block flooring to prevent damage to machines parts that might be dropped.  This flooring was also used in greasy, oily environments.  The wood absorbs oil and prevents slippery conditions.  Individual brick shaped blocks can be replaced as needed.  I also found that it was common to seal the blocks with coal tar which makes the floor a dull black.  I think they did this to make the blocks waterproof.  I made my wood block flooring from HO scale brick plastic sheets that were intended for modeling roadways.  Painted grey/black the bricks closely resemble the coal tar sealed wood blocks.


For the interior lighting I used Grandt Line O scale lamp reflectors with soft white LEDs.  The LEDs came on a roll of 500 ($15) intended for lighting effects such as under cabinet lighting.  They were in series/parallel with groups of 3 matched with a resistor to supply the correct voltage.  I needed five rows of four and simply used a matching resistor for each row.  Worked out just fine and the extra LED in each row lowered the voltage enough to slightly dim the light.  Perfect.  The picture below right shows the lamps installed on the inverted roundhouse frame and the power busses running beneath each truss.

 


I also used the printer to make workbenches and storage cabinets and shelves as well as junk to put on the shelves and tool boxes for the workbenches.


In my roundhouse research I came across a photo showing a system used in the early 1900’s for blowing out the boiler tubes in locomotives.  Water running through the tubes is high in minerals and these collect on the inner surface and eventually clog the boiler tubes, creating a dangerous opportunity for explosion.  To prevent this a regular service routine involved cooling down the boiler water, blowing it out and then replacing it with fresh water.  Then the locomotive would be fired up and brought up to temperature.  This was usually an overnight process and reduced the amount of time the locomotives could be in operation, which of course meant loss of income.  This time was greatly reduced with the use of the Miller System, permanently installed in roundhouses and locomotive shops.  The system involved plumbing used to removed the old hot water, run it through a filter and then return it to the locomotive still hot.  I modeled it using brass rod for the piping and made the storage tanks, filters and pumps with the 3D printer.  Below can be seen the original drawing of the system, the pump room and equipment added to the back of the roundhouse, the plumbing mounted to the support post of the trusses and finally, how the overhead plumbing was routed.  In that last overhead shot you can also see the floor drain grating over the speaker in the closest inspection pit.







Building the Roundhouse and Shops, Part 2


With the painting finished I next built the interior framing.  I wanted it to have more detail than just a standard barn frame so I designed wood trusses supported by 12" x 12" posts.  Doing this the posts are only need at the walls and not in the center of the room which helps to keep things open for more machinery.



Once I completed the interior framing for the shop I decided to also do the framing for the roundhouse so I designed new trusses for that.  There will still be interior posts because the space is much larger but the trusses add some real visual appeal.  Before I built the roundhouse interior framing I mocked up all the walls and discovered an anomaly.  Because the room is so small I had to move the roundhouse 13" closer to the turntable which then required spreading out the rear wall to accommodate the wider angle between tracks.  Using the rear wall sections from the kit would leave a 1" gap on either end of the rear wall.



This is where things really snowballed.  I decided to make my own rear wall sections using parts of the side walls.  The nice part of this is that the windows would be much larger allowing a better view inside and more light for the crew.  I "cut and pasted" wall castings to properly fit behind the frame posts.  Note that in the original kit it was suggested to place posts at each wall section came together to hide the joints.  I've continued this and it works well with the design.  Using the side wall castings across the back actually made more sense to because then all the windows would be the same size.  I had also noticed that the original rear walls had smaller stones, probably originating from a different kit.  The final look with the larger windows more closely resembles old factory photos I've seen.


For the roundhouse framing I made up a full size drawing (1/4" = 1") that I could build the five identical frames from.  These were more complex than the shop frames because of the skylight housing and the sloping rear roof.  When finished I added NBW (nut, bolt, washer) castings to all the frames.


Tuesday, February 11, 2020

Building the Roundhouse and Shops, Part 1



After completing the turntable and before getting too far ahead with laying track I decided to take on building the roundhouse.  Ten years ago I had bought a Thomas Yorke roundhouse kit on eBay and never got around to assembling it.  A few months after buying it my wife and I sold our home and belongings and moved onto our boat with the intention of spending the next 15 years sailing around the world.  I did put my train stuff in storage thinking I would want to get back to it in my old age.  As it turned out, medical issues prevented us from chasing that dream and six years later we were back on dry land planning my next layout.  I'm so glad I saved my train stuff.

I've gotta admit that the roundhouse kit intimidated me.  I had enough wall sections for five stalls, nine pieces altogether, plus several other wall sections the supplier had sold me to play with.  The walls are heavy cast plaster and carved to look like stone with large industrial windows in each section.  There are buttresses that extend out from the ends and midpoints and dressed stone framing around each window.  The instructions for painting were included but this was what held me back from starting the model.  I looked around the internet and saw what other folks had done and couldn't find a technique that really satisfied me.  I decided to shelve the project until I found something I really liked because with plaster you really only get one try.  Here's a shot of the original kit.


While researching the smelter I stumbled across a painting technique for plaster cast stone walls that was exactly what I had been looking for (click here).  Now I was finally ready to build the roundhouse.  The first thing I did was clean up the wall castings.  Most of the stone detail on the outside surface was of excellent quality but the inside surface was just flat plaster and not exactly flat either.  I used a course wood file and sanding block to smooth out the inside walls with the plan to have them look like the stone had been plastered over and then painted.  I carved in stone detail along the top edge and where the walls protruded beyond the doors in the front. The mating edges and bottoms of the walls also required squaring up to get a tight fit between wall sections and to get the walls to stand vertically without falling over.  The window openings are sized for Grandt Line parts and I spent time making sure everything would fit snugly.

While laying out where the walls and track would go I decided I needed a car shop and machine shop to complete the roundhouse.  I'm severely restricted on space though so I decided to build a combined car and machine shop with a small boiler room off the back.  This was plan A, later modified.  When I first laid this part out I simply ran a track to it from the turntable but then realized that prototype railroads wouldn't do this.  The track should come in directly from another part of the yard and this required me to re-position the shop.  I turned it 90 degrees and ran the track in from over by the ash pit.  Much better.

With the shop turned sideways to the turntable it just screamed out to be made of stone also, just like the roundhouse, as if they had been built at the same time.  I decided to make molds of some of the roundhouse wall sections and use them for the shop.  I would need four new full size wall castings and one additional one that I could cut up and use sections of.  The original side walls angle down towards the back and the roundhouse has a flat roof.  I wanted a pitched roof on the shop so I'll have to modify my new castings to straighten the top edge.

I sat down and made full size scale drawings (1/4" = 1') showing side, front and bird's eye views.  The interior footprint (7 3/4' x 10 1/4' or 31' x 41')) was chosen mostly because of available space on the layout but is still big enough for a respectable machine shop.  Originally I was going to have the car shop take up half the space but then decided to add a raised deck down the outer side and use that for an outdoor car shop.  Now I have some serious space to work with.  The shop will eventually have an overhead belt drive system run by a single cylinder steam engine and dedicated boiler.


Once I settled on a design I saw that things would look better if the roundhouse had the same skylights which would require modifying one wall section to match the shop's end wall.  This was the beginning of the snowball.  Things quickly got out of hand but I did learn a lot about working with plaster.  More on that later.

OK, so I got 8 molds made and I built some really excellent support frames for each one.  I felt confident that my castings would come out really well.  I hadn't poured plaster castings in something like 30 years but I didn't remember it being a major challenge.  Of course I was doing rock castings and retaining walls in HO scale and now I'm doing O scale, 1/4" = 1', so the castings are much larger.  For the shops side walls I used one section of wall from the roundhouse that had two windows.  The shop walls have three windows so I had to make a total of five castings and "cut and paste" to get what I wanted.  The plaster cuts like wood so I used a small handsaw for dissection and yellow wood glue to reassemble my parts.  In the picture below you can see the two new wall sections and one original as well as the Latex mold and support frame.


With the side walls completed I made another mold to pour the end walls and spent three days hand carving stone.  I painted the walls using watered down acrylics in five different earth tone colors.  Here's my technique:  First seal both sides of the plaster casting with flat or satin clear spray paint.  I use DecoArt acrylic paint in Grey, Mississippi Mud, Burnt Umber, and Burnt Sienna working from lightest to darkest.  Use a quarter size blob of paint with two siphon loads of water for each color.  Starting with Grey and a damp natural sponge lightly dab the color to the casting for a blotchy effect.  All the steps here use a damp sponge, never dry, and clean the sponge between each color.  Then add Mississippi Mud to whatever's left of the Grey and lightly dab on.  Mix in Burnt Umber and brush onto random stones before lightly dabbing on with sponge to blend.  Mix in Raw Sienna to the Grey/Mud/Umber mix and use a heavily loaded brush to run along the grout lines, then wipe the surface of the casting with a clean sponge.  Separately mix Raw Sienna (don't mix with other colors) with two siphons of water and dab on lightly and sparingly with a clean sponge.  Clean the mixing tray and add a quarter size puddle of India Ink and at least two siphons of water (make sure the ink is pure black.  I use "JapanBargain Japanese Caligraphy Ink - Black" from Amazon.  Some India Inks have purple mixed in and it will show).  Use one clean sponge to wipe ink across the casting surface and into the grout lines.  Then use a second clean sponge to wipe across the surface of the stones.  Work in 3" x  3" areas at a time.  Allow the casting to dry overnight.  Then fill the grout lines with wallboard mud, smeared on with a sponge, and clean off with a second clean sponge to expose the stones.  The mud works like a polishing paste and brings out the different colors to look like Pennsylvania field stone.  Cool!  Allow to dry.  I use a short-bristle wet brush to scrub excess wallboard mud from corners and other areas that are too heavily loaded with the white mud.  This can be done when the mud is wet or dry.  Once completely dry seal with a coat clear flat spray paint.




Painting Plaster Castings

 Today I painted the remaining walls of the roundhouse and thought I'd add a blurb here to share my technique for painting plaster stone...