Pinewood Derby Stopwatch/Timer Project

MrChips

Joined Oct 2, 2009
30,824
This is a piece of cake and a lot of fun for someone with MCU programming knowledge.

IR LED emitter and sensor aligned below and above the track is the way to go.
One MCU board can time both tracks or you can go with individual boards.
You can go with a manually operated start switch. You can also consider individual optical triggers for each track which would eliminate false or slow starts (depending the your preference and rules of the game).

I can even program two MCU chips for you or you can have a go at it with our guidance. All up to you.
 

JohnInTX

Joined Jun 26, 2012
4,787
Hacking stopwatches would be a great project for the older boy scouts. There are many tutorials out there. But I also believe there are lab timers meant for this exact chore (external triggering).
Here's a related project, and one from this site.
I am intrigued by the concept of hacking into the stopwatch. I like it!
Vell zen. It zeems ve haf zome convertz to our vey of zinking. Zoon, ze planet vill be ours!

Thanks for the links!
 

Thread Starter

bertz

Joined Nov 11, 2013
327
You can use a uC, be it PIC, PICAXE, or something else, but given your comfort with hardwired circuits and the simplicity of the goal, I agree a uC solution would be a bit overkill. Short of being a programming whiz, it will take more time to program than to build a hardwired solution.

That said, I like the original design you had in your first post, moreso now if you have nearly all the parts. The only thing I'll stress is you really should look for a different sensor to trip the timer. A mechanical switch/relay is going to have all kinds of noise which wil negatively affect the results. This will be a problem for any setup be it a uC, custom circuit or hacking a stopwatch.

As you mention having a piece of non-working equipment that performed this function, we may even be able to help you troubleshoot that as well. Can you take good, clear close-up pictures of the circuit board, front and back, and post them? If they are not readable in the pictures, please let us know what IC's are used. What is the equipment doing or not doing?
It seems to me that there are to roads to travel here:

First, let's see if we can fix what we have. I will see if I can persuade the overlords to get the existing gear out of storage so we can have a look see. If we know what chips are being utilized, we should be able to figure out how it is supposed to work.

Following the second road - this is building something that will work and is useful. But the real reason is to prevent brain atrophy. So let's get back to my construction project.

elec-mech brings up an excellent point about using relays. Noise, bounce and residual magnetism will do us no good here. So I scrounged around in my chip collection and came up with a half dozen of CD4066. OK, now I think we're getting somewhere. A logic level high will feed the timer pulses to the display and a low logic level will shut it off.

This brings me back to using a PICAXE (because it's easy) processor. I can use the existing limit switch to start the time The processor will de-bounce using a time delay. I can use a photo-transistor to record the finish times. These are easy to interface.

Since the 4066 is a quad device I can use one oscillator/pulse generator to time up to four tracks. I just need to build a separate display for each track. Best of all I think I can handle the programming involved.

So, lots to do this winter. Fix the existing equipment and build my own gadget.

Any thoughts?
 

Attachments

Thread Starter

bertz

Joined Nov 11, 2013
327
Following up on my previous post I have attached a block diagram of how I envision this project beginning to shape up. The only thing I would need to buy is a processor chip and a few odds & ends.

I realize that there are more elegant solutions for the display utilizing a processor but I have to utilize what is available (hardware + my limited programming skills).

Thanks to everyone who commented so far - it has helped to crystallize my thinking.

On a more humorous note - can you picture a bunch of 10 year olds hacking stopwatches? Gives a whole new meaning to "hacking".
 

Attachments

elec_mech

Joined Nov 12, 2008
1,500
I don't think you need a PICAXE for this. John mentioned the 4066 taking care of the debounce as well as functioning as a switch. This can all be done with your first circuit plus a set of IR sensors (which, unless someone corrects me, won't have any bounce because they are not mechanical). May need to add a little logic so first sensor doesn't stop the clock, but otherwise, this can be a purely hardwired solution (no PICAXE needed).
 

JohnInTX

Joined Jun 26, 2012
4,787
I don't think you need a PICAXE for this. John mentioned the 4066 taking care of the debounce as well as functioning as a switch. This can all be done with your first circuit plus a set of IR sensors (which, unless someone corrects me, won't have any bounce because they are not mechanical). May need to add a little logic so first sensor doesn't stop the clock, but otherwise, this can be a purely hardwired solution (no PICAXE needed).
You could control the timing with a flip-flop. The first IR sets it and allows clocks to the the counter, the end IR clears it and stops the counter. The reset button on the counter should also reset the f/f and the 100Hz prescaler chain to initialize to 0.

Since the clock is being gated, you could / should use a TTL AND gate. I would also do it on the 1MHz side to reduce the timing ambiguity.
 

Thread Starter

bertz

Joined Nov 11, 2013
327
I don't think you need a PICAXE for this. John mentioned the 4066 taking care of the debounce as well as functioning as a switch. This can all be done with your first circuit plus a set of IR sensors (which, unless someone corrects me, won't have any bounce because they are not mechanical). May need to add a little logic so first sensor doesn't stop the clock, but otherwise, this can be a purely hardwired solution (no PICAXE needed).
Yes, I totally agree that this can be done without a PICAXE. However, consider the reasons why a PICAXE might be a preferable solution.


Recall that earlier in this discussion I mentioned that typically two cars race at the same time. However our track has 3 lanes. It would be advantageous to time all three lanes, but I would hate to replicate the entire circuit in triplicate. My thinking is to mount the 18M2 on a Xino board (I have a couple of these) and then build a shield to interface with the Xino that would contain the oscillator section and CD4066. I would have to build three display modules containing the 74C926 driver and 7-segment displays.



A single limit switch would start timing the race and interrupting the light to individual photo-transistors would end the timing for each lane. All the tracks I have ever seen utilize a limit switch to initiate timing, so there is no need to re-invent the wheel.


The advantage to this configuration is that all of the timing is done outside the PICAXE, so all it need concern itself with is logic. The 18M2 has plenty of extra I/O so it would be a simple matter to add another 7-segment display and cheap driver to display the order of finish. That would be an added bonus.


As far as programming is concerned, it should be a matter of defining the constants and variables, then developing the logic which should consist mostly of “if…..then” and “for….next” statements. There is plenty of code available to cut and paste, then hack until I get it to work. PICAXE provides a nice little simulator to help debug the programs. Remember, the programming language is BASIC, not hex or C, so this should be within my limited capabilities.


Another thought just occurred to me. Since the duration of these races is less than 5 seconds, it makes no sense to have two digits in front of the decimal place. Why not reconfigure the second 74LS390 (IC3) as a divide by 2/divide by 5 counter so that the output is 1000 Hz instead of 100 HZ? Then I could display the time to 3 decimal place accuracy. Does this make sense?


To summarize the advantages of using a PICAXE:

  1. Fewer components
  2. Expandability
  3. Simple programming
  4. I want to try just for the fun of it
 

Attachments

elec_mech

Joined Nov 12, 2008
1,500
Timing is done via your clock circuit which outputs pulses? So the sensors go through a 4066 then feed into PICAXE. When the first car trips the finish line, the PICAXE sends a signal through a 4066 to stop the clock signal from incrementing the 74C926 and thus the display. The PICAXE then repeats this for the other two cars. Is this correct?

While you're keeping processing power to a minimum, my concern is the PICAXE being able to respond fast enough. In one scenario, two cars are 0.001 seconds apart. I'm not sure the PICAXE will be able to trip both displays and accurately reflect a 0.001 second difference. Another scenario is having two cars reach the finish line at the same time. One might appear to lag behind the other. The PICAXE is notoriously slow. I only bring this up because I've done a few clock projects with the PICAXE and I've had issues when attempting to use a one-second clock (from an external source) and perform other functions as well. I'm not saying don't attempt to use the PICAXE, but be mindful that it may not be able to meet your timing requirements. Perhaps someone with more experience using a PICAXE can confirm or deny this?
 

Thread Starter

bertz

