Hi gents, I've open this topic and deleted my long message from here to don't Hijack the original.
https://www.therailwire.net/forum/index.php?topic=34250--------------------------------------------------------------------------------------------------------------------------------------
The Micro used is this:
http://www.ebay.com/itm/5PCS-USB-Nano-V3-0-ATmega328-16M-5V-Micro-controller-CH340G-board-For-Arduino-A-/201152975734?ssPageName=ADME:L:OU:IT:3160Speedometer:
The idea was to be familiar with this game and start KISS. So, before decide where in the Layout, I plan for a "portable" one ( that can be used also on our modular Fremo meetings?).
Mechanically will be based on a plastic bar that holds two of this IR sensor at the ends :
http://www.ebay.com/itm/Infrared-reflective-Photoelectric-Switch-IR-Barrier-Line-Track-sensor-TCRT5000L-/310536079942?ssPageName=ADME:L:OU:IT:3160I've order also some spare TCRT5000 sensors (in case it works) to install somewhere along the tracks in future.
If these sensors demonstrate not enough sensible at reasonable distance ... I've order also a couple of :
http://www.ebay.com/itm/Smart-car-Obstacle-avoidance-Infrared-Sensor-module-Reflective-photoelectric-/400494756580?ssPageName=ADME:L:OU:IT:3160The "brain" can be positioned on fascia (cab or cards holders?).
Project parts are :
- 1 Arduino Nano
- 2 IR sensors boards
- 1 2x20 char LCD
http://www.ebay.com/itm/IIC-I2C-TWI-SP-I-Serial-Interface1602-16X2-Character-LCD-Module-Display-Blue-/310565065847?ssPageName=ADME:L:OU:IT:3160+ 1 .... sound voice generator card as option .... to warn the operators !
http://www.ebay.com/itm/ISD1820-Sound-Voice-Recording-Playback-Module-With-Mic-Sound-Audio-Loudspeaker-/200958077647?ssPageName=ADME:L:OU:IT:3160Parts cost (more or less!
) :
Arduino = $4.
2x IR sensor interface = $3.
LCD = $5,
Audio board ( option) $3.
------------------------------------
TOTAL = $15
To clock the interrupt, as the Arduino's internal timer is not totally reliable,
I try the PWM analog output wired directly to the interrupt pin 2. The analog PWM outputs did have a very steady square wave of
490Hz. The duty cycle is determined by the value written to the analog pin. (i.e. - 0 is zero volts, 127 is a 50% duty cycle, 255 is a logic high/5V).
Also I will limit max time measurement between 2 sensors to 60 seconds and unit is "hardware configured" to measure the train’s speed over 1/50 or 1/100 ( jumper selectable) of a scale mile (or Km) both displayed on LCD.
Means you need to install the 2 IR sensor at a specific distance (depending on Scale and resolution wanted)
The sensor spacing for N and HO is listed here:
Scale - Scale mile (inch) - 1/50 mile - 1/100 mile
N 396.000 7.920 3.960
HO 728.276 14.566 7.283
scale - Scale Km(cm) - 1/50 km (cm) - 1/100 Km (cm)
N 625.00 12.50 6.25
HO 1149.43 22.99 11.49
For example, in N scale if you use the 1/100 scale mile interval, you need to place the sensors 3.96 inches apart.
If your particular scale is not listed you need to calculate the proper interval by dividing 63360 (the number of inches in a mile) by your scale’s ratio, and then dividing that result by the interval chosen (50, 100).
The accuracy of the unit depends upon how precisely the sensors are spaced.
Sensor spacing errors can be minimized by choosing the longest spacing that is practical for your layout and scale
Also, IR sensors use available ambient light. Mounting them in tunnels or dark corners of the layout is not working. It is best to pick a well lit section of the layout where the light source comes from above and ‘inside’ the layout. If the light source is ‘outside’ the layout a person walking by may trigger the unit.
(these info are from TCS TrainSpeed device)
Speed calculation is simple:
for example if sensors are installed at 1/100 scale miles:
10 / (time in secs ) ) x 3,6 = Km/h
Km/h x 1,6093 = Miles / h
PS- to have a better speed resolution display my interrupt routine counts 1/10 of second in place of seconds.
When Arduino Nano will land here... I will follow with pictures of cards and listing of software.