Jump to content
 

Arduino based speed measurement


NinOz

Recommended Posts

First arduino project; a train speed measuring unit. 
 
Uses
* IR reflection as sensors but could equally use light sensors or IR transmission sensors (one each side of track),
* arduino pro mini as the CPU,
* 1602 LCD (16 characters and two lines for output, used in 4 bit parallel mode),
* 5V regulator module, 9V AC or DC supply
* bunch of hardware such as push buttons, stereo connectors, plastic case, and wire.
 
Most of the components were from China via e-bay and aliexpress, certainly speeds up construction and keeps the cost down.
 
post-19109-0-08713800-1430034773.jpg
Overview of the finished unit.
 
post-19109-0-17284400-1430035591.jpg
Rat's nest of wires.  Pro mini on left, LCD contrast pot and power distribution board in middle (home made), 5V regulator on the left (has about 5 sets of 5V output pins, the yellow block).  Red PCB on top is LCD board.
All held in place by dollups of low temperature hot glue.
 
post-19109-0-24123500-1430035593.jpg
Uses EEPROM CVs to store the scale, the distance between sensors and speed units.
Displays the saved values at startup.  If a cpu hasn't been used before the defaults will be -1.  There is a block of code (commented out) which can write default CVs to EEPROM but it is easier to bootup the unit and set desired units.
Measure the distance in mm between the sensors and enter value as below.  I used stereo connectors for my sensors (3 wires per sensor) but these must be inserted before powering the unit as there is the possibility of a short on insertion (minimised by selection of which wire connects where).  Probably not the best choice in hindsight.
 
post-19109-0-04382700-1430035589.jpg
Max values for each CV are set in code but a simple change and recompile will alter these however the defaults should cover most situations;  scale is set at a max 1:500, distance between detectors: max 2000mm and speed units (kph or mph).  Couldn't be bothered with allowing for imperial distance input.
CVs can be changed at any idle time using a few push buttons. Simply move the toggle switch to config position and each CV will be displayed sequentually for editing.  Pressing the <acc> button will step to next CV, <inc> or <dec> buttons will change values and any changes will be stored.  After stepping through the CVs move the toggle to the run position and ready to go.
 
post-19109-0-81860500-1430035587.jpg  post-19109-0-00753700-1430035586.jpg
                                  Sensor on                                                                                  Sensor off
Sensors:
The unit can work from either direction through the sensor gates. Sensors have a variable sensitivity set by the blue pot on the board.  I set this by turning pot until it triggers without anything in front of the sensor then backing off slightly until the sensor turns off.  This may require further adjustment if false triggering is found.
As supplied the LEDs were projecting out of the end of the boards but I cut them off and soldered to the stubs at right angles as can be seen in the picture.  BTW these are not the best IR boards but the better ones I have will be a little more difficult to change the LEDs by 90 degrees.
Sensors were mounted using velcro to some right angle plastic pieces, this allows height adjustment.  Tape, weights or BlueTac will be used for temporary anchoring of the mounts as the unit was made to be easily moveable.
Transmission sensors would be better as the reflection configuration is sometimes unreliable on where it triggers on an object.  The units I have could be easily converted to transmission configuration by unsoldering the TX LED and mounting on the other side of the track using a piece of U shaped plastic to make a tunnel gate.  Light sensors can be mounted as for the reflective ones or placed in a hole under the track.  Lots of options and variations available.  Light sensors are readily available in premade modules (about US$2 delivered).
 
post-19109-0-04706500-1430035595.jpg
Timing and Output:
Once the loco passes the first sensor, the screen clears and "Timing" will appear on the screen.  At this point the time of activation is recorded and further activation of this sensor is ignored.
When the loco passes the other sensor, time is recorded, the speed will be calculated and displayed until a sensor is triggered.  The sensor is checked to ensure loco has passed before the unit resets to timing mode (indicated by an "R" appearing on the far right of the first line of LCD).
 
IR_Speed_5.ino
 
Regards,
CFJ

Link to post
Share on other sites

  • 1 month later...

Hi NinOz

 

Thank you for your sketch. I have build and tested my version that uses a TFT touch screen. This was part of a larger project that includes a servo position

indicator for setting up switch positions on an Arduino servo decoder. I  have aso include a fuction decoder as well (but still needs work). This has indication

of the output states on the screen and 10 programmable address.

Thank once again for you sketch.

 

Alan

Link to post
Share on other sites

I have been using my speed measurer to check performance and setup the speed table on my DCC locos.  Sure makes it easier.

My test track is a simple loop of Kato track so I decided to add the ability to average a settable number of sequential readings.

Initially I also had a fairly fixed time interval before checking if the loco had exited the last gate.  Didn't work too well if the loco was moving quickly on the small loop as it couldn't reset before the loco passed the first gate.  So I have added a wait and check routine based on the measured speed of the loco.

 

New version attached.

IR_Speed_6.ino

Link to post
Share on other sites

 

This was part of a larger project that includes a servo position indicator for setting up switch positions on an Arduino servo decoder.

I  have also included a function decoder as well (but still needs work). This has indication of the output states on the screen and 10 programmable address.

 

Sounds interesting.

Description, pictures and code would be nice. :)

 

CFJ

Link to post
Share on other sites

Archived

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

×
×
  • Create New...