Jump to content
 
  • entries
    58
  • comments
    140
  • views
    35,172

Arduino's, DCC, Servos, Stepper Motors & Cranes


GWMark

758 views

For some time now I have been thinking about ways to make things other than the locomotives move on my layouts. Radio Control servos have become an accepted way to control the points and semaphore signals, but we could use them for more if we had a good way to integrate the proportional control of them into our control systems. So instead of just having something move between two positions we could make it move to any point we wanted.

 

It was with this idea in mind that I started playing around with ideas for how to get better control of servos. The obvious thing we all have is a speed control on our layouts to control the speed of our trains, so what if we could use that to control the position or speed of a servo. Given that I am a DCC person, the natural choice was a DCC decoder that instead of driving a motor could drive a servo. My first prototype was simply a decoder, based on an Arduino processor, that moved a single servo at the speed set by the throttle. This would allow me to position one servo to any point I wanted in its travel, setting a speed of zero would stop it. This was a good first step, but something like a crane would need more than one servo, it would be a pain, and a little expensive to have a decoder per servo. So the next step was to control multiple servos from one decoder. What I did was to write code for the decoder that would use a combination of a function and the throttle setting. Turn on function 0 and the first servo could be controlled by the throttle, turn on function 1 and you control the second servo. Turn on two functions together and you control two servos. Added to this I allowed the maximum travel to be defined, and the minimum time for that motion.

 

So now I had a way, via DCC CV's to define the two endpoints of the movement of a servo, expressed in degrees, and a time in seconds that it should take to move between those points if the throttle was set to full speed. This gave me what I wanted to control something like a crane with 3 servos for the rotation of the crane, the angle of the jib and the winding of the chain. The prototype decoder was shown to my local MERG area group, who liked the idea so much we ended up doing a couple of tutorial evenings during which about 20 of the members built the electronics and learnt how to program the servos and DCC library for the Arduino.

 

​Following on from this the idea of extending the decoder to also control stepper motors was introduced. In fact the motion obtainable from stepper motors was much better and smoother than the servos. I introduced the idea of either having the stepper motor run continuously or confining it to a number of steps in each direction, so that it behaved more like a servo. Next came the addition of lights to the decoder, so that we could put warning lights on our cranes. Until I ended up with a DCC decoder that could drive 3 servos, one stepper motor and 4 lights (with various effects). If anybody is interested the code for what I did is available on GitHub.

 

I have been working with one of the members of the local MERG group to automate an LGB cement mixer in G scale. He now has a cement mixer mounted on a wagon that drives up to you, with the mixer turning via a stepper motor, swings the delivery chute out towards you, using a servo. Turns on a warning light. It then reverses the direction of the mixer and dispenses Smarties down the delivery chute into the hands of the waiting admirers!

 

I also took the Arduino DCC decoder idea a slightly different way and created a decoder that could play sound effects, essentially a primitive sound decoder. The effects were recorded sounds files placed on a microSD card that was then inserted in the Arduino system. A particular function key would trigger the playing of a particular sound file. These effects could be adjusted to match the speed setting of the throttle, and hence give a synchronised chuffing effect. Nowhere near as good as a commercial sound decoder, much more a toy, but the bits for it cost me less than £10. It was more for my amusement than anything else, but it was fun to try.

 

This has been another diversion for me from building rolling stock, working on my layout or all those other projects I have started but not finished, but it has got me to learn a lot more about the DCC protocol, I now understand exactly what gets put on the rails and makes the locos move. Also I have something that is at least able to animate scenic items under the control of the same DCC handset that I drive the trains with. Plus I have enjoyed working on it, so does it matter that it has diverted me from other things - it's only a hobby after all!

 

​Maybe the thing that makes this an enduring hobby is that there are so many ways we can go, just because I am not good at painting a back scene or my weathering skills are a bit dodgy it does not mean I can not enjoy some other part of the hobby. Equally I like making locos, but if that's all I did I would probably get bored with it after a while. It makes you think, or at least it does me.

  • Like 3

0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...