Geoff Bunza geoffb

Take the 2 boards pictured below, download the efforts of Gregg E. Berman, the creator of DCC++:  https://sites.google.com/site/dccppsite/, add 2 wire jumpers and you have a DCC base station that can be controlled with multiple throttles directly from your PC. It will also act as a $9 JMRI to DCC hardware interface—really! This was pointed out by Dave here: DCC++ on Arduino supported by JMRI https://forum.mrhmag.com/post/dcc-on-arduino-supported-by-jmri-12202303 -- JMRI has recently been updated so that it can directly control the Arduino board combo without any other software on your PC. Moreover, you can follow the exploits of the intrepid Dave Bodnar here: My Experiments with DCC++ https://forum.mrhmag.com/post/my-experiments-with-dcc-12202876 and add a booster or remote handheld throttle—great stuff. This article describes some tinkering beyond my own first DCC++ build that may be of interest to other modelers too.

Uno.jpg   eld%20R3.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 2
Geoff Bunza geoffb

@Alan re: Again... GRRrrr...GRRRR

Hi Alan,

OK, let's check some basics: When you load the decoder as an Acessory decoder it starts with Acessory Address 40, and each function pin increments by 1. For a 17 function LED decoder that means addresses 40-56 to address the 17 LEDs. The CV's can only be set with ops mode programming only and not read back, and since Acessory decoders normally don't have CV's, you access the CV's via mobile decoder address 24 (default). Since you are using the JMRI interface, there should not be any scambling of address numbering -- pretty straightforward. Since it appears that you are using one of my decoders, remember that you have to load the appropriate sketch, turn on the decoder (so it sets all the CV's up in EEPROM), remove the // comment as explained in the decoder article, and then reload the modified decoder sketch. Otherwise it will not retain any CV writes you make to the decoder on power off. When I create a new "loco" in JMRI for testing, I' often pick a Digitrax DN163 or something close to it, so it has a bunch of functions available. Remember you can't read the CV's, only

When I'm on the air (getting less often these days) its 2M and some small amount of time for 6M, and 10M. I'm much more a tech than an operator. I like to restore old sets.

Hang in there Alan, and have fun! 
73
Geoff \ AD7JP

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

@Erik re: LCD-keypad shield Questions

Hi Erik,

Quote:

Would it be ok for the hardware here if a D10-activated LCD-keypad shield were used with the D10 connection to this transistor is cut? (ie. backlight on all the time)

I originally chose the LCD-keypad shield based on minimizing any pin overlap with the Arduino Module and the Motor shield. I was impressed with the simplicity of Gregg's 2 board solution and was trying to minimize changes. You will have to check if D10 is used with the Motor shield at all. I don't remember.

Quote:

You disconnect A0 from the shield stack and jumper it to A2. A0 actually reads the keypad status, does this mean you use A2 for this purpose now? And for what reason did you change it to A2?

This is in the same vein as the D10 issue. A0 is used in the motor shield/Arduino combo. If you look at the picture: A0 Pin Removed (Cut), you will see the A0 pin on the LCD-keypad shield is cut to remove contact with the boards below. The short jumper in the picture labeled A0 TO A2 Jumper Wire Installed allows control of the LCD-keypad shield A0 via the Arduino's A2 pin, which is not used in the keypad. So the Arduino reads the keypad status via A2, as you deduced. Again, I was doing this to minimize any required changes to make the 3 boards work together. Was this simplification necessary? Likely not, but I set it forth as a project goal. I think I came close.

Thank you for your very kind words. They are much appreciated.

Dave Bodnar shares some terrific work that he has done, as well as quite a few other modelers here. I think it is a "learning-rich" environment for all of us.

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
Erik A. Erik84750

Re: build questions: LCD-keypad shield

Hi Geoff,

thank you for your reply. I assume that the switch on your LCD display is used to (dis)activate the backlight and that you do no further controls of this backlight.

Keeping things simple and uniform is a great goal that I too try to use.

I did some research on possible LCD-keypad shields and there seem to be 2 versions of non-switch-activated-backlight versions (ie different from your proposes switch-activated-backlight shield): one with the backlight controlled by D3 and a Mosfet, and one with the backlight controlled by D10 and a transistor (see below).

In both cases it suffices to cut the respective pins and cut the pin from the LCD shield. If you do not want to cut the pin then make sure the track to the gate/base of the Mosfet/transistor is cut. In both cases the backlight will stay lit.

