I am in the process of building a circuit that will monitor the start and
finish times for pine box derby cars. I would like to be able to catch these
events by feeding signals, through the parallel port, to a Visual Basic
program. I was thinking of using the eight data pins from the parallel port
to monitor eight lanes.
The electronics are good to go. My problem is with Visual Basic.
Does anyone know how to access and capture bit patterns from the parallel
port using Visual Basic?
Steve
PS...I have asked this same question in several programming newsgroups, but
I have not recieved any responses.
I just had a wild idea that should do the trick in any version of
Windows, using VB or almost any language: Use the sound card!
You can set the sample rate to 44100 or 48000 Hz to get better
than 23 usec resolution. There is good language and API
support for recording. All you need is a way to encode the
8 channels onto one (or 2) analog input. The solution is to
make a really simple D/A converter. I'd recommend an R-2R
ladder type, since they are less sensitive to resistor tolerance
than a weighted resistor scheme. Now each channel will
produce it's own unique level, and each observed level will
be due to one and only one unique combination of inputs.
The sound card is AC coupled, so this only works for a
situation like yours, where the cars pass a detector and
produce a pulse that lasts a short time. Sound cards typically
go down to at least 20 Hz, so the waveform should be
pretty flat on top for the short duration of a car's passage.
If you have only one car pass it's detector at a time for
a "clear winner" situation, then you just get a pulse whose
height encodes which track it is. The duration tells you the
speed. If you get more than one car at a time, you will
have to decode the amplitude waveform, but I think this
will be pretty straightforward. (Certainly compared to
writing ring 0 drivers to use the parallel port!) And note
that this is "real-time" performance under Windows, which
is nearly impossible to get any other way, since the sound
card is doing all the heavy lifting.
Note that you will need to take care that you set the
mixer controls to the same settings each time. Windows
doesn't make this easy; you either get uncalibrated
sliders in the standard mixer, or you have to confront
the Mixer API... the most abominable interface in the
whole Windows menagerie. So you might want to
come up with a simple calibration scheme, where
you just run one car down the MSB lane and normalize
to the recovered pulse height.
Best regards,
Bob Masta
dqatechATdaqartaDOTcom
D A Q A R T A
Data AcQuisition And Real-Time Analysis
www.daqarta.com