SMA12 - 17 Channel Configurable Multifunction $5 DCC Decoder For Servos

geoffb's picture

One of my earlier entries:  SMA10 – Build a 17-Function DCC Decoder for about $5 ( http://model-railroad-hobbyist.com/node/19070 ) generated a considerable amount of interest regarding the possible enhancement for controlling Servomotors (Servos). This is my next version of a 17 Channel Multifunction DCC Decoder based on a low cost $2.56 Arduino Pro Mini. This version supports configuring each of the 17 function pins for On/Off (LED/TTL) Control, or Configurable Blinking Control, or Configurable Servo Control, or Configurable Pairs Blinking Control. Yes, that does mean it can support 17 servos, each with rate, start point, and end point setting via DCC CV’s, per pin, as well as new LED configurable functions. Read On. Additional doc found here: http://model-railroad-hobbyist.com/node/19775 There is another decoder version added herein. Look for "New Decoder Version to Control Lighting Groups" in Page 12 of the Comments: http://model-railroad-hobbyist.com/node/19446?page=11   The most recent Update can be found here: SMA20 New Low Cost 17 Channel DCC Decoders with PC Boards & Dual Motor, LED, & Servo Control    http://model-railroad-hobbyist.com/node/24316

Comments

CV_DECODER_MASTER_RESET = 120;

@Geoff,

first of all thanks for the mighty DCC source examples. They are really awesome. As a newbie I started with your example of "Production 17 Function DCC Decoder Version 5.4 ". Everything works like a charm. The only problems i have are:

1. after changing a CV and storing a 120 in CV120 the system does not restart

2. I am fully lost in understanding the notifyCVResetFactoryDefault. I don't know how to realise it.

Thanks for a short note.

geoffb's picture

@Starbug re: CV Master Reset

Hi Starbug (name?),

You are most welcome! I'm glad you find them useful for your modeling.

1. after changing a CV and storing a 120 in CV120 the system does not restart
2. I am fully lost in understanding the notifyCVResetFactoryDefault. I don't know how to realise it.
 
Because you cannot absolutely rely on what is loaded in the EEPROM of a newly received Pro Mini, the all decoders are set to first load the programmed set of CV's defined in the list:
 
CVPair FactoryDefaultCVs [] =
{
  {CV_MULTIFUNCTION_PRIMARY_ADDRESS, This_Decoder_Address},
  {CV_ACCESSORY_DECODER_ADDRESS_MSB, 0},
  {CV_MULTIFUNCTION_EXTENDED_ADDRESS_MSB, 0},
  {CV_MULTIFUNCTION_EXTENDED_ADDRESS_LSB, 0},
  {CV_DECODER_MASTER_RESET, 0},
  {30, 5}, //F0 Config  0=On/Off,1=Blink,2=Servo,3=DBL LED Blink,4=Pulsed,5=fade
  {31, 1},    //F0 Rate  Blink=Eate,PWM=Rate,Servo=Rate
  {32, 0},   //F0  Start Position F0=0
,,,
 
After the initial power up and load, you were instructed:
// ******** UNLESS YOU WANT ALL CV'S RESET UPON EVERY POWER UP
// ******** AFTER THE INITIAL DECODER LOAD REMOVE THE "//" IN THE FOOLOWING LINE!!
//#define DECODER_LOADED
 
Once you removed the // in the line //#define DECODER_LOADED and reloaded you could modify any valid CV in the decoder with Ops Mode Programming only, and it would be remembered through powering down and up.
 

If you want to change ALL CV's back to the saved CV's in the FactoryDefaultCVs list, you can load 120 into CV 120, and then power off then on again, and the original CV list will be restored after power up, and CV 120 will be cleared.

Also please note that the latest information concerning these decoders can be found here:
SMA20 New Low Cost 17 Channel DCC Decoders & Dual Motor,LED, & Servo Control Updated: 6 Ftns/Pin & New Features:  http://model-railroad-hobbyist.com/node/24316
 
'Hope this helps. Have fun!  smiley
Best regards,
Geoff Bunza

CV Master Reset

@Geoff

Wow !!!! What a fast answer. I am very much obliged to you. Thanks a lot.

My misunderstanding was that i thought writing a 120 to CV120 would automatically reset the system and come up with the newly loaded values. I did not power off and on. Is there no way to update the CVs ? As the reaction on a CV change is not always successful (changing a Blink Rate or Servo Rate) i was thinking of a CV update.

 

Jim at BSME's picture

See other thread

There are few steps to do before setting CVs by Ops programming,

  1. load the sketch and let it execute, depending on what you have hooked up you may see some initialization,
  2. power off the arduino 
  3. modify the sketch as Geoff stated above, (remove the // in front of #define DECODER_LOADED)
  4. load the modified sketch and let the arduino initialize.

Now you can connect it to your DCC buss on the layout and set the CVs by Ops programming and setting CV120 to 120 will reset the CVs to the FactoryDefaultCVs provided in the sketch.

For further help Geoff has already provided a good explanation in the other thread, at least I think so. So go read SMA20 New Low Cost 17 Channel DCC Decoders & Dual Motor,LED, & Servo Control Updated: 6 Ftns/Pin & New Features and scroll down under the first comment to: Decoder CV Configuration Details, and see if that makes sense, and if not ask the question there.

EDIT: fixed link address.

- Jim B.
Baltimore Society of Model Engineers, Estd. 1932
O & HO Scale model railroading
Check out BSME on: FacebookInstagram
geoffb's picture

@Starbug re:Changing CV's

Hi Starbug (name?),

Is there no way to update the CVs ? As the reaction on a CV change is not always successful (changing a Blink Rate or Servo Rate) i was thinking of a CV update.

The explanation I gave (and which Jim repeated) is for the master reset of all CV's to original programmed values. You should note that you can edit all the values in the list before loading to make them all what you want the "original" CV's to be reset to.

With regard to updating CV's via Ops Mode Programing: the way the decoder works is to copy all CV's into a working list once at power on, and all the functions including servo positions, LED timing, servo rates, etc. are then determined by the working list named ftn_queue[i] with its five elements. The reason for this was that DCC command stations repeat the DCC command packets to decoders an unspecified number of times to guarantee reception by decoders on dirty track. The EEPROM in the Pro Mini chip has a limited lifetime of reads and writes before memory failure (and this is where the CV values are stored to keep them around after power goes off. There is a way to capture the reprogramming of a CV and then reset the decoder operation but with 17 randomly selected functions in the middle of operations, I didn't enjoy the opportunity and complexity to add onto the decoder programming. Also, in a very real way, I didn't have any great need for this myself, nor did I think this was that important.

You can always force the update of all previously Ops mode programmed CV's by hitting reset on the Pro Mini or power cycling (power off then on) the decoder. Address changes to CV 1 will take effect immediately.

'Hope this helps. Have fun!  smiley
Best regards,
Geoff

@Jim B the link: SMA20 New

Jim at BSME's picture

Fixed link

@Starbug, I fixed the link in my original post, had an extra character in the link, but here is the fixed link as well:

SMA20 New Low Cost 17 Channel DCC Decoders & Dual Motor,LED, & Servo Control Updated: 6 Ftns/Pin & New Features

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

Single Stepper Motor Control

@Geoff

 

I read in the March 2017 about your Arduino DCC Project 18 and was searching the source of the Dec_Stepper_8Ftn Single Stepper Motor Control Sketch. Is the source available ?

Meanwhile my SMA12 is working like a charm. Thanks again.

Thanks for some help.

geoffb's picture

@Starbug re:Stepper motor Sketch

Hi Starbug (name?),

I'm really happy to hear things are working well for you!

All the sketches are free downloads in the "additional materials" that MRH makes available. For the March issue that would be here:  MRH 2017-03 - March 2017 Bonus extras 
 
Load the NmraDcc library into your ...\Arduino\libraries\  folder, start the Arduino editor and it should appear as one on the examples for the NmraDcc library. It is named "Dec_Stepper_6Ftn" in the examples.
 
Have fun!  smiley
Best regards,
Geoff Bunza

servo speed

Hi. I builded decoder using a arduino nano, everything works perfectly (15 servos version)but I tried to change servo rate ( speed) without an a success. In the description you mentioned that a higher value  will speed up the servo travel. Could you tell me what is the highest value ( quickest travel speed I can use) or what I am doing wrong. I am complete noob with dcc++ but I am finding the topic very interesting. Thank you for your help


>> Posts index


Journals/Blogs

Recent Blog posts: