Building Millisecond Timer

Thread Starter

bilbo_braggins

Joined Feb 16, 2011
2
I have a project which requires me to determine the amount of time it takes for a relay to close after having pushed a button on a keyboard. I'd like to use the keyboards momentary switch to start the timing, and and use the voltage from the relay to stop the timing. Am I crazy for considering rewiring a stopwatch like this (timing down to the millisecond is needed)? I am a software engineer with almost no electrical engineering experience, but hopefully with forums help I can pick up a little as I delve into this project.:)
 

thatoneguy

Joined Feb 19, 2009
6,359
There is a great deal to the task.

First, if you are using a PC, you need to decode the key.

Then there is the OS delay in interpreting the keystroke, then sending the data to the serial or USB external relay board, at which point you'd have to time the contact closure time.

This may be in the 1mS or less range (even through the OS).

If you are trying to measure switch time of a relay with a button, battery, and relay, you only need a handful of ICs. The button would start a timer (32.768kHz crystal counter), and the contacts of the relay closing would stop the timer (counter). Then a display system added on and you have what you want.

To sum: I'm unsure if you want to measure time from a PC keyboard to a Relay on a port, or the speed of a relay on it's own.
 

Thread Starter

bilbo_braggins

Joined Feb 16, 2011
2
There is a great deal to the task.

First, if you are using a PC, you need to decode the key.

Then there is the OS delay in interpreting the keystroke, then sending the data to the serial or USB external relay board, at which point you'd have to time the contact closure time.

This may be in the 1mS or less range (even through the OS).

If you are trying to measure switch time of a relay with a button, battery, and relay, you only need a handful of ICs. The button would start a timer (32.768kHz crystal counter), and the contacts of the relay closing would stop the timer (counter). Then a display system added on and you have what you want.

To sum: I'm unsure if you want to measure time from a PC keyboard to a Relay on a port, or the speed of a relay on it's own.

Thanks for the reply. I hoped to wire into the key's momentary switch to start the timing, and then stop the timing upon the relays trigger. The keyboard is not a PC keyboard, and timing on a single PC will not suffice. The (simplified) setup looks something like this:
 

someonesdad

Joined Jul 7, 2009
1,583
Here are two things to think about. First, if you have a computer running an OS in there, the timing will likely not be deterministic. But the standard deviation might be small enough for your purposes -- you can't tell without making measurements.

Second, if the keyboard involves a switch with no electronic buffering, then you may have to deal with contact bounce. This can confuse the timing if you're not careful.

The simplest way to do this task is to use a scope. Of course, that's salting the bird's tail if you don't have access to a scope. But it probably would be worth your time to hunt one up because you'll know immediately if you need to deal with a bouncing switch and you'll be able to get some timing measurements with virtually no work.
 
Top