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

@Erik re: Multiple Base Stations

Hi Erik,

Quote:
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.
Multiple base stations connected together doesn't work. They both think they are in charge of the DCC bus and would "conflict/step on each other's signals. That's why most commercial systems have a "throttle" concept for multiple controllers. The only way I know of using multiple throttles with DCC++ is via JMRI. Handheld cell phone/wifi controllers would work.
 
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
HVT Dave

Multiple DCC++ Throttles

@ Erik,

Dave Bodnar has successfully used multiple wireless throttles with DCC++ using HC-12 radio modules, one connected to the Base Station and one in each throttle.  For more info check his DCC++ throttle page.

Regards,

Dave

Dave

Member of the Four Amigos

 

Reply 0
Erik A. Erik84750

re: Multiple Base Stations

Hi Geoff, will searching for solutions to have multiple throttles I had come across this one from David Bodnar: http://trainelectronics.com/DCC_Arduino/DCC++/Throttle/#Wireless_Option

Seems like somehow two or more units are capable of being handled by a stand-alone setup of DCC++ (Arduino Uno or Mega, motorshield).

I will do some experiments (the coming months sometime, when I find time) to use the same idea on your throttle. I will let you know the results.

Warm regards,

Erik

 

Reply 0
Erik A. Erik84750

Multiple sensor inputs

Hi Geoff, I hope this is not off-topic, but due to the title "..JMRI to track connections.." I hope to be in the right place.

Most of your blog subjects handle outputs to track or accessories. Is it possible to reverse this and have a solution for reading sensor inputs back to a computer (ie. JMRI)? But: without sacrificing an Arduino input pin per sensor input, meaning: parallel to serial handling by hardware and its corrsponding software adaptations in DCC++?

Edit: I know there are solutions for this (ie CMRI, but there is not much to find about CMRI plus DCC++ plus JMRI) but I thought posting this here because you have such broadminded and clear views on so many issues.

 

Reply 0
Geoff Bunza geoffb

@Erik re: Sensors

Hi Erik,

I finally had some time to look into this. If you look into Sensor.cpp and Sensor.h as part of the code loaded from DCC++ Base Station load into your Uno or Mega from https://github.com/DccPlusPlus/BaseStation

You will see an explanation of how sensors are set up and assigned to Arduino pins. From looking at some of the Communications code it looks like sensor data is transmitted back via the serial USB interface. So I would expect there is some coordination with JMRI, or at least the possibility thereof. You might try experimenting with this and then asking questions on the DCC++ forum, as I am not going to be using this right now.

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

Driver for turntable

Hello Geoff

I have a question if you have not done any simple control module made on Arduino to the turntable using the stepper motor? I have a turntable controlled manually by a DC motor, but there is always a problem with the exact alignment of the track relative to the track.

Best regards

Boguslaw

Reply 0
Geoff Bunza geoffb

@Boguslaw re: Turntable control

Hi Boguslaw,

I have not developed this project, although I have a turntable which one day will be on my layout.

A geared stepper motor would likely be my preference for TT operation. You can achieve very good alignment for all the lead tracks by using small rare earth magnets and small hall effect devices. The magnets would be placed at a hidden location at each end of the TT bridge. The small hall effect sensors would be placed in the TT wall (or in the pit below) to detect precisely when the alignment was correct. You would need to either keep track of the 180 degree swing to know which end if the TT bridge was aligned. The stepper could be operated smoothly and slowly enough to look realistic under simple arduino control. A small display and track selector would complete the project.

This is the updated Hall Effect device I referred to: AH1806-P-BDI-ND from digikey.com:
 
about half way down the page.  Note too the point about the locking pin, which could be the "ultimate" alignment mechanism.
 
There is another discussion of their use here (note they reference old part numbers): Scale Model Animation 4 – Critter Guidance, Sensors, & Fun
 
This is how I would approach it. 'Hope this helps. Have fun! 
Best regards,
Geoff Bunza

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

Reply 0
Jim at BSME

re: Turntable control

@Boguslaw you might want to check out this blog by Pelsea: Control the World with Arduino

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

Hello Thank you for the tips,

Hello

Thank you for the tips, they are definitely helpful.

Best regards

Reply 0
locomansounds

