Mobile Train SpeedoMeter - Page 4 - Model Train Forum - the complete model train resource
Model Train Forum - the complete model train resource

Go Back   Model Train Forum - the complete model train resource > Model Train Workshop > Technical Model Train Forum
Forgotten your password?

Technical Model Train Forum Discussion on advanced technical aspects.


Reply
 
Thread Tools Display Modes
Old 02-05-2017, 03:44 PM   #31
gunrunnerjohn
Admin
 
gunrunnerjohn's Avatar
 
Join Date: Nov 2010
Location: SE-PA, USA
Posts: 33,884
Scales Modeled: O-gauge 3-rail
Images: 3
I'm guessing the code running on the Arduino is also going to be required.

A source for the displays would be nice as well.
__________________
MTH ASC Certified Tech, Henning's Trains, North Penn O-Gaugers, Member TCA
My YouTube Channel

Looking to enhance your TMCC Steamers and Passenger Cars?
Super-Chuffer, Chuff-Generator, LED Passenger Car Lighting Kit, LED Lighting Regulator
YLB - RailSounds Battery Replacement, Insulated Track Signal Driver Board
gunrunnerjohn is online now   Reply With Quote
Sponsored Links
Advertisement
 
Old 02-05-2017, 03:59 PM   #32
wvgca
Dispatcher
 
wvgca's Avatar
 
Join Date: Jan 2013
Location: yorkton, sask
Posts: 1,770
Scales Modeled: HO 1890's mountain logging "Squirrel Creek"
Images: 45
Quote:
Originally Posted by gunrunnerjohn View Post
I'm guessing the code running on the Arduino is also going to be required.

A source for the displays would be nice as well.
I just need to clean up the code first .. I'm a messy coder

Code attached
Hall_Mobile_Speedo_7segment_Final.ino.txt

I bought these displays from ..
http://www.ebay.ca/itm/161939143063?_trksid=p2057872.m2749.l2649&ssPageNa me=STRK%3AMEBIDX%3AIT

They were 0.99 each, good value
__________________
Warren's layout photos..>>> https://plus.google.com/photos/10301...64158873113617

Last edited by wvgca; 02-05-2017 at 05:11 PM..
wvgca is offline   Reply With Quote
Old 02-05-2017, 05:26 PM   #33
crusader27529
Hobo
 
Join Date: Apr 2016
Location: Sneads Ferry, NC
Posts: 28
On this line:

attachInterrupt(0, rpm_fun, FALLING);

Shouldn't it be pin 2 instead of pin 0???

I've never used interrupts on an Arduino, so I could be wrong......
crusader27529 is offline   Reply With Quote
 
Old 02-05-2017, 05:41 PM   #34
wvgca
Dispatcher
 
wvgca's Avatar
 
Join Date: Jan 2013
Location: yorkton, sask
Posts: 1,770
Scales Modeled: HO 1890's mountain logging "Squirrel Creek"
Images: 45
Quote:
Originally Posted by crusader27529 View Post
On this line:

attachInterrupt(0, rpm_fun, FALLING);

Shouldn't it be pin 2 instead of pin 0???

I've never used interrupts on an Arduino, so I could be wrong......
Well, kinda yes and kinda no ...
from the arduino.cc description ..

"The processor at the heart of any Arduino has two different kinds of interrupts: “external”, and “pin change”. There are only two external interrupt pins on the ATmega168/328 (ie, in the Arduino Uno/Nano/Duemilanove), INT0 and INT1, and they are mapped to Arduino pins 2 and 3. These interrupts can be set to trigger on RISING or FALLING signal edges, or on low level. The triggers are interpreted by hardware, and the interrupt is very fast.",

so actually either way will work, just a personal preference.. I'm a messy coder...
__________________
Warren's layout photos..>>> https://plus.google.com/photos/10301...64158873113617
wvgca is offline   Reply With Quote
Old 02-05-2017, 05:54 PM   #35
crusader27529
Hobo
 
Join Date: Apr 2016
Location: Sneads Ferry, NC
Posts: 28
Quote:
Originally Posted by wvgca View Post
Well, kinda yes and kinda no ...
from the arduino.cc description ..

"The processor at the heart of any Arduino has two different kinds of interrupts: “external”, and “pin change”. There are only two external interrupt pins on the ATmega168/328 (ie, in the Arduino Uno/Nano/Duemilanove), INT0 and INT1, and they are mapped to Arduino pins 2 and 3. These interrupts can be set to trigger on RISING or FALLING signal edges, or on low level. The triggers are interpreted by hardware, and the interrupt is very fast.",

so actually either way will work, just a personal preference.. I'm a messy coder...
OK, I didn't understand the limitations of the arduino interrupts....int0 is indeed tied to the correct pin 2 as on the schematic. I thought that the 0 was the pin number, not the choice of which interrupt.

Sorry for the misunderstanding on how the interrupts were defined in the code.

BTW, your code is fine, and quite minimal......my code for my speedometer is about 1200 lines, but that includes lots of documentation and explanations of how thing are supposed to operate. I also have about 10 different compile time switches to control lots of options, which also increases the number of lines.
crusader27529 is offline   Reply With Quote
Old 02-05-2017, 06:05 PM   #36
wvgca
Dispatcher
 
wvgca's Avatar
 
Join Date: Jan 2013
Location: yorkton, sask
Posts: 1,770
Scales Modeled: HO 1890's mountain logging "Squirrel Creek"
Images: 45
crusader27529 ..
I think I saw a screen pic of yours, much more involved, seems like you have average speed, and mileage accumulators .. fancier end result
This one here turned out okay with the seven segment display ... if i get some free time may tie in a ESP8266 for remote viewing ... maybe
__________________
Warren's layout photos..>>> https://plus.google.com/photos/10301...64158873113617
wvgca is offline   Reply With Quote
Old 02-06-2017, 04:48 AM   #37
jlc41
Engineer
 
Join Date: Feb 2016
Location: New Jersey
Posts: 686
Scales Modeled: HO
Images: 8
wvgca, thanks again for the information.
jlc41 is offline   Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


» Visit These Sites:
LGB World

Or Our European Train Website ModelRailForum




All times are GMT -5. The time now is 04:22 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
vBulletin Security provided by vBSecurity v2.2.2 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.