IR Speed Detector for model railway

Thread Starter

flashman99

Joined Mar 10, 2016
35
An optical accellerometer using a pair of photo-diodes/LDRs whereby a suspended shutter causes more light to fall on one than the other when subject to lateral G. The output could feed a window comparator (to provide a mid/neutral deadband) driving an H-bridge, driving a DC motor to tilt the train.

Basically, an adaptation of this old (copied from Elektor) solar tracker circuit:
http://www.homemade-circuits.com/2011/12/how-to-build-dual-solar-tracker-system.html
Thanks, I'll have a look at this.
 

Thread Starter

flashman99

Joined Mar 10, 2016
35
A 3-axis analog-output accelerometer is also available for $2 from a Chinese seller on eBay (almost 800 units sold).

http://www.ebay.com/itm/GY-61-ADXL3...625144?hash=item2ee36641b8:g:uPoAAOSwoudW3RrJ

Looks easy to use. In theory, you would only need one channel plus a pair of power wires of you use the eBay board. If You buy the bare chip, a smaller assembly is possible but you would need some type of board to be fabricated.

https://www.sparkfun.com/datasheets/Components/SMD/adxl335.pdf
It's astonishing how cheap electronics kit is these days.
 

Alec_t

Joined Sep 17, 2013
15,121
I don't think speed is the important parameter: lateral acceleration is. Ways of detecting/measuring that have been suggested above.
If you sense speed, then to get a realistic tilt you also have to sense the curve direction, the curve radius and the point at which the curve is entered.
 

bertz

Joined Nov 11, 2013
327
So using a more complex method to determine speed is preferable if I can tell you where you are?

How about a simple speed input combined with some sort of simple position info, like a light shining up thru the tracks? (you can make the light IR so it is invisible and not violate the principle of KISS)
The attached circuit will accomplish what Ernie suggests. IC1 generates a 1 kHz square wave on pin C.2 and is fed to one input of AND gate U1. A pair of IR LEDs are placed 1 cm apart between the ties. When the train passes over the LEDs, Q1 conducts and sends a pulse to pin C.3 of IC1. The first pulse makes C.1 go high and sends a stream of 1 kHz pulses to C.4. The second pulse makes C.1 go low and stops the pulse stream. IC1 counts the number of pulses in the interval and stores them in a byte variable (b0). The number of pulses stored determines the speed of the train. For example: 2 m/sec = 50 pulses, 3 m/sec = 33 pulses.

What the OP hasn't told us is what mechanism is tilting the train and whether or not track voltage varies (DCC).

Model RR Tilt control.jpg
 
Thanks, I'll have a look at this.
Rather than the opto-mechanical method of G sensing I referred to, combine this circuit concept with the accelerometer that GopherT linked to. This should result in a very simple and responsive system without the damping problems associated with a pendulum based sensor.
 

bertz

Joined Nov 11, 2013
327
Rather than the opto-mechanical method of G sensing I referred to, combine this circuit concept with the accelerometer that GopherT linked to. This should result in a very simple and responsive system without the damping problems associated with a pendulum based sensor.
Indeed, an accelerometer to determine orientation going into a curve and IR LEDs to determine velocity. This is a perfect application for an Arduino, but.......

OO scale (popular in the UK) is very close to HO scale that I am more familiar with. And there is the rub. We are trying to cram 1 kg of excrement into a 100 gram container. A typical HO car or locomotive is roughly 51 mm high x 38 mm wide. OO gauge is slightly larger. An Arduino board measures 71 mm x 53 mm. Now add a shield for the accelerometer breakout board, and you can see where this is going. On the positive side, the APT and Pendolino vehicles were quite long, so that lends itself to long custom PC boards. That is why I selected the more clunky Picaxe system over Arduino. Adding the accelerometer also adds a requirement for a 3.3 volt on-board regulator.

Have a look at the attached for some ideas on tilting.
 

Attachments

crutschow

Joined Mar 14, 2008
38,537
Indeed, an accelerometer to determine orientation going into a curve and IR LEDs to determine velocity. This is a perfect application for an Arduino, but.......
You misunderstand the accelerometer use here.
The accelerometer is used in a feedback loop to adjust the tilt so that the horizontal G-force stays near zero.
With that technique there's no need to know orientation, location, or speed.
And, since the output of the referenced accelerometers are analog, I think it can be done without a microprocessor.
 

bertz

Joined Nov 11, 2013
327
You misunderstand the accelerometer use here.
The accelerometer is used in a feedback loop to adjust the tilt so that the horizontal G-force stays near zero.
With that technique there's no need to know orientation, location, or speed.
And, since the output of the referenced accelerometers are analog, I think it can be done without a microprocessor.
I like it! However if it was me I would still opt for a micro-processor solution. I would take the accelerometer outputs into the Arduino Pro-Mini and use a PWM output to drive a micro servo which would be the tilter. Also required is a filtered and regulated dual voltage power supply.
https://www.sparkfun.com/products/11113
http://embedded-lab.com/blog/multi-purpose-dual-power-supply-5-0v-and-3-3v-regulator-board
Very little wiring required, mostly mechanical work to rig the tilt mechanism.
 

Marcus2012