DCC DIY made simple

Thanks for all the DCC tips. Soldering iron primed and ready.

Best Regards, Locoman

Range of 5 British Steam DCC Sound Decoders:   http://www.locomansounds.com

Reply 0
Heisler wanted

Adressing

Hi Geoff,

Hope all is well with you; if you remember I received extensive help trying to start up a decoder. That is working, even if it should receive some adjusrment of servos.

This question is SMA25 related; I have built Dave Bodnar's controller and is now thinking of adding turnout control to that. My first step is testing the command code, but can't get it to work. I assume every servo output has it's own address( "40" - "56") ? Please advise.

Regards

Peter

Reply 0
Geoff Bunza geoffb

Servo addressing

Hi Peter,

If you have configured your decoder as an accessory decoder, then each servo will have its own "switch" address with the default addressing starting at 40. If you configured your decoder as a mobile/function decoder, then each servo is operated by a numbered function of that decoder address (default 24) F0-F16.

Since you are asking this decoder addressing question in this blog about tinkering with DCC++, if you use the DCC++ interface with the "Processing" software you will find that DCC++ uses an odd scheme to address accessory decoders, and address 40 needs to be entered in the 2 part form as "10 and 3" decimal.

For for reference, the code to convert the "normal" accessory address to the DCC++ form is:
    sw1=(sw_address+3)/4;
    sw2=(sw_address-(sw1*4)) +3;
where sw_address is the "normal" accessory switch address, and sw1 and sw2 are the 2 parts of the DCC++ address reference. So...
    address 40 becomes 10  3
 
    address 45 becomes 12  0
    address 46 becomes 12  1
    address 47 becomes 12  2
    address 48 becomes 12  3
Remember in integer arithmetic the fractional remainder in division is dropped.
 
It is one of the features of DCC++ I don't like and don't use.
If you use DCC++ as a DCC hardware interface for JMRI, you can simply use 40,41,42,...etc. as normal.
 
'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

Servo addressing

Thanks Geoff,

weird indeed, but - it works !   I have the base station you indicate, with a Mega, and is still testing with the

serial monitor over USB, but I can define a turnout and get < o> back, which should indicate success.

