Help with lap timer project

Thread Starter

TomTheGeek

Joined Jan 7, 2008
4
I just bought a PIC 18f2520 and Olimex dev board and I'm programming with C18 in MPLAB. I would like to make a lap timer for my motorcycle. A lap timer is a device that records lap times every time it passes an IR beacon set out on the track. I thought it would be an easy first project but it may be harder than I thought ;-).

I need help with the following:

  • time source - I want it to keep the current date and time and have some sort of way to set it. The date and time will be used for keeping track of each session as well as each lap time. I don't know if I can use the PIC for this or if I need a separate circuit that I can query for the current time or something. Doesn't need to be terribly accurate, 1/100th of a sec resolution is fine but of course the more accurate the better.
  • Storage device - the PIC has some eeprom on it but I would rather use SD cards for storage. The data would be stored as comma seperated values in a text file on the SD card so I could pop the card out and load the data into excel or whatever easily.
  • IR transmitter/detector - something like a common 38hkz IR transmitter continually broadcasting a number. Should be capable of transmitting over 100 feet. Numbers or some sort of channel would be useful so multiple people can use the same beacon and/or the ability to set multiple beacons up around the track to monitor specific sections of the track. The receiver would send an interrupt that would cause the current time to be logged to the SD card along with the beacon ID.

It doesn't need much of a user interface, just a button that I can push at the start of a session to create a new file with the date and time where the lap times will be stored. Power will be from the motorcycle for the receiver and a 12v car battery for the beacon.
 

beenthere

Joined Apr 20, 2004
15,819
Here is a link to an outfit working with PIC's & SD cards - http://www.k9spud.com/sdcard/.

What is the advantage of running a modulated IR beam? Transmitted number or not, how does it distinguish your scooter from another?

Your clock for the PIC will do nicely for the timebase in your lap timer. It will certainly go beyond a millisecond in repeatable accuracy.
 

Thread Starter

TomTheGeek

Joined Jan 7, 2008
4
It doesn't have to be modulated, I just sort of assumed it would have to be. There are lap timers that you can buy and the way their system works is that there is one beacon at the starting line that all the racers share so there must be some sort of standardized IR scheme that they use. The beacon only marks a specific spot on the track, it doesn't distinguish between individual racers.

My only concern is that I don't interfere with their system but it would be even better if I can utilize their beacon. I might ask them how they do it but I'm pretty sure they won't let me in on the secret.
 

hgmjr

Joined Jan 28, 2005
9,027
As beenthere has indicated, the PIC can provide you with fairly good accuracy if you use a crystal or a crystal oscillator as your PIC's clock source. If you need greater accuracy than can be obtained from the PIC, You can consider using a Real-time Clock (RTC) device that is SPI compatible since your PIC has SPI support.

hgmjr
 

bozla

Joined Feb 5, 2010
4
Hi, I've used this forum for a while now for information but have finally joined. I'm currently doing a very similar project as the one above and am just looking for some advice as I have written most of the code already and have the backbone (multiplexed display, etc) all working.

My main question is accuracy of the onboard chip. I'm racing a go-kart instead so my lap times are shorter (around 40s) and I'm only looking for an accuracy of about 0.05s in one minute. (Actually, I think anything less than 0.1s in 1 minute would be OK).

I'm using a PIC16F785 and I've found the accuracy of the oscillator a lot worse than 1%. There is a large chance that my in-accuracy is down to my poor calculation. I've managed to recalibrate the timing against my stopwatch, seeing how long it took to get 1s second out, and then readjusting timer1 to suit.

My question is, in my nice warm home it is easy to calibrate the timer as above, but at a track on the cold day can I only expect a max 1% change in timing? (I think the internal oscillator variation is down to temperature?)

Does anyone else have any experience of this?
 

t06afre

Joined May 11, 2009
5,934
"hijacking" older threads in this forum is a no-no. I suggest you move your question to a new thread. It will also give your question better impact. In your own thread you can decide which direction your thread shall go.
As for your question. I think this will depend on which oscillator you use. Microchip MCUs have many clock source options. But for high accuracy use a crystal oscillator. How you solve the programming part is also of some importance.
 

atferrari

Joined Jan 6, 2004
4,764
I suggest you move your question to a new thread. As for your question. I think
Contradictory. By answering his question you already convalidated the hijacking, which I agree, is unacceptable.

In my case, I never answer questions originated like this one.
 

bozla

Joined Feb 5, 2010
4
Wow, thanks for the welcome! And thank you for the advice.

I didn't mean to hijack someone elses thread - I did quickly scan over the posting rules but having read them again I can see that hijacking is not allowed. (Is asking a related question in an very old thread still considered "hijacking")

However, I did use the forum search facility as recommended and it perfectly fits my question. I'm sure Tom who posted his only 2 posts over 1 year ago won't mind. Surely It will also provide more advice in one place for people searching for similar projects?

Should I create a new thread every time I have a question?
 

Thread Starter

TomTheGeek

Joined Jan 7, 2008
4
Doesn't bother me at all Bozla. I don't really frequent this site often (as you may have guessed) and I'm glad that you made me take a look at this thread again. Not sure what the deal with bringing old threads up is, I'm a member on lots of forums and never heard many people complain about it. Not really sure what the problem is?

