MRH

-06-p_26.jpg 

Share this:
  [a2a]  [facebook]  [twitter]  [email]

Please post any comments or questions you have here.

Reply 0
Bill Feairheller

Basic Speedometer

Will the speedometer and sketch work with just the Arduino, the two sensors, and the adafruit 4 digit Backpack without the sound and Digiten Digital totalizer?  This would be the "bare bones" unit, and only require 5 volts. 

Thanks for a response

Bill

Reply 0
Matt K crazyivan

Fantastic article. Could you

Fantastic article. Could you post a bill of materials for the project? It would be useful for this article, and any similar articles in the future.

Blue Ridge and Allegheny Railway - Still running steam after all these years.
Reply 0
Bill Feairheller

Parts List

The parts with info are shown on pages 28 and 29 and on the wiring schematic.  There is enough information to find them on the adafruit and ebay web sites.  

Bill

Reply 0
Bill Feairheller

Answered my own question

After looking at the sketch, the Digiten timer provides the total time between sensors to allow the calculation of the speed.  It is needed, but does not need to be displayed, unless you want to display the value.  So both 5 volts and 12 volts is needed to make the speedometer work.  The sketch provides a LOT of information that helps understand the system.  The only options in the parts list are the sound module and speaker.

The sketch also provides where additional information on the parts as well as the overall design can be found. Maybe some of this could have been in the article or at least indicated that the information was in the sketch. All in all, a good article.  The speedometer is on my to do list.

Bill

Reply 0
Bill Feairheller

Need some help

I have the parts to build the speedometer, but need some help to understand the sketch.

1. Does the sketch contain every thing needed to operate the speedometer?

2. Does the Adafruit MPH display or the Digiten Timer need to be setup to operate in this function?

3. What does it mean #include "Adafruit_GFX.h" and other six #include "Adafruit _xxxx statements?  How are these added if needed to operate the speedometer?  I understand most of the other statements in the sketch, but would not be able to do it from from the start.

I thank anyone who can help me understand what I need to do.

Two questions about an Arduino,  (1) Can you read back any sketch already on the unit, and (2) does a new sketch overwrite and remove any sketch already there? 

Bill

Reply 0
ACR_Forever

@Bill,

The include statements generally reference "include files" that can be downloaded from various sources.  They are usually easily located from within the Arduino development environment - see the help information about libraries.  I'm on the run, so perhaps if you need better guidance than that, someone else can help you.  If you want more help, message me off-list and I'll walk you through it, but it'll be tonight.

Blair

Reply 0
earlyrail

a couple answers

< < Two questions about an Arduino,  (1) Can you read back any sketch already on the unit, and (2) does a new < < sketch overwrite and remove any sketch already there

 

You cannot read back from the Arduino.  Any sketch downloaded will replace what is already there.

more info:  The Arduino programing compiles the information from the human readable form to bits and bytes that are the machine readable form.  These bits and bytes are sent to the Arduino.  To my knowedge, nobody has written a decompiler to go backward from bits and bytes to human eadable.

 

Howard Garner

Reply 0
Bill Feairheller

Thanks for the replies

Howard,

That is what I thought, but I didn't see it stated anywhere I could remember.  Thanks

Blair,

I thought that might be the case with the "include" statement.  Does that mean the all of the seven sketches need to be in the same folder as the speedometer sketch, so they can be added when he "include" statement appears?  That means that the sketch will not work as it stands unless the seven Adafruit sketches are available to be added 

Bill

 

Reply 0
barr_ceo

This kind of project has been

This kind of project has been on my "Wannado" list for some time. My requiremenrs are a bit different - the intention is to have a 2 track bi-directional "trap" with a single 4 line display,  completely embedded in a T-Trak module and powered by rechargeable battery(s), preferably either 9v or a couple of lithium 18650 cells.

I've looked into the programming, but have been frustrated by the fact that my failing vision is making it tedious to even attempt to learn programming the Arduino.

Before I go too deeply down this rabbit hole,I'm wondering if it's possible to :

1) make a rwo track version that will time and display speeds for trains entering the "traps" from either end, or

2) allow 2 Arduinos (probably Nanos...) to each use 2 lines of a single 4 line display if they can't handle the possibility of near- simultaneous triggering events in each direction. I know it's possible to use multiple displays, not so sure about having multiple sources for a single display.

Yeah, I know it could just be two completely independent systems.... but that's not the "elegant" solution. At this point, though, I'm about ready to sacrifice "elegance" on the altar of "Git-'er-done".

 

Read my Journal / Blog...

!BARR_LO.GIF Freelanced N scale Class I   Digitrax & JMRI

 NRail  T-Trak Standards  T-Trak Wiki    My T-Trak Wiki Pages

Reply 0
ACR_Forever

