Arduino Mega with Servo Shield for Turnouts


Rabman

Active Member
I have put together an Arduino Mega 2560 with a 16 channel x 12 bit Servo PWM shield to power my 12 Turnouts which include a double slip turnout and a 3-Way turnout.

I am nearing the completion of the control box.

I am using one momentary push button switch per turnout and 3 switches for the 3-Way (1 per destination track) and two for the Double Slip.

In the end I am going to install one LED per switch, but not right now.

The program is written for the Arduino to operate the servos. It is a work in progress but I think it’s 95% complete.

I purchased SG90 servos from Amazon with all the other electronic equipment. The bracket for the servos are made of 1/2” aluminum c-channel. The prototype assemblies mount the servos with Gorilla double sided tape. I am going to reinforce it with Gorilla single sided duct tape around the bracket and servo. I will see the longevity of this system but anticipate it will be good. The photo shows a previous attempt with latex chaulk as the adhesive but it wasn’t strong enough.

I have one installed and am playing with some software parameters to get the turnout throw just right.

Here are some photos.
D95CA455-D8C4-4BAC-A1C0-A5F3DF57C930.jpeg
B3D2D600-9A02-4A8B-9625-FE1DA2D44220.jpeg
E5B905BC-953A-4CBF-A5EA-C16C4BD859FB.jpeg
A6FE26AD-036E-404E-8EE8-A697B2E5F79F.jpeg
 
I'm curious if the servos return to the mid position after powering down and re-upping, or do they stay at the position they were in when powered down.
I would also like to get a look at your sketch when completed.
 
I don’t think they do. I haven’t got enough installed to notice yet. I will let you know. I will post the sketch when I clean it up a little and have the servos installed to make sure it’s fully functional with respect to the amount of travel needed.
 
I don’t think they do. I haven’t got enough installed to notice yet. I will let you know. I will post the sketch when I clean it up a little and have the servos installed to make sure it’s fully functional with respect to the amount of travel needed.

I will be keeping an eye on this. My thought is to use a PCA9865 controller board as to provide expansion of servo numbers, and not to run out of pins required for the button inputs.
You had mentioned using 3 buttons for the 3 way turnout. It would help if you just thought of the 3 way as just being 2 turnouts in series. That way only needing 2 buttons for operation.
 
The 16 Channel board I am using a 9865 chip on it but in the form of a shield. Facilitates easier installation. I think you can daisy chain over 60 boards. But I would go without a shield if I needed more than 16, because the outputs of the servos come from the top of the shield so stacking them would be problematic.

I thought of using only two switches on the 3-way and treating it as two turnouts but thought the three switches will ease operations with point and go perspective as opposed to, hmmm, I need to go to the right track, so I need servo 8 and 9 diverging. Not even sure if that is correct as I’m writing it.

I was thinking of going the same route with the double slip but didn’t.

I have plenty of open digital inputs/outputs with the Mega and Shield so expansion isn’t an issue.

Regardless, it’s super easy to change in the sketch. Change a statement from ServoDirection(I, 1) to ToggleServo(I).
 
I'm curious if the servos return to the mid position after powering down and re-upping, or do they stay at the position they were in when powered down.
I would also like to get a look at your sketch when completed.
The servos stay where you left them.
 
Attached is the sketch I have put together.

I have enhanced the code to have the servos now go at a reduced speed. More prototypical. Also, I turn off the servos after the movement to eliminate buzzing servos.

What I have learned is and is readily apparent by the variables is that I didn’t take enough care is setting the physical location of the servos or pay enough attention to the construction of the servo brackets (i.e. off centre wire holes). I needed to do some extreme values to get them to work. They all work well with the exception of the double slip turnout. It works, but because of the angles of the piano wire, it is wearing the point throw bar where the wire goes through. Not something you want to happen on an expensive turnout.

Learn from my mistake and align the servos better.

Also, keep your servos to +/- 30 degrees at the most from top-center if possible, to prevent up and down movement of the piano wire through the turnouts throw bar. It can have quite a height extreme if you go to +/- 90 degrees.

Due to size, sketch in next post.
 
Last edited:
Here is the semi completed turnout control panel. Just stuck on with 2-way tape at the moment. Need to put the lines on for the track layout still and permanently mount it.

AC5EDFCF-2C9A-4694-9A86-3E96797B6356.jpeg


FE30DE63-0A5C-439E-B53B-E7204CA105ED.jpeg


I am thinking automotive pin striping at the moment. Any ideas?
 
I am thinking automotive pin striping at the moment. Any ideas?
Actually, yeah. There is available 'glow' fiber optic material of various diameters, that could be embedded in the surface of the control board which could be lighted to suit your needs; either for 'blocks' , routing, or occupancy.
I had toyed with the mounting technique you mentioned, but as I am mounting on foam, I will explore the possibility of mounting the servo/micro switch just below surface, and adjacent to the turnout points. If its a case of a x-over... well.... no reason the Arduino can't control two servos simultaneously....(he said, staring at the ceiling wistfully)
 
So the two way gorilla tape and gorilla duct tape is a bust holding the servo to the aluminum channel. The servos keep pulling away from the channel. So don’t use this method! It take weeks for them to fail, but that is too soon.

I am going the think about using epoxy to glue them together.

4FAB3E85-7D64-47D8-A255-9A3ED6FE5D12.jpeg
 
What if you used a hose clamp, then they would be replaceable if the servo went bad. it would defiantly hold it. Just thinking out loud here.

1540067750057.png
 
Got the zip ties installed and I think they may work. Also installed the two servos on the 3-way turnout. That was a little bit of a challenge getting the two piano wires through the throw bar holes. I mounted both servos on one aluminum channel which complicated the matter but I think will be better for longevity. All the turnouts on the layout have servos on them are now working.
 



Back
Top