I'm confused now... By frequency, do you mean I can output things
distinguishably different than just the +5v I@m currently sending??
Hi Danny,
Yes. On the one hand, there is the absolute value 0 or 1, which could
be interpreted as "digital" off or on, respectively. As in my stepper
motor example, there is also the relative rate at which 0's and 1's are
changing. The coils on a stepper motor respond to these changes and
the shaft turns faster or slower. A speaker would be another example,
also operated by a coil. Passing pulses (sets of 0's and 1's) at
different rates (frequencies) could in principle yield different tones,
much like what happens when you hit different buttons on your telephone,
although, let us not get bogged down in details of how the registered
trademark "Touch-tone" works. Just note that different frequencies are
being generated when you hit different buttons. Choosing different
combinations of buttons in a series could play different tunes, for
instance. There is no reason a single pin from your parallel port could
not do something similar. Consider what would happen if you sent 20 0's
and then 20 1's, and repatedly this loop continuously and the output was
a speaker.
Distinguishing these two concepts: Feeding a counter IC, like a Johnson
4017 at different rates from a pin of the parallel port would simply
make the 4017 cycle through the stages faster or slower. Connecting LEDs
to each of the stages would cycle through each LED, but would not
necessarily change the brightness of each LED. If instead, you connected
more directly from the port to an LED (using an appropriate resistor),
you could not only turn it on, the rate at which you switch between 0's
and 1's would dictate brightness. I think it ends up working similar to
a diac/triac circuit that controls the brightness of a bulb by chopping
up the current.
For starters:
Try this, since you can program your parallel port; with whatever language
you are programming in, you can have for/while loops that cycle between
the 0 and 1 states. Add a pause between the instructions for setting 0 and
1. Below is a code fragment I once wrote in C (for Linux). You can change
frequency by changing the value of usleep. This would cause stepper motors
to turn faster or slower. It could presumably also change the tone of a speaker
or the brightness of an LED, etc. Taking this to a further level of
complexity, one could split the outgoing signal from each data pin
(voltage or current divider, logic circuits, etc) to take advantage of both
absolute 0 and 1 states, as in loading registers, etc and also the
frequency information (direct pulse modulation of LED brightness) or
via a frequency-to-voltage conversion (voltage dictates brightness). It
represents one means of sending serial information via a parallel port.
Similarly, a Morse code scheme sent from a single pin could also be used.
step_function()
{
for(i=1; i<=step_value1; i++) {
/* Set the data signals (D0-7) of the port */
outb(0, BASEPORT);
/* Sleep for a while */
usleep(10000);
outb(direction1, BASEPORT);
usleep(10000);
}
for(i=1; i<=step_value2; i++) {
outb(0, BASEPORT);
usleep(10000);
outb(direction2, BASEPORT);
usleep(10000);
}
}
Dominic