Model Railway Turntable

I'm trying to make an Arduino turntable with a DS3218MG servo and a AMT102-V rotary encoder.

How would I control the servo speed? It needs to be a set speed, able to be tweaked in code till it looks right.

Could you use PWM, or a delay between each "degree" of rotation?

I also need to have a full 360 degrees of rotation, some sources seem to mention 360 for the DS3218MG, others suggest 270 - maybe a stepper motor with super fine steps (1 degree or less - microstepping???) is better?

Servo datasheet:

Rotary encoder datasheet:

Take a look at the Servo Sweep example

As for 360 degree rotation, most servos are restricted to 180 degrees or less. There are special servos, often used for sail winches, that can rotate more than 180 degrees but they will be expensive. They also still have a limited rotation range so if your turntable needs to move by any angle from any position they will not be suitable

Do not try to use a servo described as "continuous rotation servo" as you can only control speed and direction and not its angle. You could get round this by using sensors to detect when the turntable is at the required angle but how complicated do you want to make this ?

All in all a stepper motor sounds like a better solution

1 Like

That is a good point. Stepper motor it is.

This is what the rotary encoder is for.

Phew, that has a lot of steps!!!!!

I suppose the next thing is what Stepper motor controller I use.

Those look good. Any thoughts? Looks like there is a library for them at least.

Hi @outbackhut ,

there are several libraries available ...

You may have a look at this one:

https://github.com/MicroBahner/MobaTools

It is a comprehensive library and well documented. The developer is an active member of this forum and usually provides support when needed.

Good luck and have fun!
ec2021

P.S.: Just found a library based on MobaTools to control turntables ... Even if you don't like to use a complete library it may be of interest for you ...

https://github.com/Hardi-St/MobaLedLib_Turntable/tree/main

Does that motor have enough torque?

Yes @MicroBahner is a very helpful member.

I don't specifically need a library for model trains, I have very specific design constraints for this turntable due to it being a drop in replacement for an old one. (constraints such as speed of rotation and preset points for rotating to)
But I'll have a look, might be perfect!

Good point actually. I have estimated I need 1.5Nm, that stepper is only:

In-traction Torque >34.3mN.m(120Hz)
Self-positioning Torque >34.3mN.m
Friction torque 600-1200 gf.cm
Pull in torque 300 gf.cm

If I use a stepper, I shouldn't need the rotary encoder, should I?

You might not need it but it could be useful in case the stepper misses steps

1 Like

Drop the encoder, use a stepper and microstepping. Use a home switch to calibrate the stepper position at start up. Then keep track of the position in the software.
Run tests to find the position of connecting tracks.

2 Likes

This is very interesting actually.

Would you have to calibrate it every time you start? Could you do an automatic calibration somehow?

The less user input the better, it is for a older gentleman, the simpler the better.

How would you do this though? You would need a sensor at each track location to identify it's position wouldn't you?

How will it know where it is at power up, especially considering the user may move it when not powered? So, it must 'find home' every time you turn it on. Then, it can use pre-determined pulse counts to arrive at any track relative to the home position.

Even if it isn't automatic, how would it know that?

So what you are saying is that you have to tell it where home is at every power up. Or move it to "home" before powering it up, and then no calibration required. What's easier?

If you kept the rotary encoder, it could still be automatic with no user input, yes?

That would depend on whether the encoder is absolute, or incremental.

I'm guessing incremental won't work for that, only absolute.

Hi,
If you use incremental, each time you power up you will need to do a "homing" procedure of the turntable.

Tom.. :smiley: :+1: :coffee: :australia:

2 Likes

The whole concept seems quite problematic.
What is the width of the track rail?
What kind of precision would you need for the given size of the turntable to make sure the tracks align?

There are several things to consider. Can your turntable turn endless? This depends mainly on how the electrical connections to the rotating track are inplemented.
If so you only need a home switch that can be moved over ( could also be a light barrier). When powering up, move the turntabel until the limit switch is activated. Now you know the position and this is your reference point.
You need to know how many steps to be taken from the reference point to all connecting tracks. This can be determined, for example, with a small test software that is loaded onto the Arduino just for this purpose ( or implementing a special 'manual mode' of the turntable sketch ).

In any case I would recommend a gear to get the precision needed to position the track exactly. Another possibility is a toothed beltdrive. A gear usually has a backlash which must be considered when turning CW or CCW.
Only using microstepping will not be sufficent, because microstep positions are much less accurate then full step position. Microstepping is only usefull to move the stepper more quiet.
It is best to drive the turntable via a sprocket on the outer circumference. Whether this is possible depends, of course, on the mechanical design of the turntable.

1 Like

Yes. Start by running until the home switch is reached. Then the logic know the position.

Make a test code making one step at the time and a serial.print of the position.
Use Your eye as sensor.
Note the positions for the tracks and #define their values in the code.

1 Like

Can you tell a bit more about this? Will only the motor or the entire turntable be replaced?

Yes, that bit is fairly easy.

"yes". Except that is only partly yes. It needs to be able to turn 360 degrees from 0 in both directions - 360 degrees CW, and 360 degrees CCW

Could do a laser?? that shines onto a LDR through a tiny hole in a solid object as the "switch". A physical switch will be in the way.

I didn't realise that. That's good to know.

Could I use the light "switch" idea with one at each position? I'd have to use a motor that is "braked" though, as momentum would cause issues otherwise.

I can't argue with that. But the existing turnatble has a motor mounted via a toothed belt to the centre. I don't like that because if the belt is tight enough that is doesn't slip, it breaks frequently. Any looser, and it slips all the time.

The turntable itself is good, the existing controller is super dodgy and keeps breaking. So I'm wanting to just change that. Happy to alter things where needed, but I'm not wanting to building a whole brand new turntable.

There are four tracks feeding into the turntable—one on the western side and three on the eastern side, which lead to a loco storage shed. We need to move trains between the western track and any of the eastern tracks, as well as turn a train around from the western track back to the western track.

I'll try and get some photos when I can.