This is only a preview of the February 1996 issue of Silicon Chip. You can view 26 of the 96 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Items relevant to "Woofer Stopper Mk 2 - Now It's Even Better!":
Articles in this series:
Items relevant to "Computer Bits":
Articles in this series:
|
COMPUTER BITS
BY RICK WALTERS
Test your reaction time using a PC
Are you are one of those people who doesn’t
believe your reaction time is affected by “a drink
or three”. This simple reaction timer will correct
that perception once and for all.
This reaction timer uses a PC-compatible computer and a simple Basic
program to generate an audio cue and/
or a visual prompt via the screen. It
then measures the time delay before
a key on the computer’s keyboard is
pressed.
Alternatively, if you connect a
switch to the games port and fabricate the equivalent of a brake pedal,
you can compare your hand and foot
response times.
When the software is run, the screen
shows all the options that are available – see Fig.2. First, you can elect to
have the trigger stimulus as an audible
beep, a visual red rectangle or both.
Second, either the keyboard (for hand
reaction time) or the external switch
(for foot reaction time) can be selected.
And finally, you can choose between
a single reaction time display or have
the display show the last five reaction
times and their average.
The test is started simply be pressing
the spacebar. The program now generates the cue (or stimulus) at some
random time up to 10 seconds later,
after which you press the spacebar
again (or the foot switch) as quickly
as possible. Your reaction time in
milliseconds (a time of 160ms is pretty
good) is then displayed along the bottom of the screen.
If you press the spacebar before the
stimulus appears, the screen displays
the message “No cheating – wait for
stimulus”.
The program
We have elected to write the software in GW-BASIC, as virtually all
computers will have a copy supplied
with DOS. If you have Qbasic, you
may need to allocate the odd line
number for subroutines. A fully
compiled version of the program is
also available.
The full listing is almost two pages
long and the chances of errors creeping
in, if you have to type all the code, are
quite high. To overcome this problem,
we have listed the minimum code
which will allow you to measure your
reaction time.
This “simple” version provides
for keyboard reaction time only and
doesn’t display any screen options.
The full listing with all the options
and the fancy screen is available
from SILICON CHIP on a floppy disc,
This optional footswitch can be
made up from scrap material and
plugs into the games port of the
computer.
February 1996 85
The optional external foot switch is
connected to the games port via a
15-pin male D-connector. Note that
the Port A and Port B inputs are wired
in parallel.
This close-up view shows the switch mounting details, Virtually any heavy-duty
pushbutton switch with normally closed contacts can be used.
Fig.1: connect the leads to the
15-pin D-connector, as shown
here. The other end of the
cable goes to the switch.
along with the compiled version of
the program.
Minimum version
If you want the simple version only,
it’s just a matter of typing in the listing
published here. If this is the first time
you have attempted to enter a Basic
program, go back to the DOS prompt
(C:>), change to the DOS directory
(CD DOS), type GWBASIC and press
ENTER. The screen should read something like this:
Fig.2: the opening screen when the program is loaded. The test is started by
pressing the spacebar and waiting for the stimulus.
GW-BASIC 3.23
(C) Copyright Microsoft 1983 1984 (etc)
60300 bytes free
OK
The message on your machine may
vary slightly from that shown above,
depending on the particular version,
but if GW-BASIC is present you are
ready to begin.
Start by typing the first line at the
cursor; ie, 10 REM REACT1.BAS #1.0
R.W. 20/09/95. At the end of each line
86 Silicon Chip
Fig.3: the reaction time is listed immediately below the visual stimulus (if
selected). Pressing the Esc key allows you to change the operating setup.
press ENTER. Don’t worry if one or two
long lines get to the righthand edge of
the screen – just keep typing. The line
will wrap automatically.
When you have finished, or are tired
of typing, finish the current line, press
ENTER, then type “SAVE C:REACT1”,A
then press ENTER, or if using a different drive, substitute that drive letter
for C. Note that the “A” suffix saves the
file as ASCII text, so that you can read
it on a word processor. If this suffix
is omitted, the file would be saved in
GW-BASIC format which appears on
the screen as “garbage”.
To run the program while in Basic,
type RUN and press enter. If you have
made any typing errors, the program
will stop and give you a message telling you the line number where the
problem occurred.
The usual troubles are commas for
colons, one pair of quote marks omitted, or a missing bracket. You don’t
have to retype the line, just move the
cursor along with the right arrow, until
you reach the problem, overtype with
the correction and press ENTER. You
don’t even have to go to the end of
the line. To exit from Basic, just type
SYSTEM.
To run the program at a later time,
type GWBASIC REACT1. To quit the
program, you just press the END key.
Full version
As mentioned above, the full version of the software allows you to
select the games port, instead of the
keyboard, as the stimulus input. To
run the compiled (executable) version
of the program, type REACTION at the
DOS prompt. Alternatively, you can
run the program in Basic by typing
GWBASIC REACTION.
We made a foot pedal using a
heavy- duty pushbutton switch with
normally-closed (NC) contacts, a
right angle bracket, some bolts and
nuts, and a couple of pieces of timber
which were hinged at one end – see
photos. The connection to the games
port is made via a 15-pin male “D”
connector, with the leads from the
NC contacts of the switch wired as
shown in Fig.1.
Reaction Timer Listing (Simple Version)
10 REM REACT1.BAS #1.0 R.W. 20/09/95
20 GOSUB 1000 ‘Initialise
30 GOSUB 2000 ‘Generate random delay, store time1
40 GOSUB 3000 ‘Wait for keypress, store time2 calc. reaction time
100 GOTO 30 ‘Do it again
999 END
1000 ‘***********
1010 ‘INITIALISE.
1020 ‘***********
1030 DEFINT A-Z: DEF FNCENTRE$(M$) = SPACE$((80-LEN(M$))/2) + M$
‘Centre text
1040 KEY OFF: CLS: SCREEN 9: COLOR 8,3
1050 DEF FNR = CSRLIN: DEF FNC = POS(X): DEF FNCEOL$ = STRING$(79FNC,” “)
1060 DEFSTR E,K: ESC = CHR$(27): ENTER = CHR$(13)
1070 KEYSP = CHR$(32): KEYEND = CHR$(207)
1080 LOCATE 2,25: PRINT “SILICON CHIP REACTION TIMER”;
1099 RETURN
2000 ‘**********************
2010 ‘GENERATE RANDOM DELAY.
2020 ‘**********************
2030 M$ = “Press SPACE-BAR to test, END to finish”
2040 GOSUB 5030
2050 IF K = KEYEND THEN CLS: SYSTEM
2060 IF K < > KEYSP THEN 2040
2070 LOCATE 23,22: PRINT FNCEOL$;
2080 LOCATE 25,1: PRINT FNCEOL$;
2090 RANDOMIZE TIMER: RANDNO = INT((RND*10)/2) + 1
2100 DEF FNSEC = VAL(RIGHT$(TIME$,2))
2110 NEWSEC = (FNSEC + RANDNO) MOD 60
2120 WHILE FNSEC < NEWSEC: WEND
2130 TIME1# = TIMER: BEEP: RETURN
2199 RETURN
3000 ‘**********************
3010 ‘COMPUTE REACTION TIME.
3020 ‘**********************
3040 K = INPUT$(1)
3050 TIME2# = TIMER
3060 DELAY = CINT((TIME2# - TIME1#) * 1000) ‘milliseconds
3070 LOCATE 23,2: PRINT FNCEOL$;
3080 IF DELAY = 0 THEN LOCATE 23,25: PRINT “No cheating - wait for
stimulus!”;: GOTO 3099
3090 LOCATE 23,22: PRINT “Your reaction time was”;DELAY;”milliseconds”;
3099 RETURN
5000 ‘*******************
5010 ‘CLS & WRITE CENTRE.
5020 ‘*******************
5030 LOCATE 25,1: PRINT FNCEOL$;: LOCATE 25,1
5040 PRINT FNCENTRE$(M$);
5050 K = INKEY$: WHILE K = “”: K = INKEY$: WEND
5060 IF LEN(K) = 2 THEN K = CHR$(ASC(RIGHT$(K,1)) OR &H80)
5099 RETURN
Software availability
The compiled and Basic listings
of the full version of the program
(Reaction.exe and Reaction.bas) are
available on a floppy disc from Silicon
Chip Publications Pty Ltd, PO Box 139,
Collaroy 2097. The price is $A7 plus
$A3 p&p (Aust., NZ & PNG; $5 p&p
elsewhere).
Payment may be made by cheque
or money order. Alternatively, phone
(02) 9979 5644 with your credit card
details, or fax the details to (02) 9979
6503. Please indicate the disc size
required (either 3.5-inch or a 5.25inch).
SC
February 1996 87
|