Geoff Bunza geoffb
Model animation—bringing models to life—adds enormously to the interest and enjoyment of any layout or individual model! This time we’ll focus on a mobile animation that is easy to build incorporating a Digitrax TF4 function decoder, an Arduino Pro Mini, and a small DC gear motor. This is a relatively straightforward animation, which draws much interest.

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 0
Geoff Bunza geoffb

DCC Controlled Animated Passenger Coach

Collect Some Revenue on Your Railroad
 
We start with an old Athearn coach which I equipped with intermountain wheel sets and contact wipers to pick up from both sides of each truck.
pening_s.jpg 
Basic Operation
 
You can get a good idea of what this is all about from the video above. Besides aisle and marker lights, our conductor will go about his job collecting tickets and chatting with passengers throughout the trip. He will make random stops in both directions moving along the center aisle. Passengers using the end toilet will be turning on and off the facility light at at random. I could not get definitive info whether the toilet light was actually switched in the prototype – but it is in this car!
 
In this animation, a Digitrax TF4 will control the aisle lights and the end markers (I use this coach at the end of a short mixed train for a branch line). The lights are 0603 white LEDs that are soldered to 2 parallel pieces of .025 phosphor bronze wire from Tichy. It gives the unit assembly enough stiffness to handle and mount (glue) the assembly to the car ceiling. The markers are lit with an 0603 white LED described before in Points of Light Model Railroad Hobbyist Magazine, February 2012 and the toilet light was a single 3mm LED. One of the TF4’s function outputs is wired to power an Arduino Pro Mini (see A modeler’s introduction to the Arduino Model Railroad Hobbyist Mag, Dec 2016 ). The Pro Mini runs a very simple sketch, which follows later. This is, perhaps, an unusual configuration for some readers, but the TF4 can supply 125 ma continuous which is more than enough for the Pro Mini, the LED, and the motor. The small motor drives an elastic band wrapped around a drive capstan attached to the motor and a pulley at the opposite end of the car. An old Plasticville figure, cut and modified, is glued to the outside of the band. The belt is Dritz 1/4" Braided Elastic from JoAnn Fabrics, cut and butt-end glued with a tiny amount of ACC glue (super glue).
 
ach_leds.JPG  onductor.JPG 

Aisle LEDs attached to two 0.025 stiff wires                              Our Conductor on the Belt

The small Pro Mini board easily fits inside HO scale rail cars. Here the controller (on the right in the picture below) is used to animate the conductor making random stops along the way. You can change the delays in the sketch yourself to “set your own pace!” It also turns the toilet lights on and off at random. The animation is switched on and off directly by the Digitrax TF4. I used a long 0-80 set of screws though the coach floor to mount and suspend the motor drive and capstan (made with some plastic scraps and a 2-56 screw). Roughen the capstan to give it some grip on the belt. Make sure the belt turns freely. I removed ½ of the coach seats I installed to widen the aisle for the conductor. Passengers were distributed throughout the car.
 

h_inside.JPG 

Coach Insides

3labeled.jpg 

Pulley and belt on the left, with the motor mounted up-side-down to drive the belt

otors(1).JPG  two(1).jpg 

Here’s what the motor looks like—drive gear is tapped for 2-56 thread with a bottoming tap

_inside2.jpg 

Coach belt installed without passengers

_labeled.jpg 

More details for the coach components

oach_sch.jpg 

Basic wiring diagram for the coach

 
The LM7805 regulator is used because the small regulator on the Pro Mini is a bit too weak to reliably power the motor and LED, and the DC voltage level from the TF4 can be higher than the maximum 12 Volts expected by the Pro Mini voltage regulator.
 
Loading the Pro Mini code (sketch) has been covered in this article and it’s accompanying materials: A modeler’s introduction to the Arduino Model Railroad Hobbyist Mag, Dec 2016  You can copy and paste the sketch below into the Arduino editor and modify it to make it your own. As with many other subtle animations, this coach raises some eyebrows… and smiles, when viewers catch on to the action! You can modify this to make it simpler or more elaborate. You don’t have to have it DCC controlled, and you don’t necessarily need the random variations. In my mind, however, these things change the model from having animated “features” to helping tell a story in animation.
 
