Geoff Bunza geoffb

One of my earlier entries:  SMA10 – Build a 17-Function DCC Decoder for about $5 ( https://forum.mrhmag.com/post/sma10-%E2%80%93-build-a-17function-dcc-decoder-for-about-5-12197796 ) 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/19775There 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    https://forum.mrhmag.com/post/sma20-low-cost-17-channel-dcc-decoders-ver-6-01-with-soundtriggered-soundstepperdual-motorled-and-12201920

Bemchtop.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
Al Brough

Hi Sebastjan, Can you please

Hi Sebastjan, Can you please post front and back pictures of the PCBs that you had manufactured? I am very interested in how it looks! Well done on what you have done so far. Al

~
Al Brough
Sydney, Australia
Fast Tracks, Digitrax & JMRI
Free-mo ZA

Reply 0
Jim at BSME

PCB pictures

Al, you can follow the link in Sebastjan's post for pictures, the link is a little hidden in his text since it is just the word "here" three lines above the video.

I looked at the pictures to get the board size and figuring the matt he was working on was in cm I would say his board is about 4,5 x 7 cm  (since the US is only one of two countries that haven't adopted the metric system and for those readers that is approximately 1.75" x 2.75").

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

I have had a look at the link

I have had a look at the link but on the site i cannot see the back of the printed PCB, I am very keen to start these myself!

~
Al Brough
Sydney, Australia
Fast Tracks, Digitrax & JMRI
Free-mo ZA

Reply 0
KHaus41369

adafruit feedback servos

Hey. I resently got the uno starter kit from my 84 yr old father for xmas with the surprise of the motor shield and servo shield.....so im taking the time to follow adafruits learning tutorials....my question is can the servo shield work like your design as a stationary decoder??...and i see they have feedback servos. Can that function in the servo be used to tell us switch position?     I dont know the code yet. But if 0 degree is reached light green led for mainline.  180 degree read light red led for siding.  Can be also connected. Somehow to signal system saying switch made??   Adafruit showed a sensor set. Anyone seen those yet?  Could those be usefull??

Kevin

Modeling something to do with the Grand Trunk Western.

Reply 0
Geoff Bunza geoffb

@Kevin re:Servo questions

Hi Kevin,

Quote:

.my question is can the servo shield work like your design as a stationary decoder??

The servo shield usually just provides a convenient way of attaching 3 wire servo connectors to an Arduino processor. So, yes, the servo shield could be used as well as the Arduino Uno which usually has the same or a completely compatible processor as the Pro Mini. You will stiil have to build and attach the 6N137 optocoupler and its circuitry to connect to the DCC bus.

Quote:

i see they have feedback servos. Can that function in the servo be used to tell us switch position?

Yes, but it would have to be connected to an "analog" pin and be read in as a value between 0 and 1023. Since the Arduino is already driving the servo itself (setting the servo position) it already knows what position it is in, or what position it is moving towards. So this may be a redundant feature. You may come up with another use, perhaps.

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
Al Brough

Thank you for sharing both

Thank you for sharing both the images and the gerbers Sebastjan! Keep up the good work everyone

~
Al Brough
Sydney, Australia
Fast Tracks, Digitrax & JMRI
Free-mo ZA

Reply 0
chod

direct comms with this device

hi, currently coding some basic to directly talk with come of my dcc devices, the accessorys are a touch confusing

with the /4 in one byte and spare s in another byte, would this be controlled in a similar way

 

thanks jeff

Reply 0
Geoff Bunza geoffb

@chod Re: direct comms

Hi chod (name?),

Sounds interesting. Are you saying you  are writing Basic programs to communicate with your Arduino-based decoders?

Is this a control or animation application? or something different all together?

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
Don C

Loconet Shield

Geoff,

I want to replace the front end of the 17 servo Arduino with loconet rj12 setup vs rail a/b connection.  Do you have or know where I can get a schematic for this?  Input is on pin 2 of the Arduino as before. How do I provide feedback to JMRI for instance to indicate switch position and can I use A5 output for that?  Assuming all of this is possible, could you point me to a code snippet to provide this?

Another issue I am having is the servos are being set on power up in the thrown position.  Changing the initial servo default orientation puts the switch in the closed position but when issuing the switch close command, the servo goes to thrown and back to closed position rapidly.  Electrically and physically I can get the initial setup correct by the orientation of the servo/switch, but thrown is closed and vice versa from loconet. Any help would be appreciated.

Learning to code is proceeding very slowly.

Thanks,

Don

Reply 0
Geoff Bunza geoffb

@Don re:Loconet

Hi Don,

Connection to the loconet for a decoder interface has been reported before. Best way to find it might be to search using the cusom google search box for MRH in the top right corner of most MRH pages. I don't use Digitrax's Loconet in this manner and i don't support it either. Also check the Arduini Yahoo Group. There are many knowledgeable people there that are Loconet hackers I am not a JMRI developer, nor do I code to interface to it. LIkewise, I again refer you to the Arduini Yahoo Group as a possible source of help. Typically, decoders do not transmit much of anything back to a DCC base station at all in normal operations.

Decoders usually do not retain more than their CV settings from power up to power up, and both DCC base stations and decoders assume Functions are off at power on. That is why the decoder comes up to its "known" power on state. JMRI has a Jython script people use to initialize track switches, and much anything else for that matter, when they want their layout to power on to a set of conditions specific to their layout. Look for the JMRI script examples and tutorials for a starting point.

'Hope that's enough to point you in the right direction. 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
Don C

Geoff

Very quick response as usual. Thanks for the info, I will look into it.

Don

Reply 0
hpept

Newbie needing help

Hello.

My name is Roberto and I just registered to make this help request. I'm completely new to Arduino, and with little experience with DCC. I've been following this thread with interest, but it seems I'm getting lost very easily.

I will start saying what I did until now:

1) studied the circuit reported in the beginning of the article

2) acquired all the components

