Programación Específica > Programación de Aplicaciones para Dispositivos
Captar Datos De Un Puerto Paralelo
sejis:
Como ya debes saber el purto paralelo es compatible con TTL, por lo tanto si las entradas del puerto estan al aire o no conectadas el resultado de la lectura sera como si todas fuesen uno.
Para trabajar el puerto coo entrada debes configurarlo en el setup del pc en el modo ssp o normal lo que habilita el modo bidireccional del puerto.
Tambien sabes que el puerto se compone de 3 registros cada uno de ocho bits
, debes mandar un uno al bit 5 del puerto 379 o al 37A, es uno de los dos pero no recurdo cual con exactitud. Si colocas 1 la direccion 378 funciona como entrada y si colocas 0 sera salida.
Espero haberte ayudado.
DrakerDG:
:comp: Aquí tienen más información del puerto paralelo y sus registros.
Tambien incluyo una libreria (IO.dll) por medio de la cual se pueden accesar a estos registros desdede Windows 95 a Windows XP.
Las declaraciones en Visual Basic son las siguientes:
--- Código: Text --- Public Const LPT1x = &H378 Public Declare Sub PortOut Lib "IO.DLL" (ByVal Port As Integer, ByVal Data As Byte)Public Declare Sub PortWordOut Lib "IO.DLL" (ByVal Port As Integer, ByVal Data As Integer)Public Declare Sub PortDWordOut Lib "IO.DLL" (ByVal Port As Integer, ByVal Data As Long)Public Declare Function PortIn Lib "IO.DLL" (ByVal Port As Integer) As BytePublic Declare Function PortDWordIn Lib "IO.DLL" (ByVal Port As Integer) As LongPublic Declare Sub SetPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte)Public Declare Sub ClrPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte)Public Declare Sub NotPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte)Public Declare Function GetPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte) As BooleanPublic Declare Function RightPortShift Lib "IO.DLL" (ByVal Port As Integer, ByVal Val As Boolean) As BooleanPublic Declare Function LeftPortShift Lib "IO.DLL" (ByVal Port As Integer, ByVal Val As Boolean) As BooleanPublic Declare Function IsDriverInstalled Lib "IO.DLL" () As Boolean '********************************************************'********* Function Descriptions *******************'******************************************************** 'PortOut - Outputs a byte to the specified port. 'PortWordOut - Outputs a word (16-bits) to the specified port. 'PortDWordOut - Outputs a double word (32-bits) to the specified port. 'PortIn - Reads a byte from the specified port. 'PortWordIn - Reads a word (16-bits) from the specified port. 'PortDWordIn - Reads a double word (32-bits) from the specified port. 'SetPortBit - Sets the bit of the specified port. 'ClrPortBit - Clears the bit of the specified port. 'NotPortBit - Nots (inverts) the bit of the specified port. 'GetPortBit - Returns the state of the specified bit. 'RightPortShift - Shifts the specified port to the right. The LSB is' returned, and the value passed becomes the MSB. 'LeftPortShift - Shifts the specified port to the left. The MSB is' returned, and the value passed becomes the LSB. 'IsDriverInstalled - Returns non-zero if io.dll is installed and' functioning. The primary purpose of this function' is to ensure that the kernel mode driver for' NT/2000/XP has been installed and is accessible. 'Funciones personalizadas (ejemplo). Public Function OutPort1(ByVal Num As Byte) As Byte PortOut LPT1x, Num OutPort1 = NumEnd Function Public Function InPort2() As ByteDim XB As Byte XB = PortIn(LPT1x + 1) InPort2 = XBEnd Function Public Function OutPort3(ByVal Num As Byte) As Byte PortOut LPT1x + 2, Num OutPort3 = NumEnd Function Public Function InPort3() As ByteDim XB As Byte XB = PortIn(LPT1x + 2) InPort3 = XBEnd Function
Revisen el archivo adjunto.
:suerte:
Navegación
[*] Página Anterior
Ir a la versión completa