Hi Jimmy! Great Video! One minor tweak / upgrade for a later version. If you tape the sensors to a ruler (fixed distance every time), you can throw a tiny bit of math on the Arduino and output the speed the loco is traveling in scale MPH!
Fantastic video, Jimmy. If I had seen this a couple years ago, I wouldn't have had to buy my scale speedometer. Grr... (Needless to say, I LOVE gravesclay's suggestion...) One suggestion (which will fix two minor issues): at the end of countdone, if you set countState back to ST_OFF, that will report the elapsed time ONCE, then return the Arduino to its original state (waiting for the first IR sensor). This eliminates the annoying flicker you mentioned (allowing you to remove the delay() statement), and it frees you from having to reset the Arduino to be ready for a second speed check.
This is a great tool and it's greatly customizable. My DCC system works in a way that you don't have to do speedmatching, it requires you to measure the time it takes to travel a given distance on a few different speedsteps and then just enter them in a table for each locomotive. Once you're done you can match any of your locomotives together they are going to be automatically moving with the same speed!
Hi Jimmy Just finished watching all your vids 3yrs of them IT TOOK ME DAYS good job I’m retired, I've learened so much Thankyou, Rog from Wales in the UK
Jimmy, I built this circuit, works a charm..however I wanted to put this on a bones PCB (bare bones Arduino, v2 by Chris Rye 2013, available from Oshpark) but has no reset. So, I used a reset function. At the very beginning of the sketch put in void(* resetFunc) (void) = 0; and at the end after delay (10000); put in resetFunc(); Works great. Sketch resets after 10 seconds. Enough time to record results.
This is great! Thanks for taking the time to make the video! I've been trying to figure out how to speed match my various locos and this is the answer!
I also do a lot of speed matching, for my locos and for other folks. I have a "test track" and I've done a permanent install of "speedometers" on my test layout. I use photoresistors rather than IR sensors as they are smaller and easier (at least for me) to imbed in the track. For speed matching I have two separate loops and each loop has two speedometers on it (yes, that is way overkill but was fun doing). I did find that the speed of the locos changes by a few scale mph between two speedometers on the same loop - due to not level track or where the speedometer is in relationship to the corner. Plus, I have both an LED to show "speed" and then a 5 line LCD where I show the previous speeds. I also spent a lot of time programming so that I can capture speed even if the engines are only about 6 inches apart and regardless of which direction they are going. Also, by sampling light levels during start up, the sensors work well in both bright light and low light situations. I found that the IR sensors were sometimes a bit faulty when getting direct light from the newer LED light bulbs. Anyway, this lets me set up my locos so that they all have the same top end end speed, mid speed and 20% speed. BUT, to finalize they speed, I put the two locos on (I use advanced consisting) and run them and using "Programming on the main" (POM), I do fine tune them as they chase each other around with the one that runs "slightly slower" in the rear.
You need a portable test track. It comes in handy for many things you want to do away from layout. It should have the ability to be extended for speed testing.
Hi Jimmy, If you don't mind one more suggestion, it would be really cool if when you run the second engine through the unit would calculate an adder for each of the three CVS to make it's speed match. For example if the 2nd engine were too fast, tell the user to subtract "X" from the CV. The user would have to run the engines thru three times, once slow, once mid pace, and once at a fast pace. Then the user would adjust the start voltage, mid voltage, or max speed. Just a thought. I was drinking "Bad Ass Coffee of Hawaii, Breakfast blend. And keeping with my theme I was using my "Big Ass Fans" coffee mug. (A promotional mug from the Big ass Fan Co ) Tony
@@DIYDigitalRailroad of course, if you add in the Arduino DCC library, you can then write the program that will do everything: prompt for the address of loco 1, prompt for the address of loco 2, run each loco past the sensors multiple times at various speeds, take the average of each loco's speeds, calculate the CVs and upload them to the locos.
This same setup could be configured to make a scale speed indicator. Change the math a bit and the time it takes to pass both sensors would indicate scale speed in MPH or KPH. Nice video.
Very nice Video, I plan on putting into practice as I have many locos to speed match! One thing that would be very helpful is to mount the sensors to something that will maintain the distance (like @gravesclay says below), since any movement of the sensors between locos will throw it all off.
Jimmy, this looks great. I've never used Arduino and only know about it through your channel. Using your parts list and instructions would this be suitable as a beginner project? I know less than nothing about code, and barely any more about electronics. Thanks for all your hard work!
I'm not Jimmy from @DIY and DIgital Railroad, but I think this would be an excellent beginner project if you're the kind of person who likes to just dive right into things. If you want a more gentle introduction, you can buy the Arduino Starter Kit which contains a variety of electronic components and other parts (including a breadboard and hookup wires), and several tutorial projects to get you familiar with the basics of the Arduino and the basics of the electronic components it uses. After you've gone through some of the tutorials, you'll find that building Jimmy's project will be a breeze. Either way, you are almost certainly going to have questions about compiling and uploading the program, and there are lots of very helpful Arduino forums out there to turn to. Be warned, though, that once you start with an Arduino you will find it very addictive!🤣
@@jimhyslop that's brilliant, thank you for the advice. I'll look into a starter set as it looks like there are a lot of other potential projects. It's amazing where this hobby takes you sometimes. Thanks again, Jim
Suggestion for your code. Rather than using delay to avoid flickering, how about going back to ST_OFF. It won't be update the display, and you'll get new readings without clicking the reset.
Thanks, Jimmy for this tutorial! I needed this as I needed to figure out how to speed match my locomotives and I am planning on using an Arduino to build a speedometer. Is there a way to connect the Arduino to JMRI to automate the speed matching? I am planning on building a separate test track just for this purpose.
Jimmy, basically what you've done is build a speedometer with an Arduino. Another way to do this is to buy a speedometer system, such as the Accutrak II, or Train Control Systems. The nice thing about these is that they are already calibrated in scale miles per hour.
You are exactly correct. I own an Accutrak II; they are currently retailing for about $70. The Arduino plus LCD screen plus IR sensors total about $38 (you don't need a breadboard if you're willing to do a little soldering) and you'll have 8 IR detectors left over. Add a $1 wooden ruler to mount the IR sensors (see gravesclay's coment) and you can report both milliseconds and scale speed.
The breadboard is divided into four sections: left to right, they are (1) two columns of + and GND. All holes in these two columns are connected to each other (but not to the other column), giving you a positive bus and a ground bus. (2) A field of holes which is five rows wide and thirty rows tall. Each of the five holes in the thirty rows are connected to the other holes in that row, but no other. (3) A second field of 5x30 connected in the same fashion. And (4) a second set of two columns for positive and ground buses. So hole a1 connects to holes b1, c1, d1 and e1, but no others. a1 does not connect (for example) to hole f1 or to hole a2. Once you understand this, it is easy to connect pin D3 on the Arduino to, say, hole a1. Then, you can connect any device you want to pin D3 by running a wire from that device to hole b1 (or c1 or d1 or e1).
I've done a Raspberry Pi based speedometer. Great for public shows, but rather expensive -- Pi 2, 7" screen. Seeing this I felt that I could use this as a basis for a smaller cheaper speedo. However one question/observation; the sensor you are using is digital not analog. Testing, I saw that it swings between an analog value of ~20 (low) and ~1020 (high). I tested it a digital and it works fine registering high to low transitions. Why set it as analog?
Hi Jimmy! Great Video! One minor tweak / upgrade for a later version. If you tape the sensors to a ruler (fixed distance every time), you can throw a tiny bit of math on the Arduino and output the speed the loco is traveling in scale MPH!
Great idea!
I would really like to see that done I think it would impress our friends more Seen a scale speed instead of random millisecond times
@@robbhalverson7725 Hold on, I ought to be able to publish a sketch shortly.
@@robertmyers5269 Hey Rob were you able to come up with something to show MPH?
@robertmyers5269 thanks for the reply. Not sure why I cant find it here but your sketch worked great.
Fantastic video, Jimmy. If I had seen this a couple years ago, I wouldn't have had to buy my scale speedometer. Grr... (Needless to say, I LOVE gravesclay's suggestion...)
One suggestion (which will fix two minor issues): at the end of countdone, if you set countState back to ST_OFF, that will report the elapsed time ONCE, then return the Arduino to its original state (waiting for the first IR sensor). This eliminates the annoying flicker you mentioned (allowing you to remove the delay() statement), and it frees you from having to reset the Arduino to be ready for a second speed check.
This suggestion would also allow you to take readings over several runs, and average them.
This is a great tool and it's greatly customizable.
My DCC system works in a way that you don't have to do speedmatching, it requires you to measure the time it takes to travel a given distance on a few different speedsteps and then just enter them in a table for each locomotive. Once you're done you can match any of your locomotives together they are going to be automatically moving with the same speed!
Hi Jimmy Just finished watching all your vids 3yrs of them IT TOOK ME DAYS good job I’m retired, I've learened so much Thankyou, Rog from Wales in the UK
Jimmy, I built this circuit, works a charm..however I wanted to put this on a bones PCB (bare bones Arduino, v2 by Chris Rye 2013, available from Oshpark) but has no reset. So, I used a reset function.
At the very beginning of the sketch put in void(* resetFunc) (void) = 0; and at the end after delay (10000); put in resetFunc();
Works great. Sketch resets after 10 seconds. Enough time to record results.
This is great! Thanks for taking the time to make the video! I've been trying to figure out how to speed match my various locos and this is the answer!
I also do a lot of speed matching, for my locos and for other folks. I have a "test track" and I've done a permanent install of "speedometers" on my test layout. I use photoresistors rather than IR sensors as they are smaller and easier (at least for me) to imbed in the track. For speed matching I have two separate loops and each loop has two speedometers on it (yes, that is way overkill but was fun doing). I did find that the speed of the locos changes by a few scale mph between two speedometers on the same loop - due to not level track or where the speedometer is in relationship to the corner.
Plus, I have both an LED to show "speed" and then a 5 line LCD where I show the previous speeds.
I also spent a lot of time programming so that I can capture speed even if the engines are only about 6 inches apart and regardless of which direction they are going. Also, by sampling light levels during start up, the sensors work well in both bright light and low light situations. I found that the IR sensors were sometimes a bit faulty when getting direct light from the newer LED light bulbs.
Anyway, this lets me set up my locos so that they all have the same top end end speed, mid speed and 20% speed. BUT, to finalize they speed, I put the two locos on (I use advanced consisting) and run them and using "Programming on the main" (POM), I do fine tune them as they chase each other around with the one that runs "slightly slower" in the rear.
You need a portable test track. It comes in handy for many things you want to do away from layout. It should have the ability to be extended for speed testing.
Thats really cool, I could see building that into a programming track permanently
Hi Jimmy, If you don't mind one more suggestion, it would be really cool if when you run the second engine through the unit would calculate an adder for each of the three CVS to make it's speed match. For example if the 2nd engine were too fast, tell the user to subtract "X" from the CV. The user would have to run the engines thru three times, once slow, once mid pace, and once at a fast pace. Then the user would adjust the start voltage, mid voltage, or max speed. Just a thought.
I was drinking "Bad Ass Coffee of Hawaii, Breakfast blend. And keeping with my theme I was using my "Big Ass Fans" coffee mug. (A promotional mug from the Big ass Fan Co )
Tony
This is a really good idea! I will have to work on it!
@@DIYDigitalRailroad of course, if you add in the Arduino DCC library, you can then write the program that will do everything: prompt for the address of loco 1, prompt for the address of loco 2, run each loco past the sensors multiple times at various speeds, take the average of each loco's speeds, calculate the CVs and upload them to the locos.
Thanks Jimmy! Gonna save this so I can watch it later when I run some consists
Jimmy this is SOoo kool sure Admire you R-Dino Knowledge, sure looking forward to this next segment, applying & Matching .
You are such a versatile person and always come up with some great ideas.
Great video Jimmy, I’ve just ordered the lcd screen, I have all the other pieces. I’m hoping this will work with the nano!
Is there a way to connect this to JMRI to automatically adjust the speedtables?
This same setup could be configured to make a scale speed indicator. Change the math a bit and the time it takes to pass both sensors would indicate scale speed in MPH or KPH.
Nice video.
That’s awesome Jimmy. Thanks for sharing.
Brilliant video. I love your ideas and implementation of various projects.
Really enjoyed this one! Great Video
Very nice Video, I plan on putting into practice as I have many locos to speed match!
One thing that would be very helpful is to mount the sensors to something that will maintain the distance (like @gravesclay says below), since any movement of the sensors between locos will throw it all off.
Jimmy, this looks great. I've never used Arduino and only know about it through your channel. Using your parts list and instructions would this be suitable as a beginner project? I know less than nothing about code, and barely any more about electronics. Thanks for all your hard work!
I'm not Jimmy from @DIY and DIgital Railroad, but I think this would be an excellent beginner project if you're the kind of person who likes to just dive right into things. If you want a more gentle introduction, you can buy the Arduino Starter Kit which contains a variety of electronic components and other parts (including a breadboard and hookup wires), and several tutorial projects to get you familiar with the basics of the Arduino and the basics of the electronic components it uses. After you've gone through some of the tutorials, you'll find that building Jimmy's project will be a breeze. Either way, you are almost certainly going to have questions about compiling and uploading the program, and there are lots of very helpful Arduino forums out there to turn to.
Be warned, though, that once you start with an Arduino you will find it very addictive!🤣
@@jimhyslop that's brilliant, thank you for the advice. I'll look into a starter set as it looks like there are a lot of other potential projects. It's amazing where this hobby takes you sometimes. Thanks again, Jim
Suggestion for your code. Rather than using delay to avoid flickering, how about going back to ST_OFF. It won't be update the display, and you'll get new readings without clicking the reset.
Nice project ... good explanation of millis() function.
Thanks, Jimmy for this tutorial! I needed this as I needed to figure out how to speed match my locomotives and I am planning on using an Arduino to build a speedometer.
Is there a way to connect the Arduino to JMRI to automate the speed matching? I am planning on building a separate test track just for this purpose.
Excellent! Thank you so much!
Thank you for this tutorial. Very helpful.
Jimmy, basically what you've done is build a speedometer with an Arduino. Another way to do this is to buy a speedometer system, such as the Accutrak II, or Train Control Systems. The nice thing about these is that they are already calibrated in scale miles per hour.
You are exactly correct. I own an Accutrak II; they are currently retailing for about $70. The Arduino plus LCD screen plus IR sensors total about $38 (you don't need a breadboard if you're willing to do a little soldering) and you'll have 8 IR detectors left over. Add a $1 wooden ruler to mount the IR sensors (see gravesclay's coment) and you can report both milliseconds and scale speed.
@@rwissbaum9849 Exactly. The biggest advantage to Jimmy's video is the cost.
With a little more calculation one could use this setup to display loco speen in MPH just to use as a speedometer.
Très bonne idée !
Jimmy, how do you know where to plug the wires into the breadboard? All I see is a bunch of unmarked holes in the breadboard. ...Roy
The breadboard is divided into four sections: left to right, they are (1) two columns of + and GND. All holes in these two columns are connected to each other (but not to the other column), giving you a positive bus and a ground bus. (2) A field of holes which is five rows wide and thirty rows tall. Each of the five holes in the thirty rows are connected to the other holes in that row, but no other. (3) A second field of 5x30 connected in the same fashion. And (4) a second set of two columns for positive and ground buses. So hole a1 connects to holes b1, c1, d1 and e1, but no others. a1 does not connect (for example) to hole f1 or to hole a2. Once you understand this, it is easy to connect pin D3 on the Arduino to, say, hole a1. Then, you can connect any device you want to pin D3 by running a wire from that device to hole b1 (or c1 or d1 or e1).
Does it works for all speed once the loco is calibrated? Or do i have to do this for multiple speed setting? And this is only for DCC systems, right?
I've done a Raspberry Pi based speedometer. Great for public shows, but rather expensive -- Pi 2, 7" screen. Seeing this I felt that I could use this as a basis for a smaller cheaper speedo. However one question/observation; the sensor you are using is digital not analog. Testing, I saw that it swings between an analog value of ~20 (low) and ~1020 (high). I tested it a digital and it works fine registering high to low transitions. Why set it as analog?
Good job. Great video. But don't you need a power supply?
Yes you do!
9V battery would work'
@@joelbutler7501 Thanks, from an Arduino no-nothing!
One big LIKE!
The code reminds me of old machine code used on Wang computers.
You know Jimmy I think I'll just stick with one locomotive and short trains I really don't think my Chromebook could handle that
As my eyes glaze over…
(I definitely have no idea what any of this means)
“I’m not an expert coder…” he says.
Very intersecting but not for me Im not a programmer
Chat GPT
wow to fast for me