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
huseyinozsut

Thank you for this useful

Thank you for this useful sharing!

In my modular diorama I will be using 18 switches. 6 of them needs servos (they are not motorised), so for 6 of them I can use your sharing directly! Thank you!

but 12 of the switches are already motorised. I use Lima switches (they are cheaper in my region). It needs 14V AC current to operate; but I guess 10-12V DC will also work fine with these switches. 

My main problem is: My switches have 3 cables. One is ground. Two 14V ac. When circuit is closed, one switches to right. The other cable switches back to left... What I need is a relay control. When I choose to change the switch from my dcc controller, relay should be opened for 1 second, when I choose to change the same switch to its original position, another relay should be opened for 1 second. By this, I can control one switch with two relays.

To give an example for what I need: 

Let's say at adress 15 of my dcc controller, there is one switch. When I click it to change direction, one led connected to Arduino should lighten up for 1 second. When I click the same switch to change direction again, another led should lighten up for 1 second. By this, I can use two relays for one switch and control 8 switches with one Arduino. 

I have very limited programming skills. If you can help me out, I'll be very happy.

Reply 0
Geoff Bunza geoffb

@huseyinozsut

Hi (name?),

The easiest way for you to accomplish what you would like to do is to use one of the 17 function decoders in the simplest on/off  (configuration 0) mode and connect pairs of outputs to 5 volt DC relays at each output and toggle them on/off or find in my blog the code for the decoder that was requested to "pulse" the output when selected to activate the relays. You could then use the contacts from the relay the way you use your switches now.

A suitable relay would be something like: 5 VDC DPDT DIP RELAY CAT# RLY-625 from allelectronics.com: http://www.allelectronics.com/make-a-store/item/rly-625/5-vdc-dpdt-dip-relay/1.html

or from Digikey.com: RELAY GEN PURPOSE DPDT 2A 5V  part# 399-11056-5-ND:  http://www.digikey.com/product-detail/en/EE2-5NU/399-11056-5-ND/4291122

'Hope this helps.

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
huseyinozsut

@geoffb

First of all thank you for your help. My name is Huseyin.

I actually think to use ready switch setups (16 relays that connect directly) for arduino. It is easier to set up. Before posting my message I searched your blog; but I couldn't find a pulse code. My technical English is also not so good. I may have missed out it. I made a search from this site; but couldn't find again. Can you give me the link?

I need to make the pulse code work for me; because I want to use PC based dcc system in the end and maybe I start to get automated some easy lines...

Reply 0
Geoff Bunza geoffb

@Huseyin reulsed Output Functions

Hi Huseyin,

First let me apologize for sending you looking in my blog listings-- I searched every one myself and I discovered the pulsed function sketch was never published. However, here it is in the new updated library for you (and everyone else too):

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