3) Mounted the circuit on a breadboard in a led only configuration, connecting only F0 to F4

4)Downloaded the SW from the link in the page and copied the 2 directories NmraDCC and Softwareservo in the Arduino libraries directory

Here is where I get the first problem. My configuration should be contained in the dir examples/Decoder_17LED_1Function but in this directory there is another file named "DecoderNmraDcc_4.ino". If I try to open it in Arduino IDE it says is not possible and wants to put it in another directory. If I let it do it and compile, I get the following error during compilation:"exit status 1 redefinition of 'int tim_delay'" and it aborts. What is this?

I've tried opening other versions, but I get several errors about NmraDCC library not being correct.

I've also tried to compile the "AceesoryDecoder_17LED_1Function" (I'm using a PL2303 USB/TTL cable using Arduino IDE 1.6.10 on Win10 Home Edition), and after some failed attempts, I successfully  loaded the SW into the Arduino Pro Mini. It seems like a hit and miss procedure though, not consistent, as sometimes I get error and some times I don't.

I then put the Arduino on the breadboard, connected the input to the tracks and fed the circuitry with a +5V power supply.

When I switch on, the 4 leds I´ve installed to monitor the function, all correctly cycle once.

I've tried to control the decoder with my NCE Powercab to see if i could switch the leds on and off separately, but if I use the accessories decoder function, after inserting the decoder address, the Powercab only lets me switch it on by pressing 1, or off by pressing 2.

Needless to say that it's not working.

As you may see, I've got several problems on several different stages.

To make things work, I suppose we must restart from the basics, and here is where Geoff can help me.

I need to have all the files you supplied in the zip file all checked by you in their working version. I've tried to download the updates posted in the comments but I get a file not found error.

I need to confirm that the latest circuit of this version (SMA12) is the one at the beginning of the article. I'm pretty confident it is, since the startup of the circuit works as expected, but it sdeems I cannot communicate with the decoder via tracks signals (don't know if it's something inherent to the decoder or to the powercab) 

I need to know in what the  "AceesoryDecoder_17LED_1Function" version differs from "Decoder_17LED_1Function", and if i can use the former to test the decoder or if the latter is mandatory.

This will help me to avoid macroscopic errors, and maybe some of the experienced people here can give some clues on how to proceed to make things work.

I know that I'm asking alot of things all at once, and please forgive me for this long message, but I would really like to come to an end (a happy one) with these issues because I think that this project has alot of potential.

Thank you very much in advance. Best Regards,

Roberto

 

 

Reply 0
Geoff Bunza geoffb

@Roberto re: Questions and Updates

Hi Roberto,

