Geoff Bunza geoffb

With exactly the same low cost hardware and a library of examples ready for anyone to download and use, you can now configure six “mobile or multifunction” decoders to respond to DCC Functions and a similar set of six Accessory decoders to respond to DCC Switch commands. The neat feature is that the Accessory decoders ALSO respond to a programmable single mobile decoder address, so you can configure each of the 17 pins to perform different functions, including their use as a 17 servo accessory decoder driver. This has been updated (Jan 12, 2014) with a Back and Forth Servo configuration in the Examples-- see later comments. The library was updated again Feb.15,2015  to add a new pulsed output function per channel in the Examples folder-- See later comments. As of Sept 16,2015 two new decoder varriants have been built-- See: http://model-railroad-hobbyist.com/node/20739?page=8#comment-209513 (Page 9 of this Blog). Most reccent Update can be found here: SMA20 New Low Cost 17 Channel DCC Decoders with PC Boards & Dual Motor, LED, & Servo Control    https://forum.mrhmag.com/post/sma20-low-cost-17-channel-dcc-decoders-ver-6-01-with-soundtriggered-soundstepperdual-motorled-and-12201920

l%281%29.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

@Joachim

Hi Joachim,

Quote:

During download sketch I see that the led are shortly lights.

I'm not sure what you mean by "shorty" lights-- do you mean LEDs blink during the download? If yes, this is normal.

Quote:

But I cannot activate the led with the function keys with address 17.

Works your sketches only with Arduino Pro Mini?

The sketch should work exactly the same with the UNO and the Pro Mini.

Quote:

I have installed AceesoryDecoder_17LED_1Function on my Arduino SainSmart UNO.

OK, are you using DCC Turnout Switch Commands from your DCC Throttle to switch the decoder on/off? Please note that the Accesory Decoder Address STARTS at Address 40 not 17, unless you edited the sketch. And all the pins are numbered in sequencce starting with 40-- 40,41,42,..., etc. Since the NmraDccExample_1 sketch works for you, it confirms your hardware is working correctly and you are close to getting it all working properly!    So you likely have an addressing error or some other configuration issue. Try looking at the issues I mentioned and let me know how it goes.

Spaß haben!  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
pattenjn

Hello Geoff, Thank you very

Hello Geoff,

Thank you very much for your fast answer.

For a one hour I have test your new 17-MULTIFunction-Decoder.zip file.

You are right I have taken the wrong address.

Now the sketch AceesoryDecoder_17LED_1Function is working.

At the moment I will check your other sketches.

I don’t know why the sketch DecoderNmraDcc_4 does not work.

The sketch AccessoryDecoder_7Servos_10LED_4Function print out follow error messages.

AccessoryDecoder_7Servos_10LED_4Function.ino: In function 'void loop()':

AccessoryDecoder_7Servos_10LED_4Function:358: error: 'SoftwareServo' has not been declared

AccessoryDecoder_7Servos_10LED_4Function.ino: In function 'void set_servo(int, int)':

AccessoryDecoder_7Servos_10LED_4Function:504: error: 'servo0' was not declared in this scope

And so on.

I am new with Arduino and C programs, so I need more information for dummies.

My goal is it to drive a stepper motor with dcc commands and the Arduino for a train elevator.

So I must learn very much.

Very great thanks

Jochen

Reply 0
Geoff Bunza geoffb

@Joachim

Hi Joachim,

It looks like you did not put the SoftwareSero folder into your Arduino/libraries/ folder.

I recommend you download the latest version of the libraries here: http://home.comcast.net/~gbglacier/Articles/New-Dual-MULTIFunction-Decoder.zipdelete your old copies and move both the NmraDcc and the SoftwareServo folders into your Arduino/libraries/ folder. This is NOT the standard SoftwareServo library, but has been modifies to support the 17 maximum possible servos in the decoder. This should fix your problem.

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
pattenjn

Hi Geoff, Thanks for your

Hi Geoff,

Thanks for your information.

Uploads there sketches works without error messages.