Note that there are 2 new examples in the library: an accessory decoder and a function decoder with all 17 pins configured as pulse outputs. The CV controlling the rate/increment stores the pulse duration 1-255 which is configured in tens (10's) of milliseconds. They are currently set at 10 for a 100 (1/10 second) pulse every time the function is set or the accessory switch is thrown.

I do NOT recommend you mix these with servo outputs in the same decoder as the timing for the servos will be disrupted.

'Hope this helps! 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
huseyinozsut

@geoffb

Thank you for the code! I'll be trying it soon and won't use servos and relays together.

Reply 0
gphank

need additional pins?

This may be the answer to the problem of less servos to accomplish additional functions - inputs, indicators, etc.

http://www.adafruit.com/products/732

I've used this with both the Adafruit and the Pololu arduino compatible boards. Does require I2C pins on the miniPro which I assume it has. Can chain up to 8 chips on the bus with 16 I/O pins per chip.

Gary

Reply 0
Geoff Bunza geoffb

@Gary

Hi Gary,

Consider the distinct feature that a second Arduino Pro Mini costs less than a MCP23017.

Not to say that I couldn't invent a reason to use this -- I can. But I have yet to use all 17 function pins myself, and pushed it to the limit in the project to demonstrate its utility.

Nonetheless, thanks for pointing out the expander. Others might have the need that I don't.  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
purni76

Parts

Hi 

Please forgive the ignorant question but I am new to both the model railroad hobby and electronics so going through a very steep learning curve but DCC and full computer control is what has interested me in the hobby. I am trying to match up the parts list to the schematic. There seems to be more parts in the list than in the schematic. E.g. the parts list has a 1N5819-TPCT-ND and a 1N5819FSCT-ND but the schematic only refers to a 1N4152. This has confused me somewhat. Should I be looking at another schematic in conjunction with the one one this post? Also Capacitors 3 to 5 are not in this schematic. Is that because they are no longer required? Thanks in advance

Purnima

Reply 0
Benny

...

Quote:

I've used this with both the Adafruit and the Pololu arduino compatible boards. Does require I2C pins on the miniPro which I assume it has. Can chain up to 8 chips on the bus with 16 I/O pins per chip.

Wow, 8*16...that's 128 outouts from a single chipset??!

I CAN see a use for it, though.  Let's suppose you want to run a city full of lights...instead of each streetlight requiring it;s own decoder, you'd have each light on an output.  This would be limiting in the total effects that the light could have, they'd would be either on or off...software may be able to supply random flickering.

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

Benny's Index or Somewhere Chasing Rabbits

Reply 0
Geoff Bunza geoffb

@Purnima re: Parts

Hi Purnima,

The schematic diagram is correct. Either a 1N5819, or a 1N4152, or a 1N4148 can be used here. I usually use what I have on hand in my collection of components collected over many years. Sometimes those parts are out of date/no longer readily available, so I will suggest others that people can get. All these are small signal diodes. All will work.

Quote:

Capacitors 3 to 5 are not in this schematic. Is that because they are no longer required?

They don't exist in this project. My blogs are usually written at the end of a project that I may have been working on for weeks, sometimes months. In this case there is a story behind this project. I originally put the DCC circuit together and it worked-- but not always -- and it became very frustrating. After a week I isolated the problem to noise spikes on the DCC bus in the test setup I built. I noticed that circuits shown on the web had added a filter after the 6N137 circuit, so I tried a similar circuit. It helped a bit, but was not completely effective. Moving the "filter" to the front end, with what amounted to be C8 ad R18 solved the problem in every example that I could inflict on the decoder. Along the way, I probably re-worked the circuit a dozen times, adding, changing and removing components over a 2 week period. I even consulted with other designers how they might approach the problem. Sometimes, what looks simple is the end result of an involved process. My thoughts are that most modelers don't care about that-- they want to know what works -- period. The end results are what I put here.

This blog, and its corresponding schematic are the end result of that effort. Hence the gaps in the component number assignments, which the drawing program simply increments one at a time as I add components. By trying new designs, and then eliminating components as the design evolved, I created gaps in the numbering sequence. Just ignore them.

A close examination of my circuit boards may also show you that from time to time I will add power filtering capacitors here and there. This is also part of my attempt to defeat problems along the way. The schematic and description in the blog act as the design of "record," and that's what works.

'Hope this adds some clarity. Keep building -- you will create some satisfying results -- and smiles!

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
purni76

@Geoff re: Parts

Thank you so much for the quick reply Geoff. This clarifies things for me immensely. 

This is great information. Keep up the awesome work. It is very much appreciated.

Now on to the doing.....

Kind regards

Purnima

 

Reply 0
Oberdorfer

word of warning

I have been following some Arduino lessons using the Pro Mini and had no problems until I got to lesson 16, controlling a servo.

I must add that I was using external power for the 5 volts and ground for the servo and the Arduino.  The first part of the lesson was to find the end of throw, you don't actually get 0 to 180 range of motion.  Mine was about 15 to 145.  Worked fine. Then I set it up to use a trimpot to drive the servo, and the sketch was in a loop.  Reading the trimpot and writing, the servo set midway (75), it died.  I figured I had done something wrong and popped in another pro mini.  Again everything worked fine, for a while, it also died.  

The lesson was using the Uno, and driving the servo constantly. 

My conclusion is that driving it repeatedly was too much for the tiny processor.  There was a 25 milisec delay in the loop, but I would make that a whole bunch larger, or do away with looping altogether.  Use a wait command for an input from the user so servo only moves when it is asked to.  

This only applies to the testing/learning process.

 

Reply 0
Geoff Bunza geoffb

Lesson 16?

Hi,

What Lesson 16 are you referring to? What exactly died? The Pro Mini? What kind of servo are you using? Perhaps a small 9G servo? Was the external 5 Volt power supply connected to VCC or +5 (depending on how it was labeled) or was it connected to RAW sometimes labeled VIN?

If the power supply directly to the servo is independent of the Pro Mini, the Pro Mini will rarely damage itself. If the power to the servo is through the Pro Mini, the servo (particularly a cheap one) can draw at peak over 1.5 Amps which is way too much for the regulator on the Pro Mini to provide. Trying to force the servo to go beyond its end of travel will often cause a higher than normal power drain and should be avoided.

Before you toss the Pro mini, try driving the servo from a different output pin, and also try to load the "BLINK" sketch to see if the Pro Mini is still functioning at its most basic level.

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
Oberdorfer

lessons

http://www.toptechboy/arduino

Internet is crazy for how much you can find with a simple search.  Figured that was a good place to start.  9g micro servos, I've already used them with some more expensive controllers.  I am using a powered breadboard to power the servo and the arduino.  The first part of this lesson was to find those end points. The second part was to drive the servo back and forth between those end points.  and it was at idle, when it quit working. I did try to load the blink program.  After they quit working, I can't load anything.  

However, as I sit here with three defective Pro Minis, I have managed to load and run a program, and am beginning to think I may have a bad cable.  I bought 20 of the Arduinos, but only one cable.  Going to order another, see what happens.

 

Reply 0
Geoff Bunza geoffb

Cables !

Odd that you should have this problem,. I just encountered an intermittent connection in my cable as well -- it drove me crazy until I noticed that when I moved it the Pro Mini would reset and restart for no reason.

Relatively easy fix once you find out what is wrong, but what a distraction !

Have fun !

Best Regrads,

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
Benny

...

It seems to me with these variation sin servo power levels and currents that it would be wisest to use relays with the control circuit and a separate power supply to power the relays.

This way, no matter what the servo does or however long it runs, there's never any threat to your control circuit.

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

Benny's Index or Somewhere Chasing Rabbits

Reply 0
Geoff Bunza geoffb

Separate Power

Hi Benny,

Separating the power feed to the servos is a good idea especially once you get to powering multiple servos. The current surge and electrical noise the motors generate can be a problem. I don't think the use of relays is either necessary nor generally feasible to control servos.

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
Benny

...

The whole purpose of a relay is to separate a high power circuit form a low power control interface; it is an electrically powered switch.  When the relay receives power from the control circuit, it turns on the servo circuit [completes it], and power turns off, it turns off the power circuit, depending on the delay and the time settings on the relay or if there are any caps in the two circuits, or the settings/qualities of the relay, whereas some will hold until the receive a second signal [so you could put an electrical stop in either direction of hte servo, at it's maximum throw points, and when that circuit is interrupted/completed, it would turn off the circuit/flip the diode/do whatever is needed to turn off the servo.

They're just switches controlled by a power circuit...

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

Benny's Index or Somewhere Chasing Rabbits

Reply 0
Geoff Bunza geoffb

Relay and Servo

Hi Benny,

I understand what you are saying, and this is do-able. However, a simpler technique is to simply turn off the servo control signal, and the servo will essentially idle.

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
Craigdhepburn

LocoNet on the Arduino Pro Mini

Hi Dave

 

Just built my first arduino project < Geoff's crossing gate

Next is your loconet interface

Is this the final version and have you had it working

I use Railroad and co so presume that it will control and DCC address as normal as long as the device works?

Craig Hepburn

 Perth Australia

Reply 0
Loeter

More Features

Hi Geoff,

about one and a half month ago I've seen your projects for the first time. This is what I'm looking for since years.

You did a fantastic job and I enjoy it very much. Thanks a lot for this.

Your question about other feature came to the right time and I have some ideas.

Colorlight signals in Germany change the signal aspect by dimming the light and not only switch on and off.

This looks great and maybe it's the same for US signals.

Further there are diffenrent signal aspects and you have combinations like double red, green, green + yellow, double white and so on. If it is possible to combine output pins by a CV, a single F-Key could show the signal aspect.

For semaphore signal powered by a servo it would be nice if the servo moves a bit for and back while the signal has reached his endposition. This function could also be used by railroad crossing gates. 

Thats it for the moment and thansk again

BR

Loeter

 

Reply 0
Geoff Bunza geoffb

@Loeter re: Enhancements

Hi Loeter,

I'm very happy you can use this in your modeling -- Enjoy.

I think your last point is requesting a semaphore "bounce" as the servo arm reaches its maximum travel. That should be possible, although I'm going to have to think about how the timing should go. One of the big issues in designing the decoder is managing independent timing for up to potentially 17 independent servos. This will make the loop timing a bit more tricky. Do you want the semaphore to bounce at both ends of travel? I'm going crazy right now getting  my animation clinics ready for the NMRA national convention next month, so I will have to put this in the queue to take a look at later.

The signaling issues and dimming the LEDs likely requires a little more information, as I am just plain ignorant concerning German railway signal standards. A single LED can be "dimmed" by using pulse width modulation (PWM) like commercial decoders do for motors and some do for dimmable LEDs. But consider the fact that if you add "LED dimmed" as a state then you have On, OFF, and Dimmed or 3 different states or conditions for a LED. How would you like to control this LED with one Function Key? Cycle through them? Each time you turn a function ON then OFF? So to get to all 3 LED states you would have to hit the Function Key 4 times, or to get back to the original state 6 times? (Ftn ON,OFF,ON,OFF,ON,OFF say to go from LED OFF, DIM, ON, and back to LED OFF)?

Likewise if you are trying to cycle pairs of LEDs how do you want to do that with one Function Key?

This is the problem I come to when I see:

Quote:

If it is possible to combine output pins by a CV, a single F-Key could show the signal aspect.

The first thing that needs to be done is to explicitly define what behavior you would like to see. Then I can groan and see if I (or some really clever person) can come up with a way to accomplish what you would like. There are many modelers outside the US who are using some form of this decoder, so some modeler may have tackled this problem already. Think about these issues, Loeter, and see if you can define a bit more precisely what you might need. Perhaps it is obvious, but this design has evolved way beyond what it was originally designed to do -- to control simple animations! ...and that's great!

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
Loeter

Hi Geoff, here you can see

Hi Geoff,

here you can see the soft changes of the signal aspects: https://www.youtube.com/watch?v=37TEaiu0XZE

For each signal four F-keys are required. If you press for exaple F0 two red LEDs are on all others off, F1 green  LED is on all others off, F2 green and yellow LED are on all others off, F3 one red LED and two white LEDsi are on all other off. I hope this explains the situation.

Best Regards

Loeter

 

Reply 0
Geoff Bunza geoffb

@Loeter re: Signal Changes with fading

Hi Loeter,

After seeing the video you provided, I can see why you would like the fading on and off to be  incorporated-- it is a really good effect. This is also relatively easily done. You can make some simplifying assumptions to make it workable. Also using 4 Function keys to set a group of LEDs makes this workable too. To be precise, four function keys (say F0-F3) would control a set of 5 LEDs: 2 red, 1 green, 1 yellow, and 2 white? Does this account for the full pattern? I think we could use CV's to set the pattern of each  group of LEDs for each function, so you could get anything you want for each function and each group, but you need to be precise as to how many LEDs total are in each group. For example, are the lower and upper signal groups controlled independently? How many green, yellow, red, and white LEDs would actually need to be controlled independently?

I would approach this as a separate decoder, not as an additional assignable function. There is precedent for one function to control multiple LEDs, but the coding for this signaling would be easier if we treated it as another version of a decoder. It also could be configured as an accessory decoder too. What do you think?

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

Led fading

It seems to me you could use a capacitor to achieve the fading. If you put a capacitor in parallel with the LED, when the power came on the capacitor will charge up and during that period the voltage should rise and the LED would fade up to full brightness. When the power was cut off from the LED, the capacitor with discharge through the LED causing it to gradually dim. It might take a fairly chunky capacitor, I don't know how to do the math so I would probably figure it out empirically. Might need a resister to deal with the inrush current of a capacitor that large.

Reply 0
Reply