I can also throw the defined turnout with < T ID 1> or < T ID 0> and gets < H ID "0" or "1"> back which is also correct. But (there's always a but) my turnouts don't work.... Having tested the above I have to assume there is something wrong in my layout connections, if the base station confirms the throw it should send the correct DCC code too (?) I could perhaps test with my Digitrax. However, you solved the problem at hand, many thanks !

So far I haven't physically connected a switch for sensor testing, but will do. The idea is to have turnout switches at the fascia, these will be connected as sensor inputs to the Mega/base station. BS should then confirm the sensor change as serial data which is read in my controller, and trigger the Turnout code. btw someone wrote that DCC++ is addictive - agree.....

Regards Peter

 

 

Reply 0
bogos75

Segment turntable Faller - servo - question

Hello Geoff

How are you?
I have to you as an expert in Arduino projects questions.
I bought the Ebay segment turntable Faller 120275. At the factory this turntable is to be controlled by the servo.
I wanted to use one of your projects that you published in the December MRH.
Your servicing projects have only two positions - start - stop.
I would like to use a 3 position switch to set the swing platform in 3 positions.
Could you help me in the project. It's easy for you, and I can not handle it.

Best regards

Boguslaw

Reply 0
Geoff Bunza geoffb

@Boguslaw re: Multi-Position Servo Controller

Hi Boguslaw,

I am very fine, thank you! 

Here follows a relatively straightforward Aduino sketch for a 3 position servo controller, using a multiple position switch (in your case 3 position) but this could be more positions as necessary.

You could easily control a semaphore or a train order signal with a small servo and this too.

A switch like this:

Switch.jpg 
Connect something like this wafer switch above (you wanted only 3 positions, but if you read the sketch comments you can see you can configure it for many more positions than 3.

Wafer switch common is connected to ground and other switch positions are connected to
Switch pins as defined in swpins[ ] list
Corresponding servo positions per position are defined in servo_pos [ ] list in any order you want
step_delay is the delay time in milliseconds between each servo step to slow things down
and
#define numswitches 3                // Number of switch positions
must be changed if you increase or decrease the number of positions.

_Labeled.jpg 

The picture above is labeled as if you were going to use a six position switch, as an example.
And here is the Arduino sketch:


//  Multiposition Servo selected via multiposition switch (wafer switch)
//   G. Bunza 2017
//   A special sketch for fellow modeler Boguslaw
// Wafer switch common connected to ground and positions connected to
// switch pins are defined in swpins[ ] list
// corresponding servo positions per position are defined in servo_pos [ ] list
//
#include < Servo.h>
#define numswitches 3                // Number of switch positions
#define servopin 2                   // servo is attached to this pin
#define servo_starup_pos 85          // arbitrary servo startup position
#define step_delay 200               // servo incremental delay per stap in milliseconds
Servo  ttservo ;                     // turntable servo definition

int i,swval;
int swpins [ ]= {3,4,5};             // Switch pins
int servo_pos [ ]= {20,85,150};      // Multiple Servo Positions
//
void setup() {
    ttservo.attach(servopin);       // Set up servo control
    ttservo.write(servo_starup_pos); // Set each servo to start position
    swval = servo_starup_pos;
    for (i=0; i< numswitches; i++) pinMode(swpins,INPUT_PULLUP);  // Initialize switch pins for input
}
void loop() {
  for (i=0; i< numswitches; i++)  {
    if (digitalRead(swpins)==LOW) { // Check if a switch is selected
      if (swval != servo_pos) {
        while (servo_pos> swval) { // remember where we are going
        swval++;
        ttservo.write(swval);
        delay(step_delay);
        }
        while (servo_pos < swval) { // remember where we are going
        swval--;
        ttservo.write(swval);
        delay(step_delay);
        }
        swval = servo_pos;         // remember where we are (this statement should be redundant!
      }
    }
  }
}

I hope this helps get you started. It complies on either an UNO or a Pro Mini.

Let me know how it goes. 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
bogos75

Hello Geoff Thank you, you

Hello Geoff

Thank you, you are great!
I still have to learn a lot to write such a code.
Even today I will be testing.
Good day, I wish you good

Best regards

Boguslaw

Reply 0
diehard

Does the Processing software work with loco and acessory files ?

I loaded the DCCpp_Ctrl_SW and/or DCCpp_Ctrl_Loco onto my Mega2560. I only have the LCD, no motor shield yet. The LCD shield is working fine and using Processing, I loaded Geoff's DCCpp_Controller on my laptop. That's working also.

Should I expect to see any interaction between the DCCpp_Controller screen on my laptop and DCCpp_Ctrl_Loco that's displayed on the LCD ?

If not, then why are these part of this post ?

Thanks.

Reply 0
Geoff Bunza geoffb

@diehard

Hi diehard(name?),

The processing software & .pde that Greg provided does not work with the 2 stand alone sketches that I built. It is a representation of Greg’s layout. The 2 sketches I provided were, as stated, experiments/tinkering to see what could be done with completely stand-alone implementations. I do not expect to take these any farther. Follow up on the DCC++ site for those modelers using Processing.

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
Erich Abens

LCD Shield issues and learning.

Geoff,

Thank you for your contributions to the modeling world!

I purchased the wrong LCD Shield (Velleman VMA203 LCD & KEYPAD SHIELD FOR ARDUINO® - LCD1602) and was able to get it working (mostly).

1) What does the A0 - A2 on the LCD shield accomplish?   

Once I changed the A0 to A2  in the Sketch & have rem'd out the backlight. I also had to add the Keypad.h & .cpp to the sketch as I think I have multiple libraries (which I need to clean up) and it was picking the wrong one.

2) What would be a good pin (if any) for the backlight?

I am also waiting for an ATMega+ESP8266 to see if I can get it to work without a PC using my Android Phone & Tablet.

I am trying to learn Arduino & C++ so if you have any links (hopefully DCC++ related) that can help pleas let me know.

 

Regards,

Erich 

 

Reply 0
Geoff Bunza geoffb

@Erich reins