In any case, I hope you enjoy this. Have fun! 
Best regards,
Geoff Bunza
 
 
Arduino Pro Mini Skecth for the Coach:
 
//  Coach1 Motor Control 1  Drive for Coach Animation
int motor_pin = 11;  //Motor H
int toilet_LED = 9;  // Toilet  Light
int fwdon = 1050;      //effectively sets forward speed
int cyclewidth = 2000;
// the setup routine runs once when you press reset:
void setup() {               
  // initialize the digital pins as outputs
  pinMode(motor_pin, OUTPUT);
  pinMode(toilet_LED,  OUTPUT);
  digitalWrite(motor_pin, LOW);
  digitalWrite(toilet_LED, LOW);  // A "HIGH"/1 out turns the light on
}
void loop()
{
  delay(4000);            // Wait  4 seconds
  //forward
  gofwd(7,fwdon+300);              // Kick Start
  gofwd(random(800,3700),fwdon);   // Conductor Movement Time
  delay(random(1200,4500));        // Conductor Stop Time
  digitalWrite(toilet_LED, lightsw() );
}
boolean lightsw() {
  if (random(0,100)> 30) return HIGH;  // 70% time is ON
   else return LOW;
}
// Move forward for fcnt cycles and fcycle modulation ON
void gofwd(int fcnt,int fcycle) { 
     int icnt;
     icnt = 0;
     while (icnt < fcnt)
    {
      digitalWrite(motor_pin, HIGH);
      delayMicroseconds(fcycle);
      digitalWrite(motor_pin, LOW);
      delayMicroseconds(cyclewidth - fcycle);
      icnt++;
    }
}
 
 
Bill of Materials and sources
For good prices for quality surplus electronics you can use:
for transistors, diodes, LEDs, switches, relays, and many other components
Digikey.com   and  Mouser.com  for brand new high quality components
for low cost LEDs and transistors:
but for many other components too.
Ebay.com offers very low prices but be wary of some low quality parts sometimes offered.
 
Parts
Qty
Description
Part Source
Arduino Pro Mini
1
Arduino Pro Mini
LM7805
1
5 Volt Regulator
2N3904 Transistor
1
NPN Transistor
1000 1/4W
1
RES 1.0K OHM 1/4W 1% AXIAL
Allelectronics.com  # 291-1000
470  1/4W
2
RES 470 OHM 1/4W 1% AXIAL
Allelectronics.com  # 291-470
0603 LED
5
White SMD LED
 
1830-1063-1-ND
 
White 3mm LED
1
White 3mm LED
TF4 Function Decoder
1
Digitrax TF4 Function Decoder
Gear Motor
1
5v Gear Motor
Belt
 
Dritz 1/4" Braided Elastic

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 0
HVT Dave

Great project

Geoff,

What a great project!!!  Sure to get lots of comments and something that you don't see on every layout.

Dave

Member of the Four Amigos

 

Reply 0
pierre52

Dr G strikes again

Great project Geoff just a shame I don't have any passenger cars on my layout 

Peter

The Redwood Sub

Reply 0
Bernd

Excellent Animation

Geoff,

Ah Geoff, I'm glad I ordered 100 of those motors a while back. They are the best for such animations. Very inspiring.

Bernd

New York, Vermont & Northern Rwy. - Route of the Black Diamonds - NCSWIC

Reply 0
Geoff Bunza geoffb

re: Commnets

Hi all,

Thanks for the kind words guys -- always appreciated.

And Bernd, those little gear motors will make more appearances soon! They are great little devices. Several times I've opened them up and tried to imagine re-working the gear train -- tiny and difficult though. It would be another challenge. Also check out these little motors with worm gears:  https://www.ebay.com/itm/263230232370
Not much torque but that worm gear is 0.3 Modlus and could drive a small pinion gear for a tiny right angle drive -- something I am always looking for.
Have fun! 
Best regards,
Geoff

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 0
yogiVanBuskirk