Joined Nov 11, 2013
327
Timing is done via your clock circuit which outputs pulses? So the sensors go through a 4066 then feed into PICAXE. When the first car trips the finish line, the PICAXE sends a signal through a 4066 to stop the clock signal from incrementing the 74C926 and thus the display. The PICAXE then repeats this for the other two cars. Is this correct?

Not quite. When the start limit is tripped, B.3 goes LOW. The PICAXE reads this and sets C.0, C.1, & C.6 HIGH. This routes the timer pulses through the CD4066 and on to pin 12 of the 74C926 for each individual display. The 18M2 can perform up to 4 parallel tasks, so each lane is being timed individually. As each car passes the finish line it drives the respective inputs B.0, B.1, & B.2 HIGH. This will in turn drive the complementary outputs C.0, C.1 & C.6 LOW thus freezing the time of the display.


While you're keeping processing power to a minimum, my concern is the PICAXE being able to respond fast enough. In one scenario, two cars are 0.001 seconds apart. I'm not sure the PICAXE will be able to trip both displays and accurately reflect a 0.001 second difference. Another scenario is having two cars reach the finish line at the same time. One might appear to lag behind the other. The PICAXE is notoriously slow. I only bring this up because I've done a few clock projects with the PICAXE and I've had issues when attempting to use a one-second clock (from an external source) and perform other functions as well. I'm not saying don't attempt to use the PICAXE, but be mindful that it may not be able to meet your timing requirements. Perhaps someone with more experience using a PICAXE can confirm or deny this?
I chose the 18M2 because it is cheap, has a 4 MHz processor speed, and can perform up to 4 parallel tasks. Since I am timing 3 separate lanes, my understanding is that this chip will work in my application. I realize that the BASIC interpreter really slows down the processing, that’s why I kept the clock functions out of the PICAXE. Keep in mind that I am not routing the clock pulses through the PICAXE, but through the CD4066. My thoughts are based on what I have read about using PICAXE devices, so my knowledge base here is miniscule. As you say, perhaps someone with more PICAXE experience can jump in here and confirm the logic or show me the error of my ways.


Note: The Input & Output pins that I have designated are arbitrary and are called out only to illustrate the logic sequence. The actual pins may change in the final construction.
 

MrChips

Joined Oct 2, 2009
30,824
If I am allowed to give my two cents worth, your approach while workable, is a lot of unnecessary work.

Use the PICAXE (or any microcontroller) to keep a timer running. You only need a single timer for any number of tracks. You don't need an external clock. Any microcontroller can keep track of time to 1ms or 10ms resolution.

Use optical sensors for each track. A sense signal grabs the current time for each track. You don't stop the timer, just keep it running.
 

Thread Starter

bertz

Joined Nov 11, 2013
327
If I am allowed to give my two cents worth, your approach while workable, is a lot of unnecessary work.

Use the PICAXE (or any microcontroller) to keep a timer running. You only need a single timer for any number of tracks. You don't need an external clock. Any microcontroller can keep track of time to 1ms or 10ms resolution.

Use optical sensors for each track. A sense signal grabs the current time for each track. You don't stop the timer, just keep it running.
Mr. Chips, thank you for the reply. However you give me credit for skills that are way beyond my capabilities. As Dirty Harry once said, “A man’s got to know his limitations”.


Depending upon your definition of work, it is true that there is extra hardware involved with my approach. However if you include programming into the definition, then anything beyond simple BASIC commands is a lot of unnecessary work for me. At this point in my life I am not about to learn MPLAB, C++ or HEX. For me, building stuff is more fun than the programming aspect.


I have searched through a number of websites but I have not been able to find a PICAXE based stopwatch capable of 1 ms resolution. Not to say that it can’t be done, I just haven’t found one. I have found Microchip PIC projects that can do the job, but again I’m not very interested in learning a new programming language. The problem with the PICAXE processors seems to be the slow processing speeds due to the BASIC interpreter overlay. Again, if someone with more PICAXE experience can contribute it would be greatly appreciated.
 

elec_mech

Joined Nov 12, 2008
1,500
I have searched through a number of websites but I have not been able to find a PICAXE based stopwatch capable of 1 ms resolution.
There are a few you may want to read through (most use an external clock source):

