Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Odometer logger with a Pic micro?

Status
Not open for further replies.

steveo

Newbie level 6
Joined
May 1, 2004
Messages
14
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Activity points
70
odometer pulses

I trying use a "Pic"micro to record my daily miliage with a date and time, and have the data sent to a serial printer.
I plan on using a ds1302 real time clock, and a 24lcxx eeprom to back the data!
My odometer gets 4000 pulses per mile. If I drive 600 miles that 2.4 million! inputs to the micro.
How can I have the pic Count this High!!!

Thanks
steve
 

picmicro convert to decimal

Hi,

SteveO, you're forgetting, 2.4 million, in binary would need at least 22 bits. Thats only 3 bytes!!! Of course, converting that to decimal to display on a LCD or a LED display would be tricky, if you're doing that on a PIC (as opposed to using a PC).

For binary, you simply increment a register every pulse, each time checking for overflow, when you've incremented it and it has overflowed (gone back to zero) you increment another register, and the same routine goes for this as well. You could use the PIC tmr1 incremented by an external source, so it interupts when it has overflowed, then you would only have to 'do' something every 256 pulses...or 2 seconds. It can be done, in many ways. But as I said, converting those 3 bytes of binary into 7 digits (for a maximum of 9.99.. million) requires some clever code, of which there is plenty about. but if thats not for you..

I guess you could always count in decimal, that is, convert binary to decimal 'on-the fly'. Depends on how quickly these pulse are coming in... for 4000 pulses per mile..assuming you don't go over 100mph thats ..111 pulses per second, period of 9ms. thats more than enough time to increment a decimal counter. Same deal as above, except you increment the next digit when it reaches '10' and then reset that counter. You'll end up with 7 registers each containing a digit, from millions down to units.

However, all of this is for counting 'pulses' from your odometer. With 4000 pulses per mile, that gives an accuracy of 1/4000th, or 0.00025 miles. Interstingly I think thats about 0.4 metres. are you sure your odometer outputs that many pulses per mile?? It's VERY accurate. And I assume you want your milage to the nearest 10th of a mile?? in which case, you could divide the pulses before you store the milage, by say, 400.

Anyway, there are many ways to do this, and I'm ranting, but in answer to your question, 'how can I have the PIC count this high?' well, it can count higher, a lot higher, just depends on what you want to do with the final number, whether it uses one byte (up to 255) or 100 bytes (big scary number).

Regards,

buriedCode.
 

    steveo

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top