Jump to content
 

Sensors for Track Alignment using an Arduino


BG John
 Share

Recommended Posts

Several of the layouts I'm building have multi track fiddle yard sector plates or traversers, that align with multiple tracks on the scenic part of the layout. Like this one:

post-7091-0-65305300-1493371986.jpg

 

Before I discovered Arduinos, I was going to control the DC electrics in a simple, but not very satisfactory, way with a 3-way switch to select the fiddle yard track to power, and have all the tracks in the scenic area live. The fiddle yard also represents the station throat, so there are few, if any, points in the scenic area, and as that means the operator will have to constantly switch tracks, I was planning to align it by eye and rely on friction to keep it in place, rather than messing around with locking it in place.

 

As a computer can work out, and switch, the tracks to power so easily, it seems logical to let it do it properly, but how can it detect which tracks are aligned? The above layout has three fiddle yard to four scenic tracks, but another layout has three and five, so 16 possible combinations.

 

I thought of using an LED in a tube for each fiddle yard track, aligning with a sensor in a tube on the scenic side, but that wouldn't show which fiddle yard track was aligned. The same setup using infrared LEDs could work though, with each sending a different signal. It would be useful if it also gave a visual indication of exact alignment.

 

Has anyone done this, and if so, how and did it work well? Or does anyone have any other suggestions?

Link to post
Share on other sites

How is the Sector-Plate being moved?

(Hand, Stepper, DC motor, etc)

 

 

Kev.

Hand. It would be quite difficult to motorise, although I might investigate that one day, preferably after I've done it to one designed to be motorised.

Link to post
Share on other sites

Using Hall sensors? By experience, they trigger with a magnetic field approx 10mm away, but narrowing the magnetic field may yield a better accuracy. Or use a pair or triple, where the magnetic field presence must overlap to accurately position the table. Attached is the data sheet of the TLE4905 Hall sensor, you need the unipolar type (TLE4905). These are perfect for use with the Arduino (and other micro-controllers), as they have open-collector outputs to GND, meaning that you don't need external pull-up resistors, just use the ones in the Arduino :good: The TLE4905 responds to a magnetic south pole only.

 

attachicon.gif153751-da-01-en-Hall-Sensor_TLE4905+35+45L.pdf

PS: the first 6 digits of the document name are the Conrad part number, but as you need a fair few, ordering in bulk via AliExpress is cheaper!

Interesting. I'm learning lots of useful new stuff! I can see how it could work with a one to many setup, but surely with many to many it would need two sensors, one on the scenic side, and one on the fiddle yard, for each track, and the magnets would interfere with each other.

Link to post
Share on other sites

When you say you are moving the table or sector plate by hand I wonder if you plan to align the rails by eye?

 

In that case you would not need great precision for the sensor as its only task is to decide whether A or B is aligned with X

 

...R

Link to post
Share on other sites

When you say you are moving the table or sector plate by hand I wonder if you plan to align the rails by eye?

 

In that case you would not need great precision for the sensor as its only task is to decide whether A or B is aligned with X

 

...R

I'm planning to align by eye, but it would be nice if the precise alignment could be indicated by an LED. One of the layouts is to P4 standards, so accurate alignment is quite important. If it was just an ordinary fiddle yard, I could lock it in place, but as it also represents one end of the run round loop, and the entrance to all the sidings, it will be moved a lot, so manually locking and unlocking it would get very irritating. Accurate alignment would mean I could add an automatic and fast acting servo controlled lock if necessary.

Link to post
Share on other sites

You'll need to build in some hysteresis, or tolerance to whatever system you chose, if you are using it to switch track current, since if too precise, then the slightest movement would disconnect. Personally, I'd keep it simple, use snap action micro-switches, say those with a lever/roller, and adjust the hysteresis by varying the width over the parts that said rollers rub on, or amount that lever is pushed.

 

If you really want something fancy, then pull apart a cheap optical mouse, or use it' standard usb interface, and the resolution of those will be 300dpi, or 600 if needed. A simple piece of code can count the pulses..

Edited by raymw
Link to post
Share on other sites

but it would be nice if the precise alignment could be indicated by an LED.

That is probably not an easy thing to do.

 

I built an Arduino controlled train turntable for N Gauge and I used a physical stop to ensure precise alignment. The physical stop was an aluminium arm that made contact with a piece of aluminium angle on the turntable and completed a circuit that told the Arduino to stop the motor. The aluminium arm was attached to a servo so it could be lifted out of the way to allow the turntable to move on to the next position. Of course this would all be totally impractical on the viewable part of a layout unless the "arm" system could be made very discreet.

 

