Jump to content
 

Arduino as a decoder for an n gauge traverser


Recommended Posts

  • RMweb Gold
Having been inspired by threads started by Deev, Tender, El Davo and others, I have decided to attempt to devise a DCC accessory decoder to drive an N gauge Herkat traverser (transfer table) as I (and Herkat) have been unable to identify one which is available "off the shelf".
 
Fascinated by the Arduino concept and flush with the knowledge of programming ZX81s, C64s, Amigas etc. (a hundred years ago!), I have taken the plunge and bought an Arduino Uno R3.   To examine the motor possibilities I have bought an Arduino Motor Shield and an Uln2003 board to drive a stepper.
 
I have spent my leisure time in the last week trawling the internet for snippets of code ("sketches" in Arduino land), DCC libraries and DC Motor control software.   Previous authors on RMWeb have described electronic circuits to use an Arduino to interpret a DCC signal and react to it and this is where I will start.
 
I am currently waiting for the delivery of an optoisolator to complete the DCC signal circuit, but the fun will come when I then have to program the Arduino to move the transfer table to a certain position in response to a "switch thrown" command.   Deev's traverser uses a couple of stepper motors, Tender's turntable solution just one.   This is a possibility but, as the traverser currently works with a "normal" DC motor, I wonder if it may be possible to activate the normal motor for a measured time at a measure speed, thus moving the traverser a measured distance.
 
I accept that this may be defeated by inherent positioning and reaction issues within the motor, particularly in such a small scale, but this appears worthy of further consideration.
 
Another option is to fit a stepper motor, but that takes no cognisance of the existing drive motor and gearing (rack) along which the Herkat operates.   This may be where I come back to, but it is not where I want to start.
 
Finally, I could place a sensor at each point that I would like the traverser to stop (one entrance and six exits) and drive the traverser motor until it trips the desired sensor and stops the motor.
 
There are probably other methods too.
 
I've learned a lot this week, and am looking forward to developing something that works, even if it's not quite as I've described above..........
 
Last day off work tomorrow, so i hope the optoisolator arrives in the morning.........now whoever thought I'd ever type that :-)
 
Dave

 

Link to post
Share on other sites

 

This is a possibility but, as the traverser currently works with a "normal" DC motor, I wonder if it may be possible to activate the normal motor for a measured time at a measure speed, thus moving the traverser a measured distance.
 
I accept that this may be defeated by inherent positioning and reaction issues within the motor, particularly in such a small scale, but this appears worthy of further consideration.
 

 

Unfortunately, I suspect any attempt to do this by dead reckoning is doomed to failure. You may well be able to achieve a reasonably close correspondence on an single track-to-track movement, but accumulated errors over a number of such movements without any means of absolute position registration is likely to lead to continual misalignments within a short time.

About the only way you might make it work is to always 'visit' a reference position each time a move is made. That wouldn't look very prototypical though.

Link to post
Share on other sites

If you can ensure that each sensor is placed in exactly the same location for each traverser stopping position, then have the sensor circuit remove power from the "normal" DC drive motor and short the motor terminals together, you will get a dynamic braking action that will bring the motor to an immediate stop with little or no overshoot. That will definitely improve the accuracy of position indexing. I have used photocells positioned in the wall of the Peco turntable and an IR emitter mounted under the bridge, powered from the DCC power on the rails of the bridge. The photocells are mounted in a slot to allow them to be adjusted for accurate indexing.

You may want to consider a similar technique.

Link to post
Share on other sites

I reckon you will need a stepper motor to achieve the precision you need. Unfortunately the ULN2003 is a poor choice for driving stepper motors - it is more suited to DC motors.

 

A "proper" stepper motor driver board (such as a Pololu A4988) allows you to limit the max current in the stepper coils so that you can use a higher drive voltage for better performance and it allows you to use "microstepping" for much greater precision (but there is less torque in microstepping mode). Also the proper boards usually only need two connections to the Arduino for step and direction which makes the programming far simpler.

 

...R

Link to post
Share on other sites

Which type of driver device is most suitable depends more on the type of stepper motor you are using, i.e. whether it is unipolar or bipolar.

The A4988 is intended for use with bipolar motors, and the ULN device (i use the ULN2803A myself) is more suited for unipolar motors.

Link to post
Share on other sites

  • RMweb Gold
Apologies for the tardy expression of gratitude to those who have so helpfully replied to this topic, I have no access to the forum at work and tonight has been my first opportunity to respond/comment.

 

Thanks for the advice received to date

 

Gordon H - "Unfortunately, I suspect any attempt to do this by dead reckoning is doomed to failure."

