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

@Warren

Hi Warren,

Ditto. I wold love to have all my designs in 4 layers with a protective ground layer, but 40 years of electronic systems design hints that neither power nor speed issues are existent, and the additional cost is not necessary. Still... I can dream about it!

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

@Mike

Hi Mike,

Quote:

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?

Great question. The block crossing short might be a possibility due to wheel shorts if the gaps were straight across the rails-- solution: still double gap but stagger the gaps, and/or widen the gap to prevent rail bridging (remember this is not an issue for normal running as the relay is carrying normal layout dcc to the guard block). Nonetheless, let us assume they are perfectly in line so that corresponding wheels successfully bridged the gap. The 2 DCC signals are 99.99% likely to conflict messing up the signal to each block, which the decoders will likely reject as unreadable, and continue as if they read no DCC command. Both the layout DCC command station and the DFG are normally repeating commands to decoders, so eventually all commands to all decoders should get through. The DCC signal does not propagate "through" the internal wiring as it might through a DC motor without electronics.

I haven't seen such erratic behavior myself. Regardless, if any modeler experiences any weird behavior with this (after preventative measures were taken) I would be interested in hearing about their situation.

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
MikeM

As far as staggering the gaps

I would assume that at a minimum you would want the separation distance between gaps to be minimally greater than the distance between the first wheel on the loco that collects power (and a DCC signal) and the last?  For steam this might be from the front-most driver to the last wheel on the tender; for diesels from the first wheel in the lead truck to the last wheel in the trailing truck?  If you had a small steam loco with a follow-on car containing DCC gear that wouldn't fit in the loco itself it would be the last wheel in that car's trailing truck (assuming you actually collect power/signals through the trucks on that car)?

I'm not thinking so much in terms of what happens through the internal wiring of the loco itself as that the pickups are essentially wired so that the drivers on one side are wired in series as are those on the other.  Each side of the loco becomes a long "wiper" if you will, bridging the gap for the rail upon which they ride.  Taken together they would seem to me to effectively allow the 2 controllers to have commingling packets.  At this point I don't know enough about DCC to know how the decoders would react to this but if not as just noise...  Suggesting that the result would be possibly timing dependent and cause symptoms that could appear/disappear rather randomly.

MikeM

Reply 0
Geoff Bunza geoffb

@Mike re:Staggering Gaps

Hi Mike,

Quote:

I'm not thinking so much in terms of what happens through the internal wiring of the loco itself as that the pickups are essentially wired so that the drivers on one side are wired in series as are those on the other.  Each side of the loco becomes a long "wiper" if you will, bridging the gap for the rail upon which they ride.

Yes, your description is correct, after all, multiple pick up wheels are the equivalent of multiple wipers, and as you point out -- the equivalent of elongated wipers. I think some experimentation is in order here. It may be that different systems / decoders may react differently as well.  What you point out (my view) is that there may be more interference generated crossing the gap into the guard block than I had imagined. I will have to look into this some more. If anyone tries this, I would be interested in your results-- but please include the DCC system, the decoders, and the loco types (wheel arrangements) involved.

Thanks for pointing this out. 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
Prof_Klyzlr

Check the Boosters too

Dear Dr Geoff,

Worth checking the boosters too, some boosters don't like having their "track outputs" shorted to any other "smart" device...

Happy Modelling,
Aim to Improve,
Prof Klyzlr

 

Reply 0
Geoff Bunza geoffb

@Prof K re:Booster Check

Hi Prof,

