I am a modeller on a budget and after realising that I could build a point motor with a servo for less than half the price of the cheapest solenoid point motor I could find the decision was quickly made.
After reading through this topic on RMweb.co.uk the initial idea was to strip the control board from the servos (basically ending up with a geared electro motor) powered through two micro switches that would be switched by the arm of the servo. Reversing the power through a DTDP on-on Toggle switch (with the help of two diodes) would then cause the servo to go the other way until it reached the micro switch on the other side. Anyway, for anyone interested see the earlier mentioned topic.
But then I discovered Arduino and I must say I am utterly intrigued!
Having the option to control certain aspect through software instead of hardware would save me a lot of wiring and soldering...
I've already found that you can control X amount of servos from an Arduino and also found in a different topic that you can link this to point indicator leds, interlock it with signals and change the frog polarity (the last one with the help of a relay, the first two can be done in the code I believe (correct me if I'm wrong)).
This whole thing would only increase the price per point motor by a fraction and still be a lot cheaper than buying solenoid point motors and from as far as I can see are the possibilities basically endless.
But what I would really like to know, and I haven't found this anywhere so far, is if you can 'power' the relay from a DPDT on-on toggle switch. This may sound odd, but I have a soft spot for these switches...
This would simply mean that I would like to throw the switch one way to open a point (and it would stay 'on' so the servo needs to stop after it moved and wait for it's next command) and throw the switch the other way to close the point (again the servo needs to stop after closing the point until I throw the toggle switch the opposite way). At the same time I need to light route indicators on my control board and probably change a signal and off course the frog polarity.
I've seen quite a few tutorials on how to control a servo (mostly simply using the sweep library) and a very rare few that include an actual switch (usually a push button) that powers the servo, so I am a bit at a loss here...
I have no idea what frog polarity is how how a relay helps you with that, but regarding your specific question about using a DPDT switch to control a servo, that is certainly possible if the switch is dedicated to the Arduino (i.e. you have full control over how it is wired) and almost certainly possible if it is also used by something else (i.e. you need to tap in to an existing circuit).
The basic concept of using a mechanical switch to move a servo between two predefined positions and make LEDs go on and off all seems perfectly feasible. However, your original proposal to do it all in hardware seems equally feasible. As far as I can see, the main advantage of involving a microcontroller would be that it makes digital control possible, so you could potentially manage the whole setup from a central controller rather than having discrete mechanical switches for each actuator. Of course the central controller could give you mimic displays, automatic operation, safety interlocks and so on, if you were willing to spend the time implementing it.
I sell a lot of these cards to model railroaders looking to make secure connections to a Mega if you decide to go that route (also works with the Due). http://www.crossroadsfencing.com/BobuinoRev17/
And started converting the 32 IO/16K SRAM '1284P to a combined Arduino clone/screwshield, will have that available in a few weeks. (after China Spring Holiday)
Mostly thruhole for easy assembly still (regulators and USB polyfuse, all with big pads), and onboard/offboard option for USB/Serial.
Kiwi_Ed: But what I would really like to know, and I haven't found this anywhere so far, is if you can 'power' the relay from a DPDT on-on toggle switch.
If you are driving your relay from an Arduino then it is a straightfoward matter to get it to sense the DPDT switch position.
It can be done by wiring a SPST contact between ground and a digital input on the Arduino. The digital input pin is then configured as an input with a pullup and you test the state of the input pin in your main loop and drive the relay accordingly.
If you want to control points with switches then you need to plan on the Arduino using one pin for each switch and one pin for each relay.
Because the Arduino only needs to know whether the switch is on or off you don't need a double pole switch. The Arduino can be programmed to treat the switch as "off" unless the switch contacts are closed - assuming that it is sufficient to have the point one way when the switch is open and the other way when the switch is closed.
If, for the same point you also need to switch frog polarity using the Arduino that would require another output pin to drive a relay. It may, therefore, be simpler to use a DPDT switch to manage polarity and take a connection from the same switch to tell the Arduino to move the servo (and the point).
For other readers the "frog" is the part of the point where the rails cross over and where the train wheels can cause a short circuit.
If you count up the number of output pins and find that the Arduino Uno doesn't have enough you might consider a Mega which has more pins. If you feel confident of your capabilities you could perhaps use a few of the cheap Arduino Pro-Minis. Or maybe start with an Uno and supplement it with Pro-Minis or any of several other options.
If you like to draw up a plan of attack and outline it here people will be happy to advise.
Another option is to have a screen display on a PC which is used to give instructions for point movement - but you would still need Arduino pins for frog relays.
Bear in mind that the Arduino could also be programmed to use the point switches to control signals - perhaps with suitable delays - either before or after the point moves.
I'm also planning to use my Arduino to detect train positions using Light Dependent Resistors set into the sleepers.
Kiwi_Ed:
Reversing the power through a DPDT on-on Toggle switch (with the help of two diodes) would then cause the servo to go the other way until it reached the micro switch on the other side.
I was going to say you don't need the diodes, but I realise they are there to simplify the wiring. In fact, to simplify the wiring even further, you provide both positive and negative supplies against a common ground, and the switch merely selects one or the other - a single control wire to each point.
My only concern against "hacked" servos is whether they will hold with no power to the motor. On the other hand, "un-hacked" servos will tend to draw power to maintain the tight position against an end-stop (noting that you might use some spring "give" in the linkages to maintain position). The solenoid actuators are designed specifically to "lock" into position and it becomes difficult to replicate this function easily.
Of course Arduinox - one or many - are a marvellous addition to model railways.
You could use the arm of the servo, at the end of its travel, to press a microswitch to change the frog polarity. What gauge are you working in? In the larger gauges (above N gauge) you can change the frog polarity using a copperclad tiebar and wiper contact.
I am modelling in N gauge and the attached image is a rough sketch of the average situation on the model.
I am still not convinced that the arduino is a simpler solution than hacking a few servos. I know this can be done (and they can hold the point). Anything I would like to do is done fairly simple with 'old fashion' electronics. The two main reasons I would go for the Arduino is if it would save me money and if it would save me wiring.
All in all the money seems to be more or less the same. The electronics will be basically the same, only tied together in the Arduino and I would probably save a few components here and there that would pay for the Arduino.
As far as the wiring is concerned I'm not too sure. As each function needs at least one input and output that basically means that I need to run an awful lot of wires from the arduino to each point/signal/detector/switch. I'm not sure but it feels to me like a lot more wiring than with old fashioned electronics. But I haven't properly worked that out yet, so I might be wrong.
Obviously the Arduino would open up a whole array of other possibilities as well and I am absolutely intrigued by this but at the same time annoyed by the lack of proper tutorials that are out there. 99% of the tutorials are like 'look I made an LED blink with a ready made library'. I still have to see the first youtube clip or website that shows me a complete setup running on Arduino. But that just me whining.
Thanks a lot for your suggestions so far. If you have any ideas/comments after seeing my picture, please let me know. That would be very much appreciated.
See reply #2 - I can sincerely say that a lot of modellers certainly use Megas with screwshields to run their setups. I don't have pictures to back that up, but I do have e-mail replies from folks whom I have asked "Hey, just curious, what are you doing with the screwshield?" who've said it was going into their railroad setup.
In my opinion the overwhelming advantage of a microprocessor such as an Arduino compared to using electronic components is that, if you need to adjust something it's just a software change.
And it's easy to try various options - compared, say, with swapping resistors or capacitors.
The initial learning curve may appear steep, but it's well worth the trouble.
Think of an Arduino as a Lego set with an infinite selection of bricks or an electronics workshop with an infinite variety of components.
There is a huge number of example programs (sketches) that come with the Arduino IDE. Don't be put off by the fact that some of them only blink an Led or something equally simple because the same technique can be used for lots of things. Controlling a relay is fundamentally the same as making an Led go on and off. And a "complex" program is just a lot of simple bits strung together - assuming it's designed reasonably well.
Kiwi_Ed: But what I would really like to know, and I haven't found this anywhere so far, is if you can 'power' the relay from a DPDT on-on toggle switch. This may sound odd, but I have a soft spot for these switches... This would simply mean that I would like to throw the switch one way to open a point (and it would stay 'on' so the servo needs to stop after it moved and wait for it's next command) and throw the switch the other way to close the point (again the servo needs to stop after closing the point until I throw the toggle switch the opposite way). At the same time I need to light route indicators on my control board and probably change a signal and off course the frog polarity.
I think this linear actuator with limit switches tutorial (scroll down) is what you're looking for. It doesn't have to be a linear actuator of course.
Kiwi_Ed:
Obviously the Arduino would open up a whole array of other possibilities as well and I am absolutely intrigued by this but at the same time annoyed by the lack of proper tutorials that are out there. 99% of the tutorials are like 'look I made an LED blink with a ready made library'. I still have to see the first youtube clip or website that shows me a complete setup running on Arduino. But that just me whining.
I agree that there are lots of "look what I made" tutorials out there, but there are also many "how to" tutorials. These don't show any finished layouts, but show you how to connect and program various input and output items. I suggest you look at the Jeremy Blum tutorials that he made for Element 14 for starters. They are on YouTube. Some (not his) tutorials are so poorly made (wobbly cameras, monotonous voice, stuff repeated over and over, long pauses that have me screaming "get on with it!", etc. etc.) that I just close them after the first 30 seconds!
Well I thought Id found the Holy Grail of what i was looking for but reading all this just leaves me as confused as before.
how do you control the servo with a switch -- where do i find a decent tutorial has someone made one that will show me in easy steps/plain english what the components do -- what is an arduino sensor sheild and how do i use it
reading lots on googled pages but nothing is explained simply
my objective is basically what this original post is about - switch a point using a servo controlled by arduino via a switch
so i need to switch the input to the arduino and that creates the pulse for the servo - via some 'simple programming'
that switches the point, lights an LED to show its position and via a relay board switches the frog
If you just want to control servos with an Arduino according to the setting of switches you don't need any Arduino shield.
For a single servo the arrangement could be as simple as this
A slide or toggle switch.
A servo.
A power supply for the servo (probably 5v or 6v and allow about 1 amp for every servo)
A power supply for the Arduino (unless it is connected to a PC with the USB connector)
something in the range 7.5v to 12v and about 1 amp
NB the Arduino power supply will have a too high voltage for the servos and the servo power supply will have a too low voltage for the Arduino (real PITA).
NB the Arduino has a 5v pin which cannot supply enough power except for 1 very small servo with no load on it. When the servo draws too much current the Arduino behaves very strangely and may be damaged.
The program (sketch) on the Arduino will continuously check the position of the switch and, depending on the setting, will send the appropriate command to the servo to move the signal or point this way or that way. The code will be very similar to this
thanks for the quick reply Robin
and i sort of understand what you are saying
program
1 - check the state of the switch
2 - if switch = 1
then move servo to right
else move servo to left
3 - goto 1
thats clear programming this is not my problem -- yet
but
If I have 20 plus points on the railway I need 20 plus switches
how do i connect 20 plus switches /servos to 1 arduino
as the servos each need a pulse to keep them in position
I've never set up a model railroad but have read some on the topic. I think of using an arduino as some kind of central control for all the stuff one may have in a setup would be a lot of work with little advantage over normal hardwired methods. You would still have all the physical wiring to perform and then have to mimic some kind of 'user interface' be it a switch panel or a virtual panel on some kind of display or link to a PC for fancy graphical display.
The hobby has long had a 'digital control' method called DCC that allows a simple digital bus control of train speed/direction, even multiple train control along with all the aux stuff on such models, track switches, guard crossing, lights, and other sensor and signalling devices. This 'control bus' is just superimposed on the DC voItage that is applied to the tracks, I'm sure some goggling will explain of the use and capabilities of such DCC systems and I have little doubt that an arduino could be a central controller in such systems.
yes DCC is an option but at a cost -- a very great cost to implement across the whole system train decoder is £15+ and you need 1 for each train.
non DCC manufactured point motors are depending on type £7-£20+ each
what i am looking to do is control a point using a servo
this means i move and hold the servo left or right depending on the route switch
I can get a servos from around £13-£16 for a pack of 10 on ebay
so as you can see there is a great saving to be made even including buying the arduino and other accessories
yes DCC is an option but at a cost -- a very great cost to implement across the whole system train decoder is £15+ and you need 1 for each train.
non DCC manufactured point motors are depending on type £7-£20+ each
what i am looking to do is control a point using a servo
this means i move and hold the servo left or right depending on the route switch
I can get a servos from around £13-£16 for a pack of 10 on ebay
so as you can see there is a great saving to be made even including buying the arduino and other accessories
Certainly you can implement an arduino in a limited way rather then be an overall system controllers. It's your set-up and it can be a lot of fun leaning and implementing an arduino into one's hobby. I just wasn't sure you knew about the DCC standard and it's capabilities.
One option is to use several small cheap Arduinos or just the Atmega 328 chips on a stripboard so that each one controls, say 6 items.
The Arduino Mega has a great deal more pin connections at a considerably higher price.
Another option is to use shift registers to gather data from a lot of switches using just a few Arduino pins - leaving more pins for the servos.
Or You could "multiplex" switches by using resistors to differentiate between them and using the analog inputs to read the voltage caused by the switches - different switches = different voltages. At a wild guess you could have 4 x 2-position switches on each analog pin.
Of course if the switches are buttons on a PC screen you don't need any pins for the switches (my preferred option).
Using an Arduino gives you the option to build software interlocks between signals and points.