Software
The software for this demonstration was
written in Visual Basic 5. Programming techniques were borrowed freely from
public sources on the Internet.
The program is contained in a single window
as shown below.
The graphic at the top is static and merely
serves to illustrate the concept of projectile motion.
The remainder of the screen is subdivided
into three areas from top to bottom.
Initial conditions
The starting conditions of the lab are setup
and/or displayed here. "Start Height" and "Catcher" reflect
the state of two microswitches on the demo equipment
that detect the ball release at the top of its range and the catcher adjusted
as close as possible to the launch ramp. These are used in the software to
detect an uncatchable setup. "Ball Type" is
a dropdown to tell the program what type of material the ball is made of. This
is not used at all in the program at this time but was intended to allow
analysis of potential and kinetic energy by knowing the mass of the projectile.
The most important item in the setup is the "Ramp Angle". This
dropdown allows selection of a specific ramp angle which is automatically set
by the software and used for subsequent calculations.
Finally there is the "Launch"
button. Once the angle is set and a ball has been placed in the ball release
clicking on the launch button will sound the drum roll and release the ball
down the ramp.
Flight Parameters
The next section displays all of the data for
each launch. When the ball passes through the speed gate at the end of the ramp
the computer detects the opening and closing of the photoelectric switches,
calculates the projectile velocity and displays it as "Speed" in
meters/second. The horizontal and vertical velocity components, flight time and
range are also calculated and displayed as shown. The software also sets the
D/A converter with the proper analog voltage to drive the catcher cart to the
correct position to catch the ball and then plays a another
sound file to indicate a successfully completed launch.
Diagnostic Data and Test
The lower section is used to display
diagnostic data from the demo equipment and provide some test functions.
"Status" simply displays the current state of the input data word.
"Speedbits" are the current state of the
photoelectric detectors in the speed gate. Blocking the LED in one of the gates
will cause the corresponding bit to go to zero. "Cart Position" is
the current state of the 8 bit word that is the input to the D/A converter used to drive the cart position. Cart position
255 is closest to the launch ramp and 0 is farthest away. "Gate
Times" are the raw data words from the timer function (in milliseconds)
used to calculate the ball speed. In order, they correspond to the ball
entering gate 1, leaving gate 1, entering gate 2 and leaving gate 2. As
mentioned elsewhere it is important to use a PC with at least a 233MHz
processor in order to get 1ms resolution from the timer function.
Links to some of the sites that have the most
useful information related to building the hardware and software for the
project are provided here:
The fundamentals of programming the PC
parallel port can be found at http://www.aaroncake.net/electronics/vblpt.htm.
A useful article on interfacing the parallel
port can be found at http://www.hut.fi/Misc/Electronics/circuits/lptpower.html.
Embedded in the software are a couple of
functions critical to the functionality. One that enables bitwise parallel port
I/O under the Win32 OS is win95io.dll from SoftCircuits
Programming (http://www.softcircuits.com).
Another essential function is GetTickCount which
allows access to a millisecond timer. It is interesting to note that on PCs
with clocks slower than about 233MHz ,the millisecond
timer may only return time values in increments of 5 ms. Not too useful when
timing events that are in the order of 10 ms! Finally, a non-essential but
useful function is sndPlaySound which allows the
program to play wav files on demand. This is useful for audio cues and for providing
entertaining sound bites during the demonstration.
The code for the Main form of the VB program
is here.