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

@dogz

Hi dogz,

I use the "NMRA Generic Decoder" as the configuration with JMRI. You can then rename it and save it to your roster. There is no way at present for JMRI to read the decoder settings.

I have no plans to add onto the hardware to provide service mode feedback. Perhaps someone else who is using these will. volunteer to do so.

Use "Op Mode Programing" with JMRI to set CV's or edit the table in the sketch before you load it, as per instructions. You can also use the set single CV programmer with JMRI. Remember to set the address for op mode programming.

When running down a problem, first go over every single connection, preferably with an ohm meter or continuity tester, or even a battery and a light, to check them all. Make sure when you power on the Pro mini goes through the power up sequence described. Then check the orientation of all your parts to make sure you put the circuit together correctly. If still no joy, try swapping parts as you are left with the likelihood of a bad component.

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
dogz

1k resistor

Hi, just wanted to check, in the schematic it says there is a 1k resistor ( I used a half Watt) on the rail that is going to the  optocoupler. its not in the parts list, is it the correct resistor to use ? 

Reply 0
Geoff Bunza geoffb

Re: 1k resistor

Hi dogz,

If I remember correctly that 1000 ohm resistor carries about 8ma to the 6n137, so anything larger than 1/8 Watt resistor would work. 1/2 Watt will work but you can use one even smaller, if you would like.

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
dogz

it works , had to remove c8

it works , had to remove c8  and now its working great. bit of servo jitter, bit i can sold that out later  

 

Reply 0
Geoff Bunza geoffb

C8 Removal

Hi dogz,

'Glad to hear that you got it working.  Did you have the right valure for C8? It is supposed to be 270 pf (picofarads) that is .00027 microfarads? The correct value is too small to cause a failure.

Nonetheless, if you have intermittent problems in the future, try putting it back in to see if it helps-- that's why it was there.

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
dogz

c8

Yes this is exactly what i thought and so i was very confused. tomorrow i am going to start working on the servo jitter. the jitter is caused by noise from from the DCC line and i note that in an earlier blog post you paced c8 there to stop the noise. However you noted that you attached c8 directly to the 6n137 pins.  does this indicate that you have c8 across pins 2 and 3 on the 6n137 rather than between the d3 and r18? 

I can apparently fix the jitter in code, but it is always better to do it with hardware. 

BTW, thanks for posting this, it is a cheap and easy way to get something useful up and running and the perfect intro to the idea of using Arduino for model rail. 

Reply 0
Geoff Bunza geoffb

@dogz re: C8 Placement

Hi dogz (name?),

Quote:

does this indicate that you have c8 across pins 2 and 3 on the 6n137 rather than between the d3 and r18? 

Electrically this is exactly the same. For all the connections to the input of the 6N137, keep the connections as short as you reasonably can, and place the C8 capacitor (as well as D3 and R18) as close to the 6N137 as possible. This is good practice when dealing with signals with noise concerns (in general).

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
dogz

servo jitter is still there.

servo jitter is still there. have replaced with expensive servo as its less noisy as well has applied c8. 

Have been looking into it and look like it could also be a timer issue. 

Geoff, what servos have you been using and do they jitter at all? 

 

 

Reply 0
Geoff Bunza geoffb

Servo Jitter and Servo Issues observed

Hi dogz,

It is not likely the servo jitter is due to signal timing. The typical servo jitter I've seen is due to attempting to make the servo go past its mechanical limits by incorrectly setting the servo limits via code or CV setting beyond the particular servo's mechanical limits-- and they are usually not the same from servo to servo-- especially if you use the cheap servos like I do. Even though you can set the limits from 0 to 180, I've had some servos that can only go from 38 to 140. When you set the limits too high or too low, the feedback mechanism (electronics) keeps trying to make the motor mechanism go farther. Jitter can be observed, and increased current draw-- sometimes quite a bit (like 6 times normal)-- can occur. This I personally have observed.

In some cheap servos I've used, some mid-point settings also can be accompanied by servo jitter. I think, but cannot prove, that the cheap potentiometer (variable resistor) used in the feedback mechanism may be at fault. From my experience, this is not rare, but also not common.

I have only used 2 of the higher quality, more expensive servos that are available so I have very limited experience using them. Neither showed any mid point jitter. Both demonstrated the oversetting endpoint jitter I described above. In all cases, I do not consider these to be precision devices, so I don't have much concern for mid point jitter issues.

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
dogz

Jitter

Well after adding C8 back into the mix jitter is reduced. But it is still there. 

when i say jitter i refer to the servo moving about 1mm back and forth. This seems to be caused by noise from the track, to test i removed the track connection and the jitter stops. The servo is set correctly. I have never been able to get a servo to be 100% noise free... so maybe i am just being a bit anal about the thing. 

 

Reply 0
Geoff Bunza geoffb

More Jitter

Hi dogz,

Are you powering the servos from the DCC signal? For use with servos you should be using a separate 5 volt power source for your decoder application. In this case disconnecting the DCC signal from the decoder should have no effect on sevo jitter at all. If you are disconnecting the DCC signal, and using a separate 5 volt supply, you very likely have something miswired. The whole purpose of using the 6n137 opto-coupler is to isolate the decoder from the DCC signal. If you have elimiated the jitter by disconnection you clearly have some form of coupling present.

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
dogz

servo's optocoupler and the

servo's optocoupler and the arduino are all powered from the same source. on the layout its a wall plug and on the bench its from a 5.2v ubec off a 3cell lipo. 

i think it might be the cheap optocoupler. i got another in the mail today so will build another. this is my first time scratch building something so the practice is good. 

