Geoff Bunza geoffb

Because of the interest in this project (Details can be found here: https://forum.mrhmag.com/post/sma12-17-channel-configurable-multifunction-5-dcc-decoder-for-servos-12198051 ) more example decoder variations have been added and some start up timing problems have been fixed. The new libraries and examples can be downloaded from here (Updated November 26, 2016):

http://mrhpub.com/files/users/geoffbfiles/new-dual-multifunction-decoderv5_4.zip

Please see:

SMA20 New Low Cost 17 Channel DCC Decoders & Dual Motor,LED, & Servo Control Updated: 6 Ftns/Pin & New Features
for the latest update information.

Installation is the same as described previously. Delete your previous version, replace it with the new one, and load in onto your decoder. Below is a brief description of how I’ve built my new boards followed by a detailed working example for a 7 servo 10 LED configuration that may help people configure their own versions for their particular modeling needs. Also, now check the fourth comment page for the accessory decoder version.  Have at it!

Decoder.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

Configuration details and a bigger board for my own use

With no great need for a tiny footprint, this board layout suited my needs better. Here are the major features: The two blue terminals are the DCC connections. The red terminal is for +5 Volts DC only, Black next to it is for DC Ground from the power supply.  A 5 Volt wall AC adapter powers everything. The group of 7 by 3 pins on the left is for the servos—white servo wire (sometimes yellow) control pin goes towards the Pro Mini board. Black servo wire (Ground) goes away from the Pro Mini board. The middle pin is +5 Volts from the power supply. A group of 10 LEDs are mounted on a small board with dropping resistors on the right (with socket strips added below). They are for use as a debugging tool.

The little LED board can be carefully lifted off the pins (see pic below) to reveal another set of pins 10 by 3 which pins could also be configured for servo control. The Pin nearest the Pro Mini board can be used to drive a LED or LEDs off board. There is no dropping resistor connected directly to this pin (for the red LEDs, surface mount device (SMD) resistors are already mounted on the little board). You’ll note the LED board can be used to test the pins on either side of the Pro Mini.

Parts.jpg 

17 Pin Configurable Multi Function Decoder with LED debugging Board Removed

Decoder Configuration Details for a 7 Servo 10 LED Decoder Configuration

When first loaded the decoder is set to short DCC address 24.  The decoder can be reset to the original parameters by loading CV 120 with 120 (decimal). This will reset everything including the decoder address, when the pushbutton on the Pro Mini is pushed (reset) or by powering the decoder off then on.

The decoder address can be changed to another short DCC address by changing CV 1.

The 7 Servo 10 LED decoder configuration

Arduino Pro Mini Pins are set as follows: 3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19

Pro Mini Pin          Function

3                                  F0 Servo

4                                  F1 Servo

5                                  F2 Servo

6                                  F3 Servo

7                                  F4 Servo

8                                  F5 Servo

9                                  F6 Servo

10                                F7 Single LED Blink

11                                F8 Single LED Blink

12                                F9 Single LED On/Off

13                                F10 Single LED On/Off

14                                F11 Single LED Blink

15                                F12 Single LED Blink

16                                F13 Double LED Blink F13 and F14 LEDs (Pins 16 & 17)

17                                F14 Single LED Blink (Ignored because of F13)

18                                F15 Double LED Blink F15 and F16 LEDs (Pins 18 & 19)

19                                F16 Single LED Blink (Ignored because of F15)

(Blink rates are set differently for demonstration purposes)

Correspondingly, for the 7 Servo 10 LED decoder configuration, CV’s are initially set to the following:

{CV number, Value}    Description

{1, 24}  Decoder Initial Address

{30, 2}, //F0 Config  0=On/Off,1=Blink,2=Servo,3=Double LED Blink

{31, 1},    //F0 Rate  Blink=Eate,PWM=Rate,Servo=Rate

{32, 28},   //F0  Start Position F0=0

{33, 140},  //F0  End Position   F0=1

{34, 28},   //F0  Current Position

{35, 2},  //F1 Config  0=On/Off,1=Blink,2=Servo,3=Double LED Blink

{36, 1},    // Rate  Blink=Eate,PWM=Rate,Servo=Rate

{37, 28},   //  Start Position Fx=0

{38, 140},  //  End Position   Fx=1

{39, 28},  //  Current Position

{40, 2},  //F2 Config  0=On/Off,1=Blink,2=Servo,3=Double LED Blink

{41, 1},    // Rate  Blink=Eate,PWM=Rate,Servo=Rate

{42, 28},   //  Start Position Fx=0

{43, 140},  //  End Position   Fx=1

{44, 28},    //  Current Position

{45, 2}, //F3 Config  0=On/Off,1=Blink,2=Servo,3=Double LED Blink

{46, 1},    // Rate  Blink=Eate,PWM=Rate,Servo=Rate

{47, 28},   //  Start Position Fx=0

{48, 140},  //  End Position   Fx=1

{49, 28},    //  Current Position

{50, 2}, //F4 Config  0=On/Off,1=Blink,2=Servo,3=Double LED Blink

{51, 1},    // Rate  Blink=Eate,PWM=Rate,Servo=Rate

{52, 28},    //  Start Position Fx=0

{53, 140},    //  End Position   Fx=1

{54, 28},    //  Current Position

{55, 2}, //F5 Config  0=On/Off,1=Blink,2=Servo,3=Double LED Blink

{56, 1},    // Rate  Blink=Eate,PWM=Rate,Servo=Rate

{57, 28},    //  Start Position Fx=0

{58, 140},    //  End Position   Fx=1

{59, 28},    //  Current Position

{60, 2}, //F6 Config  0=On/Off,1=Blink,2=Servo,3=Double LED Blink

{61, 1},    // Rate  Blink=Eate,PWM=Rate,Servo=Rate

{62, 28},    //  Start Position Fx=0

{63, 140},    //  End Position   Fx=1

{64, 28},    //  Current Position

{65, 1}, //F7 Config  0=On/Off,1=Blink,2=Servo,3=Double LED Blink

{66, 1},    // Rate  Blink=Eate,PWM=Rate,Servo=Rate

{67, 1},   //  Start Position Fx=0

{68,35},  //  End Position   Fx=1

{69, 1},    //  Current Position

{70, 1}, //F8 Config  0=On/Off,1=Blink,2=Servo,3=Double LED Blink

{71, 1},    // Rate  Blink=Eate,PWM=Rate,Servo=Rate

{72, 1},   //  Start Position Fx=0

{73, 100},  //  End Position   Fx=1

{74, 1},    //  Current Position

{75, 0}, //F9 Config  0=On/Off,1=Blink,2=Servo,3=Double LED Blink

{76, 1},    // Rate  Blink=Eate,PWM=Rate,Servo=Rate

{77, 1},   //  Start Position Fx=0

{78, 10},  //  End Position   Fx=1

{79, 1},    //  Current Position

{80, 0}, //F10 Config  0=On/Off,1=Blink,2=Servo,3=Double LED Blink

{81, 1},    // Rate  Blink=Eate,PWM=Rate,Servo=Rate

{82, 1},   //  Start Position Fx=0

{83, 5},  //  End Position   Fx=1

{84, 1},    //  Current Position

{85, 1}, //F11 Config  0=On/Off,1=Blink,2=Servo,3=Double LED Blink

{86, 1},    // Rate  Blink=Eate,PWM=Rate,Servo=Rate

{87, 1},   //  Start Position Fx=0

{88, 5},  //  End Position   Fx=1

{89, 1},    //  Current Position

{90, 1}, //F12 Config  0=On/Off,1=Blink,2=Servo,3=Double LED Blink

{91, 1},    // Rate  Blink=Eate,PWM=Rate,Servo=Rate

{92, 1},   //  Start Position Fx=0

{93, 20},  //  End Position   Fx=1

{94, 1},    //  Current Position

{95, 3}, //F13 Config  0=On/Off,1=Blink,2=Servo,3=Double LED Blink

{96, 1},    // Rate  Blink=Eate,PWM=Rate,Servo=Rate

{97, 1},   //  Start Position Fx=0

{98, 35},  //  End Position   Fx=1

{99, 2},    //  Current Position

{100, 0}, //F14 Config  0=On/Off,1=Blink,2=Servo,3=Double LED Blink

{101, 1},    // Rate  Blink=Eate,PWM=Rate,Servo=Rate

{102, 1},   //  Start Position Fx=0

{103, 4},  //  End Position   Fx=1

{104, 1},    //  Current Position

{105, 3}, //F15 Config  0=On/Off,1=Blink,2=Servo,3=Double LED Blink

{106, 1},    // Rate  Blink=Eate,PWM=Rate,Servo=Rate

{107, 1},   //  Start Position Fx=0

{108, 60},  //  End Position   Fx=1

{109, 20},    //  Current Position

{110, 0}, //F16 Config  0=On/Off,1=Blink,2=Servo,3=Double LED Blink

{111, 1},    // Rate  Blink=Eate,PWM=Rate,Servo=Rate

{112, 1},   //  Start Position Fx=0

{113, 4},  //  End Position   Fx=1

{114, 1},    //  Current Position

{120, 0}   Master Reset CV When set to 120 and Power cycled resets all CV’s

Each Function is controlled by a maximum of 5 CV’s.

For example F0 is initially set for servo control:

{30, 2},     // F0  Pin Function Configuration  2=Servo

{31, 1},     // F0  Rate  Blink=Rate, Servo=Rate

{32, 28},   // F0  Start Position  F0=0  Initially 26

{33, 140},  // F0  End Position   F0=1  Initially 140

{34, 28},    // F0  Current Position or State

F7 is initially set for single LED blinking control:

{65, 1},    // F7 Pin Function Configuration  1=Blink

{66, 1},    // Rate  Blink  1= Slowest

{67, 1},    //  Start Count Set to 1 or 0

{68,35},   //  End Count 2-255 -- 255 = Slow Blink

{69, 1},    //  Current State of LED

F13 is initially set for double LED blinking control of F13 and F14 LED Pins:

{95, 3},    // F13 Pin Function Configuration  3=Double LED Blink

{96, 1},    // Rate  Blink  1= Slowest

{97, 1},    //  Start Count Set to 1 or 0

{98, 35},  //  End Count 2-255 -- 255 = Slow Blink

{99, 2},    //  Current State of LED

F9 is initially set for single LED On/Off control:

{75, 0},    //  F9 Pin Function Configuration  0=On/Off

{76, 1},    //  Ignored

{77, 1},    //  Ignored

{78, 10},  //  Ignored

{79, 1},    //  Ignored

Before changing the CV settings take a look at the initial settings and make small changes first to observe the effects. This should give modelers a starting point, and a better understanding for customizing their decoders.

Please also note there is a new 17 LED (On/Off) decoder configuration, which while providing the 17 LED on/off control like the very first decoder introduced in this project. However, this version now can be reconfigured via CV control to perform the other functions too.

Comments and appropriate suggestions are always encouraged.

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
Michael Duckett

The bottom

Could we have a picture of the bottom of the board please to give us an idea of your layout?

Michael Duckett

Reply 0
Michael Duckett

Filtering

It looks to me like you are filtering vcc at the Pro Mini and at each header pin set.  Is that correct?

Michael Duckett

Reply 0
Geoff Bunza geoffb

@Micheal D. Re: Picture & Filtering

Hi Michael,

Here's what the bottom looks like:

ard_rear.jpg 

It's pretty straightforward. Most of the connections are bare wire. The green wire is the DCC pickoff from the 6N137 to Pin 2 on the Pro Mini. The Blue and White wires go to A4 and A5 (Function pins 16 & 17). On the bottom of the Pro Mini at A4 & A5 (note: these are NOT along the edges of my Pro Mini and they are often repositioned by the manufacturer) I put two pin sockets ( http://www.allelectronics.com/make-a-store/item/psip-80/peel-a-way-r-machine-pin-socket-strip/1.html ) facing down, solder a pin or an 0.020 wire to the lead and make the removable connection to the board from the underside. This way if I need to replace the Pro Mini I could simply unplug it, and put in a new one.

You are also correct that this board has the 3 Capacitor pair filters. The instantaneous draw from any servos can sometimes crate electrical noise. Physically close filer placement to either noise generators or noise sensitive components often adds a bit more protection just when you need 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
Michael Duckett

Awaiting parts. Takes a while.

I have ordered a bunch of parts mostly in lots of 100.  Its gonna take a while.  Stripping parts off of everything.  Gonna take a while.  Need an ardueno loader that works with ubuntu.  And a tutorial to help with setting it up. Also an ociloscope program for the sound card also for my ubantu computer.  Such a mess just to keep all of these projects orignized and moving forward.

Michael the Disorganized

 

Reply 0
Quackers69

Thank you

Geoff,

Thanks for the great how to articles.

I've built this board today after reading your articles. Can't wait to experiment with it for both turnout and animation control.

Quackers

Reply 0
Geoff Bunza geoffb

@Quackers

You are very welcome! Share how you put it to use. Best of luck with your modeling!

On a different note if you have suggestions for improvement/modifications, please let me know. 

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
homoandroidus

optimum !!!

Hi geoff

first, please sorry for my english :-(

i found this article very very interesting

i think we are right ring to connect old and new generation of model train fans. In italy all "old man" are be able to build but the have no idea of dcc. the "young man" are inside byte from morning to night but have refused about any construction manual.

i made the prototype and it worked well immediately. wondefull !!! i tried it with fleishmann multimaus.

i'd like to suggest to add a way to modify address of board manually. for example to put a bridge from ground to A5 or/and A6, like old electronic board (i'm 54, so i remember that !)

i'm not very good about arduino language. i tried to do that but i saw that address of board is chosen BEFORE void setup and void loop, so it is possible change it only re-loading right code.

i think it'd better to change with little bridge (jump), so after a reset arduino load preferred address looking for A5 or/and A6 to ground or to +5v (only three address possible .. for example 10-20-24 - depend of jumper)

best regards

peppe from rome

 

 

Reply 0
Geoff Bunza geoffb

@Peppe re: Decoder addressing

Hi Peppe!

Il tuo inglese è molto meglio del mio italiano!

The initial address is designated in the sketch with the line:    #define This_Decoder_Address 24   so the EEPROM in the Pro Mini can initially be loaded with valid data. If you follow the instructions, after the first load, go back and change the line:    //#define DECODER_LOADED   to      #define DECODER_LOADED  

In other words, delete the // and reload the Pro Mini. Now you can set the short address in CV 1 to any valid short address that your DCC system will accept. Please note that different DCC systems have different upper limits for the short DCC address. This would eliminate the need for address jumpers-- and yes, I very much remember the use of address jumpers!   I avoided the use of jumpers since setting the CV was simpler, and I didn't have to give up 2 or more pins for the address. If you must use address jumpers, pick 2 (or more) pins as you suggest, remove them from the fpins[  ] list, define them as inputs, and read them in and set the address in the block:

#if defined(DECODER_LOADED)
  if ( Dcc.getCV(CV_DECODER_MASTER_RESET)== CV_DECODER_MASTER_RESET )
  #endif 
     {
       for (int j=0; j < FactoryDefaultCVIndex; j++ )
         Dcc.setCV( FactoryDefaultCVs[j].CV, FactoryDefaultCVs[j].Value);
         //   READ YOUR PINS HERE AND CALL:    Dcc.setCV( 1, your_address); 

digitalWrite(fpins[14], 1);
         delay (1000);
         digitalWrite(fpins[14], 0);
     }

Please note that any time the decoder is reset, either upon first program load, or if you load 120 into CV 120 (master reset) the address will be reset via you jumper settings (however you interpret them).

If you rework your decoder to use jumpers and need more help, just ask. If you have difficulty reading this try "google translate" on this text:  https://translate.google.com/  It is not perfect, but it can help.

I have wonderful memories of great times in northern Italy and always wanted to get to Rome, but never got there-- my loss.

Have fun with your modeling and let us know how you use your decoder!

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
homoandroidus

jump address

hi geoff

posso assicurarti che il tuo italiano è veramente di alto livello !!

thanks for your answer.

next week-end i will try to modify your .ino to add the feature i spoken last time

i understand that you do not love jumper but remember that here in italy all persons that works with model train are "old style".

they have a lot of difficulties to "play" with a tv-remote control ... please image them to set an address with multimaus or other device.

it's more simply to say them : this is the decoder ---> put your chosen address (example : 10 - 20 - 120) . it is very simply !!! insert or remove jumper as written in the sheet )))

in italy dcc is not for all ... is for limited group of people. 95% of model train persons are collectors. very few have a model railway ... even less have a dcc model railway ...

after my test i will say here for everyone if ok or not !!! i hope to insert some pics of board

best regards !

peppe

p.s. next time in italy do not miss a 3 day walk in rome !!!

 

 

Reply 0
Bogos_75

Question - level crossing

Hi Geoff
Following your projects, some of them done. They give great results on the track.
He has a question for you. Are you able to write the code for the Arduino, so as to control the level crossing?
The whole has to consist of two IR sensors, two servos and four LEDs.
The system has such a function: where the train crosses the beam IR LEDs start blinking and servo leave detention. If the train will pass the IR sensor lights go out and the gate will rise.
I'm trying to do such a deal on the arduino and I can not cope.
Sorry for my English - I'm Polish.

Best regards

Boguslaw

Reply 0
Geoff Bunza geoffb

@Boguslaw re:Question - level crossing

Hi Boguslaw,

I put this together to help you get started:

http://model-railroad-hobbyist.com/node/20176

Twój angielski jest o wiele lepszy niż mój polski!

'Hope this helps. Ask more questions if needed and share your modeling results too!

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

Why are you using Softservo

Hi geoff

It is included as part of the Arduino in latest versions (0017 and after).  Is yours different ?  Does not really matter i guess, just looking at the code, there will not be much changing by me.

 

Still waiting for parts, in awe.

Ivan

 

 

Ivan Lee Herring

Mountain Valley Western

Reply 0
Geoff Bunza geoffb

@Ivan Re: Softservo Modified Library

Hi Ivan,

This is a modified Softservo Library simply because there was code built into the original library limiting the number of servos it supported. I wanted to build a configurable decoder where every pin could be fully functional. So I modified the Softservo library to support the 17 servo maximum That's it! 

Good luck with your project.

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
nicolasg

Very excited

Im looking forward to making use of the library modifications soon.
Coming from an embeded world I can see so many uses in my upcoming  project.

One important note, in regard to the NMRA spec and your samples.
I think it would be best to adjust the sample code CV's you are using so that it doesnt overlap existing reserved CV's. Many people are using your samples already.
See: http://www.dccwiki.com/Configuration_Variable
/> CV's 30-47 have specific purposes already in the spec. You could argue 33-46 are function related but not the rest.

The simplest approach is to move them to 112-256.
Move 30 -> 130, 31 -> 131, etc.

--edit note. removed man cv comment-

One final thing, normally sending anything to CV8 (write) resets a decoder to default settings. The call notifyCVResetFactoryDefault() would take care of that, but in your case you simply set an flag, which is used on reset to change/set the values to default.
Is there any specific reason you went via implementing your own CV120 method ? Iam just curious as to the design choices so I can better understand the library/samples.

Excellent work.
 

 

 

Reply 0
Geoff Bunza geoffb

@nicolasg Re: CV's & Reset

Hello Nicolas,

Quote:

I think it would be best to adjust the sample code CV's you are using so that it doesnt overlap existing reserved CV's.

Well... the short form answer is that I wanted this to be simple for me. This meant I wanted to access all the CV's as a mobile multifunction decoder, not an accessory decoder, and that I did not want any indexed or multi-part addressing scheme. The NMRA standard S-9.2.2 July 2012 lists all CV's 30 and higher as Optional, not Mandatory and not Required. So from the NMRA standard-- it was my option, and indeed it actually is in compliance. Frankly, even if it was Mandatory I would likely have done it this way anyway. I was building this for a specific reason, and for my own use, not as a "product" and not looking for NMRA DCC CV conformance, merely DCC communications compatible-- which it is. Now with that said, you can easily renumber the CV's in the table, for example in this portion of the CV definition table:

  {30, 2}, //F0 Config  0=On/Off,1=Blink,2=Servo,3=Double LED Blink
  {31, 1},    //F0 Rate  Blink=Eate,PWM=Rate,Servo=Rate
  {32, 28},   //F0  Start Position F0=0
  {33, 140},  //F0  End Position   F0=1
  {34, 28},   //F0  Current Position
  {35, 2},  //F1 Config  0=On/Off,1=Blink,2=Servo,3=Double LED Blink
  {36, 1},    // Rate  Blink=Eate,PWM=Rate,Servo=Rate
  {37, 28},   //  Start Position Fx=0
  {38, 140},  //  End Position   Fx=1
  {39, 28},  //  Current Position
  {40, 2},  //F2 Config  0=On/Off,1=Blink,2=Servo,3=Double LED Blink

the first number in the brackets "{ }" represents the address of each of the respective CV's. So by changing these and then changing the code to index at the beginning (30 in my case) of your table, you can put this anywhere you want.

Quote:

normally sending anything to CV8 (write) resets a decoder to default settings

Quote:

Is there any specific reason you went via implementing your own CV120 method ?

First, in some, but not all, decoders CV8 is used for a similar factory reset. Sometimes it is necessary to write a specific value, like 8 or 9.

The reason I used this at all was that I wanted the decoder to remember it's CV's after it was powered down and then back up. So subsequently changed CV values would be retained. This required the use of what is called EEPROM (Electrically Erasable Programmed Read Only Memory). But, the very first time the Pro Mini is loaded, there is no reliable data in the EEPROM, so I needed a way to put it there. Also I eventually realized that since I couldn't read from the decoder, I did want a way to restore everything to a known state. Hence the CV 120 invention. Again if you would like to change that to CV 8, change the line:

uint8_t CV_DECODER_MASTER_RESET = 120;   

to

uint8_t CV_DECODER_MASTER_RESET = 8;

this will also mean you will need to put "8" into CV 8  and power cycle the decoder to restore its CV's.

"Hope this helps a bit and enhances your modeling. 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
nicolasg

Im sorry if I came off

Im sorry if I came off attacking your choices. Not my intention at all. I like to learn.
The suggestion for the example change was because I see many people are using the library for train control - and so I wanted to avoid issues with people trying it at home and getting conflicts.

Technically while the spec does list CV30+ as optional, the implementation is optional not their purpose. So for example a manufacturer can choose to implement/make use of CV66 "Forward Trim" or not, but they cant choose to use this CV for another purpose and still remain to spec.
But i completely understand your needs in this code - simple and personal use.

As for the reset, I understand the need for eeprom use and keeping the variables after power down.
The question was mostly because this function was implemented in the sample files

void notifyCVResetFactoryDefault()
{
  // Make FactoryDefaultCVIndex non-zero and equal to num CV's to be reset
  // to flag to the loop() function that a reset to Factory Defaults needs to be done
  FactoryDefaultCVIndex = sizeof(FactoryDefaultCVs)/sizeof(CVPair);
};

The library already implements the CV8 reset to default functionality, by calling the above function in the user code (the user code must then do the proper resetting off course). Thus my interest in the CV120 method.

uint8_t validCV( uint16_t CV, uint8_t Writable )
{
  if( notifyCVResetFactoryDefault && (CV == CV_MANUFACTURER_ID )  && Writable )
    notifyCVResetFactoryDefault();

....

}

That is in the library file, NmraDcc1.cpp, if it notices a write to CV_MANUFACTURER_ID (CV8) it calls the reset function in the user code.

Again my apologies if I came off rude or unappreciative.

Reply 0
Geoff Bunza geoffb

@nicolasg

Hi Nicolas,

Not to worry, I didn't take your questions as anything but interest. Posts sometimes don't come across the right way at all.   

I did see the CV 8 call, but originally I didn't think it did what I wanted in my early versions, so the code "evolved" to this state. I just left it alone. It's more of my "it's modeling not production code" and when I get it to do what I want, I stop. From a professional engineering approach, it's really not perfected code. Nonetheless, when I get it to do what I want -- I stop and move on. One thing I do try to do is test the code for basic functionality and corner cases, but again, when I think it's "good enough" then I stop.

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
Logger01

Remembrances

Quote:

it's really not perfected code. Nonetheless, when I get it to do what I want -- I stop and move on.

Remembrances of tmrc PDP coding and layout wiring in building 20.

Ken K

gSkidder.GIF 

Reply 0
Geoff Bunza geoffb

@Ken

Oh my Ken ! Are you another TMRC alum (said with a big SEG) !! 

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
Logger01

Alum? Or Designed by Committee Victim

I became a victim (er member) in the mid 60's. I think some of my hearing loss is from squatting next to crossbar switches! The new TMRC layout is much quieter, but PC's and PIC's are just not as exciting to watch.

Ken K

gSkidder.GIF 

Reply 0
Axel-T

I/O Extention?

Hi Geoff,

Thanks for sharing this work! Cool I have a question to you - because I am not yet deep enough into this to answer it myself...

Would it be possible to extent this Decoder to a let's say 8 Channel I/O Decoder? I would need this to run it on my modular arrangement with 8 switches next to the turnouts into the front...

So it the operator switches/toggle on an button, the decoder runs the servo by using the "correct" DCC command and sub adress internally. That would allow to run this in a kind of "analog" mode, if I work on a single module or in a "full DCC" Mode together with any type of central (Hardware, JMRI, ...) - Actually I am looking for a replacement for the LocoIO (http://users.telenet.be/deloof/) based on Arduino to avoid pre-programmed pic's and their availability... .

It should be possible/work - but does the underlaying library provide the needed functionality?

Best Regards,

Axel Thobaben

Reply 0
Babbo_Enzo

Axel, I remember we have

Axel, I remember we have already discuss in the past about this configuration in some previous post.

See here: http://model-railroad-hobbyist.com/node/19446

But I forget if Geoff have done the software or not .... to my search now it seems not.

-----

Geoff, just for my personal curiosity:

- Why you've not implement the decoder as "accessory/stationary decoder" in place of "mobile" ?

- As his functionalities are "function only" I have image this was your first choice.

 

Reply 0
Kevin Rowbotham

Arduino based DCC control of 8 relays

http://model-railroad-hobbyist.com/node/19739

This circuit discussed in the video employs the function keys (F1, F2, etc.) to control the individual relays, rather than toggles but i believe there is a way to use switches for input.  Geoff Bunza or David Bodnar can likely elaborate where I can only guess.

~Kevin

Appreciating Modeling In All Scales but majoring in HO!

Not everybody likes me, luckily not everybody matters.

Reply 0
Reply