The problem was during unzipping the New-Dual-MULTIFunction-Decoder in the library.

I must copy NmraDcc and SoftwareServo dirckly under the library.

I have tested the AceesoryDecoder_17LED_1Function and it works fine.

With address 44 PIN3 is activated and with address 45 PIN4 activated and so on.

But I have an understanding a problem with other sketches.

I have to try to work with AccessoryDecoder_17LED_4Function but I think I make something wrong.

Is address 24 a train decoder address?

If yes, I cannot program the decoder with cv’s example 30,2, because my Rocco system find not decoder address 24.

What make I wrong?

Sorry, but I don’t understand how I can program the decoder.

Thanks for your great help

Jochen

Reply 0
Geoff Bunza geoffb

@Jochen

Hi Jochen,

I'm glad to hear you made more progress!!

Quote:

Is address 24 a train decoder address?

Yes, the 24 is a train/mobile decoder address. The Accessory decoder uses both a train/mobile decoder address and a set of accessory decoder addresses. This is because accessory decoders typically do not have a set of CV's associated with them, but a train/mobile decoder does have them. So you can set each set of addresses the way you want. To set functions, you either edit the sketch before you load it into the Arduino, or you can set the appropriate CV's via DCC control.. With 17 configurable pins and 5 CVs per pin that is a great deal of work. JMRI decoder Pro would be perfect to set this up, but I do not know how to set up such a decoder definition for JMRI, and have other things to keep me busy.

I am not familiar with the Roco DCC system. 24 should be referenced as a short mobile decoder address-- like a loco address. Setting the CVs should then work for address 24. Once they are set, you should be able to use all the functions, turning them on and off as an accessory decoder, with the accessory addresses 40,41,42,etc.

If you use the AccessoryDecoder_17LED_4Function sketch, you should be able to able to turn attached LEDs on and off with accessory commands. However, I rechecked the example and it had a mistake-- the line :

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

should be:

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

and I have corrected it in the download library here:

http://home.comcast.net/~gbglacier/Articles/New-Dual-MULTIFunction-Decoder.zip

This was the only CV that had this error. You can make the correction yourself or download the new library. (30,2) would set accessory command 40 to control a servo not a LED. (30,0) set up accessory command 40 to turn a LED on and off. Sorry for the mistake.

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
pattenjn

Your sketches

Hello Geoff,

Yesterday I had time to test everything again.

Now everything works fine.

I can change and save the values in the program.

So I could test leds and servos. All functions were possible.

But, I have found no way to change the CVs with my Roco system.

(Roco Multimaus per 10830)

I think the Roco system needs a real locomotive decoder for changes CVs?

Which system do you use to set the CVs?

Thanks for your help (I have fun)

Jochen

Reply 0
Geoff Bunza geoffb

@Jochen rerogramming CV's

Hi Jochen,

Great news that you got all the sketches to work.

I don't own a Roco Multimaus per 10830 but the manual I found and read would indicate it should easily do the job. There are two things to note: The decoder will only respond to the mobile address (originally short address 24) to program the CV's, and only with Ops mode programming on the main-- NOT service mode programming (often with a special programming track). There are some library "hooks" to use long DCC addresses but I have neither implemented them in the example sketches, nor have I done any testing to see what would happen if you used long addresses. So, long DCC addresses should be avoided.

I use Digitrax DCC, but these have been tested with many other DCC systems too. I have reason to believe that hundreds of these have already been built by modelers.

Try ops mode programming (there is no feedback with ops mode programming) and 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
Geoff Bunza geoffb

@Jochen rerogramming CV's

Hi Jochen,

One more comment-- when you change the pin function/configuration (say from LED On/Off -0- to servo control -2-) you should power cycle off-on the decoder since the certain setups need to be performed  at power up (like setting up the servo library). This is overly cautious, as many/most of the CV changes are immediately effective.. To be certain everything is reset, perform the power cycling. This was covered before, but I am beginning to realize many people are using these decoders without having read all the SMA entries.

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
pattenjn