Oh how right you were!   I was delighted to get the Arduino to respond to simple motor commands and spent a while basking in a glow of success that I had achieved anything at all!   However, as I had wondered and you had advised, there was a marked difference in how far the "normal" DC motor drove the traverser each time it ran for a set amount of time.   This experience has led to the removal of this solution from my original list above.

 

DigitalD - "If you can ensure that each sensor is placed in exactly the same location for each traverser stopping position, then have the sensor circuit remove power from the "normal" DC drive motor and short the motor terminals together, you will get a dynamic braking action that will bring the motor to an immediate stop with little or no overshoot. That will definitely improve the accuracy of position indexing."

 

I think this is the next option I am going to attempt......I have no sensors (other than reed switches), so am currently considering (and reading threads on RMWeb about...) whether Hall Effect or photocells would be my preferred option.   I have discovered how to stop or start things happening by using an Arduino and a reed switch though, so progress in theory even if the practical application will involve another type of sensor!

 

Robin2 - "I reckon you will need a stepper motor to achieve the precision you need. Unfortunately the ULN2003 is a poor choice for driving stepper motors - it is more suited to DC motors."

 

Thanks for the advice.   I bought the ULN2003 board and a small stepper motor simply to see how the Arduino worked with steppers.   I accept that any solution using a stepper motor would require a more appropriate motor shield/board/chip and a more powerful motor than I currently have (though I do have access to an Arduino motor shield for experimentation too).

 

Again though, there was delight in getting the stepper to work in its own right and actually to do what I wanted it to do.......all good learning.   

 

I am unsure yet how best to apply a stepper to drive a threaded rod mechanism and suspect either a flexible coupling "end to end" between the motor shaft and the traverser's threaded rod or removing the threaded rod mechanism altogether and drive the traverser with a cog and rack system as Deev had done with his big traverser?   More reflection required here.

 

I'm off to contemplate...............
Link to post
Share on other sites

Cornerman

 

Regarding the drive connection between motor and bridge deck, a photo of the traverser & its drive would help.

 

I do think that a stepper will be needed, but the option to have a sensor for each track may give sufficiently accurate positioning. The opto sensor I bought last Saturday might be ok, they're very small, cheap, and seem to give a decent signal. I think you'd want to mount each of your sensors on an adjustable sub-base so they can be individually calibrated.

 

Of course, you could have one sensor on the bridge, and the "other bits" on the well, but this implies flexible cabling, which looks likely to cause reliability problems sooner or later.

 

The other issue that you might face is that it might work going one way, and not work at all well going the other due to backlash in the drive.

 

Do have a look at Tender's thread about DCC controlled Peco turntables, which will hopefully help

 

Best

SD

Link to post
Share on other sites

  • RMweb Gold
Thanks for the help SimonD.......

 

This week I have managed to write a little sketch that drives the DC motor until its position "trips" a reed switch and stops all movement.   The reed switches are all I had that would work as sensors, and proved to be quite reliable.

 

Having been delighted to write the sketch (and watch it working), I have ordered some very small hall effect sensors that will fit more readily in the well of the traverser (or outside it if they are sensitive enough through the plastic....?).   Once they arrive, I should be able to have the traverser "working" in a rough and ready manner (on the dining room table :O  )

 

I have also been working with a bipolar stepper motor as an alternative and have managed to get it working on the arduino motor shield.   The motor came with a 4.95 mm spindle and is fitted with a mxl timing cog, so I need to find some mxl timing belts now to make a "rack" for this to run on.   The accuracy of the stepper motor in comparison to the old DC motor on the traverser is remarkable and is making me focus more favourably on its use.   This is fully in keeping with the advice received from SimonD and Robin2, but I have enjoyed proving them right !

 

Just developing the sketch now whilst waiting for the sensors to come.

 

Thanks for your continued interest.

 

(Photographs to come soon).

Link to post
Share on other sites

  • 2 weeks later...

If you are using threaded rod and a die nut concept to position the moving deck, you could count revolutions of the rod (or half revs, or a smaller fraction if needed for accuracy) using a proximity sensor and a steel target fixed to the rod.  To compensate for backlash in the mechanism the stop positions would be one or two counts different depending on the direction of approach.  Ideally use a square-form thread.

 

To get a small dc motor to dead-stop, use a changeover relay to short-circuit the windings in the 'off' position. Don't try this with anything but the smallest motors, or any system with a large flywheel effect as all the kinetic energy is dissipated in the motor windings.

 

Good luck!

Link to post
Share on other sites

  • 5 months later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...