Joined Feb 22, 2015
425
I love this sound of this project :) My Dad loves his OO gauge but he's mainly steam. As I recall the original APT never worked properly due to technical limitations. But it did look awesome :) And as I understand it (from dad) they tried to use master and slave gyroscopes at the end of each carriage to set a tilting curve for the length of the entire train. I think this was applied to the Pendolinos and actually works now lol :) Could you install Inertial measuring units (combined gyros and accelerometers) in your carriages to feedback this information? I'm not sure how small these units are at the moment and if they are suitable for OO gauge but I'll have a look.
 

djsfantasi

Joined Apr 11, 2010
9,237
Indeed, an accelerometer to determine orientation going into a curve and IR LEDs to determine velocity. This is a perfect application for an Arduino, but.......

OO scale (popular in the UK) is very close to HO scale that I am more familiar with. And there is the rub. We are trying to cram 1 kg of excrement into a 100 gram container. A typical HO car or locomotive is roughly 51 mm high x 38 mm wide. OO gauge is slightly larger. An Arduino board measures 71 mm x 53 mm. Now add a shield for the accelerometer breakout board, and you can see where this is going. On the positive side, the APT and Pendolino vehicles were quite long, so that lends itself to long custom PC boards. That is why I selected the more clunky Picaxe system over Arduino. Adding the accelerometer also adds a requirement for a 3.3 volt on-board regulator.

Have a look at the attached for some ideas on tilting.
There are much smaller implementations of the Arduino. Unfirtunately, I am away from my laptop and can't remember the names unaided. My contribution is that they exist, in a size that fits within an HO boxcar...
 

Thread Starter

flashman99

Joined Mar 10, 2016
35
I don't think speed is the important parameter: lateral acceleration is. Ways of detecting/measuring that have been suggested above.
If you sense speed, then to get a realistic tilt you also have to sense the curve direction, the curve radius and the point at which the curve is entered.
The prototype APT-P in the 1970s picked up tilt parameters from a transmitter between the rails which told the loco when and how much to tilt.
 

Thread Starter

flashman99

Joined Mar 10, 2016
35
The attached circuit will accomplish what Ernie suggests. IC1 generates a 1 kHz square wave on pin C.2 and is fed to one input of AND gate U1. A pair of IR LEDs are placed 1 cm apart between the ties. When the train passes over the LEDs, Q1 conducts and sends a pulse to pin C.3 of IC1. The first pulse makes C.1 go high and sends a stream of 1 kHz pulses to C.4. The second pulse makes C.1 go low and stops the pulse stream. IC1 counts the number of pulses in the interval and stores them in a byte variable (b0). The number of pulses stored determines the speed of the train. For example: 2 m/sec = 50 pulses, 3 m/sec = 33 pulses.

What the OP hasn't told us is what mechanism is tilting the train and whether or not track voltage varies (DCC).

View attachment 102336
Micro servo motors to tilt the train and DC 12v at the moment but may want to go to DCC later.
 

Thread Starter

flashman99

Joined Mar 10, 2016
35
So does an analog or digital processor approach sound better to you?
Am I right in thinking the output from the accelerator board can go directly to the motors or do I need some interface? I like the simplicity of the analogue approach so I would probably try that first and see how it goes.
 

Thread Starter

flashman99

Joined Mar 10, 2016
35
I love this sound of this project :) My Dad loves his OO gauge but he's mainly steam. As I recall the original APT never worked properly due to technical limitations. But it did look awesome :) And as I understand it (from dad) they tried to use master and slave gyroscopes at the end of each carriage to set a tilting curve for the length of the entire train. I think this was applied to the Pendolinos and actually works now lol :) Could you install Inertial measuring units (combined gyros and accelerometers) in your carriages to feedback this information? I'm not sure how small these units are at the moment and if they are suitable for OO gauge but I'll have a look.
The original APT-P was actually very successful just before they axed the project! The initial teething problems were ironed out but the bad publicity and Thatcher's hatred of rail transport led to it's demise. The whole project cost something in the region of £40m compared to the French TGV, which needed new track to be laid and cost £600m! The engineers on the APT project were some of the best in the in the world and they managed to produce a train that was 30 years ahed of anything else in the world. The government sold the patents to Fiat and bought the Pendolino which uses APT technology. The technology is in use in the class 90s too but not the tilting bit.
 

Thread Starter

flashman99

Joined Mar 10, 2016
35
I love this sound of this project :) My Dad loves his OO gauge but he's mainly steam. As I recall the original APT never worked properly due to technical limitations. But it did look awesome :) And as I understand it (from dad) they tried to use master and slave gyroscopes at the end of each carriage to set a tilting curve for the length of the entire train. I think this was applied to the Pendolinos and actually works now lol :) Could you install Inertial measuring units (combined gyros and accelerometers) in your carriages to feedback this information? I'm not sure how small these units are at the moment and if they are suitable for OO gauge but I'll have a look.
Thanks
 

crutschow

Joined Mar 14, 2008
38,537
Am I right in thinking the output from the accelerator board can go directly to the motors or do I need some interface? I like the simplicity of the analogue approach so I would probably try that first and see how it goes.
The motors require high power so it will need a driver and perhaps some other signal conditioning to get the accelerometer low power output to power the motor at the proper level.
What type of motor are you considering?
 
Top