Hi Erich,
Quote:
What would be a good pin (if any) for the backlight?
The reason I picked the specific display and button board was precisely to avoid the problems you are having with your board. You have to map out what each board's interconnect pins are actually required to make this work. Since there are 3 boards, you have a 3 dimentional interconnect puzzle to solve. So start by determining all the connections required for each board, and especially which ones are not needed. The switch from A0 to A2 was an example of avoiding the pin conflict with 2 of the boards. As I did with mine, you can also cut off, or bend out pins that are not needed for connections to all 3 boards. I am not familiar with the Vellman VMA203 board you are using so you will need to do all the pin mapping yourself.
 
With regards to the backlight, I would recommend you simply solder the pin to GND (ground) or VCC to make it on or off to suit, using another connection on the same 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
relder

Relay vs Motor Shield

Greetings,

This is a newbie question, and I apologize if this is the wrong forum. I have built my dcc++ Arduino base station with the GitHub code and have tested the uno to verify code is operational.  I ordered and have a relay board and not a motor board.  The relay board that I have is HiLetgo Relay Shield 5V 4 Channel Arduino UNO R3 Relay Shield Arduino, Shield

  • My question: Can I use a Relay shield to connect to Uno and also my HO scale track power? If yes, how should the wirings get connected to the relay (main and programming)? 

_20%20PM.png  As you can see, the relay has many different wiring connections, I am unclear on the proper location of main track power and the programming track power.

 

Thank you and I look forward to learning from your knowledge and experience.

~ Ryan

Reply 0
HVT Dave

@ Ryan

Sorry, but the relay shield will not work for DCC++.  DCC++ requires an H-bridge for the PWM (Pulse Width Modulation).  There are a few different motor shields and H-bridges that have been used.  If you don't use one of the motor shields shown on GitHub you might take a look at Dave Bodnar's work here.

Good luck and let us know how you get on.

Dave

Member of the Four Amigos

 

Reply 0
Geoff Bunza geoffb

@Ryan re:Motor Shield

Hi Ryan,

Dave is correct. The relay shield cannot perform the functions needed for driving a DCC bus.

Please see more details in Prof K's answer in your duplicate post here:
 
This is the typical DCC++ motor driver board used, and it is still available:
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

Reply @Geoff: Servo addressing

Hi Geoff, when in JMRI Panel Pro a table for 15 switches is set up wit a range starting at hardware address 40 I get a list with system names starting DT54, then DT40 etc.. until DT53. When activating DT40 (user named SMA20-test:1) then the DCC++ traffic controller gives Accessory Decoder Cmd: Address 9 Subaddr: 3. DT41 gives: Address: 10 Subaddr: 0, next DT42: Address: 10 Subaddr: 1, etc..

Why does DT40 (first address) not start with 10/0?

Grts,

Erik

 

Reply 0
Geoff Bunza geoffb

@Erik re: Acessory Decoder Addressing

Hi Erik,

Your question is wrapped up in the ambiguity of the NMRA accessory decoder addressing scheme:

If you have configured your decoder as an accessory decoder, then each servo will have its own "switch" address with the default addressing starting at 40. If you configured your decoder as a mobile/function decoder, then each servo is operated by a numbered function of that decoder address (default 24) F0-F16.

Since you are asking this decoder addressing question in this blog about tinkering with DCC++, if you were to use the DCC++ interface with the "Processing" software you will immediately find that DCC++ uses an odd scheme to address accessory decoders, and address 40 needs to be entered in the 2 part form as "10 and 3" decimal.

For for reference, the code to convert the "normal" accessory address to the DCC++ form is:
    sw1=(sw_address+3)/4;
    sw2=(sw_address-(sw1*4)) +3;
where sw_address is the "normal" accessory switch address, and sw1 and sw2 are the 2 parts of the DCC++ address reference. So...
    address 40 becomes 10  3
 
    address 45 becomes 12  0
    address 46 becomes 12  1
    address 47 becomes 12  2
    address 48 becomes 12  3
Remember in integer arithmetic the fractional remainder in division is dropped.
 
It is one of the features of DCC++ I don't like and don't use.
If you use DCC++ as a DCC hardware interface for JMRI, you can simply use 40,41,42,...etc. as normal. My SMA20 series of decoders all use the "linear" scheme consistent with JMRI.
 
'Hope this helps. Have fun! 
Best regards,
Geoff Bunza

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

Reply 0
Reply