Now back on topic of the thread, I've come to realize this is way, way harder than I originally thought. I still have the board and still plan on using it one day but for now I've switched to using PicAxe chips. I've made a few devices using a PicAxe 08M and have a 14M now to play around with. It's helped me get used to building circuits and soldering again.

Bozla, I think you'll have to use an external crystal or a crystal oscillator as your PIC's clock source like hgmjr suggested to me. I would expect the internal Pic oscillator to be a lot more prone to temperature fluctuations. I'm pretty new at all of this though. I would love to hear more details about your setup.
 

bozla

Joined Feb 5, 2010
4
Thanks Tom. You popped out of cyberspace in the most awesome way!

I've calibrated my lap timer to 1s in 45 minutes, which is good accuracy for my short laps. I know that I will gain some more inaccuracy at the track but I think the only way to truly find out would be to calibrate it against the circuit timing system (they have a few loaner transponders at my local for rental).

The main issue is when micro-chip says they are 1% inaccurate, do they mean the clock speed it-self, or is it variance due to temperature/other factors etc..(1% is 0.4s in 1 lap = no-good, but 0.1% would be fine) If it's just a quality issue with the internal oscillator and I can calibrate each chip at home by hand then there is no problem. If it's temperature related, then question is how bad is the variance due to temperature, then we'll know if the only way is an external oscillator. As you can appreciate, I'm trying as much as possible to avoid any unnecessary complexity - motor-racing environments tend to be pretty hostile!

Are you still looking at using a beacon? I've been saved a lot of that hassle as my track runs two Alfano strips (magnetic strips embedded in the circuit). I thought I was going to have to use a sensitive hall effect sensor (cost!) but it appears that Alfano themselves actually used reed switches. I have yet to test any switching yet though - the project is still on the breadboard.

Edit: acutally, I did test a basic proximity sensor (a window fixed burglar alarm type) which uses a reed switch - didn't work at all. But I can use the device to test other switches.
 
Last edited:

Markd77

Joined Sep 7, 2009
2,806
From the datasheet - figures 20-34 to 20-37 it doesen't look like the oscillator frequency changes that much with temperature. The 85 centigrade graph looks about 0.5% slower than the 25 centigrade graph. The -40 centigrade graph is pretty close to the 25 degrees one.
 

bozla

Joined Feb 5, 2010
4
Thanks Mark. I didn't realize they had that kind of data. It also seems it would be better to operate at 3.5V for oscillator stability, or maybe at worst 4V. That puts my mind at ease about using the internal oscillator.

I shall retest it at this voltage as I have been running it at 5V.
 
Hello,

People, please help me with some info:

What EXACTLY does an OLIMEX PLC-P2148 do? I know its for development issues. I have searched, but the exact circuit implementations have puzzled me.

I have a PIC IC as well as the OLIMEX board and I would like to know how to program the PIC with it. I want to interface the PIC with a mobile phone as well.

Awaiting your response

Thank you
 

maxpower097

Joined Feb 20, 2009
816
Hello,

People, please help me with some info:

What EXACTLY does an OLIMEX PLC-P2148 do? I know its for development issues. I have searched, but the exact circuit implementations have puzzled me.

I have a PIC IC as well as the OLIMEX board and I would like to know how to program the PIC with it. I want to interface the PIC with a mobile phone as well.

Awaiting your response

Thank you

OLIMEX PLC-P2148

This is a NXP LCP2148 ARM7 development board. You use this to develop electronics for the LCP2148 chip. The development board basically wires the basic hardware you need to run the chip, and adds certain features commonly used in electronics.
Here are the features of that particular chip
http://ics.nxp.com/products/lpc2000/datasheet/lpc2141.lpc2142.lpc2144.lpc2146.lpc2148.pdf

To program it and make it do stuff you will need a programmer for said chip. So you need a programmer with a jtag 20 pin plug capable of programming and debugging a LCP2148. Like these
http://cgi.ebay.com/Standard-H-JTAG...lectrical_Equipment_Tools?hash=item3a5709b1fc
http://cgi.ebay.com/ARM-ULINK2-USB-...emQQptZLH_DefaultDomain_0?hash=item35a791276b

Now to interface it with your phone is a whole other ball of wax. Once you get everything above sorted then start a new thread.

Also heres a bunch of demo's, schematics, and info on that perticular board.
http://www.olimex.com/dev/lpc-p2148.html
 
Using Lap beacons could give some problems ... and also they are
not dynamic. I have done similar project , which driver could mark his
own lap markers , when he want .

For this you want to get a GPS unit , which can easily interface with PIC from UART. Here first you have to go a teaching lession around the track.
You must have a push button to mark lap markers. So push the button ,
where you want to do a mark on the track. so in this point , PIC should store the GPS co-ordinators of that point and store it in the device. Like wise if you push the push button ten times , then you have 10 lap markers , which represented by from GPS coordinators in the PIC.

So you have to use little mathematics and , every time you have to read the current GPS co-ordinators and have to look , whether they are cross the existing lap marker point. if it cross , they you have pass a lap marker and you have to record the time from last lap marker intersection for the current lap marker intersection. this is lap time for that sector. You may want to use some mathematics like line intersection for this.

Finally you can write all your lap timing and relevant lap marker GPS coordinators into SD card. You can make a nice PC application to draw the track and mark your track markers and relevant times there. This is very easy as you have all the GPS co-ordinators. In this way you can analyse your driving performance very easy and systematic way

chamindacj
 
Top