One option I am thinking of is to use a microswitch with a roller that drops into a groove on the edge of the turntable when the correct alignment is reached. The spring of the roller arm would be part of the alignment process.

 

I guess you could put a strip of paper around the circumference of the table with printed (or painted) marks that could be detected by a reflective optical sensor. Or use a slotted optical switch with some tabs that interrupt the beam. But the problem with that is to get the motor (or your hand) to stop the turntable very precisely (+/- 0.25mm perhaps) at that point. I suspect some sort of physical stop is pretty much essential.

 

Using a stepper motor to rotate the table would probably work but I think you would need to lay the tracks at the positions that are natural for the motor.

 

...R

Link to post
Share on other sites

For your turntable, use a stepper motor, and simple gearing to give the resolution you need. Use a micro switch to give a home position, and count pulses from there to rotate to the exact positions you want. The gearing could be a simple worm drive, you only need to rotate the turntable fairly slowly, and you needn't bother with micro-stepping drivers. If you had only a few track alignment positions needed, then they could be selected by push-buttons, (or probe to a panel) and simply read in to the pio, or if more use a diode array, or resistors and the ad inputs. The worm drive would negate the need for locking in the track alignment or the need to lay said tracks in any particular configuration. If you have no access to a lathe, you can easily make a worm and plastic worm wheel, with a suitable gashed  bolt in an electric drill cutting its wheel in a disc of nylon. If you can program a pic or arduino the software is trivial. You can get good enough stepper drivers (up to a couple of amps) for less than a fiver on ebay (inputs being direction and step pulses).

 

My assumption was that BG John was wanting to manually align/operate his system, just needing confirmation of alignment and current switching, but a stepper/etc. as I've described could be more automatic for a sector plate, as well as for a turntable.

Link to post
Share on other sites

I thought this might be complicated, and the experts are coming up with more complicated ideas than I did, so I think I need to simplify my ambitions! I need to have a think about it, and maybe use my original simple but not ideal manual solution to start with. Then perhaps look at this again later.

Link to post
Share on other sites

For your turntable, use a stepper motor, and simple gearing to give the resolution you need. Use a micro switch to give a home position, and count pulses from there to rotate to the exact positions you want. The gearing could be a simple worm drive, you only need to rotate the turntable fairly slowly, and you needn't bother with micro-stepping drivers. If you had only a few track alignment positions needed, then they could be selected by push-buttons, (or probe to a panel) and simply read in to the pio, or if more use a diode array, or resistors and the ad inputs. The worm drive would negate the need for locking in the track alignment or the need to lay said tracks in any particular configuration. If you have no access to a lathe, you can easily make a worm and plastic worm wheel, with a suitable gashed  bolt in an electric drill cutting its wheel in a disc of nylon. If you can program a pic or arduino the software is trivial. You can get good enough stepper drivers (up to a couple of amps) for less than a fiver on ebay (inputs being direction and step pulses).

 

My assumption was that BG John was wanting to manually align/operate his system, just needing confirmation of alignment and current switching, but a stepper/etc. as I've described could be more automatic for a sector plate, as well as for a turntable.

I've got sector plates on two layouts, and a traverser on another. The layout with the traverser is O gauge, so quite easy to align by eye, but the two sector plates are EM and P4 (broad and standard mixed gauge). They were designed for hand operation. One layout is on a door that I don't really want to cut into, and the other on a baseboard that has been rebuilt and extended, and I don't want to weaken by cutting into. I'm tempted to try building a motorised fiddle yard on the next layout.

 

As I said in my last post, I think I'll come back to this later. I'll concentrate on using Arduinos for operating the rest of the layout first.

 

If anyone has more suggestions, I'd like to see them, and thanks for all the suggestions so far.

Link to post
Share on other sites

Hi BG John,

 

It's not complicated at all, as I said in my first post, you won't get simpler, or more reliable, than by using micro-switches, easier, than fiddling with magnets, photo cells in tubes/whatever, if all you want is to light up an LED for alignment or track current switching. If I've made it seem complicated by using words like 'hysteresis', then ignore that, unless later on you find that you can't get the precision you thought you might get.

 

My second post was referring to Robin's turntable, and I had noted that I thought your requirement was less complex than that.

 

I've no idea what other suggestions you want concerning what?

Edited by raymw
Link to post
Share on other sites

I think fitting the components in may be complicated, due to the limited space. The idea is simple enough. The layout in the photo has quite a lot more space between tracks than the other one. Anyway, I'll have a look at it, and see what I can do.

 

I've no idea what other suggestions there might be, but someone may come up with another bright idea :).