also, if its ok with you,  once i get my head around it and i don't have this jitter i would lie to do a circuit board so that people can just order a board from a maker (about $15 delivered for three) or print their own, then just solder the components on. It would be my first time doing that as well, but it would make this more accessible for people like me who have little to zero electronics experience. 

Reply 0
Geoff Bunza geoffb

Circuit Board

Hi,

It is kind of you to ask, but you don't need my permission to make and offer such a board. I think it's a good idea and there amy be many modelers who might take advantage of your work.

Good luck with it! 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
DBodnar

Circuit Board Design & Servo Jitter

Hello, Dogz - I may be able to save you some time on designing a circuit board as I have already done so.  Information on the circuit board and the Gerber files are on my web page here:

http://www.trainelectronics.com/DCC_Arduino/Decoder_board/index.htm

There is also a link there to a YouTube video that shows it in action.

http://youtu.be/oI-NjCDbUXo

I use an external power source for the servos and, as you can see in the videos, have virtually no jitter.

I do have some extra boards from my first order.  If you, or anyone else, is interested in the circuit boards drop me an email at dave@davebodnar.com

Thanks & good luck with your project.

dave

Reply 0
dogz

Function triggering multiple actions

Activating multiple led's and Servo's with a single function?

basically I my decoder set to address 4, this is also the address of the loco. so i can just load the loco throttle and operate everything from the one window in JMRI or wiithrottle on ipad.

I have set up led's on F3 and F4 (pin 6 and pin 7 on the arduino). and i have the servo on F5 (pin8)

I would like the decoder to perform the led signaling. In this case i would like pin6 to be in the ON state when and pin7 to be in the OFF state when the decoder loads. when i toggle the servo position i would like the led's to toggle at the same time. 

ps, i think the 22uf capacitors i got where either faulty or not the right kind. I replaced the capacitor across pins 5 and 8 of the 6n137 with a larger cap and the jitter from the track has been eliminated. there is a slight jitter remaining, i think its from the 5V power. 

Reply 0
Geoff Bunza geoffb

Function decoder-- Servo on F5 switching 2 LEDs

Hi dogz (name?),

This sketch:

http://model-railroad-hobbyist.com/files/users/geoffbfiles/Decoder_special.zip

should implement exactly what you specified. F5 will control a servo that switches 2 LEDs connected to pins 6 & 7. The decoder address is set in this sketch to 24. You can use this as a starting point for more modeling adventures.

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
dogz

thanks !

Hi Geoff, 

Thanks it works great, i think i should be able to implement changes on my own to do more LED+servo combinations. 

Next step is feedback :D  makes sense to use an arduino base for the feedback, but cant find out much about it on the net. any pointers ? 

ben


 

Reply 0
Geoff Bunza geoffb

@Ben

Hi Ben,

You are welcome!

What kind of feedback? In what situation? With what equipment??

It's hard to offer any pointers without a little bit more information. 

Good work. 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
dogz

feedback

 

Hi Geoff

feedback to computer (block control?)  for automation (my main interest) 

i would like to implement this feedback using the cheapest method possible eg... building my own. I have seen a few things but not in detail and in one of your posts i noted that you had though about using the arduino as a receiving point for the various triggers. 

I like the idea of the coil type trigger as they don't create any load on the equipment. 

magnetic reed switches and photocell sensors should be able to work with arduino with no hardware other than the switch/sensor.  I am not sure about infrared transmitter receiver pairs.  i would also like to coils(http://tonystrains.com/product/rr-cirkits-ct-coil-set-of-6-for-lncp/) for block detention to avoid inducing load using current drop sensors, there are some diy circuits for this and i am reasonably sure they outpit high/low that the arduino could interpret. 

 

also have you thought about starting a github project to develop the codebase for the hardware? as far as i can see this hardware could be used for a lot of stuff in its current form and hosting it on a project development environment might  help to centralize code development.... benefiting the users like me that are not proficient coders. 



 

Reply 0
Geoff Bunza geoffb

@Ben

Hi Ben,

I use RR-CirKits coil detectors and I really like them for block detection. They work quite well. For an absolute point detector I have been using the cheap IR detectors that I described in the level crossing here:

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

Sometimes you need "pinpoint" position accuracy which block detectors give only when you go to tiny blocks.

The idea about a github project is a good one. I don't think I can divert enough time and energy into it to even scope it out until this fall. My attention is directed to too many other activities between now and the NMRA national convention this August. I will keep it in mind.

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
James109

Big Thanks

Geoff

 

Just a wee note to say a big thanks, now have three boards up and running including a Arduino Nano on a servo shield.

Cheers

Jim

Reply 0
Geoff Bunza geoffb

@Jim Great !!

Hi Jim,

That is great news. Now I bet you will find even more things to model with these. 

Happy modeling. 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

Thanks Geoff

Geoff,

I'm late to your party here but I have had some limited exposure to Arduino so I expect to find my way through your work directly.

Thank you for your efforts and generosity!

Joe Baldwin

 

 

Joe Baldwin

Northern Colorado 

http://www.joe-daddy.com

Reply 0
pattenjn

Hello Geoff, My name is

Hello Geoff,

My name is Joachim Patten and I am from Germany.

I have downloaded the New-Dual-MULTIFunction-Decoder from your blog and I have installed AceesoryDecoder_17LED_1Function on my Arduino SainSmart UNO.

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

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

Works your sketches only with Arduino Pro Mini?

NmraDccExample_1 sketch works.

I see in the serial monitor information if I switch a turnout.

I need help what I made wrong.

Many thanks for help.

Regards

Jochen

Reply 0
Geoff Bunza geoffb

@Joe B

Hi Joe,

No Worries-- the party goes on, and you are welcome! If you have questions, please ask, and 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