![]() |
| |||
| ||||
As it is already known, the standard parallel port only has 4 digital inputs. Some applications can need more the 4 inputs. In this case to expand the inputs you can make a simple circuit based on a chip as the buffer 74LS157 to feed the data in form on two nibbles (half byte, 4 bits) through the status register (4 or 5 lines) towards the parallel Port . The data register or the control register can be used to select the nibble.
Description of the buffer 74LS157

Fig. The 74LS157 buffer
References
Inputs
Entered I0a 0a Qa Qa Exit
Entered I0b 0b Qb Qb Exit
Entered I0c 0c Qc Qc Exit
Entered I0d 0d Qd Qd Exit
Entered I1a 1a
Entered I1b 1b
Entered I1c 1c
Entered I1d 1d
Feeding and operation
S nibble Selection.
- Inable Rating of the component (to maintain signal in low)
Vcc 5 volts
Gnd Earth
The source of 5 volts to feed this circuit can be obtained from the port game, USB Port, the power supply or a homemade power supply
Operation
With 74LS157 the selection is made through the data register or the control record. In the figure that is next it shows in case the selection is through control record

Fig. Suggested Connection of 74LS157 with Parallel Port
Programming
The following algorithm allows to read the eight bits of the entrance of 74LS157
El siguiente algoritmo permite leer los ocho bits de la entrada del74LS157
/* Inicio */
/* Selección del primer nibble */
Colocar 0 en el bit C3- para seleccionar el nibble N1
Leer el registro de estado en una variable, por ejemplo d_leido
Realizar la operación d_leido XOR con 128, para corregir el signo de S7-
Este resultado operar con AND 240, para descargar bits no deseados
Desplazar a la derecha 4 bits para colocarlo en el nibble de abajo
Almacenar el resultado de un lado
/* Selección del segundo nibble */
colocar 1 en el bit C3-, para seleccionar el nibble N2
Leer el registro de estado en una variable, por ejemplo d_leido
Realizar la operación d_leido XOR con 128, para corregir el signo de S7-
Este resultado operar con AND 240, para descargar bits no deseados
Realizar la operación OR del resultado con el nibble almacenado previamente
En el resultado final están los 8 bits leídos.
/* Fin */