Link to post
Share on other sites

Can I suggest that a mechanical system may be best for this as the sector plate is to be moved by hand and you are after an indicator that the track is in perfect alinement. Rather than trust the indicator it is best to have a mechanical system that is accurate, and then the indicator just confirms the action.

 

I have used in the past a "V" blade that is sprung downwards to run on a rail that has adjustable V gates that match the V, into which the V drops when in exact alignment. Such an arrangement has no play in it, you line up each track on building, and adjust the V notch once to get the track to line up.

 

The Sector plate has a solonoid on it that raises the V edge upward, from a single button that is used to move the sector plate by eye to very near the correct alignment and than turn of at which point the V knife edge pulls the sector plate into alinement.

 

Each area of the "Rail" that passes the particular track has half sawn way, and a bolt on section with the V notch added, allowing the bolt on piece to be moved to adjust via elongated holes.

 

The action of the V dropping into place can switch an indicator to show that the track is exactly in line, a single micro switch would do this.

 

I have used this system on sector plates and turntables, the main point being the extreme accuracy of lining up the track. The scheme can be automated totally of course. But at the heart of it are the V gates that give accuracy to lining up the track.

 

Stephen.

Link to post
Share on other sites

Why not use an ultrasonic module to measure the distance from a fixed point on the base board to a plate on the fiddle yard?

 

Looking at your original photo if the sensor was mounted off the picture but aimed at the L shaped aluminum bits it should be able to work out which track is lined up.

 

http://www.ebay.co.uk/itm/2-X-Ultrasonic-Module-HC-SR04-Distance-Range-Measuring-Transducer-Sensor-Arduino-/262512802366?hash=item3d1efb7a3e:g:W1wAAOSwZ1BXfPmm

Link to post
Share on other sites

Can I suggest that a mechanical system may be best for this as the sector plate is to be moved by hand and you are after an indicator that the track is in perfect alinement. Rather than trust the indicator it is best to have a mechanical system that is accurate, and then the indicator just confirms the action.

 

I have used in the past a "V" blade that is sprung downwards to run on a rail that has adjustable V gates that match the V, into which the V drops when in exact alignment. Such an arrangement has no play in it, you line up each track on building, and adjust the V notch once to get the track to line up

 

..........

I've been thinking more along those lines. I may have got a bit carried away wanting to use Arduinos for everything!

Link to post
Share on other sites

Why not use an ultrasonic module to measure the distance from a fixed point on the base board to a plate on the fiddle yard?

 

Looking at your original photo if the sensor was mounted off the picture but aimed at the L shaped aluminum bits it should be able to work out which track is lined up.

 

http://www.ebay.co.uk/itm/2-X-Ultrasonic-Module-HC-SR04-Distance-Range-Measuring-Transducer-Sensor-Arduino-/262512802366?hash=item3d1efb7a3e:g:W1wAAOSwZ1BXfPmm

Interesting idea. I've got one of those, so could try it. If it works it could be the simplest option, as I'd only need one of them. Maybe something to try combined with Stephen's suggestion of V notches for accurate alignment. Absolute accuracy in the measurements wouldn't be needed for switching, as long as every position gave a different, and fairly consistent, reading.

Link to post
Share on other sites

I reckon the V system from Reply #17 has a lot going for it. The lever-roller type of a microswitch could be used in a similar fashion.

 

I don't think you would get sufficient accuracy with ultrasonics - but, much more importantly - the sound won't physically hold the tracks in alignment.

 

...R

Link to post
Share on other sites

I reckon the V system from Reply #17 has a lot going for it. The lever-roller type of a microswitch could be used in a similar fashion.

 

I don't think you would get sufficient accuracy with ultrasonics - but, much more importantly - the sound won't physically hold the tracks in alignment.

 

...R

The original plan was that they stay in alignment with friction. The sector plates are just stiff enough to do that, while being easy to move. The O gauge layout with the traverser works quite nicely like that too. Something like the V system would make something adequate rather better.

 

I can try the ultrasonics, as it's the only suggestion I've got all the bits for. If it works, it's a nice easy solution. If it doesn't, I've learned how to use the sensor!

Link to post
Share on other sites

It is not just the V notch, it is getting the mechanics to come first, then automate as desired. The V blade can be manually raised or by a solonoid or by a servo from the micro PC. The fact it is down and in register gives a positive position to run an indicator from.

If fiction along is used the a roller tip of a microswitch can run over a V notch and give the indication required and aid setting.

But a free running one would be better as the notch pulls the track into exact alignment as it operates.

 

Stephen

Link to post
Share on other sites

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
 Share

×
×
  • Create New...