The pages on this site have been mainly concerned with software development. Other aspects such as the current drain have not been considered to be an issue. However, in this project the practical issues of having the servos successfully control the points were more elusive so it was considered a separate page documenting some of the issues would not go astray. For this project almost nothing worked on the first attempt.
Historically the model train layout fitted in a room 24m by 5m with various stations and activities occurring around the edge. There was some vacant space at one end where it was decided to construct an area known as a Coal Basin. This would include multiple sidings to grain silos, a wharf, a coal mine and as shown in the photo a cattle yard and a station. Associated with the station was a village.
Initially the electronics was proven away from the final layout with a microcontroller reading switches on a control panel and then driving selected servos to give the desired routes. For example, in the photo if the station is selected the three points shown, plus others not in photo would all be to the left. As noted, the electronics all worked on the bench but when the servos were asked to drive real loads there were major problems. With many interacting problems it was impossible to isolate and solve one problem at a time.
A major problem could be grouped under the title management. For this model railway group there was no such thing as management. In the past everyone did their own thing and there were few conflicts. With the Coal Basin there were modelers who were interested in laying out tracks, there were modelers who liked building scenery and there were modelers who were involved with the electronics. The result was there was much scenery in place before the electronics was ready. This meant from day one all the electronics was under the baseboard where it was almost impossible to work on. If doing this project again I would have the electronics on top where it can easily reached. When the design was proven the electronics can then either be moved under the baseboard or some scenery built around it. Some form of plan of attack should be also developed - That is when this is working do this, then when that is working do something else.
A major issue was that no-one had used servos to drive several points at once so no-one had any comprehension of how much current the servos would draw when they were switching especially if they were driven hard against their stops**. Sometimes this destroyed the servo but often caused subtle problems that were hard to identify. For example, the micro-controller and/or the servo driver might give intermittent results.
**An even when the electronics was thought to be up and running ballast was added to the track area about the points that jammed one point causing one servo to overheat and ultimately self-destruct.
The initial design used a one Amp regulator for the servo driver. This was changed to 2A buck regulator, but this alone did not resolve all the issues. In the project the worst-case scenario was simultaneously changing 6 points. The current surge involved caused the micro-controller to be reset. Resetting is not a minor glitch. With C++ used in this project, after every reset 12 copies of the servo object were generated so it was many seconds before the system is operational. Prior to upgrading the power supply, it was easiest to modify the software. To avoid multiple servos switching at the same time a 500mS delay was included in the servo object.
void Coal_Basin_Servo::do_servo(int dir){
if (dir == current_pos) return; //no change necessary
if (dir==LEFT) pwm.setPWM(_ch,0,RIGHT);
else pwm.setPWM(_ch,0,RIGHT);
delay(500);
}
With the model train layout this delay did not create any issues, but such a delay would not be acceptable with a robot where multiple arms have to be moved simultaneously.
The issue of a sudden surge of current was further addressed by making the servos change in small steps rather than the bang-bang approach. This also had the advantage of appearing more realistic.
void Coal_Basin_Servo::do_servo(int dir ){#define STEP 20 if (dir == current_pos) return; //no change necessary int tt; if (dir==LEFT){Serial.print(_left); Serial.print(" LEFT ");} else {Serial.print(_right); Serial.print(" RIGHT");} //debugging if (dir==LEFT) {if (_right < _left) {for (tt=_right;tt<_left;tt=tt+1) {pwm.setPWM(_ch,0,tt); delay(STEP); }} else {for (tt=_right;tt>_left;tt=tt-1) {pwm.setPWM(_ch,0,tt); delay(STEP);}}} else {if (_left < _right) {for (tt=_left;tt<_right;tt=tt+1) {pwm.setPWM(_ch,0,tt); delay(STEP);}} else {for (tt=_left;tt>_right;tt=tt-1) {pwm.setPWM(_ch,0,tt); delay(STEP);}}} current_pos = dir; delay(500);}Initially the Arduino NANO was powered through the USB port. This provided plenty of power to the circuitry (less the servos - their power was separate) but moving to the NANO's internal 5V, whose current capability was much less than the USB source removed most of the safety margin. Having the servos slowly step helped restore the safety margin.
When everything appeared to be working attempting to run a real, but faulty loco through the Coal Basin caused the electronics to reset due to the loco continually creating short circuits when transversing the points. While the desirable solution was to fix the loco and points there was always going to be a situation where there was a short circuit on the track, so the best solution was not to take power from the track but to use a separate power supply with plenty of grunt. Hence in the final product a 5V 3A battery power pack was used**.
**If starting the whole layout from scratch it would have been sensible to have a separate power bus from the start for all the electronic accessories.
With all the problems the servos were continually being unplugged and then re-plugged into the servo control board (PCA9685). Since the controller board was mounted under the baseboard removing/replacing the servo cables implied climbing under the baseboard for each change. The headers in the PCA9685 Servo Driver Board were packed closely together, and mistakes very frequently made with either the pins miss aligned or inserted into the wrong header. This was not helped by having the power PCA9685's LED shining in one's face while attempting to re-insert the servo cable. Initially short extension cables were "permanently" wired to the headers and the servos plugged in and out of the extension cable. Later these were replaced with an in-house I/O board whose main attribute was that the headers were replaced a significant distance apart.
No-one in the team had used servos previously so what could and could not be done was not appreciated. With 12 servos there was always going to be the situation where there would not be free space under the baseboard away from support members framework etc to mount the servos. This should have been rule number one when deciding on the layout; keep the location of the points well clear of any framework under the board (or vice versa).
For this project the servos were mounted in aluminum "U" tube which was squeezed to hold the servos in place. While in theory this appeared to be acceptable no one appreciated how much force the servos could generate and work themselves loose. A better solution was to use a proper servo mount, two types of which (horizontal and vertical) are shown below.
While it appeared that mounting the servo, inserting the arm, inserting the arm retaining screw and the driving rod for the point could be all done upside down under the baseboard this proved not to be the case and any number of the servo arm retaining screws were lost in the process.
The whole process is so fiddly/messy that before attempting to do it the first time a practice prototype should be made on a single piece of board that can be readily turned over. A possible development sequence will be: (Note one objective is to do as much as possible above the baseboard where everything can be easily got at.)
Since the driving wire for the point will be difficult to shape with the control arm in place before mounting the control arm bend and insert the driving wire into the control arm.
Centre the servo output either by applying a control PWM signal or rotating the shaft by hand until it is halfway between its two extremes.
Attach the servo arm and control wire as shown in the photo. (photo shows .64 wire). Do this on a clean work bench where if the retaining screw is dropped it will be easily found.
Mount the servo on its mount.
Decide on the location of the point and lightly tack it into position and, with its control arm/rod centered drill a guide hole in the baseboard.
Hand hold the servo in position under the baseboard and feed the control wire though the hole in the baseboard and the small hole in the point arm. Everything should be reasonably square.
Lightly tack the servo holder in place (BluTac is useful) and then drill holes for the 4 retaining screws of the servo holder. If reasonably confident of holding a drill vertical the holes for the retaining screws could be drilled through the base board from the top.
With the points and servo holder removed enlarge the hole in the baseboard. The hole must be large enough to cover the full swing of the servo. I used a 3/8th inch spade bit which was more than adequate.
Permanently mount the points in place.
Feed the control wire though the hole in the point arm, check that all is square and when satisfied screw the servo mounts firmly in place. (Ideally with the servo centered the points will also be centered. In practice they will probably be to one side.) Using BluTac might aid in inserting the screws.
In the software slowly increase the LEFT-RIGHT movement/timings of the points until the blades are in the desired positions. If the contact is too light trains may not take the turns and become de-railed. If the contact is too tight the servo will be still trying to close the point and will draw significant current. In extreme situations the servos could be destroyed**. If the final design consists of a number of servos, it might be worthwhile developing a small design that remotely can be used to determine the servo timings.
If it turns out the servo arm is not centered remove the whole servo and above the board remove the arm and rotate it a little in the desired direction. Then return/remount the servo. Do not attempt to remove the servo arm when the servo is mounted under the baseboard. At best its fiddly, at worst the retaining screw will be lost.
At this point the control or drive wire will be protruding well above the points. It should be snipped.
** This was the situation in the original project