Skip to main content

There are attractively priced socketed relays such as this 10 Amp DPDT.

ebay dpdt relay 12V

There are also automotive relays for even less $ that carry more current and have sockets or push-on tabs to facilitate change-out.

A consideration though if using an Arduino or similar is the relatively large coil current to directly drive the relay.  Additionally, the most common relay coil voltage is probably 12V DC so some buffering circuitry would be needed to drive each relay from the "weak" 5V Arduino outputs.

What's nice about the eBay relay modules shown earlier is they have on-board relay buffer circuitry so you typically need only a few mA of current to control the relay.  This simplifies the inter-connect to an Arduino.

 

Attachments

Images (1)
  • ebay dpdt relay 12V

Stan, I would tend to agree that for most applications using one of the multi-relay boards with built-in opto-isolators is liked the easiest and most cost effective approach.  However, if you are not afraid of a couple of the simplest components that exist, you can a resistor, diode and a transistor to boost the output current, and effective voltage to levels easily capable of driving most relays that might be practical for model railroad use.   Most arduino boards will provide 50ma of current at 5v.  With a 2n3904 (18 cents digikey, 5.4 cents Auction site) transistor you can boost that to about 200ma.  Using a bit more robust Pn2222 (cents digikey, 10 cents Auction site) transistor you can raise that to up close to 1 amp.  

As a side to this, if one was going through the trouble of boosting the Arduino's output current with a transistor like this, they could consider doing away with the relays all together and use triacs to switch the track power, though this would probably require a large heat-sink on the triacs.  This is getting into the realm of overly complex, but it's something to throw out there.  


Going back a little, rotary encoders are really nice, but you can do the same job with a standard potentiometer if you're using an arduino anyway.  You can even buy pots with stops, and have quite a few positions.  For example, the LionChief remotes use a 10K potentiometer with 41 positions.  You can also typically pry out the stop tab on most normal pots to allow free rotation.  

Other simple options that exist are to use up and down selection buttons, or to use a numeric keypad.  one could also add a simple text display to show which track is selected, or of course you could use 7 segment displays, or standard LEDs.  

Honestly once you incorporate a micro-controller in the task, the options for both the input options and the track powering side grow exponentially, and the costs of even the most extravagant options are more reasonable than the price of high current rotary switches.  


Ine last solution, stepping completely away from the fancy electronics:  If one is reasonably handy with some fabrication, you could build your own high current rotary switch.  The premise being to have your control knob turn a disk below the panel with microswitches placed around the circumference of the disk.  On the disk a small section would form a bump, or cam, that would press a switch when it is turned past that switch.  I see a 10 pack of 16A microswitches on the auction site for about $9, so the over-all cost here is probably going to be around $20 ( +$15 per pole on the switch) to build your own switch.  It may not be the most cost effective solution, but it would be a fun project for someone that likes to build things, and would allow a custom number of switch poles, and they could be positioned so that the "on" positions on the selector knob/dial match up perfectly with the positions of the actual tracks around the turntable.  You'd probably need to add a separate on/off switch so that iach track is not briefly powered as you turn the knob past them.  Here the micro-controller shines as it can easily be programed to delay powering a track for a half a second or so, so that only the position you stop on will be powered.  

JGL

JohnGaltLine posted:
 

...Most arduino boards will provide 50ma of current at 5v.  With a 2n3904 (18 cents digikey, 5.4 cents Auction site) transistor you can boost that to about 200ma.  Using a bit more robust Pn2222 (cents digikey, 10 cents Auction site) transistor you can raise that to up close to 1 amp...

Are you sure about that?  I don't know what you mean by "most" but the Arduino site suggests the most "robust" board to start with is the Uno which has only 20 mA of output current.  The point being a 5V relay that switches many Amps of current (for track power) but only needs 20 mA of coil current (100 mW of coil power) are few and far between or quite expensive.  Agreed that all kinds of interesting things can be done as you add additional circuitry.  As I see it, the biggest "issue" is how to deal with driving 15 or 16 relays...in addition to handling control signals to select the relay(s) when "most" (now I'm using the term!) Arduino boards might not support that configuration/quantity of I/O signals.  That is, is soldering an expander board in the cards?  Or are there reasonably priced off-the-shelf shields capable of driving large numbers of relays?
 
Untitled

Attachments

Images (1)
  • Untitled
stan2004 posted:
JohnGaltLine posted:
 

...Most arduino boards will provide 50ma of current at 5v.  With a 2n3904 (18 cents digikey, 5.4 cents Auction site) transistor you can boost that to about 200ma.  Using a bit more robust Pn2222 (cents digikey, 10 cents Auction site) transistor you can raise that to up close to 1 amp...

Are you sure about that? 

No, no I'm not sure at all.  It seems I mis-remembered the spec here.  In either case it doesn't mean much to the idea of using a transistor to boost the output current or voltage levels.  


stan2004 posted:

As I see it, the biggest "issue" is how to deal with driving 15 or 16 relays...in addition to handling control signals to select the relay(s)...

The standard solution here is the 74HC595 8 bit, latching, shift register.  With this IC you need only 3 GPIO pins on the arduino to control a practically limitless number of outputs.  ( you are limited by the speed of the arduino so some ridiculous number of shift registers that can be daisy-chained, but for something like 100 outputs, there should be no problem.  Support for shift registers is built into the standard arduino library with the ShiftOut command.  As suggested earlier, the 74595 has a output pin that can send data to additional chips connected in series, allowing just those 3 GPIO pins to run countless output pins.  Each output of the 74hc595 can provide 20ma of current.  A companion chip exists to do the same job with inputs.  From Digikey these cost 58 cents each, but on the auction site, shipped from China, they cost about 10 cents.  

A very quick search for 74595 Arduino shield found a 48 output shield for $28.00, but a $2 bread board will really provide the same functionality, though it is not a pretty as a shield.  

Another solution, if you need as seriously huge number of output pins is to use the SLI (3wire interface) or I2C (2 wire interface) built into all recent Arduino boards, which provides access to surface mount shift registers with 64 outputs per chip, among many other uses.  

Of course for the size of projects that most people here would need, the truly simple solution is to use a Mega2560 board which has 54 GPIO pins on the board.  Off brand boards cost less than $10.  

JGL

 

I can see the potential issues of the arduino's ability to drive the relays and the voltage going thru it. 

I should add that only one relay will be selected and operated at a time.  As a matter of practice once  the locomotive is moved onto the turntable I will de-select that stub removing its power.

Folks have offered up many different and better ways to do this.  Given my skill set am attempting to keep the process of using a keypad and arduino as simple as I can to start.  Once the basic process is working I can then look to incorporate some of the suggestions.  I just need to start simple.

Thanks,

Ed

Add Reply

Post

OGR Publishing, Inc., 1310 Eastside Centre Ct, Ste 6, Mountain Home, AR 72653
800-980-OGRR (6477)
CONTACT US
www.ogaugerr.com

×
×
×
×
Link copied to your clipboard.
×
×