Trains.com

Subscriber & Member Login

Login, or register today to interact in our online community, comment on articles, receive our newsletter, manage your account online and more!

Servo Controller Schematic (warning, for electronic nerds only)

2097 views
9 replies
1 rating 2 rating 3 rating 4 rating 5 rating
  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Posted by rrinker on Friday, February 1, 2019 10:25 AM

 There was a reason, the first version of ths I drew up more than a year ago and posted to an EE forum for comments. I was planning to do the same with this one.

 Well yes, I know where the servo is at all times, but there's no test for midpoint in the code. Yes, I can add one. I've already mentioned using jumpers (or a solid trace that could be cut) to bypass the power relay if not needed. 

 The pullups are only on the inputs, the buttons. The 100 ohm series resistors are for protection. Each RJ45 on the left is for 1 panel, there are 4 active lines and 4 grounds (by pair, I need to change the pin numbers) 2 are inputs from the buttons, 2 are outputs to the LEDs.

 The remote inputs from the right side are all inputs. The remote line is pulled high, as are the locks. Lock line high means the buttons are UNLOCKED - so if I turn on the layout but not the CMRI nodes, the layout will be operational in full manual mode. hen unlocked, the input from the remote line is ignored. When the lock line goes low, the buttons for that servo are locked out and do nothing. The remote input for that servo now determines the servo position, high is normal, low is reversed. Simple digital logic, no analog stuff. I'm just doing digitalread on an analog port - the whole nalog pin vs digital pin is an artificial construct of Arduino, that ATMega328 allows those poorts to be used as analog or digital, they just happen to be the ONLY ones that can be used for analog because that's where the internal ADCs connect. 

 The centering jumper puts the servos in their centr position. To make it easier to stick the wire up through the throwbar when physically installing them. Yes, you can move them by hand, but why not set it the right way? You can then power off everything, install the servos, and turn it all back on with the jumper off and it will just work normally.

                                      --Randy


Modeling the Reading Railroad in the 1950's

 

Visit my web site at www.readingeastpenn.com for construction updates, DCC Info, and more.

  • Member since
    July 2009
  • From: lavale, md
  • 4,678 posts
Posted by gregc on Friday, February 1, 2019 9:27 AM

rrinker
The extra diode is to keep the servos from sucking down the power to the micro.

so why not use a 2nd mosfet to avoid the diode drop?

rrinker
The only test for servo position in the loop is to see if it has reached either endpoint.

if you're slowly changing the servo signal to drive from one position to the other, then you know when you're at the mid-point where you could switch frog polarity, but you have no true feedback that the points are in the correct position.

you have 2 relays and drive circuits to unpower the frogs.   You could add a jumper/pads to bypass the relay circuit to make it optional

rrinker
Each panel controls one servo. Panel one is 2 pushbuttons and 2 indicators for servo 1.

you have pull-ups on the indicator outputs as well?

rrinker
Yes, I could play games with multiplexing and cut it down

isn't this how you intend to use the analog input from the remote?   could you explain the input more

rrinker
Right now, when the centering jumper is on, the LEDs alternately blink, like a grade crossing flasher.

what exactly is the purpose of the centering connector? 

greg - Philadelphia & Reading / Reading

  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Posted by rrinker on Friday, February 1, 2019 7:22 AM

 The extra diode is to keep the servos from sucking down the power to the micro. It may be uncessary - other suggested it a long time ago.

 Yes, I could set it up so that it changed the polarity relay when the midpoint has passed. The current way is pretty simple - pull in the power relay (the NC contacts carry the power) start the servo moving. When opposite end of travel is reached, switch the polarity relay, switch the indicator LED, and finally release the power control relay. The only test for servo position in the loop is to see if it has reached either endpoint. They are momentary.

Each panel controls one servo. Panel one is 2 pushbuttons and 2 indicators for servo 1. Panel 2 is 2 pushbuttons and 2 indicators for servo 2. They don;t interact with each other. The panel lights do change if the input comes from the remote connection. 

 Yes, I could play games with multiplexing and cut it down - look at the Tam Valley controllers, 3 wires to a fascia controller handls 2 LEDs and a pushbutton. Those are toggle pushbuttons, frankly I hate toggle pushbuttons, rather have one for each route. So maybe I would need 4 wires to the panel, 2 IO pins, to drive 2 LEDs and read 2 switches. Instead of the 4 IO lines I am using. But it keeps the code simple, basic checks for button push, and steady state outputs for the LEDs. Plus it's easy to change what I want to do with the LEDs. Right now, when the centering jumper is on, the LEDs alternately blink, like a grade crossing flasher. They go out when the servo is in motion, but I could easily change that to blink the newly selected position while in motion and then go steady on when the position is reached. Or sub in bi-color LEDs so the selected route is green and the other side is red. 

                                 --Randy

 Well that was strange, one paragraph got moved down to the bottom.

 


