Making A Trip Odometer
G McMurry
Posts: 134
I am using the Basic Stamp BS2P24 to control a large scale gas/electric locomotive. The last feature I put installed was a speedometer. I have just enough time to use the COUNT function to accurately give me a speed in MPH. My Locomotive is 1/8 scale. Speeds vary from 0 to 10 mph. Any faster.... Not really.
I probably have the most accurate speedometer in the hobby with my Basic Stamp. I have steel wheels, 5 inches in diameter that are connected by a 2:1 gear reduction to a 36 tooth pulley. I have a Cherry Gear Tooth Sensor that gives me nice pulses that I sample and compute MPH. I love it...
It occurs to me that making a trip odometer or just about any type odometer is not so easy. I am already going out to the COUNT function for 40 ms and that works fine for the speedometer. My STAMP has other stuff to do...
I am operating 2 hobby servos, one for the Throttle and one for the choke. I am also doing a PWM that is converted to analog to operate the air brakes. Not a lot of time left for even the BS2P24. My servos can just tolorate that 40ms wait. They are much happier at 20ms updates.
Anyone have any good ideas for keeping track of miles traveled as a trip meter or odometer would do. Especially good would be something that would use the COUNT numbers I am already acquiring.
I would love to have the EEPROM store the info but with the 100,000 cycle limitation on the BS2P24 that doesn't seem practical. I could just upload the count every 10 minutes and probably get something close but I am thinking that there is a better idea out there.
Greg
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
AUTOMATE EVERYTHING
http://www.trainyard.net
I probably have the most accurate speedometer in the hobby with my Basic Stamp. I have steel wheels, 5 inches in diameter that are connected by a 2:1 gear reduction to a 36 tooth pulley. I have a Cherry Gear Tooth Sensor that gives me nice pulses that I sample and compute MPH. I love it...
It occurs to me that making a trip odometer or just about any type odometer is not so easy. I am already going out to the COUNT function for 40 ms and that works fine for the speedometer. My STAMP has other stuff to do...
I am operating 2 hobby servos, one for the Throttle and one for the choke. I am also doing a PWM that is converted to analog to operate the air brakes. Not a lot of time left for even the BS2P24. My servos can just tolorate that 40ms wait. They are much happier at 20ms updates.
Anyone have any good ideas for keeping track of miles traveled as a trip meter or odometer would do. Especially good would be something that would use the COUNT numbers I am already acquiring.
I would love to have the EEPROM store the info but with the 100,000 cycle limitation on the BS2P24 that doesn't seem practical. I could just upload the count every 10 minutes and probably get something close but I am thinking that there is a better idea out there.
Greg
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
AUTOMATE EVERYTHING
http://www.trainyard.net
Comments
http://forums.parallax.com/showthread.php?p=842331
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Don't worry. Be happy
so if you run 20 times a day it will be 13.69 years before there is a problem
now if you write to 5 different locations (new one each shutdown) instead of just one spot then it's even longer.
is there anything on this rig that you expect to last 13 years (includes you)??
You may not want such insane accuracy. "Yes, I've traveled 141,578 inches today!" In that case, use a second gear counter, which will reset every 7,264 pulses. When it resets, it also increments the tenth-mile counter. You may also want another counter to correct for the missing 0.2 counts. Increment the tenth-mile counter every fifth update.
There definitely are rounding errors in the numbers I've used. Go for all the precision you want, and good luck!
--Rich
It just happens that I have been discussing this very thing in a private thread with another individual from the forums. In order to get accurate odometry you cannot miss any incoming pulses. It is for this reason that in my original Z80-powered car computer from the nineties that I used a CTC chip. Incoming pulses were sent to the chip and it was read at specific intervals. This gave me both accurate odometer and speedometer readings. Since the BASIC Stamp does not have an internal counter and cannot process pulses while running other commands you will also need either an external counter or a co-processor such as an SX designed to do the same thing. For a revisit of the project I am instead going to use a Propeller chip. Also, you definitely don’t want to write to the EEPROM continuously. Instead consider some sort of battery-backed RAM or the suggested FRAM. I hope this helps. Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
50 72 6F 6A 65 63 74 20 53 69 74 65
·
Chris -- I have done many counter designs with Z80s, though it was decades ago. NMI is a great counter input. You are reminding me how old I am...
I am also not familiar with FRAM. I found another thread that mentions the FM24C16A. Think this is a good part for me to start with in a new design?
I am not using surface mount yet. Maybe this will force me to make the jump.
Greg
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
AUTOMATE EVERYTHING
http://www.trainyard.net
Post Edited (G McMurry) : 9/23/2009 5:56:45 AM GMT
I was trying to remember exactly what I did back then and I believe I used an external CTC chip…it may have even been a Zilog chip designed for the Z80. It’s been a long time (yeah, age is setting in). I know I didn’t use the NMI line because that was connected to a 60 Hz source in all my designs to run an internal software RTC and to update certain specialized registers. In fact, I only used the IRQ input when an external chip used it. What I do remember is that I had at least a 16-bit CTC running and I remember that at max speed it would not roll over before I could read and reset it.
I have a design coming up where I need a similar system and I will be using the Propeller, but if I was tied to a BASIC Stamp design it could be easily done using an SX or PIC or any cheap microcontroller with an internal counter. The concept is that you want the chips counter to be able to continue counting pulses while the last known data is being read. A PIC or SX design would (upon a read) copy the current count into another register, reset the CTC and then continue sending the data to the host MCU. I hope this helps. As usual, it won’t help you now, but once my system is completed I will be posting it on my project site as well as the forums here. Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
50 72 6F 6A 65 63 74 20 53 69 74 65
·
The external counter method is very reliable. One of my projects used 2 Stamps on board. One would run the control program and the second did nothing but count pulses and wait to be queried by the main controller. When triggered by the main controller, it would blast out (SEROUT) its current count and reset to zero.
Some might call it a bit expensive, but in my case it meant only 1 spare chip in a fleet of 800 units and no learning curve.
A second application was the log processor shown in my ID panel to the left. It used a Stamp to do the digital i/o and a commercially available industrial counter for the log positioning. For each log length, the Stamp changed the settings on the counter by a serial link and reset the counter after each log was cut.
Cheers,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Sisk
http://www.siskconsult.com
·
I am back on this project.. I would love some advice on picking a counter/timer that would be good for use with a Basic Stamp. The only devices I have ever used was over 20 years ago. There must be something out there..
Any advice would be appreciated.
Greg
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
AUTOMATE EVERYTHING
http://www.trainyard.net
· That will let you get a feel for how they work and if they'll·do in your application.
·Cheers,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Sisk
http://www.siskconsult.com
·
Greg
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
AUTOMATE EVERYTHING
http://www.trainyard.net
·· The extra cost in hardware will be saved in ease of programming.
··· If you jumped to the Propellor you'd have lots of power to do the whole controller in one chip at the expense of learning a different (but similar)programming language.
·· Cheers,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Sisk
http://www.siskconsult.com
·