I'm sorry you are having difficulties. The library you downloaded was an old version. I have updated the link in this Blog entry to the correct and current library: /sites/model-railroad-hobbyist.com/files/users/geoffbfiles/new-dual-multifunction-decoderv5_3.zip

This work has been going on for some time and now spans multiple entries:

SMA10 – Build a 17-Function DCC Decoder for about $5  https://forum.mrhmag.com/post/sma10-%E2%80%93-build-a-17function-dcc-decoder-for-about-5-12197796
SMA12 - 17 Channel Configurable Multifunction $5 DCC Decoder For Servos  https://forum.mrhmag.com/post/sma12-17-channel-configurable-multifunction-5-dcc-decoder-for-servos-12198051
SMA 13 - Update to the 17 Pin Configurable Multi Function Decoder / Accessory Decoder Version Added  https://forum.mrhmag.com/post/sma-13-update-to-the-17-pin-configurable-multi-function-decoder-accessory-decoder-version-added-12198262
SMA15: New Dual Accessory-Multifunctionl 17 Channel Configurable DCC Decoders for about $5 with Configurable Servo Support  https://forum.mrhmag.com/post/sma15-new-dual-acessorymultifunctionl-17-channel-configurable-dcc-decoders-for-about-5-with-configurable-servo-12198949
Scale Model Animation 18: DCC Control for Random Building Lighting  https://forum.mrhmag.com/post/sma18-dcc-control-for-random-building-lighting-12200851
SMA20 New Low Cost 17 Channel DCC Decoders & Dual Motor,LED, & Servo Control Updated: 6 Ftns/Pin & New Features

The last entry SMA20, is the most up to date and is referenced in this entry SMA12, in the intro.

The Decoder file you are looking for is now Dec_17LED_1Ftn

Accesory decoders use Track Switch DCC commands (Closed/Thrown) instead of DCC Function commands. Read up on these with whatever DCC command station you use. The decoder can be configured either way. More details are in the writeup -- see SMA20.

The circuit has not changed since the beginning. I f you use the same circuit and the same components, it should work quite well -- better than any other one I've tried.

Always ask questions-- it is how we all learn.

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
hpept

@Geoff: thank you

Hello Geoff.

Just an hour ago I received an update warning from the Arduino NmraDCC libraries. I updated them, tried to upload the 17LED 1FTN and it loaded succesfully on the Pro Mini. When i power up the circuit it now cycles the lights correctly.

Still have to figure out how to communicate with the decoder. I'll have to study thoroughly the SMA20.

Thank you very much for your help and will to share your huge knowledge with fellow unexperienced modellers like me.

Grateful,

Roberto

Reply 0
hpept

Too good to be true. More errors on the way.

Hi Geoff,

After the initial enthusiasm injection, here I am again with problems.

As i said in the previous post, the first upload to the Pro Mini was successful.

As you mentioned, to retain the values in the EEPROM memory, is recommended to overwrite the program by enabling the #define DECODER_LOADED by toggling the // characters

When I compile the second version, i get the following error

'CV_DECODER_MASTER_RESET' was not declared in this scope

pointing at line 83

82

83
84

Am I missing something?

UPDATE: I finally succeeded in communicating with the decoder. I made a mistake in the circuit setup (reversed the polarity of the 1N4148 input diode) which I corrected and used the Powercab throttle with Loco address #24 to switch on/off the functions. Works like a charm!!!

Now I need to solve the above compiling error. I started to debug it, but i'm completely ignorant with C++ commands, so I may require a lot of time to learn the correct syntax and logic of commands to find the error.

Is it correct that the DECODER_LOADED variable is declared but unassigned (no value?)

Thanks

Roberto

Reply 0
Geoff Bunza geoffb

@Roberto re: Error

Hi Roberto,

Yes, there is a line missing! Somehow the definition for CV_DECODER_MASTER_RESET got dropped in editing. Here is what it should look like:

const int FunctionPin13 = 16;     //A2
const int FunctionPin14 = 17;     //A3
const int FunctionPin15 = 18;     //A4
const int FunctionPin16 = 19;     //A5
NmraDcc  Dcc ;
DCC_MSG  Packet ;
uint8_t CV_DECODER_MASTER_RESET = 120;
#define This_Decoder_Address 24

I have fixed and uploaded the new library here:

/sites/model-railroad-hobbyist.com/files/users/geoffbfiles/new-dual-multifunction-decoderv5_3.zip

FYI, as of this instant in time the above linked library is more current than the NMRAdcc library that will auto update.

This was entirely my mistake, not yours. I re-looked at the other decoder files and they also look OK. Thanks for catching this for everyone. 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
hpept

Update working

Hello Geoff,

I'm glad I could help to find out a little bug. The installation was successful.

I also tried the version with 6 functions with blinking and fading lights and it works great . I've noticed although that if contiguous lights (i.e. F0 and F1)  are set to blink or fade, if both activated simultaneously,  the second one only really activates after i release the button of the the previous to deactivate, and only then it starts to blink or fade. Is it supposed to work like this? It would be nice to have something that allows alternated blinking or fading lights, like ditch lights on locomotives, or a railroad crossing.

Thank you for your invaluable support once again.

 

Roberto

Reply 0
Geoff Bunza geoffb

@ Roberto re: Dual Blinking LEDs

Hi Roberto,

I'm glad you have your decoder working.

Quote:

if contiguous lights (i.e. F0 and F1)  are set to blink or fade, if both activated simultaneously,  the second one only really activates after i release the button of the the previous to deactivate, and only then it starts to blink or fade. Is it supposed to work like this?

For Dual Blinking LEDs, you should not attempt to set or control the second LED in the pair -- leave it alone and operation should proceed just fine. Attempting to control the second LED will temporarily confuse the decoder timing.

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
hpept

change blink rate

Hello Geoff,

thank you for your explanation. Double blink function is working correctly now. I've found the instruction on how to configure the CVs. This is a very smart project!!!

Best regards,

 

Roberto

Reply 0
hpept

Servo controlling

Hello Geoff,

Just going on exploring. I converted the circuit from test protoboarding to PCB layout, and after some debugging (forgotten tracks, short circuits, anyone?) I'm ready to go.

I just received two 9g Arduino compatible servo motors and was testing functionalities. I set the servo controlling channel to F6, by programming the following CV with the values you suggested

CV60=2(setting servo)

CV61=1(rate)

CV62=28(start position, F disabled)

CV63=140(stop position, F enabled)

CV64=28(default position)

It happens that the servo is not moving. I just hear a faint tick sound when pressing the function number, but no visible movement. The servos are working because they shake when i connect them. I also tried to set up a different channel (F7) with the same result.

Could you please explain the CV effects, especially CV61 (value range and relationship with actual angular speed), CV 61 and 62 ( what zero is and what 255 is, such like 0=0deg and 255=360deg)?

I'm so excited to see this project working  at full steam.

Thank you.

 

Roberto

Reply 0
Geoff Bunza geoffb

@Roberto re: CV settings for Servos

Hi Roberto,

First I am going to state some assumptions for my response: I assume you are using a Mobile/Function decoder and NOT an accessory decoder. I am also assuming that your "two 9g Arduino compatible servo motors" are likely the cheap, generic, 9G servos -- not name brand, nor metal gears.

The CV's for F6 are:

  {60, 2},      //F6 Config 02=Servo control
  {61, 1},      // Rate  control values from 1== slowest --  255==instant change
  {62, 28},      //  Start Position of the servo arm traverse with  Fx=0  Max range 0-180
  {63, 140},    //  End Position  of the servo arm traverse with  Fx=1  Max range 0-180
  {64, 28},      //  Position --don't bother to set internal use only and possible future use

In the later version of the library a new parameter was added:

#define servo_slowdown  3   //servo loop counter limit

Near the beginning of the decoder sketch (look around line 22). With the servo_slowdown set to 3 the servo will move fairly slowly. Setting servo_slowdown higher will slow it down even more. You might trying setting it to 1 to speed things up. Note this is the opposite range effect of the CV rate setting (CV 61) where the lower number is slower. If you haven't read through SMA20 you really should, as it has all the updated info.

The vast majority of cheap 9G servos will not move 0 to 180 degrees (the max limits); mechanically they are just not built that well! Hence my starting suggestions of 28 and 140 which I have found to work well for most servos. It would be of general benefit for you to read through the comments in these decoder blogs regarding general operation problems and issues with these servos concerning maximum current craw (over 1 Amp) excessive nose, rattle, and stickiness at the end of arm travel attempted beyond the mechanical stops. On another posting group it was reported that some 5-10% of all received cheap 9G servos simply did not work, and another 15% did not work well. I have had pretty good luck with mine: only 2 failed in operation after installation, and none dead on arrival.