Modeling the Reading Railroad in the 1950's

 

Visit my web site at www.readingeastpenn.com for construction updates, DCC Info, and more.

  • Member since
    July 2009
  • From: lavale, md
  • 4,678 posts
Posted by gregc on Friday, February 1, 2019 6:57 AM

rrinker
The MOSFET is a little trick to get reverse polairty prootection without the voltage drop of a diode

yet you have a diode in the path supplying power to the processor

rrinker
Killing frog power is to handle things like the older Walther/Shinohara turnouts where they even had problems with Tortoise contacts when used for DC.

presumably you kill power to the frog, change the signal to the servo to switch the points and wait some period of time before restoring power to the frogs.

since servos have a specified rotation rate, couldn't the frog polarity simply be changed sometime after the servos start changing the position, presumably at their mid-point?   avoids the need for the relays, circuitry and I/O.

 

you have 8 I/O lines to control 2 turnouts from either of 2 panels.   Are the lighted pushbuttons momentary so that either panel can be used to control the turnout? 

Would the lamp in a pushbutton on one panel change if the turnout was toggled on the other panel?

if momentary switches are used, couldn't you use a single analog input for each servo using the momentary switches from either panel to pull the ADC either hi or lo?

couldn't a single I/O for each servo be routed to both panels to indicate turnout position regardless of which panel or remote was used to affect the turnout?

 

 

and would you be better off with latching relays (> $$) to avoid constantly powering the relay?   (looks like the SRD-05VDC-SL-C requires 71 ma).

greg - Philadelphia & Reading / Reading

  • Member since
    January 2009
  • From: Bakersfield, CA 93308
  • 6,526 posts
Posted by RR_Mel on Thursday, January 31, 2019 6:25 PM

CirCAD is far from perfect as far as I’m concerned but it does do better than OK and what I like the best about it is it will import my CAD drawings saving a lot of time building up the boards.
 
Almost any footprint is available from CirCAD ready to go.  I have only had to draw one to fit my projects in almost 20 years and I can’t remember what that was.
 
I’ve never liked working online but it does have its advantages.  I got a bug in my CAD three weeks ago and I had to do a reload, that hasn’t happened in over twenty years.  The auto dimensioning quit and dove my crazy.  The reload fixed what ever got lost.  Luckily it didn’t corrupt any drawings.  I had taken a Windows 10 upgrade a couple of days earlier and I think it dinged something in the program.
 
 
Mel
 
 
My Model Railroad   
 
Bakersfield, California
 
I'm beginning to realize that aging is not for wimps.
 
  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Posted by rrinker on Thursday, January 31, 2019 5:54 PM

RR_Mel

Randy
 
Ever tried CirCAD by Holophase?  Works great!  I’ve been using it for about 20 years.
 
 
 
 
Mel
 
 
My Model Railroad   
 
Bakersfield, California
 