That's another good point. I went back and looked over my notes. I used a 2 axle industrial switcher (EMD Model 40) and it may have been too good a test case given this discussion. I'm going to have to make some time to set up a better test run. (More items for the to-do list). Your suggestion now makes me wonder what happens when a loco crosses a block boundary where 2 boosters are feeding either side of the boundary where the wire runs to the adjacent blocks are very different (one very long the other very short. Is there enough of a propagation delay that the DCC signal can be messed up in a similar fashion? Hmmmmmm...

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

Booster 2 Booster

Dear Dr Geoff, Not sure about propagation and timing, but I know that wiring "polarity" of multi-booster systems and what happens when a loco "jumps the gap" from one booster district to that of another booster is a primary headache for both booster manufs and modellers/modular-setups. Guess my big concern is more "...DFG gets it's H-bridge output connected to the 5A output of a Booster that isn't on the same GND...and then the smoke came out..." type situation... Happy Modelling, Aim to Improve, Prof Klyzlr PS my understanding was that H-bridge driver outputs "had no ground", and accidentally tieing either "H bridge output leg" to GND was a short way to end the life of the H-bridge driver?
Reply 0
MikeM

A possible tweak for the gap problem?

In my other post about using an Arduino to address the open bridge/gate problem I tried to suggest how occupancy detection might be included in deciding when to issue the ESTOP commands:

img.png 

This would depend on the type of occupancy detection selected but for some forms could be set to trigger only if you were reasonably certain the gaps were not being spanned.  This approach could become complicated itself by issues such as multi-track gates/bridges, trains backing through if blocks weren't long enough, etc.  Just some food for thought...

MikeM

Reply 0
Geoff Bunza geoffb

@Prof

Hi Prof,

Quote:

my understanding was that H-bridge driver outputs "had no ground", and accidentally tieing either "H bridge output leg" to GND was a short way to end the life of the H-bridge driver?

It's slightly more complicated than that in this case, and partly dependent on how the DFG is powered. For example, I commonly use the DFG to power small animations that use DCC decoders, My demo animations for clinics are almost all battery powered for portability (12V for a DCC DFG). I run some small dioramma animations with a DFG powered by a wall wort (AC Adapter). On a layout I powered my "animation bus" with a separate Power supply than the one I used for DCC track power. In the battery examplemthe DFG electrically "floats" (ie. has no common ground) with layout DCC power. Just how the circuit interaction would occur becomes a more complex analysis, examining return paths for the combined circuit. I would not want to offer a conclusion without a closer look.

Nonetheless, this is worthy of more consideration and thought. I do not want to dismiss this lightly, especially since I "stirred the pot."

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

@Mike Guard Block Logic

Hi Mike,

You're in the same neighborhood of thinking as me. I think the "logic" can be a bit simpler. Using an "absolute position" sensor (like an optical detector) as opposed to a block detector (although a short block detector would be equivalent), a simpler solution would be:  if the open gate switch (estop_pin) was detected and the absolute position sensor detected the lead loco (assuming a consist or multiple locos in the worst case), then the DFG would switch and execute repeated ESTOP commands in the guard block. The position sensor would be placed in the guard block such that lead unit would be detected when the maximum length consist was entirely contained in the guard block. In this way, all appropriate loco pick-ups for all units would already be in the block to be switched by the DFG to ESTOP.

One line in the main loop in DCC_FTN_Gen_ESTOP_SW would be changed to:

void loop() {  
      dcc_cmd_rpt ( 2 );
      while ( (digitalRead(estop_pin)==LOW) && (digitalRead(position_sensor)==LOW))   {
        digitalWrite(p0, 0);    //Turn on block relay
        dps.eStop();              // ESTOP Power Cut Off
                                         // Global Broadcast to the Guard Block
        dcc_cmd_rpt ( 10 );   // stop everything in the block
      }
      digitalWrite(p0, 1);       // Turn off block relay
}

There is another issue that has not been brought up -- the switch back to layout DCC control once the lift-out / bridge was put back in place. This was always meant to be an emergency guard for unwatched trains and mismanaged keep-alive locos. So the quick switch back to layout DCC control as before was not an issue to me. Nonetheless, I would assume that in the case of a train forced to stop (before it goes into an abyss) the train crew would think about regaining train control and throttle down before regaining train control. Even if they did not think about it, with momentum turned on in the loco decoder(s) at least would likely not lurch forward.

ESTOP behavior is actually not completely specified in the NMRA standard (except the motor cut off). In particular, restart after an estop may generate different decoder behavior particularly for "complex" sound decoders with elaborate startup sequences.

Remember this was meant to be a safety cut out as a "last measure." Again, I would be interested in modelers' opinions and experiences with this application, and appropriate suggestions for improvements and enhancements. My point being that this can be adapted to fit different situations on your layouts that I may never see on mine.

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
MikeM

Now you've "restarted" my curiosity!

I tried searching for information about "restart after an estop" but couldn't really find anything that clearly suggested what I should expect when cutting back to the layout controller.  I could not find (did I not look in the right place?) any special packet to reset an estop so barring there being one I'd assume a "normal" (non-zero) speed setting packet would set the locomotive into motion again.

That said, unless changed by the operator, wouldn't the layout controller eventually retransmit the last speed setting packet selected by the throttle assigned to the stopped loco?  In that case I would expect to see the loco (re)turn to the speed setting specified by that packet, presumably acting as dictated by its momentum settings.

Forgive my choice of terminology, by the term "occupancy detection" I didn't intend to imply any particular device or technology for that purpose.  I've gotten suggestions from others about how it might be done but opinions vary widely.  I'm also inclined to think in terms of absolute position detection because 1) I think it might help keep the detection blocks shorter and 2) it seems to me a better, simpler method for detecting anything reaching the critical stopping point whether it is a powered loco or unpowered piece of rolling stock.

I'll also toss in one other thing that occurred to me--just as we might want to be concerned about a bridged gap might allow the estop to leak out, it might also allow a retransmitted speed step selection packet to leak in.  If that happened your estop might not last, unless...  Any reason why the DFG would not want to continuously issue estop packets as long as the condition requiring it continues to exist?

MikeM

Reply 0
lceggering

@ Geoff A quick question

Can this generate switch commands based on an input being occupied so as to throw a servo or three off of one of your other projects? I could use it to report to JMRI..

Thanks

Lawrence Eggering

CEO, COO and head engineer of the WDCNP Lines.

Reply 0
Geoff Bunza geoffb

@Lawrence re: Accessory (Switch) Commands

Hi Lawrence,

Short form answer, yes! The CmdrArduino library supports 2 accessory decoder calls:

setBasicAccessory   (address,  function);         //Turn on
unsetBasicAccessory   ( address,  function);    // Turn off

"function" according to the NMRA standard are the 2 bits determining which of 4 pairs of outputs the packet is controlling. All other bits in "function" are ignored.

Another issue-- I have never used this feature of the library, and have not incorporated it into my examples, particularly in the way I "refresh" / repeat the packet calls. I encourage you to try it out. If you want me to consider adding it in some form, specifically ask, and I'll put it in the to-do list. As usual, no committed ETA.

Better : you should be able to able to have the Arduino sense occupancy in a block, using any of the standard methods, and based on that sensor, set however many servos accordingly to a desired route (easy). How you report it to JMRI I am not sure but likely there are several ways-- again that is something I am not messing with at present. I use a RRCirKits Towerman as a general purpose input and output to JMRI (it would do the job easily) and is Loconet and JMRI compatible.

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
lceggering

@Geoff

The tower man seems to be reasonably priced but as I have a love of DIY I would like to implement this myself so if you can add it to the list please I would appreciate it. I will also add it to my list in case I get to my it first.

 

Thanks again for all you do!

Lawrence Eggering

CEO, COO and head engineer of the WDCNP Lines.

Reply 0
Geoff Bunza geoffb

@Lawrence

Hi Lawrence,

I will add your request to my to-do list, but it is likely to stay with a low priority for some time, as my own modeling does not require it. With that said, I would like to point you to Alex Shepherd's other arduino library, for Loconet: http://mrrwa.org/loconet-interface/

Realize Loconet is proprietarty to Digitrax, uses a different communication protocol, but might well offer a better interface for you to JMRI. Please don't take this as fact, because I have not used this, nor have I interfaced with JMRI through this mechanism. Nonetheless, I know there may be future applications I might build, where this becomes necessary for me.

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
Heisler wanted

DFG program

Hello Geoff,

Sorry to come up with newbie questions, but I tried to load your basic DFG program, just to see the memory space it would occupy, and immediately my editor said "Error compiling to Pro or Pro Mini".  Am I missing something basic here ?

Regards  Peter   

Reply 0
Geoff Bunza geoffb

@Peter re:Compiling Error

Hi Peter,

I've compiled that example sketch on the Arduino 1.6.0 through the 1.6.8 IDE's with no problems.

On 1.6.8 I get the compile message:

Sketch uses 6,892 bytes (22%) of program storage space. Maximum is 30,720 bytes.
Global variables use 146 bytes (7%) of dynamic memory, leaving 1,902 bytes for local variables. Maximum is 2,048 bytes.

So it is quite small. Make sure you download the zipped library with examples and place the CmdrArduino library into your \Documents\Arduino\libraries\ folder. Then reference the appropriate example

from the File -> Examples -> CmdrArduino   menu pick.

And make sure it is the ONLY CmdrArduino folder in your \Documents\Arduino folder.

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
Heisler wanted

Re compiling error

Yeah, I had missed a few things !  To begin with that library maneuver; I haven't built the hardware to test the

programs, but  the "Basic" and  the "Template" compiled right away now. My first project is still to control turnouts

by switches, but.... Your DFG - Decoder pair is indeed a finished solution (if I can modify the DFG sketch to accept maximum number of switches). And even without involving main DCC. My first programming attempts have been a switch/case scenario which didn't turn out well, in fact not at all !  Probably some more of "didn't know that".....

Many thanks for putting me on track again(old pun,sorry) !

Best Regards

Peter     

Reply 0
Heisler wanted

Compiling error, again

Hello Geoff,

I regret having to ask those simple questions, compared to others on this forum, but a humble question

is now necessary. I have finally built a decoder, and is eager to test it, but trying to load it it won't even compile.

NmraDcc.h is missing, "No such file". I have copied that into the libraries folder, but no change. Any ideas to solve that is much appreciated!

Best Regards

Peter

Reply 0
Geoff Bunza geoffb

@Peter re: NmraDcc.h is missing

Hi Peter,

Quote:

NmraDcc.h is missing, "No such file".

Is a message telling you that the Arduino compiler cannot find the NmraDcc library and its components. The NmraDcc library and the software servo library should have been downloaded from: 

/sites/model-railroad-hobbyist.com/files/users/geoffbfiles/new-dual-multifunction-decoderv5_2.zip

unzipped, and put into the ...\My Documents\Arduino\libraries folder, unmodified. Your individual saved sketches should be saved in the ...\My Documents\Arduino folder. Doing otherwise will confuse the compiler.

Also, NmraDcc is the library for decoders not the DCC function generator. This blog is for the DCC function generator. So either you logged your comment in the wrong blog entry or you have confused which library you are working with? In any case, corresponding libraries need to be in place before running the Arduino editor. If you move the libraries in place after starting the Arduino IDE you will also confuse the compiler.

'Hope this helps. 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
Heisler wanted

re: NmraDcc.h is missing

Thanks Geoff,

This should do it; I haven't really checked yet but, yes, I probably had not copied the right file into the correct folder.

It is indeed a decoder I am working with; it just seemed appropriate to continue the "compiling error" path.

You have so much interesting information and ideas, in various blogs, that I am reading bits and pieces all over the place(blog). But, of course, actually constructing units require a bit of carefulness, which, I guess, I have now demonstrated. Thanks again for helping out !

Best Regards

Peter    

Reply 0
Heisler wanted

NmraDcc.h is (still)missing

Sorry Geoff, or more correctly, sorry for putting you through this....

Have now tried downloading your file as described, and placing it in the libraries folder. Unzipping it to the same folder produces the various examples and, I think, also the NmraDcc file. But whatever I do, the editor refuses to compile it, still the same error message. At the moment I have not connected a Pro Mini, but just compiling it should work, I think. Also it says there's an invalid library found, in the library folder. I have missed somewhere, that's obvious. Will see tomorrow what can be done.

Regards

Peter

 

Reply 0
Geoff Bunza geoffb

@Peter re: NmraDcc.h is missing

Hi Peter,

Let's start with some checks: What Arduino IDE Version are you using? Are you using an MS Windows machine? Do you have only one copy of the NmraDcc library loaded? and in the proper place? Do you have the correct Arduino Board selected that you are using from the Tools menu? This has been successfully used with the Pro Mini, Uno, and Mega 2560. Independent of any of your own sketches can you load an Example from the NmraDcc library and successfully compile it with the Menu pick Sketch -> Verify/Compile ? If you get any errors what precisely and totally are the error messages you get? Did you download the library only from: /sites/model-railroad-hobbyist.com/files/users/geoffbfiles/new-dual-multifunction-decoderv5_2.zip

When you copy the folders to My Documents\Arduino\libraries\ you should only copy the NmraDcc and SoftwareServo folders independently to My Documents\Arduino\libraries\NmraDcc and My Documents\Arduino\libraries\SoftwareServo.  Again the general message:  NmraDcc.h is missing  says the compiler cannot find the library. Last alternative-- remove the entire arduino install including the folder in My Documents (you can rename them if you want too) and reinstall the IDE and then the libraries from scratch.  Let us know how you do. 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
Heisler wanted

NmraDcc missing

Geoff,

I take the liberty to answer myself. Have now checked a bit more on basics, and there is a function in

the editor, to install zip libraries; I tried that and it seems to work, but gives back an error "Specified folder/zip file does not contain a valid library". Could it be this is not the right file?

The file is the one you gave in a recent answer about this problem. As the library manager, in this case, wants a zip file should mean that it will not confuse libraries with sketches, right?  I have done this with the (zip)file in the libraries folder, and elsewhere too.

The solution to this is probably simple, but I fail to see it. (If this goes on a really old Port will become mandatory...)

Again, just humbly asking for a push in the right direction....

Best Regards

Peter 

 

 

Reply 0
Geoff Bunza geoffb

Library Provided is for Manual Install

Peter,

The libraries I provided are for manual installation. I have no experience and no idea what the library manager will do with them.

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
Reply