Great project and very clever

Great project and very clever on how you mounted the conductor. Watching the video, I was wondering how you turned him around for the reverse trip Another fantastic idea.

I was/am working on a grist mill and had played around with a DC motor and belt drive for the water wheel. I was using the same simple BJT drive as I only needed a single direction on/off. 

Wanting to ramp up and down the speed, I was using AnalogWrite for speed control but switched the setup to a stepper motor. The DC motor was making too much noise because of the PWM and start up and slow speed was very 'iffy' due to the motor's low torque (motor was not geared); going from standing still to 5-10 RPM. Do you know of a better way to do speed control, maybe a better Lib with a higher PWM rate (higher then audio range)?

The stepper has drawbacks too. Number one is the need for a Step/Direction driver ( to minimize Arduino pin use). Also, at slow speed the steps are more prononced. Maybe if I toggle Enable between steps, wheel momentun will smooth it out.

Thanks for your great ideas Bill

Reply 0
Geoff Bunza geoffb

@Bill re:Questions

Hi Bill,

Thanks for the kind words!
Quote:
Wanting to ramp up and down the speed, I was using AnalogWrite for speed control but switched the setup to a stepper motor. The DC motor was making too much noise because of the PWM and start up and slow speed was very 'iffy' due to the motor's low torque (motor was not geared); going from standing still to 5-10 RPM. Do you know of a better way to do speed control, maybe a better Lib with a higher PWM rate (higher then audio range)?
I don't use AnalogWrite at all, as it never seems to be doing what I want for different motor control.
If you look closely at the sketch you find:
  //forward
  gofwd(7,fwdon+300);              // Kick Start