When I install any servo, I make sure that physically near the servo power feed (4.5-6V) a small pair of filter capacitors is placed across the +/- power leads (like +10uf 15V and .05-0.1uf ceramic cap) to limit the electrical noise generated by the servo motor. Some engineers will consider this overprotective design.

In you particular case check the power leads to the servo that they are at least 5 Volts or so, If you are trying to power the servo from the decoder 5V source it should work for a couple of servos, but it is possible that you will see some erratic behavior from time to time. Most of the time this works for me, but not every single time in the last 4 years!

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
hpept

Servos now working

Hello Geoff,

thank you for the thorough explanation of the servo functionality.

About your initial assumptions, they are both correct (Mobile/function decoder + cheap noname servos). I discovered that the two servos were kind of stuck in one of the end positions. I realized that plugging and unplugging them several times, they both started to crawl towards a more ideal position of the gears, so that when i reset and powered again the decoder they finally started moving between the programmed range.

Since you mentioned the fact that I was using the decoder as a mobile function decoder instead of an accessory decoder, I would like to understand which is the difference between the two versions. Is the accessory version allowing to use it as an NCE accessory (by setting the address n. and then by pressing 1(ON) or 2(OFF) on the PoweCab enabling and disabling the corresponding actuator?) I'm a little confused...

About servo powering, I'm using a switching power source of 5V (actually measured 5.3V) 1Amp to power the decoder. I don't think I will require to move many servos simultaneously, since I still want to operate them manually, although electrically assisted, via JMRI.

Finally, I would like to understand if and how I can use this multifunction decoder to control lights (mainly buildings, roads, etc.) and servos for turnout throwing ( which are presently mechanically operated by hand with rods in my switching layout) by means of JMR, by building control panels. Presently I can only operate locomotives through the JMRI WiThrottle, web interface, or with an Android mobile phone using Engine Driver and Digitrains. Even the multifunction decoder is seen by the system as a  locomotive in the roster.

I've tried to create turnout or light tables, but they seem to be disabled since they don't appear when I call the corresponding windows in the JMRI menu. I'm afraid that the NCE USB interface I'm using is not compatible with these functions...

Still have a lot to learn, but I'm presently enjoying the journey, and it's good to have some experienced tutors like you to clarify the doubts and show the way.

Best Regards

 

Roberto

Reply 0
Geoff Bunza geoffb

@Roberto re: Questions and Comments

Hi Roberto,

I am glad to hear you made progress with your servos.

Quote:

About your initial assumptions, they are both correct (Mobile/function decoder + cheap noname servos). I discovered that the two servos were kind of stuck in one of the end positions. I realized that plugging and unplugging them several times, they both started to crawl towards a more ideal position of the gears, so that when i reset and powered again the decoder they finally started moving between the programmed range.

It sounds like your servos were driven hard to the end of their traverse. The binding/friction on the gears and arm would make it more difficult to reverse the servo out of its position past what would be considered the maximum limit of its travel. When this happens, you may also get the servo drawing larger than normal current (I have measured this to be more than 1 Amp on some servos). This should be avoided for normal operation.

Quote:

Since you mentioned the fact that I was using the decoder as a mobile function decoder instead of an accessory decoder, I would like to understand which is the difference between the two versions. Is the accessory version allowing to use it as an NCE accessory (by setting the address n. and then by pressing 1(ON) or 2(OFF) on the PoweCab enabling and disabling the corresponding actuator?) I'm a little confused...

You actually do understand the basics of this. Accessory decoders respond to different DCC commands than mobile/function decoders. I do not use the NCE system, so read up in your NCE user documentation about using accessory decoders with NCE. Accessory decoders are often associated with setting/using track switches, and the nomenclature of Thrown and Closed is often used instead of On and Off (or Off and On -- I never keep these straight!). The addressing for accessory decoders is different too and often accessory decoders are simpler and lack CV settings (unlike the way I set these accessory decoders up-- read SMA20 for more detail).

Quote:

Finally, I would like to understand if and how I can use this multifunction decoder to control lights (mainly buildings, roads, etc.) and servos for turnout throwing ( which are presently mechanically operated by hand with rods in my switching layout)

You can use these decoders to turn on and off LEDs for lighting easily, by using a limiting resistor in series with a LED connected to any function pin. There are many ways to control these with different features and groupings. Again read 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

for details. For more applications I'll refer you to my blog: http://model-railroad-hobbyist.com/blog/geoff-bunza

for more elaborate use. Also there are many great modelers in the MRH forum that are doing great things with LED lighting and Arduinos and other controllers, like Dave Bodnar for one. Use the Search box on the top left of each MRH page for help.

Quote:

by means of JMR, by building control panels. Presently I can only operate locomotives through the JMRI WiThrottle, web interface, or with an Android mobile phone using Engine Driver and Digitrains. Even the multifunction decoder is seen by the system as a  locomotive in the roster.

Don't be bothered by JMRI's equating mobile decoders to locos, nor by the relatively primitive JMRI interface for accessory decoder control. There is a wealth of other JMRI resources that can be applied, although there is a steep learning curve. Have a look at JMRI scripts to control lighting via decoders, for a start.

Last, I should have a new blog or blogs coming out soon regarding DCC control that may be of interest to you too. Stay tuned! 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
hpept

Accessory Decoder version

Hello Geoff,

still messing around with the decoders. I recently joined the JMRI group on Yahoo, and I was suggested to try out the Accessory version of your decoder.

Since I built two decoders, I would like to reserve one for lighting, and the other for servos.

I loaded the code AccDec_15Servos_@LED_6Ftn into the Arduino and tested it. It went all right, so now I can control the servos turnouts via the ACCY button on Powercab.

I was also able to control the servos via JMRI, by setting up a small test panel. Wohooooooo... it seems I'm on the right way!!!!!!

But.....all went well till I tried to modify the program. I changed the decoder address from 40 to 20, and the CV decoder address from 24 to 19, and then modified the CV parameters of the last two functions from the CV table so that the decoder can control 17 servos. As soon as I modify any of these parameters, no matter if one, two, or all, the decoder doesn't respond anymore to controls.

I've tried re-uploading several times, with no success. Only a clean version of AccDec_15Servos_@LED_6Ftn seems to work. It sounds strange to me, because I'm not messing with the code, only some declared parameter which are clearly identified in the code itself.

Am I doing something wrong? Can I change the addresses only by changing the values of

#define SET_CV_Address       24

#define Accessory_Address    40

to whatever value I want (I would like 19 and 20, respectively)?

Can I change the values of CV associated with the two last functions to change from LED to Servo?

I'm pretty baffled by this behaviour, but I suspect that the last two pins, which are connected to A4 and A5 of the Arduino board are kind of special and don't behave like the othersso that servos may not work on these two specific channels.

On the other hand, I was able to  successfully change the decoder address to 20 via Powercab by setting CV1=20 when programming the decoder as a loco on address 24.

Could you please help me to set up a version fully Servo and a version fully LED for the Accessory decoder? What am I supposed to change to have them work the way I want?

Best Regards

Roberto

Reply 0
Geoff Bunza geoffb

@Roberto re: CV Changes

Hi Roberto,

Quote:

As soon as I modify any of these parameters, no matter if one, two, or all, the decoder doesn't respond anymore to controls.

Since you are trying to modify the CV's, did you remember to follow the directions as posted:

Open one of the sketches (programs), set your decoder address, and you are good to go!  Once you have loaded the Pro Mini, remove the “//” in  the line: “//#define DECODER_LOADED” so it looks like below:

/ ******** UNLESS YOU WANT ALL CV'S RESET UPON EVERY POWER UP
// ******** AFTER THE INITIAL DECODER LOAD REMOVE THE "//" IN THE FOLOWING LINE!!
#define DECODER_LOADED

And then RELOAD the Pro Mini. This will set up all the default CV’s and then permit you to modify them with your DCC controller of choice. You can even reset the short address in CV 1.

Not following these directions your decoder will reload the original settings every time you power up your decoder.

Quote:

Can I change the addresses only by changing the values of

#define SET_CV_Address       24

#define Accessory_Address    40

Yes, you can, and these are the correct statements to change. Editing the sketch is the easiest way to set the decoder up.

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