PS1: this is no endorsement for any make; in fact most/all of the shields found on Aliexpress and/or Ebay use the second schematic.

PS2: any use of a LCD shield has to make sure the right constructors are used in the sketch initialisation code; this is about the addressing of the LCD driver pins. A previous post by Geoff already discussed this issue.

PS3: the initiation code for the bottom LCD shield is:

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

Grts,

Erik

etronics.jpg _0%20SCH.jpg 

Reply 0
Jiri

Re: build questions: LCD-keypad shield

Hi Erik,

pin 10 is in DCC++ project reserved for Ethernet shield (with 5100 chip). If you do not plan to use that shield, you do not have to care about that pin.

Pins A0 and A1 are used by Arduino motor shield for analog measuring of main track current and programming track current. It is important for detection of short circuit on track (as well as for programming - not used here I guess). When we reroute the output of keypad to pin A2, it needs to be changed in the LCDKeypad.h file.

I have compiled the sketch and did basic testing successfully. Using of the keypad for controlling speed of loco is not convenient- too many clkicks... Besides, I would be afraid of interfering with DCC signal production as each analog read takes 100us to Arduino.

Good luck!

Reply 0
Cosmos

Murphy Still here....

Hi Geoff....

Between Murphy & I... we're messed up... Well I went & removed the " // " in the sketch.  I'm still Cornfussed about how to get the leds to light. I used the Digitrax DN163, in new loco, had two diff loco's one on 40 & other on 24. Do I go & change the CV decimal values or should I be able to just use the existing function keys in Throttle ? I do see data on the Uno with throttle but NOT with Turnouts.

This may be the culprit... I did the " // " removal re-loaded the Nano & didn't notice any problem,,  BUT...  When I decided to reload the Org 17 led First & Then remove the " // " the second time I got " Java.Io.IOException : Access is Denied "  ( I attached a Pic of the Mess ) when I tried to upload . I thought I had cleaned up the file folders  , but prob I haven't done all the correct removal's.

Sorry for being such a pain  Geoff... & thanks for all of your help...

73....  Alan...

IMG_0333.JPG 

 

 

Reply 0
Geoff Bunza geoffb

@Alan

Hi Alan,

Why are you getting Processing errors? If you are using DCC++ as the hardware interface between JMRI and one of my preconfigured decoders, the Processing program is not involved and should not be running. Yet your errors indicate these errors are coming from Processing.

Quote:

I used the Digitrax DN163, in new loco, had two diff loco's one on 40 & other on 24. Do I go & change the CV decimal values or should I be able to just use the existing function keys in Throttle ? I do see data on the Uno with throttle but NOT with Turnouts.

All you did was configure the throttle for JMRI. If you configured your decoder as an Accessory decoder, mobile decoder functions are not relevant and do not work. Only track switch commands at the appropriate address will work by definition. Acessory switches/turnouts are accessed in JMRI from the Tools-> Turnout Control Menu dropdown. I had recommended to you to use the DN163 when you expressed confusion in what to use for your JMRI throttle before. If you want to use function commands, configure your decoder as a mobile/function decoder and it will then respond to throttle function commands.

I think you should take a deep breadth and re-examine what you are running, specify in detail what you have connected in total, and how they are configured. When you take any action, like deleting/modifying lines of code, state what the line was, in whole, not just designate by "//." Also state specifically and in full what decoder your are using and the exact configuration it has.

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
Cosmos

Smoke in the Cockpit..

Hi.. Geoff...

You're gonna  SHOOT me ...  I started double checking my decoder pcb..  Everything looked ok.. Then I thought , what if I have the polarity of track 1 & track 2 reversed....  @$#*&^  wires were reversed.. I gotz led's a working...

Curious though...  using DN163.  is it keeping me from turning on Func 4 - Led 5 ?  I looked at the Function map & not sure.

Thank you again for putting up with my lack of knowledge  Geoff...

73...  Alan

Reply 0
jayfmn

Jay

Is that I/F board available & can a Nano be used instead?

Also, what's the source for the rotary encoder?

Thanks Dave!!!

Reply 0
Geoff Bunza geoffb

@Alan

Hi Alan,

No shooting here... but you may have to listen to an hour of 60 cycle hum!

Quote:

Curious though...  using DN163.  is it keeping me from turning on Func 4 - Led 5 ?  I looked at the Function map & not sure.

No, I suggested the DN163 to allow you to set up a throttle. But you will note with your throttle, that all the functions are available, including F4. If your LED connected to Pro Mini D5 then you need to turn on Fuction 2 not Function 4. F4 works whatever is connected to Pro Mini pin D7. Here's the table used in the sketch:

byte fpins [] = {3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
const int FunctionPin0 = 3;
const int FunctionPin1 = 4;
const int FunctionPin2 = 5;
const int FunctionPin3 = 6;
const int FunctionPin4 = 7;
const int FunctionPin5 = 8;
const int FunctionPin6 = 9;
const int FunctionPin7 = 10;
const int FunctionPin8 = 11;
const int FunctionPin9 = 12;
const int FunctionPin10 = 13;
const int FunctionPin11 = 14;     //A0
const int FunctionPin12 = 15;     //A1
const int FunctionPin13 = 16;     //A2
const int FunctionPin14 = 17;     //A3
const int FunctionPin15 = 18;     //A4
const int FunctionPin16 = 19;     //A5

'Hope this helps.  Have fun! 
73
Geoff \ AD7JP

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

@Jay

Hi Jay,

Yes you could use a Nano instead of the UNO, not sure which I/F board you are referring too, but the motor shield is available on e-bay and other sources, here is an example:  http://www.ebay.com/itm/R3-DC-Motor-New-L298P-Shield-Driver-Module-2A-H-Bridge-2-way-Fr-Arduino-UNO-2560-/371160920100?hash=item566aea3024:g:3qUAAOSwY45UNkeS I noticed this one does not have a heat sink which will need to be added to get the full 2 amp output. The advantage of the UNO with the motor shield is they can stack and you only need one jumper, with the nano you would have to run a few more wires.

Not sure what rotary encoder you are asking about, but you might want to ask over on Dave Bodnar's blog posts about DCC++, which Geoff has referenced in the original post.

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

Murphy again...

Hi Geoff.....

I haven't gotten back to that Function 4 led problem, but I wonder if it was something to do with Processing messing with it. I have no output on pin 7.  I DID go & clean up my file folders &  by reading SMA20 I saw that I need to install the  NEW  Libraries , which I did....

Murphy popped up again when I tried the DEC 7 servo 10 led sketch. On a Reset the DO pin gives a full 5 V  Pulse on the signal line to the servo. When I use the function button on the JMRI to flip directions the servo does run back & forth. But after about 8 or so flips it slows down & then it Dies ( 0 Volts ). The resistive load form Gnd to Signal pin on the servo is aprox 12.5 K... Measuring with my Fluke 87 III I see only 34 uA & highest voltage recorded is .44 V. As you know this is  VERY  LOW...   As mentioned before I'm using a Nano. I don't think it's diff from the Pro Mini as to a DO ...  I have two Tiny Radio Shack servo's & same prob on both. Even tried a Giant Hi-Tech servo & same problem.. I can wait a few minuets & it will do the same die off... I would think I should see aprox 5 V on the Siginal line / DO out............   What do you think is going on ???  

Thanks for your  help again Geoff.....

73...    Alan....

BTW...   That 60 Hz hum was rough.....    LOL

Reply 0
Geoff Bunza geoffb

@Alan and his close friend Murphy

Hi Alan,

Quote:

On a Reset the DO pin gives a full 5 V  Pulse on the signal line to the servo.

Errr... the DO pin? Is this correct? or do you mean the Function 0 pin which should be D3 on the Arduino Pro Mini Decoder, or are you using a different decoder? D0 should not be touched, it is one of the communication lines for USB comms.

Quote:

When I use the function button on the JMRI to flip directions the servo does run back & forth. But after about 8 or so flips it slows down & then it Dies ( 0 Volts ).

What are you using to power your servo? What servo are you using? This sounds like your power source is heating up and drpping out of service. A singl servo can have an instantaneous draw of over 1 Amp and a nominal draw of over 300 ma.

Quote:

The resistive load form Gnd to Signal pin on the servo is aprox 12.5 K... Measuring with my Fluke 87 III I see only 34 uA & highest voltage recorded is .44 V. As you know this is  VERY  LOW...  

Yes way too low, a servo typically is speced from 4.5-6 Volts DC power.

Quote:

As mentioned before I'm using a Nano. I don't think it's diff from the Pro Mini as to a DO ... 

Again, I am not understanding the DO reference. What you are describing usually indicates a power problem involving your servos, especially if it is also powering the decoder, or if you are using decoder power for the servos. Enough repeated current draw overwhelms the regulator on board, heats things up, and thermal cut offs engage, or sometimes melt down failures. If you are using a separate power supply for the servo +5 Volts, are the grounds connected between the decoder and the servo power? They must be connected.

'Hope this helps. Have fun! 
73
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
Cosmos

Murphys Family moved in...

Hi  Geoff...

The DO  refers  to a  Digital  OUT  Pin.... I am using D4 to drive the  MICRO SERVO... Radio Shack 2730765, not a lot of specs except supply V range is 4.8 to 6 Volts.

Power is 5 V   500 ma that powers the Nano & the Servo. The very Low Voltages I refer to are the Signal drive levels coming out of the Nano going to the signal in, on the servo.

I monitored the 5 V supply & didn't see any Drop....  BTW...  I am using the  NANO V3 Running at 16Mhz....  I do not remember what speed your Pro's run at, but if slower, prob the PWM rate is to fast......Causing the Very Low Voltage showing up...   Dunn K-now....   LOL...

73...   Alan

Reply 0
Geoff Bunza geoffb

@Alan

Hi Alan,

The Pro Minis I use and recommend are all 5V 16MHz, so there should be no problem. If you do use a 3.3V or 8MHz version you should set the correct configuration you are using in the Tools -> Processor drop down menu in the Arduino IDE/Editor. This automatically sets up/changes all the settings for the compiler so all the timing is consistent, including PWM timing!! It's one of the features of using Arduinos.

Quote:

Power is 5 V   500 ma that powers the Nano & the Servo.

This may be your problem. The Nano will need 30-60ma and the servo peak current draw is likely way more than 450ma. Try a bench supply or even a battery and see if it makes a difference.

'Hope this helps. Have fun! 
73  \  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
Cosmos

Geoff

Hi Geoff...

Well Last night I decided to move the fixed 5 V .5A leads to the Variable (set @ 5V ) 3 amp output & still same problem... I did hook up my scope & it looked like a lot higher voltage....  Was tired , late last night.... I would have thought the Fluke meter would have caught the peaks, but maybe not.... I'll try looking at the voltage with the scope tonight & let you know what I see....     Thanks..  Again...

73....     Alan

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Looks like same small V on Signal to servo using the scope...  about .5 Volts...   GRRrrrrrr....

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

WELL.....   It's kinda looking like the @#$%^& Header Connector on the Servo may be the problem, or the Header Pins on the PCB. ( Murphy )......   I do not power down the DCC station & turn back on to be able to get the servo going again.... I can put side pressure on the header & the servo will start up again...  GRRRRRrrrrrrrrr..... I don't think it has anything to do wil my fingers capacitance....

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

WELL....  GOT IT WORKING...  Long story short... I put a Faster Diode on the Opto ( 200 ns ) 1N4934 & Plan to order some 1N4454's ( 4ns)  at BG Micro for $.03 ea or 100 for $2.00...  I Finally got rid of Murphy......  GEEezzz

Reply 0
jayfmn

Case

Hi Dave! Do you have the case for the throttle available for sale?

I have almost everything to build the wireless version already!

Thanks!!

Jay AT&SF

Reply 0
alarsson

sma25 code question

I was looking over the code modification, was the changes in serialcommand.cpp the only changes you made?

 

I am thinking of making some other changes based on your code, but do not want to miss anything.

 

Reply 0
Geoff Bunza geoffb

@re: Code changes

Hi alarsson  (name?),

The code changes were overwhelmingly concentrated in serialcommand.cpp which handles the command processing. I also removed code from CurrentMonitor.cpp and Accessories.cpp. I think the motivation for removing the current monitor code was because I was trying to reduce the pin usage on the motor driver board.

'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
alarsson

Thanks

Thanks for the info Geoff.

I think my first step is going to identify your changes, in part to allow myself to continue to use new code form dcc++ bug fixes without having to do major rewrites all the time.

Was there a reason you removed the normal serial processing, or was it because you did not need it?

Alan Larsson

Reply 0
tourbiker

DCC++ and JMRI

Hi Geoff,

I have read an article concerning DCC++ in a German magazin called "digitale Modellbahn" 2-2017. Immediately I was enthusiastic about this solution. Thanks a lot for your work!

Nearly everything is running fine - I have only one question:  programming on main (POM) does not function with my boards. Am I doing something wrong?

I have connected the 2 wires from motor-shield board to my main track. Then set radio buttons in JMRI to main track and press programming after selection of loco. But then I got the message that this functionality will not be supported by this central station (error 303). With the programming track everything works fine.

I have tried it with ROCRAIL and there I found the same behaviour

Do you have any hints for me?

Best regards

Michael Adolphs

 

Reply 0
Geoff Bunza geoffb

@Michael re: Programming on the Main

Hi Michael,

You are most welcome.

I also had difficulty with using JMRI's decoder pro and DCC++ to program Digitrax decoders.

Let me first say that after I reported my difficulty in this blog, another modeler reported he did not experience the same problem. You might want to read through this blog and see his comments.

With that said, I was not able with Ops Mode Programming on the Main to write a whole sheet to a program a Digitrax decoder. I was able to use the single CV Programmer to successfully set any one CV I wanted. I did not ever expect to use DCC++ for programming decoders much so I did not pursue what was going on. Others here and on the net have also reported problems programming some decoders via decoder pro and DCC++. This is not something I am likely to pursue, as DCC++ itself is not my code.

One thing for you to consider is that all my use of DCC++ has been with a 12 Volt power source for the motor control board. Technically the NMRA spec says the output to the DCC bus should be about 14.5 Volts or so for HO scale. A power supply of 15 or even 16 Volts for the motor control board would come closer to spec. This might affect the programming of some decoders. If you do use a power source larger than 12 Volts, you will need to cut a jumper on the motor control board. You can find a detailed description of that here: https://github.com/DccPlusPlus/Documentation/blob/master/Motor%20Shield%20Pin%20Mappings.pdf

'Sorry I don't have a well formed solution for you, but I 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
atanisoft

With that said, I

Quote:

With that said, I was not able with Ops Mode Programming on the Main to write a whole sheet to a program a Digitrax decoder. I was able to use the single CV Programmer to successfully set any one CV I wanted.

You might want to give it a try with the latest JMRI.  I have had issues with various configurations of DCC++ with JMRI and many of them have been addressed in 4.7.1 and a couple that are still in dev builds.

The main area I saw problems was with WiFI enabling my base station, JMRI was flooding the base station with too many commands too quickly and that caused the base station to eventually start rejecting the commands outright.

Reply 0
tkillam

Keypad on LCD shield not working

Geoff;

I have built the hardware exactly as instructed but when I execute either sketch the key presses are not detected.  Your article does not state where to obtain the libraries that are needed for the sketch.  Since you moved the keyboard analog input from pin 0 to pin 2 I assume that you must declare that the keypad is on another analog pin (2).  However I cannot find where this is occurring.  I may have used a library that has not been modified for the change in pins.  Is this possible.  Please comment.  Thanks for your wonderful help in this hobby.  I really appreciate your efforts.

 

Thomas Killam

Reply 0
Geoff Bunza geoffb

@Thomas re: Keypad Problems

Hi Thomas,

Quote:

Your article does not state where to obtain the libraries that are needed for the sketch.

Correct. The LCDKeypad is actually a standard board and uses one arduino standard library. Nonetheless,
Unzip and put the lower LCDKeypad folder into the libraries folder like  ..\Documents\Arduino\libraries\LCDKeypad and you should be fine. I also found that there were 2 or 3 versons of this library on the net and others did not work well if at all.
Quote:
Since you moved the keyboard analog input from pin 0 to pin 2 I assume that you must declare that the keypad is on another analog pin (2).  However I cannot find where this is occurring.  I may have used a library that has not been modified for the change in pins

The output of keypad goes to pin A2, it needs to be changed in the LCDKeypad.cpp file, in line 26:

input=analogRead(2);

Thanks for your kind words. They are appreciated.
'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
Erik A. Erik84750

Multiple simultaneous base stations

Hi Geoff, is it possible to connect multiple base stations (handheld controllers)? Such as when two (or more?) people need to have their own handheld controller for a layout. How could that be accomplished?

Thank you for this great blog!

Erik

 

Reply 0
Reply