which basically turns on the motor for 7 PWM cycles with a 1350/2000 duty cycle to give the motor a jolt to overcome starting friction. This is another great examplle of the flexibility of control you have with an Arduino. I don't go to 2000/2000 (DC) because the slight vibration due to the pulses helps!  With different motors, you should experiment by changing the overall frequency of PWM -- in my sketch this is set by:
int cyclewidth = 2000;
and the duty cycle (ON time of the PWM pulse) by:
int fwdon = 1050;      //effectively sets forward speed
The following function (or method for the software purists) sets the speed:
// Move forward for fcnt cycles and fcycle modulation ON
void gofwd(int fcnt,int fcycle) { 
It runs for "fcnt" number of PWM cycles and returns.
I have yet to find a DC motor that this cannot be adapted to control well. Depending on the constuction, armature mass, brush/brushless type and size, and coil current you will need to experiment to get fine control, with low noise. Brushless motors including pager motors respond well to higher PWM control frequencies. You can also run lower voltage motors with high voltage pusles if you control plse width very well to minimize heating in the motor armature/coils. Heat will eventually damage the motor.
 
I'm sure you can find good alternative motor libraries on the web, but I have not needed them. More libraries offer more possibilities for incompatibilities when mixing libraries. It is an inherent, largely undoucumented problem with Arduino public libraries.
Quote:
The stepper has drawbacks too. Number one is the need for a Step/Direction driver ( to minimize Arduino pin use). Also, at slow speed the steps are more prononced. Maybe if I toggle Enable between steps, wheel momentun will smooth it out.
Steppers need more complicated hardware drivers and control sequencing, but offer the possibility of tighter control, and knowing almost precisely where the stepper is positioned. It can be made to move incredibly slow. Fast movement with a stepper opens up the distinct possibility of "missing" a ste or two -- literally. There are some elaborate stepper driver libraries that are available that will ramp up and down stepper speed allowing for quick, smooth speed changes. I have not had much need for these.
 
DC motors, steppers, and servo motors all have application to model railroading and animation. Studying their strengths and weaknesses will help you pick the right motor and control mechanism.
'Hope this helps. Have fun! 
Best regards,
Geoff Bunza

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 0
Jim Wells

Just terrific!

Hey Dr. Geoff,

Ever so clever, and downright fun.  At first I thought you had painted the figure differently on each side... then I realized he just appears differently when stopped closer to coach lighting (but it's a thought.  Am curious, is the light in the window the conductor's office?  Restroom?

I suppose it's only a matter of time before you add sound!?!  "Tickets, please!"  "Next stop... "

Just kidding, it's WONDERFUL animation work, and thank you for sharing!

Best,

jim

Reply 0
Geoff Bunza geoffb

@Jim re: A Restful Light

Hi Jim,

'Glad you got a kick out of this!

The light is actually in the location of the restroom in the prototype coach. I actually tried to find out if the restroom light was switched on and off or peranently on in these heaveyweight coachhes, but could not get confirmation.
I simply "made" it switched so I could add a bit more life to the animation -- modeler's pivaledge you know!
I did consider painting each side differently -- but got lazy! But it is still an interesting idea !
Have fun! 
Best regards,
Geoff

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 0
VE7KKQ

WOW...PRETTY COOL

What an excellent project...Geoff, you have so much time to be creative...you should really think hard about getting a hobby...

 

John

Reply 0
Geoff Bunza geoffb

@John

Hi John,

Your comment somehow brings to mind: "it's not just a hobby... it's an adventure!"  (Very big grin!)

Thanks for the kind words! Have fun! 
Best regards,
Geoff

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 0
kledbetter

Just WOW, Excellent work

This has to be one of your best!   I was blown away with it honestly.  I mean sure once you break it down it's not all that difficult but one done nothing ever is.  Even though I model in N scale which makes things more difficult to fit size wise this definitely has my creative juices flowing.

Keep on inspiring us with your great work and know that it's much appreciated!

Reply 0
Geoff Bunza geoffb

@kledbetter re: N scale

Hi kledbetter (name?),

You can likely fit this into an N scale coach with a little creative thinking:
The motor could be replaced with something like this:
%20motor.jpg 
The elastic belt should still work. The TF4 decoder is also plenty small, and you might even consider using a different variation of Arduino controller like this DFRobot "Beetle":
20Beetle.jpg 
at https://www.dfrobot.com/product-1075.html which is just slightly smaller than a US quarter.
 
It will take a little experimenting, but I think it should fit.
 
...and thanks for the kind words too!
Have fun! 
Best regards,
Geoff Bunza

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 0
gnryrob

Loading sketch to the Mini

Geoff,

Super animation ideas!  As my friend says, "Geoff's mind works overtime". Great fun.  You mention a method to load a sketch to the Pro Mini but I could not find that info in your articles. Probably missed it somehow. Could you point me to it?

Thanks,  Rob

Reply 0
Geoff Bunza geoffb

@Rob rero Mini Loading Instructions

Hi Rob,
 
You can find the step by step instructions for loading an Arduino Pro Mini here: Starting from Scratch with an Arduino Pro Mini   http://mrhpub.com/2014-11-nov/land/#99
which was part of an article on Battery Powered Locos in the November 2014 MRH.
 
I don't always work overtime, but there is one tiny brain cell that seems to run amok occasionally !
 
'Hope this helps. Have fun! 
Best regards,
Geoff Bunza

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 0
Goober

@ geoffb

 Simply outstanding'...and totally cool'...  

😉
Reply 0
gnryrob

Alternative for the ProMini

Thanks Geoff.  Found it.

A new item from AdaFruit called the Pro Trinket makes this all much easier.  It has a microUSB port which is used to download sketches to the Trinket.  Much easier than adding pins and getting a special cable for $17.95.

Great stuff Geoff.

Thanks for sharing!

Rob

Reply 0
Geoff Bunza geoffb

@Rob Another option

Hi Rob,

Another similar option is the Arduino Nano (with the same 328P processor) from many sources.

One of the advantages of the Arduino family is the wide variety of processor boards (many sizes, differing pin numbers, differing speeds, and differing capabilities) all using very similar libraries to support a wide variety of modeling situations.
Have fun! 
Best regards,
Geoff

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 0
yogiVanBuskirk

Some considerations with the

Some considerations with the Pro Trinket is pins 2 and 7 are used for the soft USB so are unavailable to the sketch. Considering that pin 2 is used for DCC In would mean that the board is incompatible with the SMA 20 sketches without some (major?) changes.  The USB bootloader is also larger,  @ 4K, then the optiboot BL so the max sketch ROM footprint is slightly smaller.

For the cost of the Pro Trinket, I can get a Pro mini and a FTDI board; and remember that the FTDI can be reused on Pro Mini #2, #3.... Not that the PT is bad but I have had problems with the software based V-USB lib and Windows in the past, where as the hardware based FTDI has been flawless over many projects.

Just my $0.02,

Bill

Reply 0
PaulOmilian

Wiring Diagram

Geoff, what program did you use to produce this diagram?

I'd love to use something like this to explain the wiring of a project like this to my 11 year old grandson who's learning to program Arduinos.

-662x371.jpg 

Paul O

Reply 0
Geoff Bunza geoffb

@Paul re:Wiring Diagram

Hi Paul,

This diagram was done with an old copy of Microsoft's PowerPoint. I prefer a standard electrical schematic, but too many modelers get scared off with a schematic, and using the pictures of the components helps people identify the correct pieces and orientations. I keep a folder of components I usually use, but I will occasionally just do a web search for images of something like "560 ohm resistor" to get what I need. Then I use a picture editor like Corel's Paint Shop Pro to crop and enhance the picture before dropping it into PowerPoint. PowerPoint itself has some basic picture editing features too. Lines, labeling, rotations, and other symbols are all drawn with PowerPoint.

'Hope this helps. Have fun! 
Best regards,
Geoff Bunza

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 0
Jim at BSME

Fritzing

Paul,

You might want to look at Fritzing, it is really meant for producing PC boards, but you don't have to go all that way. It has a virtual Breadboard layout which can then be viewed as a schematic and even the PC Board. For what you want I think the virtual breadboard would be good.

Here is an overview: 

And the website is:  http://fritzing.org/home/

- Jim B.
Baltimore Society of Model Engineers, Estd. 1932
O & HO Scale model railroading
Check out BSME on: FacebookInstagram
Reply 0
lonestaraggie

dirty track, etc

Geoff,

I love the project! A super way to add excitement to a passenger car.

Do you have any recommendations for adding something to the circuit to get some sort of "keep alive" effect to keep the animation and lighting from flickering on dirty track or over plastic frogs, etc?

I am about to start adding arduinos to my pullmans to get some lighting effects in the bedrooms and toilets, similar to your work here, without the roving conductor (for now), and want to be sure to have my bases covered when the layout has filthy track.

Thanks for all the great projects! They keep me thinking of ways to get more wow out of the hobby.

AJ Chier

Los Angeles

Reply 0
Geoff Bunza geoffb

@AJ re: Anti Flickering Circuits

Hi AJ,

Thanks! It is always great to know that other modelers are enjoying and using this material!
 
Quote:
Do you have any recommendations for adding something to the circuit to get some sort of "keep alive" effect to keep the animation and lighting from flickering on dirty track or over plastic frogs, etc?
Yes. First, a general comment. Anti flickering methods are best described in terms of power: store the most (highest) power, and use the smallest amount for on board usage. "Power" is simply Volts X Current (Amps). You will get the best results when you store the maximum track voltage with the maximum capacitance, and use the lowest current at the lowest voltage. This can  translate to our modeling by using LEDs with the highest tolerable limiting resistors -- use the highest resistance for which you can tolerate the brightness it gives (for each LED). Arduino controllers usind in animation can be operated at very low current draw as well.
 
There are different ways of storing the energy which will provide power over gaps and dirty track. I've discussed different approaches here: SMA17 – Cheap Flicker Free Car Lighting for DCC, DC, and AC – a New Kind of KAOS  https://forum.mrhmag.com/post/sma17-%E2%80%93-cheap-flicker-free-car-lighting-for-dcc-dc-and-ac-%E2%80%93-a-new-12200310
That should get you going. Note the simple diode bridge and single capacitor traditional version too. If you have a very light load, this can be effective.
'Hope this helps. Have fun! 
Best regards,
Geoff Bunza

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 0
Reply