Geoff Bunza geoffb

Model animation—bringing models to life—adds enormously to the interest and enjoyment of any layout or individual model! This entry describes how to build what I call a “DCC Function Generator,” a combination of DCC base station and throttle for about $8 that can be used for mixed DCC animation control, DCC testing, Absolute/Emergency Stop blocking for lift-outs and bridges even for Keep-Alive equipped DCC locos, trolley multi-stop control, and all around DCC havoc!

CC_Gen-s.JPG 

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 Control Variety

I have been using both DCC decoders and independent LEDs, motors, servos and sound modules together in animations for years, like

and:

  What enables the close coordination of all of these is an Arduino based DCC generator combined with the general purpose capabilities of Arduino control. This article describes the newest version I use, based on a low cost add-on or daughter board that attaches to an Arduino Pro Mini. This is similar to the decoder series I have presented earlier in SMA20 New Low Cost 17 Channel DCC Decoders with PC Boards & Dual Motor, LED, & Servo Control ( https://forum.mrhmag.com/post/sma20-low-cost-17-channel-dcc-decoders-ver-6-01-with-soundtriggered-soundstepperdual-motorled-and-12201920 ). These boards are included for the modeler too. This pair can be configured in a large number ways, and like the decoders, a pre-configured set of options is described and made available for the modeler to load into their own Pro Mini. Then, you are good to go. These pre-configured examples include a simple, autonomous DCC controller with speed and 6 function control, a break-in test version for point to point running with slow down and reversals at each end point, a “trolley line control” with independent stops and reversals, and an absolute stopping block for DC and DCC locos including those equipped with keep-alive features. Absolute stopping blocks can be used as safety or guard block to prevent your fine locos careening into the abyss beyond lift-uts and open bridges on your layout.  

I call this module a DCC Function Generator. The combination can also be used as a general purpose interface board for an Arduino Pro Mini, to ease interface tasks, or directly drive 2 DC motors or a stepper motor.

What is a DCC Function Generator?

A DCC Function Generator (DFG) is a combination DCC base station and throttle rolled into one unit. Normally, I do not use it for manual control, even though I will show how it can operate as a basic substitute, perhaps for a display or test track. Like the Arduino Pro Mini – based decoders I use ( https://forum.mrhmag.com/post/sma20-low-cost-17-channel-dcc-decoders-ver-6-01-with-soundtriggered-soundstepperdual-motorled-and-12201920 ) the DCC Function Generator is also built using the ubiquitous Pro Mini. Also like the motor control version of the decoder, the DFG uses the Texas Instruments SN754410 Dual H-Bridge chip to drive the DCC signals. This is limited to a mere 1 Amp but other H-Bridge chips and/or modules could also be substituted if higher amperage is desired, like http://www.ebay.com/itm/170926726867. I started with this design because I built animated scenes that used commercial DCC decoders, and had the need to control other lights, motors, and sounds in addition. I’ll give some examples and provide the sketches used to set up the Pro Mini later. I do wish to make it clear this is, and was, never meant to be used as a substitute for a complete DCC command station. In my view it has utility and value beyond that. Similar to the Pro Mini DCC decoder series, the DCC Function Generator’s code or sketches are built on the groundbreaking work of another modeler, D.E. Goodman-Wilson, who created the CmdrArduino DCC library ( http://railstars.com/software/cmdrarduino/ ), which my work uses. While the library does not account for every operation a base station might want, for my purposes it works quite well, and I am grateful for Don’s contribution.

Configurations

One might think that such a little board serves one purpose and should be built one way. Well …no! You can certainly build it with all components and use it to drive its own DCC bus. You can also use it as a Pro Mini bread board or prototyping aide, a single or dual motor driver, a stepper motor driver, a DCC Function Generator and a single DC motor driver. Consider the small set of 3 pads in a row next to the +PWR- connections on the board top. If you “solder blob” the middle pad to the one marked 12V, then the DCC and the MOT out from the H-Bridge driver will swing +/- 12Volts. If you “solder blob” the middle pad to the one marked 5V, then the DCC and the MOT out from the H-Bridge driver will swing +/- 5Volts. “Solder blob-ing” means to load the 2 adjacent pads with a small blob of solder, and add enough to bridge the tiny gap connecting the 2 pads – a cheap way to make a semi-permanent option switch or jumper! Connect the appropriate blobs before attaching the Pro Mini board. It will be easier that way. You can also leave off the two 22uf SMD capacitors if you feel you don’t need the extra filtering (they will be hidden under the Pro Mini board once attached). I always include them.

pads.jpg 

Building the Board

This little unit is composed of 2 small boards, sandwiched together in a mother/daughter board arrangement. The daughter board or driver board can be soldered or socketed to the Pro Mini controller. There is provision for an on-board, 5 Volt regulator. I prefer to use the PSU3-5 shown  in the parts list. You connect 12 Volts - 15 Volts to the PWR+/- connections on the driver board. Input/output connections D8, D11, D12, D13, D14/A0, D15/A1, D16/A2, and D17/A3 are brought out to a separate set of pin headers for connection convenience, but you may also solder directly to the pin holes in the board. A0-A3 designate those pins that can also be used for Analog inputs (like for use with a resistive potentiometer as a speed controller). Each input/output pin is labeled and situated next to a +5 Volt pin and a ground pin for ease in connecting to switches, potentiometers, servos, sensors, and LEDs. The board combination is small enough to hide in an HO scale model structure, building, or scene.

The PC Board can be ordered from this board fabricator:   oshpark.com            

The boards are 1.60x1.19 inch (40.64x30.15 mm) 2 layer boards. OSHPark offers a public service fabricating very high quality, low cost PC boards in low quantities. Download the (Eagle PCB layout) board files (.brd) from here:   zip SMA22_Download.zip     

Set up an account at OSHPark (really easy) and upload the board file(s) you want to fabricate and specify the quantity (always in multiples of 3—their rules) either of these will cost $ 9.45 for 3 (3.15 per board). They accept Paypal and will ship international. I have no vested interest in OSHPark – I’m just a satisfied customer. Please feel free to use whatever fabricator you know. I know of no source for fully built boards. That could change in the future.

The bare boards are shipped “panel-ized” so break or cut them apart. Follow the component diagrams below and solder the components to the board. I add the pins and/or sockets, last. Use a low temperature soldering iron or a low wattage soldering iron for these.

Board.jpg 

Daughter /  Driver Board
chematic.jpg 

Driver Board Schematic

rd_top_s.JPG 

Board Top

rd_bot_s.JPG 

Board Bottom

ts_top-s.jpg 

Top Component Placement (Note: This Board is Equipped with Strip Sockets for the Pro Mini

ts_bot-s.jpg 

Bottom Component Placement

Example Materials

Arduino Pro Mini atmega328  5V 16MHz   (from EBay:   http://tinyurl.com/kexh66b )   $1.95
(This price varies. Search Ebay for "Pro Mini." Price often includes free shipping.) These can also be obtained from many other sources. Problems have been reported using these with Windows 10 drivers. If you don't want to mess with the anomalies of the Chinese knock offs, try these likely genuine FTDI cables instead

Arduino Pro Mini USB FTDI TTL Programming Cable (Ebay: http://www.ebay.com/itm/111241824248)
Please note some programming cables sold have scrambled pin outs, and color coding is wrong! Please be careful. The correct configuration is:
Pin Wire     Signal on      Signal on
#   Color      Cable            Pro Mini Label
1  Black        GND               GND or BLK
2  Brown       CTS
3  Red          +5 Volts          VCC
4  Orange    TXD     
5  Yellow       RXD     
6  Green       RTS                DTR or GRN
 
This is the standard coloring and order that FTDI used. It is clear that some cables were manufactured incorrectly. I would be cautious of the wire colors too! I have found that red for +5 Volts and Black for ground is commonly used. If you have a voltmeter, plug your cable into your computer, but not into the Arduino Pro Mini and measure the voltage from the black wire to red wire-- it should be +5 volts. The set these 2 pins into the Pin 1 and Pin 3 socket as shown above.
 
Digikey example parts ( http://www.digikey.com):
478-8312-1-ND                CAP TANT 22UF 25V 10% 2312 SMD         1.22
296-9911-5-ND                 IC HALF-H DRVR QUAD 16-DIP                   2.43
LM78L05ACZXCT-ND      IC REG LDO 5V 0.1A TO92-3                         0.44
497-5838-1-ND                L4931 IC REG LDO 5V 0.25A TO92-3           0.37
497-15682-5-ND              L7805 IC REG LDO 5V 1.5A TO220              0.58 
PSU3-5                              5V 1A Cool-running switch-mode voltage regulator (from EzSBC.com):
( http://www.ezsbc.com/index.php/products/psu3-5.html#.VpGVvV55yMQ )
PSIP-80                     PEEL-A-WAY(R) MACHINE PIN SOCKET STRIP      2.50/50 socket pins
http://www.allelectronics.com/make-a-store/item/psip-80/peel-a-way-r-mac...
SHS-40                      1 X 40 HEADER, 0.1" SPACING                                 0.85
These socket strips will accept DIP packages, or 0.020 wire – like the Tichy phosphor bronze wire.
MTS-5                      SPDT ON-OFF-ON MINI TOGGLE SWITCH              1.25
PTW-10K                 10K BOURNS POT, PRE-WIRED                                2.75
 
Between the diagram and the pictures, assembly should be straightforward. Use a low wattage (15-40 Watt) or temperature controlled soldering iron and take your time.
 
Switches (for function control) and variable resistors (potentiometers) are connected to the appropriate header pins (or holes if you don’t want to use pins) according to these diagrams:
26Pots-s.jpg 

The switch may also be a normally open pushbutton.

Realities of DCC Control: Some Additional Comments

The modeler using the DFG is exposed to the “nits and grits” of DCC in a way that commercial products normally shield the mere mortal modeler. Several things must be remembered:

*****  DCC commands are normally repeated over and over again to decoders on the DCC bus (tracks). In using the CmdrArduino library, it is still very much incumbent on you setting up the DFG to assure that commands are sent out in a timely fashion. You cannot assume that every command will reach the decoder, the first time. Typically you can’t assume a decoder has memory to retain its speed and function states.

*****  As a DCC modeler at this level, you will find that different decoders do not quite behave as consistently as you might like. I have noticed that some decoders act on  the transition of a function from off to on, some behave differently when the function is repeated “on.” Some even have a slightly different behavior when a function is switched from on to off.

*****  Simply sending a single speed packet does not necessarily start a loco moving, particularly one with sound, or one with momentum effects turned on. Likewise, immediately reversing the direction of a locomotive sometimes has unpredictable effects on decoders – including just coming to a halt! You should take a look at the trolley/shuttle example and note the delays inserted.

***** You should note that each of the examples provided have been tested, and they work as described. So you should get some utility using them as a starting point.

*****  For the intrepid modeler, note that the “set_function(function_number,0/1)” has been provided to turn a function numbered from 0-12 on or off (1 or 0). Also, one sets the appropriate speed for whatever decoder is addressed by the variable locoAdr by setting dcc_speed to a number from 0 to 127 or 0 to -127. Avoid one (1) which will send an estop to the decoder. All these simply set up the command set to be retransmitted over the DCC bus. You provoke the transmission by using dcc_cmd_rpt (time in milliseconds up to 32767). This is also how you insert delays before changing functions or speeds

*****  Setting locoAdr to zero (0) sends a “broadcast message to all decoders.” I do not know how all decoders will respond to broadcast messages, although it is part of the NMRA DCC standard. If you have lived in a DCC cave for the last 20 years or so, you may not know that there are inconsistencies in the way certain decoders (commercial decoders) implement the NMRA specification (or don’t).

***** This library does not implement speed stretching for DC motored locos on DCC tracks.

***** There are more features in the library that you can explore. It can address more than one decoder address serially, it can generate accessory decoder switch commands. I will leave all the other “features” for the readers (your) exploration. To my knowledge, active development has stopped on the Cmdr Arduino library. I have made some minor changes that I have included in the accompanying download. With its limitations, it is still a usable, featured, free library and so far, the best one I have found.

Give Your DCC Function Generator (DFG) Its Personality!

Since this is a bit different and likely new to most modelers, I am making an attempt to simplify DFG usage by providing a starter set of examples. You can download the daughter board file (.brd) and all the sketches—provided as examples with a version of the CmdrArduino library, which I have fixed some minor bugs). Load the entire CmdrArduino library folder into your …\Arduino\libraries folder in your …\My  Documents\ folder (on Windows).

Build the DFG hardware variant of you want, and then look here for information on setting up and loading the DFG sketch (program) of your choosing. With that said, a step by step cookbook for loading the Pro Mini sketch, oriented to the modeler, can be found here:
Starting from Scratch with an Arduino Pro Mini (or Moteino):
http://mrhpub.com/2014-11-nov/land/#99

The “Arduino Pro Mini Controller” used here is one of a set of small processors (computers) on boards, set up to allow easy use by people who want to use them as a tool, rather than focus on the details of the technology. Arduinos were originally conceived as a teaching tool in Italy. All aspects of their design and construction are available for public use with no restrictions. These are manufactured and distributed by many companies worldwide, some for as little as $2 (quantity one) including shipping! With such a cheap and powerful tool, a series of tested, working, and packaged instructions (called Sketches or programs) to set up these versatile DCC Function Generators with many practical functions are made available.

I have pointed out before that I am not a proponent of asking modelers to learn how to program-- just learn how to use these new tools. You can stop there or take it as far as you want. These are used in high schools and colleges all over the world to teach basic concepts. I am not trying to do that here, merely trying to show others that these little guys can add a great deal to your modeling enjoyment.

If you really want to learn more, a good start for climbing the Arduino Learning curve would be the tutorials at:    http://arduino.cc/en/Tutorial/HomePage
and there are allot of topics there for searching and browsing or
http://arduino-info.wikispaces.com/TUTORIALS
or    http://arduino.cc/en/Guide/ArduinoProMini

Pre-Configured Examples

You can download the board file (.brd) and DFG sketches here: 
zip SMA22_Download.zip     

DCC_FTN_Gen_ESTOP_SW
 
This version is used to protect and open /up bridge or a lift-out
A double insulated section of track (block) is switched over to a DCC ESTOP
    stopping ALL DCC equipped locos, even those equipped with keep-alive
D8 has a double pole double throw relay to switch in DCC Function Generator Control
     This pin goes low (connects to Ground (GND) when active (see diagram below on the left)
D17 has a normally open switch connected to GND, This switch is connected to Ground
     when the bridge is open or the lift out is missing, this activated the ESTOP Block
default locoAdr= not relevant
rivers-s.jpg 
DCC_FTN_Gen_Basic
This version provides basic speed and function control using switches for Functions F0-F4,ESTOP, & Direction
 Speed is controlled by a variable resistor (potentiometer)
D8,D11-D15 Have switches connected SPST to GND controlling F0-F4
D17 has a normally open pushbutton connected to GND for an Emergency Stop ESTOP and may be omitted
A2 / D16 Has the slider of a 10K potentiometer connected, either other pot end to VCC and GND
     this is the speed control
     Direction is controlled by Switch connected to D15
default locoAdr= 3
 
DCC_FTN_Gen_Back_Forth_Stops
This version is used to operate a trolley or shuttle on its own independent track with stops and reversals
Each of the following inputs are typically connected to a position sensor or short block sensor which goes low
  when detecting the presence of the loco/trolley/shuttle (like an optical sensor):
D11  sense forward motion, stop, & go in reverse
D12  sense reverse motion, stop, & go forward
D13  intermediate short stop switch / sensor
D14  intermediate long stop switch / sensor
If you don’t need the intermediate stops, then don’t connect D13 or D14 to anything
If you want multiple long or short stops, connect multiple switches/sensors together (in parallel)
A switch or pushbutton is connected to D17 to act as an emergency stop ESTOP and may also be omitted
default locoAdr= 3
 
DCC_FTN_Gen_Back_Forth_on_PB
This version is used for simple testing and demos – with each pushbutton press it sends a loco
    forward with the speed set by a variable resistor (potentiometer) for approximately 12 seconds,
    stops and reverses travel for 12 seconds and stops
Functions F0-F5 are set by switches connected to D8, and D11-D15
A2 / D16 Has the slider of a 10K potentiometer connected, either other pot end to VCC and GND
     this is the speed control
default locoAdr= 3
(This was the controller I used in SMA21 – Animated Rough Handling Boxcar in HO Scale with a Wink to John Allen  http://model-railroad-hobbyist.com/node/24891 ) to get the repeatability needed for the demo video.)
 
DCC_FTN_Gen_Decoder_Test
This version is used to test functions F0-F12
All functions are turned on in sequence with a half second delay between each,
and then turned off in sequence; after a 2 second delay, the test repeats
default decoder (locoAdr)= 24
 
DCC_FTN_Gen_Template
This example is provided as a teaching tool and starting point for you to see what capabilities are available
You should pay close attention to the heavily commented loop() section (duplicated below)
and use this as a starting point for your own experimentation
This version provides basic speed and function control using switches for Functions F0-F4,ESTOP, & Direction
   Speed is controlled by a variable resistor (potentiometer)
D8,D11-D15 Have switches connected SPST to GND controlling F0-F4
D17 has a normally open pushbutton connected to GND for an Emergency Stop ESTOP and may be omitted
A2 / D16 Has the slider of a 10K potentiometer connected, either other pot end to VCC and GND
     this is the speed control
     Direction is controlled by Switch connected to D15
locoAdr= 3
 
DCC_FTN_Gen_Template   loop()  section example:
void loop() { 
//
// YOU CAN SET UP YOUR DCC COMMANDS HERE
// WHICH WILL BE REPEATED OVER AND OVER IN A LOOP
//
// F0-F12 ARE SET TO OFF (0) AT THE START, AND DCC SPEED IS SET TO 1
// IF YOU WANT TO USE AN EMERGENCY STOP (ESTOP) BUTTON INCLUDE THE NEXT LINES:
//
      if (digitalRead(estop_pin)==LOW) {
        dps.eStop();  // ESTOP Power Cut Off
                             // Global Broadcast
        dcc_cmd_rpt ( 30000 );                // stop everything for 30 seconds
      }
// END OF ESTOP SECTION
//
//  THIS NEXT LINES CAN BE USED TO SET DCC LOCO SPEED (OF THE SELECTED locoAdr)
//  READING A POTENTIOMETER CONNECTED TO Analog pin 2 == D16
      dcc_speed =  (analogRead (speed_pin)/16)+1 ;
              dcc_cmd_rpt ( 1 );
// THE PREVIOUS LINE: dcc_cmd_rpt ( 1 );
// DOES 2 THINGS - IT SEND OUT DCC SPPED COMMAND AND ALSO REFRESHES FUNCTIONS F0-F12
// AT PRESENT THE LIBRARY CAN ONLY HANDLE F0 - F12
//
// THE FOLLOWING LINE READS A POSSIBLE SWITCH CONNECTED TO P5 (D15)
// AND SETS THE DIRECTION ASSUMING THAT THE AALOG READ AVOVE SET THE SPEED
      if (digitalRead (p5) == LOW ) dcc_speed = - dcc_speed;  // reverse direction
//
// THE FOLLOWING LINES SHOW HOW FUNCTIONS ARE SET BASED ON READING SWITCHES
//
      set_function (0, digitalRead (p0) & 0x01) ;
      set_function (1, digitalRead (p1) & 0x01) ;
      set_function (2, digitalRead (p2) & 0x01) ;
      set_function (3, digitalRead (p3) & 0x01) ;
      set_function (4, digitalRead (p4) & 0x01) ;
// THE FOLLOWING LINES SHOW HOW FUNCTIONS ARE SET BASED SKETCH VARIABLES OR CONSTANTS
//
      set_function (5, 0) ;           // TURN OFF FUNCTION 5  (F5)
      set_function (6, 1) ;           // TURN ON FUNCTION 6   (F6)
      set_function (7, F_VARIABLE);   // SET FUNCTION 7 (F7) TO WHATEVER IN IN F_VARIABLE
      dcc_cmd_rpt ( 1000 );           // UPDATE ALL DCC COMMANDS & WAIT 1 SECOND
//
//
//
//  END OF YOUR DCC COMMAND LOOP
//
}
 
Appropriate comments and suggestions are always welcome.
If hope you can use this, and I hope you share your work with other modelers. Have fun!  [smile]
 
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
ILHO

2 Stunned 2 think

Just amazing, again and again and...

My understanding is:

The Daughter boards are always what you are doing-making and the Mother board is the Arduino board.

This is a DCC controller that 'could' operate the SMA 20 version Decoder boards, especially in off line animations.

AFAIK there can be only 1 DCC controller so your Bridge protector is on its 'own block' and will stop everything when the bridge is up-out per the switch for 30 seconds repeating while the bridge is up-out. ... I have not read the code and am not a DCC knowledgeable person either.  So I do not understand how the trains work when the ESTOP is active and the bridge is in place.  Is the Arduino actually the DCC controller for the whole layout?

Thanks for all the great things you do and give to the community.

Lee

 

Ivan Lee Herring

Mountain Valley Western

Reply 0
Geoff Bunza geoffb

@Lee re: Comments

Hi Lee,

Quote:

The Daughter boards are always what you are doing-making and the Mother board is the Arduino board.

Yes.

Quote:

This is a DCC controller that 'could' operate the SMA 20 version Decoder boards, especially in off line animations.

Yes. In fact I use the DCC_FTN_Gen_Decoder_Test version to test my decoders that I build.

Quote:

AFAIK there can be only 1 DCC controller so your Bridge protector is on its 'own block' and will stop everything when the bridge is up-out

No, there are 2, but only one is connected to the track at a time. There is the normal DCC base station (say from Digitrax or NCE or whoever), and there is the DFG. Imagine a track block (let's call it the guard block) on either side of a lift-out (consider it one block). When you remove the lift-out, it closes a switch connected to the DFG.The DFG recognizes the switch is closed and switches control of the guard block to DFG control. The DFG generates a broadcast ESTOP command to turn off all motors to anything in the guard block. Even with a keep-alive circuit, all conforming NMRA decoders will shut down power to the motor immediately, regardless of sound and momentum effects. When the lift-out is replaced the switch is opened, and normal layout DCC control is returned to the guard block.

I also tried to show that you could also have a switch that opened when the lift-out was removed, and closed when it was in place-- one would have to change the sketch to implement this.

Quote:

Is the Arduino actually the DCC controller for the whole layout?

No. In this application, it only controls the guard block.

You are most welcome. I hope this makes things a bit more clear. If not, please ask more questions.

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
pierre52

Clearly......

......you don't have enough to do

Must be time for a holiday young man 

But when you get bored, I have another challenge for you. You have partially come up with a Faller car system equivalent  but would it be possible to develop a drive and steering system that is affordable. If that can be achieved then I suspect that the DFG would be perfect for controlling vehicle animations on a layout that go way beyond the capabilities of the Faller car system. Perhaps a 3D steering and gear drive system loaded to Shapeways that is ready to mount a small motor to. Just a thought 

You never cease to amaze me Dr B

Peter

The Redwood Sub

Reply 0
Prof_Klyzlr

Orientation VS Direction gotcha

Dear Dr Geoff,

Quote:
DCC_FTN_Gen_Back_Forth_Stops
This version is used to operate a trolley or shuttle on its own independent track with stops and reversals
Each of the following inputs are typically connected to a position sensor or short block sensor which goes low
  when detecting the presence of the loco/trolley/shuttle (like an optical sensor):
D11  sense forward motion, stop, & go in reverse
D12  sense reverse motion, stop, & go forward

Some questions, from someone who has dug rather deeply into "shuttle on DCC" issues previously...
https://forum.mrhmag.com/post/a-solution-for-a-problem-tvd-solution-retired-ise-successor-12187989
(or search "Klyzlr Shuttle Problem")

- When the shuttle is initiated, what is the first move the loco makes?

- If the loco is facing with it's _BACK_ aimed at the D11 "Sense FORWARD motion" detector,
and it runs over the detector, what happens?
(Prediction says it will run straight over the detector, 
be asserted to "run backward" which it already is,
and run straight off the end-of-track)

- What happens if the "shuttle" routine is invoked _while_ the target loco is sitting on top of _either_ D11 or D12? (allied question, could using a similar relay-switching system to the "stop generator" system allow switching of a track section between "normal Manual-drive Host DCC system" and "DFG shuttle auto-control"?)

- Will the shuttle automatically shuttle _any_ loco (IE with any address 0001-9999), or does it demand the shuttle loco be set to a given address?

Happy Modelling,
Aim to Improve,
Prof Klyzlr

 

Reply 0
John C H

SMA-22 Schematic

Geoff,

Could you add the SMA-22 Eagle schematic to the download ZIP please. It would help some of us really geekies so we don't have to re-enter from your post imbedded schematic.

Also, if you have used any non standard parts libraries, if you can list them.

Thanks

John C H

Collingwood, ON

Canada

 Canada 

Reply 0
Geoff Bunza geoffb

@Peter re:Suggestions

Hi Peter!

I usually need vacations from my vacations!

I have actually looked at some kind of low end equivalent to the Faller Car System. It is a tough problem. You can build a lower cost alternative, by purchasing a complete spare front end steering set (including tires, axle assembly, and magnet guide) -- all a mechanical guide based on the magnet follower mechanically steering the tires. It is clever, delicate, and  ingenious. Likewise the rear axle drive is a coreless 1.5-3V motor with a worm, driving a geared axle -- simple and effective. ON/off switch to the battery is manual. A magnetic reed switch in series with the battery gives you the ability to stop the vehicle with an electromagnet or a servo-raised permanent magnet. With a larger model truck, low power electronics could be fitted. I have yet to devise a low power, electronically steered system for guidance that doesn't run the tiny battery down quickly. There may be a solution out there somewhere. I've also thought about a "landing" area where you might stop the truck and charge the battery in place-- likely very do-able -- but I have not proceeded with this either.

Another project/problem tossed on the to-do list! Thanks so much for kindly adding to the pile! < Giant Grin>

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
Geoff Bunza geoffb

@Prof K re: Shuttle Questions not for NASA

Hi Prof!

As usual, all great questions and comments...

Quote:

When the shuttle is initiated, what is the first move the loco makes?

That depends... If it is not over any sensor it will move forward, and note that the "forward" sense of DCC direction is set entirely in the decoder and its installation in the loco/trolley by definition (likely obvious but this determines other decisions). If it is over either "end of travel" sensor, it will start out in the opposite direction, away from the end of the run. If it is over a "stopping/pause" sensor, it will wait the corresponding time and continue forward. There is no way operationally to determine the "forward" direction the decoder/loco combination is set. So, since the modeler is placing the 2 end sensors, he/she/it must place the loco with its forward direction facing the sensor connected to D11  sense forward motion, stop, & go in reverse. Likely a BIG decision for some, but one I leave as an exercise to the reader/modeler. < Giant Grin>

Quote:

- If the loco is facing with it's _BACK_ aimed at the D11 "Sense FORWARD motion" detector, and it runs over the detector, what happens?

Since it first starts moving forward it would have to cross sensor D12  sense reverse motion, stop, & go forward and it would keep going forward over the sensor. This is the technical situation where one assumes that placing the loco forward in the correct direction is beyond the capabilities of the superintendent of this layout, and hence this shuttle system should be avoided. < Giant Grin>

Quote:

- What happens if the "shuttle" routine is invoked _while_ the target loco is sitting on top of _either_ D11 or D12?

Answered above, if the loco is placed in the correct direction.

Quote:

could using a similar relay-switching system to the "stop generator" system allow switching of a track section between "normal Manual-drive Host DCC system" and "DFG shuttle auto-control

Absolutely yes. This should simply be an issue of providing a "shuttle switch" to cut out the shuttle block(s) and redirect control from the layout DCC to the shuttle controller-- relatively easy. If you want to do this and need help, please ask.

Quote:

Will the shuttle automatically shuttle _any_ loco (IE with any address 0001-9999), or does it demand the shuttle loco be set to a given address?

This is a terrific question! As currently implemented, it runs with one short DCC address. I actually don't know if you "DCC broadcast" on the shuttle track with address 0 (zero) whether any loco on the track will respond as if it is normally addressed, like it would to an ESTOP command, which is in fact a broadcast with address 0. I will have to look at the NMRA specification and actually try it -- two different things, as I don't know if all decoders will actually respond the same!

Ignoring the broadcast technique, the shuttle sketch could easily be modified to include a list or a range of DCC addresses, such that all considered addressed would be included in a command list , at each shuttle stage. So, for example, when the pause/stop sensor was activated, all addresses in the list could be sent a speed stop command. The list would need to be managable, and able to be transmitted quickly enough, but I would imagine perhaps a list of at least 5-15 addresses could be accommodated. So any loco whose address was in the list would respond if placed on the shuttle track.

One last comment, If you could guarantee that the loco was not placed over one of the end sensors at power on, since the DFG always starts in what it thinks is "forward" motion. The first end sensor to detect the loco could automatically be designated the sense forward motion, stop, & go in reverse sensor, and it would automatically reconfigure it self to reverse the loco correctly, as long as power to the DFG was maintained, and the loco was not physically lifted off the track and reversed.

'Hope this helps clarifiy how this works and can be made to work! Additional appropriate questions and comments are always welcomed. 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
Geoff Bunza geoffb

@John re: Additional Eagle Files

Hi John,

Unfortunately, past experience has encouraged me to provide the schematic as a high resolution image only, to minimize additional complexity and grief in my life. Sorry. If you have suggestions for possible changes, I will consider them, and possibly add them to the growing "to"do" list, as always.

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
Neil Erickson NeilEr

Inductance Charging?

@Geoff:

My Apple Watch and QR charging pads got me thinking of how to charge batteries while on the rails or, in the case of the battery powered vehicles, on the road. Pololu (I think) had a kit so I ordered it and now have it out and wondering what it will take to charge my 11.1V battery pack with this low powered 5V charger.

My Bachmann engines are On30  so I have more room than HO models but a battery "dummy" could also carry the coil. Upping the voltage will decrease the charging amps but it could sit overnight. The opposing coil will be inside a engine house but could be some other arrangement.  Creative thinkers out there must have some other ideas. 

By the way, my rails are dead and I don't want to charge through the wheels even for a small section. Having live wheels to batteries on the main would be one more challenge to overcome.

Question (after all this lead-up) is regarding shutting off the connection to the decoder while charging.If this could be done "hands free" as it begins to charge that would be ideal. Magnets and reed switches would work, of course, or perhaps an electromagnet in the engine house? Let me know any thought you might have. 

Neil

 

Neil Erickson, Hawai’i 

My Blogs

Reply 0
Geoff Bunza geoffb

@Neil re:Battery Charging

Hi Neil,

Inductance charging will work, with all the characteristics you cite. It is inefficient, and likely you will need to up the voltage at the cost of a quick charge due to current drop. I would not opt for an "auto detect" cut out of the decoder, since you would likely need to detect a charging current's existence, and that detection if intermittent during operation would be ugly. A hidden or disguised switch would be better, and they can be very small.

Have you considered a simple 2 contact arrangement for a direct charger connection, possibly held in place by a small rare earth magnet (say 3-8 mm in size)? Think of 2 exposed contacts at the end of a cable with the magnet between the contacts. There could be a similar arrangement on your loco or tender such that the magnetic field alignment would guarantee correct contact polarity, and firm connection. It would then be very easy to connect for an overnight charge. I could even consider a water spout arrangement for a water tower, where the contact set was at the mouth of the spout (same arrangement as above) and the spout was lowered onto the tender hatch to re-charge the battery as the engine took on water (or oil). Neat, easy, cool animation too! remember the contacts and the magnets can be really tiny! This would be a great product for the larger scales at least!

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
Prof_Klyzlr

Suggestion RE "which way is the loco oriented"

Dear Dr Geoff,

As per the linked post in my previous, requiring the loco to be placed in a certain orientation to work with the shuttle route is a non-starter for many show work applications, and is another "limitation" of a DCC implementation that the long-serving analog equivalent does not force the user to think about
(on analog, place the loco anywhere on the shuttle route, Inc over/in a "stop block",
in any orientation fwd/back <> east/west,
at any time,
and the shuttle system "does what it's supposed to"... [smile]) .

Suggestion : wire _both_ end-stop detectors into a single input pin,
And have the software say:
- move until "stop pin" = high
- toggle direction (repeat ad nauseum ad infinitum)

By using a single "stop pin" for any/all "loco must stop now" inputs,
The explicit "loco must hit X detector while travelling forward, hitting Y detector is ignored" issue is removed,
(there's only 1 "stop pin" the software is looking at, it's direction agnostic, and Stop means STOP!)

And it would also allow easy setup/deployment of multi-end-point shuttle routes, say, a "Y" or "X" track schematic...
(just couple up more "stop detectors")

BTW, is there any reccomendation for end-stop/mid-point detectors? just thinking out loud...

Happy Modelling,
Aim to Improve,
Prof Klyzlr
Reply 0
Yaron Bandell ybandell

single stop pin?

Prof, I can see the advantage of 2 separate stop pins. Just check in the logic if either (or both?) pins are 'high' indicating the train should stop and act on that But your point is valid.
Reply 0
Geoff Bunza geoffb

@Prof re: DCC Limitations

Hi Prof.

Quote:

requiring the loco to be placed in a certain orientation to work with the shuttle route is a non-starter for many show work applications, and is another "limitation" of a DCC implementation

Well... you can call this a limitation but actually it is a requirement of DCC -- you may not like it, but it is part of the specification. Only the decoder knows which way is forward, at power-on. Every time anyone puts a loco on a DCC track they inherently know "forward throttle" moves the loco forward (unless you re-configure the decoder). I don't see this as a limitation, just a fact of DCC life for independent loco control.

Quote:

Suggestion : wire _both_ end-stop detectors into a single input pin,
And have the software say:
- move until "stop pin" = high
- toggle direction

Well... maybe.As I stated to you before, if you accept the "shuttle limitation" that you start the loco not over either end of  track sensor, given that the DFG starts in a known (forward) direction, when it hits the end of track sensor, it certainly can reverse the direction and continue, and in this case, since it knows the direction of movement, the DFG can combine the two end sensors to one pin, just like the pause/stop sensors, since it is now keeping track of direction of movement. But you cannot start the shuttle with the loco engaging either end of track sensor. So, Prof, which "limitation" would you like? Somehow, the controller needs to be told or infer what is the actual direction of shuttle travel.

Quote:

BTW, is there any recommendation for end-stop/mid-point detectors?

I have successfully used the same cheap optical sensors I described in Scale Model Animation 14: Grade (or Level) Crossing Control http://model-railroad-hobbyist.com/node/20176 which can be found here: http://www.ebay.com/itm/131356972026

but they are bulky, and like the vast majority of optical sensors, they are sometimes erratic with varying intensities of light. Stay tuned for another future blog article that solves this problem. No ETA as yet.

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
dark2star

Double end-stop

Hi,

reading the discussion about locos facing backward and going off the line if started over the forward end-stop...

Why not splash the big bucks and put small switches into the end-of-track bumpers (or more detectors "beyond" the end-of-track)? Sure you'll need another input. So, if a loco is facing the wrong way when started over the end-stop detector this is what will happen:

  • loco starts up slowly
  • loco hits the bumper (slowly)
  • loco is e-stopped
  • loco is reversed
  • loco starts up slowly...

This is not an elegant solution, but I guess it's reasonably fool-proof.

Similarly, to address the loco address issue you could go brute-force. If the loco does not hit any sensor within XX minutes, the DCC Function Generator tries to brute-program-on-the main and set the loco to address 3 (whatever)?

Have fun!

Reply 0
Jim at BSME

E-stop / Shuttle comment

Geoff, you state:

Quote:

dcc_speed to a number from 1 to 127 or -1 to -127. Avoid zero (0) which will send an estop to the decoder.

But in the code you use one (1) not zero (0):

Quote:
      if (digitalRead(estop_pin)==LOW) {
        dcc_speed = 1;  // ESTOP Power Cut Off
        locoAdr =   0;  // Global Broadcast
        dcc_cmd_rpt ( 30000 );                // stop eerything for 30 seconds
      }
// END OF ESTOP SECTION

I don't want to seem nit-picky so please don't take it that way if the above code is incorrect, please fix the typo on the dcc_cmd_rpt line and about six lines latter you have SPEED typed SPPED. I don't know why I pick up on typos like that or why they bother me, probably an OCD thing, sorry.

I hope to use the shuttle sketch on our club layout, before we went to DCC we had a branch line that was simply automated to run back and forth.  I know we could have gotten the Prof silencer aka the Tam Valley Shuttle, but our club doesn't have the finances. I didn't feel like spending the money personally for such a limited use item, it would only be used during public shows, now I can have the fun building my own!

Thanks for all your hard work.

@Prof, you know if you make something fool-proof only fools will use it! I don't think it is un-reasonable at all to require the user to put the locomotive in the shuttle section in the correct forward direction.

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

Apology

Dear Dr Geoff,

Dr Geoff, I apologise if I'm applying a "more than the original circuit was designed to address" set of specs to the Shuttle route. I'll be very interested to see the results of the development, and any/all practical deployment examples our fellow modellers put this excellent piece of engineering towards...

Happy Modelling,
Aim to Improve,
Prof Klyzlr

 

Reply 0
Geoff Bunza geoffb

@dark2star

Hi dark2star (name?),

This might be made to work, but it is tough on the bumper and loco w/consist. I would avoid it to avoid the possibility of a derailment. Also, sswitches are as good or as bad as most absolute position sensors. In effect this scheme would force the loco to the end of track in order to infer the correct direction. I still think the simpler solution uses one of the two scenarios I mentioned  before. But you've got me thinking about this!

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
Geoff Bunza geoffb

@Jim re:discrepancies

Hi Jim,

People seem to be very sensitive with this! No need! Thanks for pointing this out, Jim.  

The dcc_speed = 1; is actually correct. The speed range is nominally 0, & 2-127. I've changed the text in the blog accordingly. The code will actually work correctly, but there is a special estop broadcast command dps.eStop(); that may be slightly better to use with the CmdrArduino library. Your comment has provoked me to re-look at the library internals -not something I go out of my way to do (takes time away from modeling!). I will update all the examples in the download tonight. I have tested this with both code scenarios, and both do work.

This nits are what I had hoped to shield modelers from. Just read the NMRA spec a few times and you may need an adult beverage ...or two!

Thanks for the help in pointing this out, Jim -- much appreciated.

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
Geoff Bunza geoffb

@Prof re:Your Shuttle Application

Hi Prof,

I can't quite figure out why I deserve an apology? I tried to go to the link you provided to read about your application, but it is a bad link.

I am glad you asked the questions you did because it make me read up a bit more about DCC broadcast messages. According to the NMRA spec. decoders are supposed to respond to DCC broadcast messages (address 0) but it also says the decoder manufacturer is supposed to provide a list of which features/messages it will respond to in broadcast mode! While I really haven't gone out of my way to notice, I don't remember ever reading a decoder manual that talked about "legitimate" broadcast message for a particular decoder. I will put it on the stack of interesting questions to be pursued. But if this really worked for speed and direction commands, it could be part of the solution to your question.

Without knowing more about your shuttle application -- which sounds like it may be more complicated than a single loco/trolley on a single point to point track (this was the setting I was targeting) I don't know if this simple shuttle is a good enough match (as you alluded to). It really isn't meant for general purpose train automation. I have a small narrow gauge (HOn30) 2 or 3 car shuttle that this was intended to run. That's where this came from. It was originally an end to end trolley shuttle that was scrapped.

Also, like you, I am interested to see how modelers would adapt these relatively simple examples to their own needs, modeling, and layouts.

Have fun! 

Best regards,

Geoff

Addenda: Hi Prof,

I just read a second post from you that has some kind of spam marking, but after reading it it seems you do have a larger set of requirement than I had imagined! Now I'm not quite sure how large a shuttle project you want to tackle? It sounds like there are many locos (staging tracks?) and a wye? I think the DFG could be made to work (example: the 12 sec timing is not a limitation) but it likely would require more understanding and more code too.

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
wjwalsh53

SN754410 GND

I find it surprising that the ground traces on the 754410 and the two caps are only tied into the system ground with the single narrow trace between pin 12 of the 754410 and pin 9 of JB1. Is this really so?

Regards,

Warren

Reply 0
Geoff Bunza geoffb

@Warren re:Ground trace to 754410

Hi Warren,

Yes, it is so. Once I get a fully connected layout, I go back over it and widen all/most of the power and ground traces that I have space for. I recently did this for the board layout I included, but missed that trace  While it will work just fine for many situations,I will change the layout and upload a new layout. I'll post a message when completed.

***** Update: Ground trace widened to 754410 consistent with "system" ground. This bothered me enough, I thought it needed attention!  Done, ...Download .brd file has been updates and put in place!

Thanks for pointing this out Warren. I appreciate it. Have fun! 

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
wjwalsh53

@geoffb re:Ground trace to 754410

As someone who designs electronics for a living the ground trace hit me right between the eyes. I am happy you were able to increase that trace width.

While I know for economic reasons 2 layer PCBs are the way to go, it is sometimes a better choice to go 4 layer which will allow for a dedicated ground layer and another routing or power layer.

Regards,

Warren Walsh

Reply 0
MikeM

ESTOP/guard block question

I'm very interested in the possible use of the ESTOP feature described here to protect gates/lift outs but something has occurred to me that clearly demonstrates my lack of understanding of some aspects of DCC.  It is my understanding that ESTOP is a broadcast command, to be acted upon by all decoders that receive it regardless of the locomotive's address.  What happens if a locomotive happens to be spanning the gap between a "normal" block and the adjacent guard block when the ESTOP command gets issued?  Would the command inadvertently be propagated to the normal block through the internal wiring of the locomotive that spans the gap, i.e. as if the loco were a jumper?  I would assume that were this to occur all locomotives in the normal block would immediately stop as well?

MikeM

Reply 0
Reply