I'm beginning to realize that aging is not for wimps.
 
 

 I use EasyEDA (I tried KiCAD but I just can't deal with it). EasyEDA is part of the sme company that I got my PCBs from, JLCPCB. And they have another component, LCSC, which is a component house (mini-Mouser, they have most anything you would need, just not 30 brands of the same component, and the prices are good). They also have a footprint for every component they sell, so I know the space I leave for a given resistor or capacitor on the PCB will actually fit the component I buy. It all ties together neatly into an integrated system - draw the schematic, design a PCB from it, submit the PCB to be made, and submit the BOM to get the parts. Real one-stop shopping. And it's not all Wun Hung Lo components, they have name brand stuff like Panasonic and Nichicon electrolytics and Ceramet ceramics. Atmel micros (and others), real Molex screw terminal connectors, etc. Prices seem as good as anybodies, and they'll ship it all in one big box - PCB and all your components, ready to use. But you aren't locked in, either, EasyEDA will export your Gerbers and you cna have your board made by anyone you want. Best of all, it's completely free - as long as you share your projects, there's a limited number of private projects you can have with the free version. There's an installed client but it also works in a web browser - so I cna go anywhere there's an internet connection and work on my schematic or PCB layout.

                                      --Randy

 


Modeling the Reading Railroad in the 1950's

 

Visit my web site at www.readingeastpenn.com for construction updates, DCC Info, and more.

  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Posted by rrinker on Thursday, January 31, 2019 5:43 PM

gregc

- what's the purpose of the mosfet at the power input (why not a diode)?

- why drop power to the frog when switching the turnout (is it because the points are hot?   what kinds of turnout are there?)

- what is the "center servo" connection for?

- what kind of interface is "Remote"  (no rs-485/422 driver chip)?  what is it intended to communicate with?

- what are the 2nd pair of wires on Remote for?  why one digital the other analog?

 

- did you consider an ISP connector to reprogram the chip to avoid remove/replace the processor?

 

 

 The MOSFET is a little trick to get reverse polairty prootection without the voltage drop of a diode (which in the real world is highly non-linear). 

 Killing frog power is to handle things like the older Walther/Shinohara turnouts where they even had problems with Tortoise contacts when used for DC. I don;t have any, and I'm not using any, but I had this discussion a while ago - I could leave that all off, but it doesn;t free enough pins to say add support for a 3rd servo, so meh, it's there. I will probbaly build all mine with a jumper and not populate the relay, transistor, protection diode, etc. Or maybe I'll just design the PCB with a jumper, and should someone want to copy it and use it for such turnouts, they can cut the trace and install the relay and associated components.

 The center servo jumper sets both servos to the center position for installation. It's read at startup and centers the servos and goes into a loop. I have to look at my code again, I don't know if I periodically check it so you cna remove it and return to normal operation of if you need to reset the program with the jumper off to get back to normal.

 The remotes are just digital inputs They will connect to outputs on my CMRI-like nodes. The servo controllers are basically standalone devices - like the Tortoise driver boards Dr. Chubb has for CMRI. The just drive the mechanism, they don;t link to each other. The nodes link via RS422/485 and drive these controllers, read block detectors, and light signals.

 One pair sets the position of each servo, normal or reverse, The other pair locks out the pushbuttons for that servo. One position line, one lock line per servo. Just because it's connected to what Arduin uses as an analog input doesn't mean it has to be analog - I'm not using analog anything on this board, all pins are used a digital input or output.

 The chip will be socketed - old habits die hard, I never solder anything but the passives right to a board. I figure it's just as easy to crawl under the layout and pop the chip out should it ever need updating, vs crawling around with an ISP programmer and connecting it. The programmer I made with an Arduino Nano as the devices has a ZIF socker for the 328 being programmed. Really shouldn;t ever have to touch them though, there's no address to set, and the servo mounts expect the servo to go nearly completely end to end for over-center action (so I am cutting servo power at end of travel) so there is little need to adjust the endpoints once I get a good working value. The CMRI nodes need an address, so I am having it read the 6 analog pins as digital inputs to set the address - 64 possible nodes which should be more than enough for my layout. But that's another circuit I haven't committed to 'paper' yet.

                                  --Randy

 


Modeling the Reading Railroad in the 1950's

 

Visit my web site at www.readingeastpenn.com for construction updates, DCC Info, and more.

  • Member since
    January 2009
  • From: Bakersfield, CA 93308
  • 6,526 posts
Posted by RR_Mel on Thursday, January 31, 2019 8:22 AM

Randy
 
Ever tried CirCAD by Holophase?  Works great!  I’ve been using it for about 20 years.
 
 
 
 
Mel
 
 
My Model Railroad   
 
Bakersfield, California
 
I'm beginning to realize that aging is not for wimps.
 
  • Member since
    July 2009
  • From: lavale, md
  • 4,678 posts
Posted by gregc on Thursday, January 31, 2019 7:15 AM

- what's the purpose of the mosfet at the power input (why not a diode)?

- why drop power to the frog when switching the turnout (is it because the points are hot?   what kinds of turnout are there?)

- what is the "center servo" connection for?

- what kind of interface is "Remote"  (no rs-485/422 driver chip)?  what is it intended to communicate with?

- what are the 2nd pair of wires on Remote for?  why one digital the other analog?

 

- did you consider an ISP connector to reprogram the chip to avoid remove/replace the processor?

 

greg - Philadelphia & Reading / Reading

  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Servo Controller Schematic (warning, for electronic nerds only)
Posted by rrinker on Wednesday, January 30, 2019 8:42 PM

 Well here it is, revision 1.0 of my servo controller project. Probbaly have some things to fix still.

http://www.readingeastpenn.com/images/ServoController10.pdf

There are two connectors for panels, each of which will have a pair of lighted pushbuttons for local control, 2 servo outputs. Power input, with reverse polarity protection. A connector to go to outputs on a controller board to provide dispatcher control of the servos and to lock out the pushbuttons. There are 4 relays, 2 per servo. One controls power to the frog, on and off, and the other controls the frog polarity. So any kind of turnout can be used - before a servo moves, power is cut to the selected frog, then the servo moves, then the frog polairy switches, and finally frog power is turned back on. If not needed, jumpers can bypass the contacts. All centered around an Atmel ATMegas328p microcontroller (same as in the basic Arduino boards, but here just the bare chip and none of the Arduino baggage.)

 Next comes the PCB - that's the hard part, getting it all laid out neatly and efficiently.

                            --Randy

 


Modeling the Reading Railroad in the 1950's

 

Visit my web site at www.readingeastpenn.com for construction updates, DCC Info, and more.

Subscriber & Member Login

Login, or register today to interact in our online community, comment on articles, receive our newsletter, manage your account online and more!

Users Online

There are no community member online

Search the Community

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
Model Railroader Newsletter See all
Sign up for our FREE e-newsletter and get model railroad news in your inbox!