Hi Geoff, I am one step

Hi Geoff,
I am one step further.
I can now change the CVs with the Roco Multimaus Pro in POM mode.
I have made some changes in the sketch, so I can better understand what is happens.

-----------------------------------------------------------------------------------------------------------------------------------

void exec_function (int function, int pin, int FuncState)  {
  switch ( Dcc.getCV( 30+(function*5)) )  {  // Config  0=On/Off,1=Blink,2=Servo,3=Double LED Blink
    case 0:    // On - Off LED
       digitalWrite (pin, FuncState);
      ftn_queue[function].inuse = 0;
      break;
    case 1:    // Blinking LED
      if ((ftn_queue[function].inuse==0) && (FuncState==1))  {
        ftn_queue[function].inuse = 1;
        ftn_queue[function].start_value = 0;
        digitalWrite(fpins[function], 0);
        ftn_queue[function].stop_value = int(Dcc.getCV( 33+(function*5)));
        Serial.print("PIN: = ");
        Serial.println(pin,DEC) ;
        Serial.print("Funktion: = ");
        Serial.println(function,DEC) ;
        Serial.print("CV: = ");
        Serial.println(Dcc.getCV(35),DEC) ;
        Serial.print("FuncState: = ");
        Serial.println(FuncState,DEC) ;

      } else {
          if ((ftn_queue[function].inuse==1) && (FuncState==0)) {
            ftn_queue[function].inuse = 0;
            digitalWrite(fpins[function], 0);
            Serial.print("FuncState: = ");
            Serial.println(FuncState,DEC) ;

            }
        }
      break;
    case 2:    // Servo
      ftn_queue[function].inuse = 1;
      if (FuncState==1) {
      ftn_queue[function].increment = char ( Dcc.getCV( 31+(function*5)));
      Serial.print("PIN: = ");
      Serial.println(pin,DEC) ;
      Serial.print("Funktion: = ");
      Serial.println(function,DEC) ;
      Serial.print("CV: = ");
      Serial.println(Dcc.getCV(35),DEC) ;
      Serial.print("FuncState: = ");
      Serial.println(FuncState,DEC) ;
      Serial.print("servo inc: ") ;
      Serial.print(ftn_queue[function].increment,DEC) ;
      Serial.print("servo inuse: ") ;
      Serial.print(ftn_queue[function].inuse,DEC) ;
      Serial.print("servo num: ") ;
      Serial.print(function,DEC) ;
      Serial.print(" stop: ");
        Serial.println(ftn_queue[function].stop_value,DEC) ;

      }else {
        ftn_queue[function].increment = - char(Dcc.getCV( 31+(function*5)));
      }
      
      if (FuncState==1) ftn_queue[function].stop_value = Dcc.getCV( 33+(function*5));
        else ftn_queue[function].stop_value = Dcc.getCV( 32+(function*5));
      /*
      Serial.print("servo inc: ") ;
      Serial.print(ftn_queue[function].increment,DEC) ;
      Serial.print("servo inuse: ") ;
      Serial.print(ftn_queue[function].inuse,DEC) ;
      Serial.print("servo num: ") ;
      Serial.print(function,DEC) ;
      Serial.print(" stop: ");
      Serial.println(ftn_queue[function].stop_value,DEC) ;
      */
      
      break;
    case 3:    // Blinking LED PAIR
      if ((ftn_queue[function].inuse==0) && (FuncState==1))  {
        ftn_queue[function].inuse = 1;
        ftn_queue[function].start_value = 0;
        digitalWrite(fpins[function], 0);
        digitalWrite(fpins[function+1], 1);
        ftn_queue[function].stop_value = int(Dcc.getCV( 33+(function*5)));
        Serial.print("PIN: = ");
        Serial.println(pin,DEC) ;
        Serial.print("Funktion: = ");
        Serial.println(function,DEC) ;
        Serial.print("CV: = ");
        Serial.println(Dcc.getCV(35),DEC) ;
        Serial.print("FuncState: = ");
        Serial.println(FuncState,DEC) ;

      } else {
          if (FuncState==0) {
            ftn_queue[function].inuse = 0;
            digitalWrite(fpins[function], 0);
            digitalWrite(fpins[function+1], 0);
          }
        }
      break;
    case 4:    // Future Function
      ftn_queue[function].inuse = 0;
      break;
    default:
      ftn_queue[function].inuse = 0;
      break;
  }
}