@Bill,

No

Quote:

Blair,

I thought that might be the case with the "include" statement.  Does that mean the all of the seven sketches need to be in the same folder as the speedometer sketch, so they can be added when he "include" statement appears?  That means that the sketch will not work as it stands unless the seven Adafruit sketches are available to be added 

You really must look at the help info in the Arduino environment, and learn a bit more about software development.  Libraries are downloaded, sure, but they are not project-specific, so are stored elsewhere.  Yes, the sketch requires those downloads to work.  Not sure why it's bothering you.  The presence of an include statement in a sketch indicates there's more under the hood than just the sketch content itself - it also usually means someone else has done a good bit of work to simplify the interface embedded in the included code, making it easier for the beginner to manage those first steps.

Hope that helps.

Blair

Reply 0
danw

Typo?

I believe there is a typo on page 4 of the article on Building an Arduino speedometer.  It states the detectors are spaced 47.5" apart, but looking at the pictures of the building they're located in, shouldn't the spacing ( paragraph 2) be 4.75"??

Dan Wilson

Reply 0
Geoff Bunza geoffb

Complete Arduino sketches and libraries

Hi,

I am getting messages from modelers regarding the sketches and libraries for this project. I assembled the article sketch and the libraries needed for your convenience here:  /sites/model-railroad-hobbyist.com/files/users/geoffbfiles/The%20Need%20for%20Speed.zip

The zip file has 4 folders for you:

Take the ModelRailroadSpeedometer folder and copy it into your ...\Documents\Arduino\  folder complete with contents.

Take the Adafruit-GFX-Library-master folder and the Adafruit_LED_Backpack-master folder  and the Adafruit_BusIO-master folder and copy it into your ...\Documents\Arduino\libraries  folder complete with contents.

and you should be good to go.

This is neither my project nor my code.

Have fun! 
Best regards,
Geoff Bunza

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 0
Ron Ventura Notace

Multiple Arduinos driving a single display

You could drive a single display from multiple Arduinos by getting the two Arduinos to talk to each other via I2C. I2C is a communication protocol built in to all Arduinos. It uses two wires between the Arduinos to communicate. One is set up as the “master” and the other the “slave”. The solution would be something like:

  • one of the Arduinos would have the display attached to it. Let’s call it the slave (doesn’t really matter)
  • Each Arduino would run the speedo code
  • As well as running speedo, and displaying its data, the slave would periodically check for a message from the master. This message would be the speed data from the master that should be displayed
  • The master would run speedo, gather the data, and send it to the slave over the I2C bus.

I’ve not done this myself, but the concept is reasonably simple. There are Arduino libraries (wires.h) to make this reasonably easy to implement, and plenty of examples in Google land. I’m sure Geoff Bunza could explain this much better than I have.

I’d rather have a dedicated display for each track, but that’s just a personal preference. Good luck with your project.

Ron Ventura

Melbourne, Australia

Reply 0
Weaver

My speedometer

I built a similar speedometer into the layout. The OLED display is used also as a billboard ( with different animations). When a train passes the trap, it shows for about 5 seconds the speed. The speed is recalculated into the prototype speed. ( here in kilometres per hour).

In this form it is also very useful to set the line speed on analog layout. 
 

Eugen

B4F3DEB.jpeg 

Reply 0
Weaver

Double track version

Hi 

yes you can do it. You have to modify the code. Here is one of the simplest solution.

You can use two pairs of sensors ( one pair for each track), and the code shall dissable the second pair, when the first is triggered.

Of course when both tracks are occupied simultaneosly the speedtrap will indicate the speed of the first train. 
You can use more complex display ( like my OLED) and indicate the speeds in different lines with additional text, like Eastbound or Westbound.

Eugen

Reply 0
barr_ceo

Dual Track

Thinking out loud a bit,,.

The more I look into this, the more I'm thinking it's going to be far easier to make two independent speedometers. This is going into an N scale T-Trak module (about the same size as a piece of printer paper) and a layout could be anything from about three by four feet to much, MUCH larger. For a small layout, it's possible the triggers would never be completely clear. On larger layouts, it might have several trains running on each track under DCC. 

As far as the actual text of the display, I want to show

"Track 1     Clear" or  "Track 1     WB"

(or EB, depending on which sensor was tripped first)

on one line, and then 

"Tracking..."  or  "37.5 MPH"  on the second line of the display

I only need a single display for each unit - the actual elapsed time is immaterial for my purposes - I only want to shpw the actual scale speed.

 

 

 

Read my Journal / Blog...

!BARR_LO.GIF Freelanced N scale Class I   Digitrax & JMRI

 NRail  T-Trak Standards  T-Trak Wiki    My T-Trak Wiki Pages

Reply 0
Reply