Saving data for later use - Auto odometer
franklin9090
Posts: 59
I am in the process of creating an electronic speedometer using a BS2, but I need to consider the odometer also. A speedometer is interactive and is only in use during driving, but an odometer needs to constantly store the miles driven(even when the ignition is turned off).
What type of memory medium is available for interfacing with the BS2 for this type of use?
And, how is the data stored when the power is turned off.
Thanks.
What type of memory medium is available for interfacing with the BS2 for this type of use?
And, how is the data stored when the power is turned off.
Thanks.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
It sounds like your setup is very similar to my objective.
May I ask, what BS board did you use, etc?
That was in 1998/1999 just before I got into Parallax products…That system was built around a Z80 Controller. That’s why I mentioned if I had to do it again…In any event, the DS1302 would serve the same purpose, or you could write the data once per mile to a special odometer location in EEPROM. Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
I have looked into the DS1302 and was thinking, is this a bit overkill for my application? Since I am only looking to store the data, other than the 30K Ram, the logic in using this solution is unclear to me. Plus, this is RAM right? What happens when I turn off the ignition?
Are there other solutions that would perform the same function and retain the data overtime?
The DS1302 is a clock that happens to have a little extra storage in it that's usable directly. You normally have a backup battery attached to the DS1302, usually a "coin" lithium battery that keeps the clock going when there's no other power and incidentally maintains the extra RAM. It's always nice to have a clock in a car and the DS1302 is pretty cheap, even with a 32KHz crystal, battery, and battery holder.
You certainly can store your odometer reading in the Stamp's EEPROM with the READ/WRITE statements. This doesn't need a battery, but can only be changed a limited number of times (100,000 is a typical guaranteed minimum). The trick is to change it only when the value actually changes. Typically, you read the saved value using READ, compare it to the new value, and only WRITE it when the value has changed. I believe the PBasic manual discusses this in the section on the WRITE statement.
The DS1302 may or may not be overkill for your application. I seem to find a use for it in most of my projects but that is me. That was why I mentioned you could write to the EEPROM once per mile and be okay just using it. Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
Mike/Chris,
You have to admit, keeping odometer readings is a bit of a hassle. If I use the EEPROM, eventually I will run out of "writes", if I use a lithium battery with a DS1302 and the battery dies I lose my mileage.... hmm.....
I guess I am more used to PC technology, where I can write to a static medium, like a disk. Is this possible with a BS2?
Or, maybe my solution is in using a combination of the EEPROM and the DS1302.... need to think about this one a bit.
Any thoughts?
1. Write the data to EEPROM only before an imminent power-down condition. The following circuit will detect a power-down before the power to the Stamp actually fails. You need to poll the "power good" input often enough to ensure that you catch a power-off and can write the EEPROM before the capacitor discharges below the Stamp's reset level, plus the dropout voltage of the Stamp's 5V regulator.
2. Write the EEPROM on changes only, but use "wear-leveling" to minimize the maximium number of writes to any given location. For example, if you were to store each digit in its own byte, the "ones-digit" byte would get hammered 100,000 times in 100,000 miles, but the "hundreds digit" would get written only 1000 times. With wear leveling the mileage data are encoded in such a way that each digit gets written at nearly the same rate. Some sort of Gray coding may be the answer here. (This is assuming that EEPROM bytes are written individually. In some EEPROMs, an entire page may be read and rewritten with each write.)
-Phil
Post Edited (Phil Pilgrim (PhiPi)) : 3/15/2007 4:58:39 PM GMT
[noparse][[/noparse]Edit] - If you update every 10th of a mile you would only get 100,000 writes...That is always a possibility...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
Thanks for the detailed explanation and the circuit. There was concern about having to smooth my power source in the automobile feeding the BS, so as not to damage my BS. Would this circuit provide that kind of power smoothing?
Also, your explanation on #2 was very detailed and easy to understand. I am not sure if I can attain the Gray coding or if the BS requires it, I will definitely keep it in mind.
I like the idea of only writing to the EEPROM upon shutdown (power loss).
-Phil
I googled a 22uF tantalum (I didn't know what they were) and noticed that they are another type of capacitor. They seem to be rated by voltage i.e. cap 22uF tantalum 16V. Am I correct in my assumption and how do I determine which "v" version is right for me?
Thanks.
-Phil
Thanks for the information on capacitor voltage. Does that mean that the 1000uF and .1uf caps in Phil's schematic should be at 24V (twice the automobile's input)?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
Thanks for the feedback on the 35V capacitors; that sounds like the way to go.
I started to look at coming up with a list of parts (I would like to put in one order to save shipping costs) , but I ran into another snag. I looked on digikey.com for 1000uF 35V capacitors and they had all kinds(aluminun, electronic, etc.), and this was only the first vendor I went to. How is a novice to know, which one to choose?
Also, I am going to try to take Phil's approach above, but doesn't that mean that I would have to construct an electronic circuit to monitor and regulate the power BEFORE it gets to the Super Carrier Board? I was over at RadioShack and they had some blank circuit boards with holes and copper plating on one side. Although I have some novice level electronics experience and have put kits together before, I have not had to create a circuit from scratch.... I guess there is always a first.
Anyone have any links or tips on how to get up to speed.... Of course, this problem also relates to the Super Carrier Board that has through-holes in one corner ( I am not sure how to utilize them). I wish I had some examples or some simple how-to's....
Any help you guys can provide would be much appreciated.
Lay out the circuit on graph paper using the actual components as templates. If it's easy, arrange the components so their own leads can be used to connect them on the underside of the board. Use individual wires (usually solid hookup wire) to make other connections. Use stranded wire to make connections off board (whenever there can be any mechanical movement). Look at some of the electronics hobbist magazines for examples and suggestions for construction. You might start with some simple projects from one of those.
Electrolytic capacitors are what you need for the larger units. These come in both Radial and Axial lead styles, which just means the leads either come out of the same end or out of opposite ends, respectively. The .1uF capacitors are ceramic disc and most are rated to at least 50V. Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
Ok, I'll use electrolytic for the larger capacitors and ceramic for the ones in the .1uF range.
Phil mentioned using a 22uF "tantalum" as part of smoothing the power. Is that another kind of capacitor?
One other thing, should I "heat sink" the LM2940? Does it need it?
Mike,
Thanks for the circuit board tips, I really need to brush-up on the subject. As I said before, I have assembled kits in the past, but they have always had a circuit board with them. This particular project is different, of course.
On the solid hook-up wire and the stranded wire, where do I get those and what gauge?
Thanks.
To heat-sink or not ... It depends on how much current you need for your circuitry. Get the datasheet for the regulator and look at the charts at the back. There'll be one for heat dissipation. It'll tell you how good a heatsink you need based on power to be dissipated (voltage drop x current flow) and ambient temperature. Mostly it'll tell you how much the regulator can handle without an external heatsink.
Post Edited (Mike Green) : 3/17/2007 9:38:45 PM GMT
I was looking at the datasheet for an LM2940 and realized I need to need to calculate the power dissipation (Pd) with some formulas. There were two:
Iin = Il / Ig
Pd = (Vin - Vout)Il +VinIg
I wasn't sure how to determine the I values....
You said that with your circuit above, you would probably put an 8V LM2940 between the 1000uF cap and the BS.
Are you recommending an 8V regulator to dissipate some of the heat and to let the regulator on the BS to perform the 8V to 5v smoothing?
Do I need to do anything to the "Power 'good' signal" output to the BS pin(I am assuming that the output is going to a pin)?
Would installing the LM2940 at the point of input (12V) a purdent thing to consider? I'm thinking my circuit is not protected at this point, is it? Or, does it matter? And, if it is installed at the point of input, how does it change the circuit?
I took another look at the charts and it looks like, if the ambient temperature is less than 90C or 194F, a heat sink is not needed (which is most likely my case). Is this correct?
I don't know. You'll find out. The regulator will just shut itself off to prevent overheating. If you find that happening, just try a small heatsink. Make sure to use some thermal conductive paste.
Thanks for your feedback, always appreciated.
On the zener diode, should I be testing for the zener current? Anything particular I need to be looking for?
I am still grappling with how best to construct the circuit board. I think Mike's idea of using the leads off the components and laying it out on paper are good, but ultimately, I think I need to get the components on to a breadboard of some kind.
I am trying to avoid the ferrite cl. route, seems to messy and don't seem to be able to source a small quantity.
I tried my local library last night for magazines on electronics; I was shocked, they didn't have any.
Any recommendations?
Just make sure the output voltage saturates at 4.7V before connecting it to the BASIC Stamp.
-Phil