---------------------------------------------------------------------------------------------------------------------------


But now I have some more questions.

I have set in the sketch for F1

{35, 0},  //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

F1 is output PIN 4.
First I have at that PIN a led.  With F1 the led goes on and off.
Than I have set with my roco multimaus cv35 to 1.
Ok the LED is blinking.
Than I have set with my roco multimaus cv35 to 3.
Ok the LED is Double LED Blink.
I can all LED function cv 0,1,3 set.

But if I try to set CV to 3 the servo does not work.

If I upload the sketch with follow parameter the servo works correctly.

{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

If I set the CV to 0 or 1 or 3 the Led work not correctly.

With the serial print out in the sketch I see that the CVs are correctly set.

I am not sure what that problem is.

Regards and very thanks for your help
Jochen

 

 

 

 

Reply 0
Geoff Bunza geoffb

@Jochen re: Changing CV's

Hi Jochen,

It looks like I did not make this clear enough from my last reply:

Quote:

One more comment-- when you change the pin function/configuration (say from LED On/Off -0- to servo control -2-) you should power cycle off-on the decoder since the certain setups need to be performed  at power up (like setting up the servo library). This is overly cautious, as many/most of the CV changes are immediately effective.. To be certain everything is reset, perform the power cycling. This was covered before, but I am beginning to realize many people are using these decoders without having read all the SMA entries.

When you change CV 35 (or any CV that defines the FUNCTION of the pin, like CV 30,35,40,45,50,55,...) to a value of 2 or from a value of 2, need to power the decoder off and on, or push the reset button on the Pro Mini. This is because the servos are assigned to the pins only once in the setup() and there alone. Right now this is how it works. It is a limitation of the way the configuration for each function is defined. All the other function definitions do not require power cycling, only when you use the servo function. There is no problem. This is how is works. It is a limitation of the implementation. 'Sorry if I didn't make this clear before.

Have fun!   It looks like you do have it completely working!

Best Regards,

Geoff

 

 

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
Joe Baldwin

Milestones not millstones!

Geoff,

I can't tell you how thrilling it was this afternoon to press the F0 function key on my Touch Cab and have the LED on my Arduino based DCC Decoder board toggle on and off and the Servo to move on command!

My next challenge is to mate a DFRobot MP3 player to my decoder and control the player with DCC commands.  I'm automating the Sawmill on my automated railroad where I use CTI-Electronics to operate the HO railroad in my basement.  The work you and Dave Bodnar have done for the hobby cannot be understated.  

It could be quite useful to others to know that Dave offers a couple of custom made PC boards for DCC Decoders based upon the Arduino.  contact Dave at info@trainelectronics.com  Sure beats using a proto board!

 

Thanks again, Geoff!

 

Joe Baldwin

 

  

Joe Baldwin

Northern Colorado 

http://www.joe-daddy.com

Reply 0
pattenjn

Hello Geoff, Sorry, when I

Hello Geoff,
Sorry, when I answers now.
I was the whole week busy.
Today I have checked your help information.
You are right, if I make after changes the CV values a reset all function are correct.
Thanks for your great help.
Now I have a new question!
In which position in the program cv values are set?
Thanks and regards
Jochen

Reply 0
Geoff Bunza geoffb

@Joe re Milestones

Hi Joe,

This is just great !!

I also use the DFRobot MP3 player and like it quite a bit because it can drive a cell phone speaker at consideable volume with very good sound, albeit single channel. Look carefully at the specs and you will find you can trigger playing certain tracks on the SD card with a single arduino/decoder pin, but you can also use an arduino to communicate with it via serial communication (with the full module command set).

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

@Jochen re: program cv values

Hi Jochen,

Great ! 'Glad to see you have everything working !!

Quote:

In which position in the program cv values are set?

Look in the sketch (program) that you are using for the lines that look like this (or similar):

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, 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

....

 {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

(I added the boldface for emphasis) Each group of 5 lines refers to a new DCC Function definition starting with

  {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

For F0, the 30,2  sets CV 30 to have an initial value of 2 (configuring F0 for servo control)

The description of each group of 5 CV's is presented at the beginning of this blog entry -- SMA 15.

When I use these decoders, I change the decoder CV's with my throttle or JMRI remembering what I set them to (pencil and paper is an amazing memory aid for me! ), and then I edit the settings in the sketch. Consider this list as your "Factory Default settings." For my own use, I do not REMOVE THE "//" IN THE FOOLOWING LINE!!
//#define DECODER_LOADED

and this will force the "Factory Defaults" to be loaded every time the decoder powers up. The flexibility is designed in so you can choose which way is best for you.

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
Norber

Please note that the Accesory

Quote:

Please note that the Accesory Decoder Address STARTS at Address 40 not 17, unless you edited the sketch. And all the pins are numbered in sequencce starting with 40-- 40,41,42,..., etc.

Dear Geoff:

I'm not sure if this has been said before, but with Roco Multimaus the addresses corresponding to this 40 setting will not be 40, 41, 42... but 44, 45, 46... I mean that with a setting in the Arduino code of 40 as the first accessory address, the first accessory you can move is number 44 in Multimaus display, and then the ​45, 46 ....

Congratulations for your excellent work.

Salamanca - Spain

HO - DCC: Multimaus + GenLi-S88+z21f+RocRail

Reply 0
Norber

Another issue (#1):

I'm using your schema and code with this prototype of mine:

niversal.jpg 

You can see the Arduino on top of the 6N137 optocoupler, and on the lower left part of the PCboard the resistor & C8 capacitor & diode, very close and linked to pins #2 and #3 of the optocoupler. Can you believe I'm suffering a lot from servo jittering?

Best regards, Nor

Salamanca - Spain

HO - DCC: Multimaus + GenLi-S88+z21f+RocRail

Reply 0
Norber

Final issue (#2): [SOLVED]

I can control accesories #44, 45 ... from my Multimaus, but no success with "loco" #24. I'm using what I believe are the last libraries & code version (february 2015) and the response to the accessory commands is perfect, but to the "#24 locomotive" function commands is simply inexistent... I've tried, of course, #19, #20 ... up to #28 without success.

Any one using Roco Multimaus has experienced this problem? Any hint? Thanks in advance.

Nor

Salamanca - Spain

HO - DCC: Multimaus + GenLi-S88+z21f+RocRail

Reply 0
Geoff Bunza geoffb

@Nor re:decoder & Roco Multimaus

Hola Nor,

Sorry, I do not have any familiarity with the Roco Multimaus. Perhaps another modeler can comment on its use.

Quote:

the response to the accessory commands is perfect, but to the "#24 locomotive" function commands is simply inexistent..

If you have set up the decoder as an Accessory Decoder, then no function commands will work with your decoder, only DCC accessory commands (like track switches). The #24 address is provided with the accessory decoder only to set CV's for configuring the operations on each pin. If you have set up your decoder as a mobile Function Decoder, then you can set DCC functions and set CV's. In all cases, you can only set CV's with Operation Mode Programming and not with service mode programming. During programming, there will be no response/acknowledgement from the decoder as well.

Great to see your board and implementation of your decoder. 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
Joe Baldwin

DF Player MP3 library

Geoff,

If a fellow were to want to make changes in the .h and or .cpp files for a library, how does one do it so the changes are recognized in the Arduino IDE?  Example, in the DF player library, they do not include the Volume Increase or Volume Decrease commands.  I'm thinking I know what needs to be added to the code, but when I attempted to implement it in the IDE, I'm missing something(s).   

TIA, your contributions here are simply awesome!  

Joe Baldwin

 

Joe Baldwin

Northern Colorado 

http://www.joe-daddy.com

Reply 0
Geoff Bunza geoffb

@Joe re:make changes in the .h and or .cpp files for a library

Hi Joe,

There are 2 separate libraries on the web for the DFPlayer, this answer will apply to both.

I assume you have unzipped your DFPlayer Lib and copied its folder  to \Arduino\libraries\

In that folder you copied are the .h and .cpp files you need to modify if you want to add onto them. Remember that they need to be consistant. One major adviso: you may well need to close and then re-open the Arduino IDE after making your changes. Each of the files can be edited with a text editor that does not add special formatting characters to the text. I typically use Notepad+ which you can download for free off the web. It has some useful features and "knows" about C and C++ code. Remember the changes you made must be in the working library that the IDE reads upon startup.

Have fun!   Be careful playing with libraries-- some are not very well written.

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
pattenjn

Hi Geoff, Thanks for your

Hi Geoff,
Thanks for your great support in this forum.
All Decoder sketches works properly.
In the last days I have work with your sketches AccessoryDecoder.
Example AccessoryDecoder_17Pulsed_5Function.

First I have thought that the AccessoryDecoder sketches do not work.
But I have found out that the real accessory address is always four higher.
If I take 40 the (#define Accessory_Address    40) it begins at 44.
I have tested with other addresses example 30, 20 and so on.
It begins always four addresses higher.
I don’t know why it is so.

So I have change the line
Current_Decoder_Addr = Dcc.getAddr();
to
Current_Decoder_Addr = Dcc.getAddr()-4;
So it works well with define address. (#define Accessory_Address    40)
The next changes what I have make is
if ( Addr> = Current_Decoder_Addr

to
if( ( Addr> = Current_Decoder_Addr ) && ( Addr < = Current_Decoder_Addr+17 ) ) {
Now the follow cases now really between 40 and 57.

But why is the address always 4 higher?
Have you any idea?

I have more and more fun at your sketches.
Regards,
Jochen
Reply 0
Geoff Bunza geoffb

@Jochen re:Accessory decoder addressing

Hi Jochen,

That's great that you got everything working!

I use a Digitrax DCC system, and also use JMRI with it. The Accessory decoder addressing is as I described it-- address 40 maps to 40. I remember that you use a Roco (?) system and unfortunately I don't have the experience with it to answer your question. But I am glad you have a work-around fix for yours.

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
Joe Baldwin

Status Report

Geoff,

Based upon your work and that of David Bodnar, I have been able to design and have built a custom PCB board that is rather a universal board able to accomodate most anything I intend to use the decoder for. Capabilities are MP3 player, Relay pinout, 3 servo pinouts, 5 LED pinouts and a place for a push button. While I made some mistakes in the design based a misunderstanding of the net feature, it works fine with only 3 backplane wiring adds. After I incorporate automatic start from a Pushbutton, it will be ready for the layout.  Thanks for your inspirational work guys!

Youtube video  https://youtu.be/ZYuVfdQ2Qx8

Bare Board

 

11.15.22.jpg 

Populated board

15.23.51.jpg 

Joe Baldwin

Northern Colorado 

http://www.joe-daddy.com

Reply 0
Greenalien

Hornby Railmaster with e-link

Hi Geoff,

Just to say that I have now downloaded your Accessory decoder code onto my 15-servo plus LED board, and it works fine with Hornby Railmaster and e-link, giving a nice graphical layout view with 'click to operate' turnouts and signals. Worth noting that the Railmaster/e-link package is by far the cheapest commercial DCC setup available.

Thanks again for this amazingly helpful and well-presented project.

All the best...John (Southampton, U.K.)

Reply 0
Geoff Bunza geoffb

Hornby Railmaster Success

Hi John,

Thanks for letting us know about your success with the Hornby Railmaster.

Modelers might be very interested to know this. 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
Reply