PDA

View Full Version : Olympic Timer



Melanie
- 6th August 2004, 21:18
It's almost Olympics time... so here's a topical program using PBP exclusively (no embedded Assembler) to give you a Stop-Watch with 1/100th Second Timing (yes that's 0.01 of a Second) and gives you REAL-TIME display on your LCD. Now you can do your own timing and challenge the official time...

The program demonstrates using TMR1 in BACKGROUND (multi-tasking), uses PICBasic Interrupts, and accounts for the fact that PICBasic doesn't respond to those Interrupts immediately. There's also a set-Up CALIBRATION menu item, so you can adjust and calibrate your timer to an accuracy of 360mS per Hour.

How does it do all that? Better download the PDF and find out...

Melanie

PS. Questions and Comments post on this forum/thread. No off-list mail please.

frederick
- 13th August 2004, 07:24
Could you use a 2x16 lcd with backlight or even a 1x16 with a backlight

Melanie
- 13th August 2004, 08:27
Sure you can.

The 16F876 which this was originally written for has two PWM ports. One can be used to give you software Contrast adjustment, and the other can be used to give you software Backlight adjustment. Whilst you can get away using just two Resistors for the Contrast, the Backlight will need a Driver (in it's simplest form a Transistor or MOSFET along with a couple of Resistors) as the PIC cannot directly sink the current needed for most Backlights.

You can then add the Contrast and Backlight Menu Set-Up's into the built-in Menu structure of the Olympic Timer.

If you have any problems integrating those features, let me know and I'll post the code and hardware circuits.

Melanie
- 13th August 2004, 08:32
Hey, anyone else going to Athens Olympics opening night party? See you there...

frederick
- 14th August 2004, 00:49
What would work. I was looking into a photo resistor.

This what I am going to use your design. I complete in Olympic style weightlfting. I want to measure the time it take to reach the top of my pull (desired hight) and when I reach the top of the pull the timer will stop and also give me audio alarm.

The unit will start/stop the timer by the bar breaking a beam.
This is will be use for a training aid.

Any help would be appreciated.

Melanie
- 16th August 2004, 04:32
Do you start timing the instant the weights are lifted off the ground, or after the lift has reached a certain height?

How do you plan to account for the fact that one weightlifter stands 1m50, and his buddy stands 1m90, and a third guy is waving the weights around over his head like a tree in a Florida hurricane?

frederick
- 16th August 2004, 05:09
The timer would start as soon as you lift the bar off the ground and stop at a certain height.

frederick
- 16th August 2004, 18:42
I am looking for an 1x16 LCD and If you can recomend a brand.

Melanie
- 16th August 2004, 21:26
I use PowerTip big-time... consuming thousands of pieces a month. Never any problems interfacing to PICs or using with PBP. PC1602F (which is actually a 16 x 2) is very price competitive and perhaps the one to consider.

When I was in China a few weeks ago, I visited Tri-T, who claim to offer a direct compatible unit to PowerTip (TMBC16265SP) but with Backlight at the same price as PowerTips standard reflective unit. The sample I walked away with was excellent. The first batch of 200 is clearing customs at the moment and I'll let you know if they're all as good as that original sample by the end of the week.

Moving back to the weights...

I see no problem detecting the weights being lifted, as you can have a photosensor on the floor with the weights covering it. At the lift end, I'd use a IR emitter/detector (of the sort found in TV remotes). Modulate it at it's working frequency (usually around 38kHz) and detect that. It should make it pretty much immune to extraneous light, flash-photography etc.

You may want to change the Olympic Timer software so that you can only START the clock ONCE following a RESET. As it stands, once it's stopped, you can start again and continue timing from where you left-off.

Melanie
- 3rd September 2004, 10:43
I said I'd report back on the LCD business...

Tri-T model TMBC16265SP-03 'Cool Blue' (full Part Number TMBC16265SP-SN-LED05-W) has to be one of the sexiest 2 x 16 displays around. Fully PBP compatible, excellent contrast ratio, and super bright white LED for backlighting which requires minimal current consumption...

Just ordered 5000 pcs (eta 6-weeks)... if anyone is interested, I will get some put aside to offer people on this list with a price tag of US$15.00 which includes shipping worldwide.

Melanie

Dwayne
- 3rd September 2004, 16:32
Hello Melanie,

Whats the current drain on these puppies?

Dwayne

Melanie
- 3rd September 2004, 17:46
I assume you mean the Backlight Current since the LCD module itself is less than 1mA... I run them between about 5mA (what I consider the minimum acceptable Backlight level) and 40mA (what I consider seriously bright). The example jpeg I posted is running at 22mA.

There is a spin-off here if you're clever... that super-white LED throws out a considerable amount of collateral light at the right-hand edge of the LCD module. I tend to put my control push-buttons at that right-hand edge. If you specify the correct material for your panel overlay and get your artwork right, you end up backlighting your control buttons for free. See appended jpeg...

DelBoy
- 13th October 2004, 03:09
Do you have any of these Blue LCD's, but in 20X2.....

Melanie
- 17th October 2004, 00:17
Only just returned from China today... sorry for my delay in replying.

No, only 16 x 2 at this time.

Melanie

badrad
- 26th October 2004, 07:11
I checked out the website, and the pc1602-L looks like a direct replacement (other than the background colour) for the Optrex displays I am currently using. Unfortunately Optrex has obsoleted some of their character displays so the order of the day is to locate alternate replacements for my design.

I am considering to redesign using one of the graphic displays instead. have you worked with any of the powertip graphic displays, and if so, any tips or suggestions?

Melanie
- 26th October 2004, 13:08
I've never had time (or the requirement) to play with Graphic LCDs... I'm already struggling with a 30-hour day and I'm looking to buy a good condition Time Machine the instant one appears on eBay.

I can however recommend these Guys...

http://www.compsys1.com/workbench/

Ranjit's been playing with PBP and LCD graphics for a long time, and has posted routines and goodies in the MeLabs email forum over the years which you can extract from the Archives...

http://list.picbasic.com/cgi-bin/board-search.cgi

Art
- 10th July 2005, 05:52
Hi Melanie,
Is there any chance you could post a direct link to the LCd you have pictured?
A Google search for Powertip yeilds many results, and I can't find that part
number under any of them..
Cheers, Art.

Melanie
- 10th July 2005, 10:37
Hi Art

If you looked halfway up the thread you'd notice I said "Tri-T model TMBC16265SP-03 'Cool Blue' (full Part Number TMBC16265SP-SN-LED05-W)"

These are manufactured by Tri-T which is why you can't see them on the PowerTip site. Tri-T won't even acknowledge you unless you start talking thousands of pieces, so I do keep a surplus over what we consume just for folks on this list.

Melanie

wilfrieds
- 28th July 2005, 02:32
Hello Mel

I am designing a LCD dashboard for Earthmoving/forklift equipment.
Do you have a 2 x 16 or 4 x lcd LCD that's waterproof.
Background lighting prefered.

Wilfried

Melanie
- 28th July 2005, 08:19
I'm holding class today (oooh goody... a whole day of young techies saying "Yes Mistress" - or something similar)... give me a day and I'll edit some pics together and show you a method I use of waterproofing what otherwise isn't...

Melanie
- 7th August 2005, 13:26
Sorry about the delay in responding... had to find the Digicam, allocate time to take pics, then edit-out the client logo's etc etc...

LCD1. We start off with our Control Panel with our LCD, Buttons, LED's etc all attached. Ribbon Cable plugs into main electronics located elsewhere (in our example here in the base of a IP66 rated enclosure). Yes, you can have your LCD (example in 4-bit Parallel Mode) on the end of a long Ribbon Cable. I've used 350mm without any problems.

LCD2. That's the Lid from an IP66 rated enclosure. The Lid has been machined to take the LCD, Buttons, LED etc etc. You attach your Control Panel to the back of this Lid. Ribbon Cable plugs into the electronics secured in the base.

LCD3. A clear, self-adhesive reverse-printed flexy-acetate is overlayed on the Lid. Your silk-screen printer will advise as to the different adhesives available to make this watertight. It is Reverse-Printed so that the markings will not be rubbed-off with use. It's semi-flexible, so that you can push through to access the Buttons. Again your Silk-Screener will advise you as to the range of materials available to you. A medium-duty favourite of mine is 250 micron clear PVC. The electronics you'll note is now in the sealed enclosure with IP56 rated cable glands for entry/exit.

LCD4. Finally, the addition of a Bezel (in this case a 18swg Steel Plate) makes it Bullet-proof. The Bezel prevents peeling or otherwise tampering with the edges of the acetate panel. The Bezel can additionally have a gasket seal around the inside edge. You can hoze-down the final assembly, stand it out in the rain, or perform whatever watersports you fancy in it's proximity. Rather than a Steel Bezel, I've also used a reverse-printed Plexiglass panel. That's also a good option where there are no Buttons, just Displays and/or LED's.

Have fun.
Melanie

Gevo
- 8th August 2005, 12:30
Hi,

For daylight applications, and battery applications I use Winstar (WH1602), the PLED for low current (5V/20mA) and very high bright.

If you need more info, please let me know,

Best regards,
Gerben

wilfrieds
- 9th August 2005, 15:02
Hi Mel ( mistress??)

Thanks for the responce

It will be a bit difficult finding all the materials down here in South Africa( the ass-end of the world) but it will certainly put me on track.

P.S. Still battling getting the DS1307/16F877/LCD to work.

Appreciated greetings.
Wilfried

lukygrl
- 28th August 2005, 21:27
Hi, I have been reading the post, and I have a PC1602F but although it came with the electrical specs I can't find an instruction set for it, could someone help me?

Thanks in advanced.

Melanie
- 29th August 2005, 00:12
Page out of the Hitachi Controller Manual...

Squibcakes
- 7th October 2005, 01:52
Mel,

Your Olympic timer program is a piece of work. Wow. The example has given me a pretty good start with timer operation.

I was wanting to use the PIC's TMR1 resource to do two things.

1. Act as "a timer" as in the Olympic Timer Demo to set a FLAG after 5 mins
2. Simulate a program PAUSE (say 3 seconds)

I gather from your program description that instructions can NOT take longer thatn 10ms, otherwise my 5 min timer will in (1) will not be accurate. (Hence cant use a simple PAUSE command)

I have attached code that I think should work (but doesn't) and was wondering if you could help me out.

This is the main difference:

DELAY VAR BYTE
TIME_END VAR BYTE
TIME_START VAR BYTE

Begin:

DELAY = 3 ' CREATE A THREE SECOND DELAY
TIME_START = SECONDS ' SAVE CURRENT TIME
GOSUB KILLTIME ' GO WAIT FOR THE DELAY
TOGGLE PORTB.0 ' DELAY FINISHED NOW TOGGLE LED

goto begin ' DO IT ALL OVER AGAIN

DISABLE


KILLTIME: ' KEEP DOING THIS ROUTINe UNTIL delay time reached
TIME_END = SECONDS-TIME_START ' MINUS START TIME EQUALS THE CHOSEN DELAY
IF TIME_END > DELAY THEN RETURN
GOTO KILLTIME

jessey
- 6th November 2005, 02:33
I said I'd report back on the LCD business...

Tri-T model TMBC16265SP-03 'Cool Blue' (full Part Number TMBC16265SP-SN-LED05-W) has to be one of the sexiest 2 x 16 displays around. Fully PBP compatible, excellent contrast ratio, and super bright white LED for backlighting which requires minimal current consumption...

Just ordered 5000 pcs (eta 6-weeks)... if anyone is interested, I will get some put aside to offer people on this list with a price tag of US$15.00 which includes shipping worldwide.

Melanie

Hi Melanie,

Do you have any of those Lcd's left? I realize it's been over a year since you posted the offer but I thought I'd ask anyway as they look pretty cool and seem like such a good deal.

Thanks
jessey

mister_e
- 6th November 2005, 09:37
Jessey, as you live in Canada, may i suggest you
www.crystalfontz.com
www.norgay.com

Both offer great prices even on low quantity

jessey
- 6th November 2005, 10:45
Jessey, as you live in Canada, may i suggest you
www.crystalfontz.com
www.norgay.com

Both offer great prices even on low quantity

Hi Steve,

I'll be sure to check them out.

Thanks
jessey

Melanie
- 6th November 2005, 17:09
Yes we still use those 'Cool Blue' LCD's - several thousand a month....

jessey
- 7th November 2005, 13:30
Yes we still use those 'Cool Blue' LCD's - several thousand a month....

Hi Melanie,

That's great, are you still selling them for $15.00 USD with free shipping? I'd like to purchase a few if I could, so how would I make payment?

Thanks
jessey

Melanie
- 7th November 2005, 16:18
Message me off-list.

micro
- 8th April 2006, 16:18
hello Melanie

i have some questions

1- i did not understand yet why did you used calibration? and what is that for ? all what i understood it that
you used to speed up or down, but i could not understand it why ?
2- all i know, the Disable i use it before interrupt routine and Enable after it, but i note you used it at different place
why did you placed at these places ?

Enable

DisplayLoop:
if ButStart=0 then runningflag=1
if butstop=0 then runningflag=0
lcdout $fe,$80,Dec2 hours,":", dec2 Minutes,":", dec2 seconds,":",dec2 Hundredths


if overflowerror=1 then
if seconds.0=1 then
lcdout $fe,$8c,"ERR"
else
lcdout $fe,$8c," "
endif
endif
if runningflag=1 then goto Displayloop
if butreset=1 then goto Displayloop



Disable

Melanie
- 8th April 2006, 16:33
Calibration

With the best intentions in the world, a 4MHz Clock is NOT a 4MHz clock. It is a few Hz fast, or a few Hz slow, but is is NOT exactly 4000000.0000Hz. so the Calibration feature is used to speed-up or slow-down the clock slightly to compensate, and to compensate any lag in software instructions used to service the interrupt.

Interrupt ENABLE

I only ENABLE interrupts where they are needed. In other places they are either not needed, or not wanted. This also makes for smaller and more efficient code.

micro
- 18th April 2006, 16:01
so put some codes between Disable and Enable, that will delay interrupt
handler rountine for few times?? and use that trick if i want to finish some
procedures, i fear if without it the interrupt could screw it up ?then for that i give some
delay to interrupt to finish that procedure?


Disable

Enable

emavil
- 30th October 2006, 03:24
Wouldn't it be nice to display the time in big 7-segment displays like 2" etc.
My question is what is the probability of using Serial-In Parallel Out IC like CD4094 or 74HC595? The olympic timer code excellently. I'm planning to try it using PIC16F628A. 8 pcs of 7-segment displays with individual SPI drivers communicating through a 3-wire interface (Clock, Data & Latch). I'm planning to change the LCDOUT command with a series of 8 SHIFTOUT command followed by 1 PULSOUT. Which is faster, 1 line LCDOUT or 8 lines of SHIFTOUT? What will happen to Timer's accuracy?

I'm very much happy to hear something from you.
Thanks. This forum is the best.

mister_e
- 30th October 2006, 04:27
why 8 lines of shiftout and tons of hardware while you can use a single line of I2CWRITE with a MAX6955 OR a single HSEROUT/SEROUT with built an external 7-segment display driver with a PIC?

jessey
- 16th February 2007, 03:43
Yes we still use those 'Cool Blue' LCD's - several thousand a month....

Hi Melanie,

Any chance of purchasing another 4 of your cool blue Lcd's?

Thanks
jessey

Melanie
- 16th February 2007, 07:21
Yes of course Jessey, I'll email you direct.

zigapetric
- 17th January 2008, 18:54
Hi!
First my introduction:
I am racing with a dirt bike and I have my own race track. I would like to record my lap times with something like this program. But there is a problem. I don't know how to program in Picbasic. I am used to assembler or C program language. So I'm asking if you have this code translated in assembler or C.
I just need to change that the measured time is stored in memory and on LCD which already is and that when I cross the line timer has to store lap time which ended up and at the same time start timming for the next lap.
I'll realise this with an IR diod installed on a motorbike and a reciever.

I know that it's a bit komplex, but if you have something like this Please respond to me.

Thanks! Ziga

AIAMRE
- 17th March 2008, 14:05
Hello,

Is it possible to have the HEX file ?

Thanks

Melanie
- 18th March 2008, 03:17
Rename the TXT as HEX.

It's a PBP2.46 compilation of a 4 year old BAS... so usual caveats apply about wasting your life trying to get it to work in time for this years Olympics... it should... but...

damien
- 17th September 2008, 15:43
Hi Melanie,

Newbie alert with dumb questions!

Not meaning to drag this topic on (4 years - wow). I am interested in doing the project and would like a to ask a couple of questions.

Has the PIC16F876 been replaced by anything, as I seem to be having trouble buying them.

In the photo's you posted showing the casing for the LCD, it only appears to be small, how is the PIC interfaced with the LCD (is it inside the casing) on a carrier board or spacific schematic.

Do you still ahve any o fthe LCD's for sale - the 'sexy blue' ones.

Thanks in advance.

Melanie
- 17th September 2008, 16:08
> Has the PIC16F876 been replaced by anything, as I seem to be having trouble buying them.

Yes, the 16F876A replaced it.

Two lines need to be added in the initialisation sequence of the program to disable the Comparators and the Voltage Reference module...



CMCON=%00000111
CVRCON=%00000000


...and any @ DEVICE statements right at the start need to have an 'A' inserted to indicate it's now a 16F876A and not a straight 16F876.

You can also migrate to an 18F242, 18F2420 or any of that family as they're all pin compatible but need a litte more code adjustment...

> In the photo's you posted showing the casing for the LCD, it only appears to be small, how is the PIC interfaced with the LCD (is it inside the casing) on a carrier board or spacific schematic.

Those LCD pictures and casing digressed from the Olympic Timer topic per se. I do have a PCB and bezel that is more suitable for playing with that I can let you have. Though it wasn't intended for that purpose, with a bit of frigging (techical engineering term) you can use it for the Olympic Timer project. It'll also house an EEPROM and a RTC so it can be used for other things too when you get bored waiting for the next Olympics.

> Do you still ahve any o fthe LCD's for sale - the 'sexy blue' ones.

Yes, about 8,000 pcs at the last inventory-check. Contact me off-list.

tenaja
- 17th September 2008, 17:33
> Has the PIC16F876 been replaced by anything, as I seem to be having trouble buying them.

Yes, the 16F876A replaced it....
You can also migrate to an 18F242, 18F2420 or any of that family as they're all pin compatible but need a litte more code adjustment...
My guess is that the 16F866 is probably going to be the 16F876A replacement--and they are cheaper than either of the older parts. It will possibly require more edits than going to the A part, but not as many as going to the 18F part.

Note that 18F parts, given the same specs, are like having larger code space. They don't have code pages, and they have almost twice as many asm commands. You can expect a 20% savings right off the top. I also believe the 18F2420's are facing impending obsolescence, as the 18F24K20 (I think that's the new part...) has migration instructions to it. And it's cheaper.

rmteo
- 17th September 2008, 17:59
Note that the 18F24K20 is a 3.3V ONLY part, so the 18F2420 is likely to remain in the MicroCHIP product line. Another advantage is that the 18 series have larger stack.

Of course, from a purely cost/performance standpoint, a 28-pin PIC24FJ is several orders of magnitude above the 16/18 parts. For example, a PIC24FJ16GA002 has more RAM (4096 bytes), more peripherals and costs less than either the 16F876A or PIC18F2420.

Bruce
- 17th September 2008, 20:15
The 24 series are nice, but they aren't supported by PBP.

rmteo
- 17th September 2008, 20:46
The 24 series are nice, but they aren't supported by PBP.

Agreed. For me, selecting the right tools (both hardware and software) is more than half the battle won.