http://www.picaxeforum.co.uk/showthread.php?24348-1st-Project-amp-post-so-please-be-gentle

http://www.picaxeforum.co.uk/showthread.php?24403-Stopwatch

http://www.picaxeforum.co.uk/showthread.php?14517-High-Accuracy-Timer

I understand you're not having the PICAXE generate the clock signal nor are you routing said signal through the PICAXE itself, but you are planning to have the PICAXE respond and react in the ms range. My concern is it can't, but I may be wrong - the links above should help.

Again, not to deter you from learning PICAXE (it's the first microcontroller I suggest to those starting out), but it seems overkill for your application and may not be able to meet your timing requirements to boot. You can do this without the need for a microcontroller. An AND gate comes to mind.

Example:
One clock fed to multiple 3-input AND gates (one gate per car). The AND gate output is fed to a counter display IC for each display. One input of the AND gate is connected to the clock (100Hz or 1kHz depending on whether you want to display 0.01s or 0.001s resolution, respectively. Second AND input comes from start sensor/limit switch. Third input comes from stop sensor connected to a flip flop as John suggested.
 

elec_mech

Joined Nov 12, 2008
1,500
I won't guarantee this will work as is, but here is what I'm thinking of in place of the PICAXE. IC2 takes care of switch bounce and assumes once the limit switch is tripped, it stays that way until the next race.

IC1 is a 3-input AND gate. One input is the clock and is fed to all AND gates (one gate per track). One input is the limit switch which is also fed to all gates. The third input is tied to an IR pair through a toggle flip flop. In this circuit, I'm using a D flip flop as a T flip flop so once the car passed the IR beam, the output is latched to turn off the clock to the display.

This is a fast, rough cut and I leave it open for suggestions, corrections, or improvements from people far smarter than I. :rolleyes:
 

Attachments

Thread Starter

bertz

Joined Nov 11, 2013
327
There are a few you may want to read through (most use an external clock source):

http://www.picaxeforum.co.uk/showthread.php?24348-1st-Project-amp-post-so-please-be-gentle

http://www.picaxeforum.co.uk/showthread.php?24403-Stopwatch

http://www.picaxeforum.co.uk/showthread.php?14517-High-Accuracy-Timer

I understand you're not having the PICAXE generate the clock signal nor are you routing said signal through the PICAXE itself, but you are planning to have the PICAXE respond and react in the ms range. My concern is it can't, but I may be wrong - the links above should help.
Yes, I have pretty much exhausted related threads on the PICAXE forum and as you noted most use an external clock or timing device. The best that I have seen using an internal timer has a 1 second resolution. The following quote from one of the threads pretty much sums the utility of the PICAXE as a timing device:


“IMO the picaxe is a useless timing device when compared to other add on chips like a RTC that plods along in the background until its integrated for a time value, the picaxe is a slow microprocessor in today’s standards, so to palm off any function to an additional chip dedicated for the task is the best way to go in my book. This allows the picaxe to do what it do best (processing data) at the fastest way it can.”

So with that having been said, I believe that I am on the right track using an external clock in order to get the desired resolution. The only question is whether to use TTL logic or a PICAXE processor to control this puppy. A good analogy from industry would be PLC vs. relay logic. I’m still studying and weighing my options.
 

MrChips

Joined Oct 2, 2009
30,824
The mcu used in the PICAXE is not slow.
It is the code that is inefficient.
You can use the same generic mcu as that in the PICAXE or any other mcu, program it in C and get 1ms resolution easily.
 

Thread Starter

bertz

Joined Nov 11, 2013
327
The mcu used in the PICAXE is not slow.
It is the code that is inefficient.
You can use the same generic mcu as that in the PICAXE or any other mcu, program it in C and get 1ms resolution easily.
You're right! Now once and for all - I don't know how to program in C and I don't intend to learn how. So it's a moot point!
 

MrChips

Joined Oct 2, 2009
30,824
Geez, well have it your way!
I guess you're not willing to learn something that is light years ahead of what you are attempting to do.
 
Top