TODOPIC

Microcontroladores PIC => * PROYECTOS * => Mensaje iniciado por: afar119 en 08 de Agosto de 2006, 23:09:31

Título: emulador de teclado ps/2 para xp
Publicado por: afar119 en 08 de Agosto de 2006, 23:09:31
hola amigos les cuento que ya hice una adaptacion de un codigo que consegui para emular el teclado , pero ahora no me anda con xp. les agradeseria si alguno tiene el codigo para la secuencia de inicilalizacion que es donde falla
Título: Re: emulador de teclado ps/2 para xp
Publicado por: jel_75 en 22 de Diciembre de 2006, 22:05:55
Hola, mira estoy en lo mismo que vos, logro transmitir datos pero no recibir, ni inicializar el teclado, pegale un vistazo a mi post que hay un manual y mi codigo para descargar ,por ahi te sirve y si llegaste a algo mas que yo porfa pasamelo que me quede estancado ahi.

http://www.todopic.com.ar/foros/index.php?topic=15102.0

Gracias
Título: Re: emulador de teclado ps/2 para xp
Publicado por: arcabuz en 26 de Junio de 2008, 10:23:53
Hola, sabes que estoy recien metiendome en esto de los PICs y mi meta es desarrollar un emulador de teclado ps/2, para usarlo en una máquina arcade. Quise revisar tu link, pero no me deja entrar, me dice que no existe o no tengo permiso... plop.... hasta ahora estaba pensando hacerlo con un 16F877A (no se si sera adecuado) y lo poco he avanzado del tema es generar los codigos (las secuencias de tren de pulso)... se que el codigo es tosco y poco refinado, pero se los adjunto para que hechen una ojeada.


Título: Re: emulador de teclado ps/2 para xp
Publicado por: aitopes en 26 de Junio de 2008, 10:29:49
hola amigos les cuento que ya hice una adaptacion de un codigo que consegui para emular el teclado , pero ahora no me anda con xp. les agradeseria si alguno tiene el codigo para la secuencia de inicilalizacion que es donde falla

Quizas seria bastante util que pusieras el codigo por aqui.... Resulta bastante complicado encontrar el error en algo que uno no conoce ;)
Título: Re: emulador de teclado ps/2 para xp
Publicado por: arcabuz en 26 de Junio de 2008, 10:42:15
Hola, antes que todo, gracias por tu respuesta.

Respecto al código, te cuento que lo adjunte, se llama 'teclado2_bruto.asm', y esta como "pie de mensaje", al lado de un clip, quise ponerlo como otros codigos, en una ventana, pero no pille como, ahora si pille como, asi que ahi va...... 

Código: [Seleccionar]
;---Inicio---
list p=16f877
radix hex

;---Mapa de memoria---
status equ 0x03
porta equ 0x05
portb equ 0x06
portc equ 0x07
portd equ 0x08
porte equ 0x09

reg1 equ 0x0C
reg2 equ 0x0D
reg3 equ 0x0E
reg4 equ 0x0B
bits1 equ 0x1C
bits2 equ 0x1F
tecla1 equ 0x1D
tecla2 equ 0x1E

;---Configuracion de puertos---
reset org 0x00
goto inicio
org 0x05

inicio bsf status,5
movlw b'11111'
movwf porta ;Puerto A entrada
movlw b'11111111'
movwf portb ;Puerto B entrada
movlw b'11111111'
movwf portc ;Puerto C entrada
movlw b'11111111'
movwf portd ;Puerto D entrada
movlw b'000'
movwf porte ;Puerto E salida
bcf status,5

;---Espera---
espera btfsc portb,0
call tecla_up
btfsc portb,1
call tecla_down
btfsc portb,2
call tecla_right
btfsc portb,3
call tecla_left
btfsc portb,4
call tecla_shift
btfsc portb,5
call tecla_control
btfsc portb,6
call tecla_Z
btfsc portb,7
call tecla_X
btfsc portc,0
call tecla_M
btfsc portc,1
call tecla_N
btfsc portc,2
call tecla_B
btfsc portc,3
call tecla_H
btfsc portc,4
call tecla_Q
btfsc portc,5
call tecla_W
btfsc portc,6
call tecla_A
btfsc portc,7
call tecla_S
btfsc portd,0
call tecla_R
btfsc portd,1
call tecla_T
btfsc portd,2
call tecla_1
btfsc portd,3
call tecla_2
btfsc portd,4
call tecla_5
btfsc portd,5
call tecla_6
btfsc portd,6
call tecla_esc
btfsc portd,7
call tecla_O
btfsc porte,0
call tecla_K
btfsc porte,1
call tecla_enter
goto espera


;==================================================================
; PROTOCOLO PS/2
; 1 bit de inicio: siempre 0
; 8 bit de datos: menos significativo primero
; 1 bit de paridad (paridad impar -odd-) (0 si 1 impar, 1 si 1 par)
; 1 bit de parada: siempre 1
;
; VARIABLE TECLA1 = 0110 0100
; 0-3, teclas con paridad 1 (1 par)
; 4-7, teclas con paridad 0 (1 impar)
;==================================================================

;---Teclas---
tecla_up
bcf porte,1 ;0 (Inicio)
call pausa
bcf porte,1 ;0 (Datos)
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;1 (Paridad)
call pausa
bsf portd,1 ;1 (Parada)
call pausa2
return

tecla_down
bcf porte,1 ;0 (Inicio)
call pausa
bcf porte,1 ;0 (Datos)
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;1 (Paridad)
call pausa
bsf portd,1 ;1 (Parada)
call pausa2
return

tecla_right
bcf porte,1 ;0 (Inicio)
call pausa
bcf porte,1 ;0 (Datos)
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;1 (Paridad)
call pausa
bsf portd,1 ;1 (Parada)
call pausa2
return

tecla_left
bcf porte,1 ;0 (Inicio)
call pausa
bcf porte,1 ;0 (Datos)
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;1 (Paridad)
call pausa
bsf portd,1 ;1 (Parada)
call pausa2
return

tecla_shift
bcf porte,1 ;0 (Inicio)
call pausa
bcf porte,1 ;0 (Datos)
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;1 (Paridad)
call pausa
bsf portd,1 ;1 (Parada)
call pausa2
return

tecla_control
bcf porte,1 ;0 (Inicio)
call pausa
bcf porte,1 ;0 (Datos)
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;1 (Paridad)
call pausa
bsf portd,1 ;1 (Parada)
call pausa2
return

tecla_Z ;bsf portd,0
bcf porte,1 ;0 (Inicio)
call pausa
bcf porte,1 ;0 (Datos)
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bsf porte,1 ;1
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;1 (Paridad)
call pausa
bsf portd,1 ;1 (Parada)
call pausa2
return

tecla_X bcf porte,1 ;0 (Inicio)
call pausa
bcf porte,1 ;0 (Datos)
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;1 (Paridad)
call pausa
bsf portd,1 ;1 (Parada)
call pausa2
return

tecla_M bcf porte,1 ;0 (Inicio)
call pausa
bcf porte,1 ;0 (Datos)
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;1 (Paridad)
call pausa
bsf portd,1 ;1 (Parada)
call pausa2
return

tecla_N bcf porte,1 ;0 (Inicio)
call pausa
bcf porte,1 ;0 (Datos)
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;1 (Paridad)
call pausa
bsf portd,1 ;1 (Parada)
call pausa2
return

tecla_B bcf porte,1 ;0 (Inicio)
call pausa
bcf porte,1 ;0 (Datos)
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;1 (Paridad)
call pausa
bsf portd,1 ;1 (Parada)
call pausa2
return

tecla_H bcf porte,1 ;0 (Inicio)
call pausa
bcf porte,1 ;0 (Datos)
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;1 (Paridad)
call pausa
bsf portd,1 ;1 (Parada)
call pausa2
return

tecla_Q ;bsf portd,0
bcf porte,1 ;0 (Inicio)
call pausa
bsf porte,1 ;1 (Datos)
call pausa
bcf porte,1 ;0
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0 (Paridad)
call pausa
bsf portd,1 ;1 (Parada)
call pausa2
return

tecla_W bcf porte,1 ;0 (Inicio)
call pausa
bcf porte,1 ;0 (Datos)
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;1 (Paridad)
call pausa
bsf portd,1 ;1 (Parada)
call pausa2
return

tecla_A bcf porte,1 ;0 (Inicio)
call pausa
bcf porte,1 ;0 (Datos)
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;1 (Paridad)
call pausa
bsf portd,1 ;1 (Parada)
call pausa2
return

tecla_S bcf porte,1 ;0 (Inicio)
call pausa
bcf porte,1 ;0 (Datos)
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;1 (Paridad)
call pausa
bsf portd,1 ;1 (Parada)
call pausa2
return

tecla_R bcf porte,1 ;0 (Inicio)
call pausa
bcf porte,1 ;0 (Datos)
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;1 (Paridad)
call pausa
bsf portd,1 ;1 (Parada)
call pausa2
return

tecla_T bcf porte,1 ;0 (Inicio)
call pausa
bcf porte,1 ;0 (Datos)
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;1 (Paridad)
call pausa
bsf portd,1 ;1 (Parada)
call pausa2
return

tecla_1 bcf porte,1 ;0 (Inicio)
call pausa
bcf porte,1 ;0 (Datos)
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;1 (Paridad)
call pausa
bsf portd,1 ;1 (Parada)
call pausa2
return

tecla_2 bcf porte,1 ;0 (Inicio)
call pausa
bcf porte,1 ;0 (Datos)
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;1 (Paridad)
call pausa
bsf portd,1 ;1 (Parada)
call pausa2
return

tecla_5 bcf porte,1 ;0 (Inicio)
call pausa
bcf porte,1 ;0 (Datos)
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;1 (Paridad)
call pausa
bsf portd,1 ;1 (Parada)
call pausa2
return

tecla_6 bcf porte,1 ;0 (Inicio)
call pausa
bcf porte,1 ;0 (Datos)
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;1 (Paridad)
call pausa
bsf portd,1 ;1 (Parada)
call pausa2
return

tecla_esc
bcf porte,1 ;0 (Inicio)
call pausa
bcf porte,1 ;0 (Datos)
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;1 (Paridad)
call pausa
bsf portd,1 ;1 (Parada)
call pausa2
return

tecla_O bcf porte,1 ;0 (Inicio)
call pausa
bcf porte,1 ;0 (Datos)
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;1 (Paridad)
call pausa
bsf portd,1 ;1 (Parada)
call pausa2
return

tecla_K bcf porte,1 ;0 (Inicio)
call pausa
bcf porte,1 ;0 (Datos)
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;1 (Paridad)
call pausa
bsf portd,1 ;1 (Parada)
call pausa2
return

tecla_enter
bcf porte,1 ;0 (Inicio)
call pausa
bcf porte,1 ;0 (Datos)
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bsf porte,1 ;1
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;0
call pausa
bcf porte,1 ;1 (Paridad)
call pausa
bsf portd,1 ;1 (Parada)
call pausa2
return


;---Retardo 50us----
;PIC Time Delay = 0,00005000 s with Osc = 4000000 Hz
pausa movlw D'15'
movwf reg1
loop decfsz reg1,1
goto loop
retlw 0


;---Retardo 150us---
pausa2 movlw D'45'
movwf reg1
loop2 decfsz reg1,1
goto loop2
retlw 0



;---Retardo---
;pausa movlw 10      ; Aquí se cargan los registros
; movwf reg1     ; reg1, reg2 y reg3
;      ; con los valores 10, 20 y 30
;tres movlw 10      ; respectivamente
; movwf reg2
;
;dos movlw 5
; movwf reg3
;
;uno decfsz reg3,1     ; Aquí se comienza a decrementar
; goto uno      ; Cuando reg3 llegue a 0
; decfsz reg2,1     ; le quitare 1 a reg2
; goto dos      ; cuando reg2 llegue a 0
; decfsz reg1,1     ; le quitare 1 a reg1
; goto tres     ; cuando reg1 llegue a 0
; bsf porte,1
;retlw 00     ; regresare al lugar
; return      ; de donde se hizo la llamada

;---FIN---
end

Supongo que el codigo no está del todo mal, sin embargo se que es tosco, ya que debe haber otras formas de hacerlo mas eficiente y lo que definitivamente no hace es obtener señales del computador y sincronizarse con éstas.

Quiero agregar un enlace a otro tema del foro que me esta bastante avanzado y bien interesante al respecto...

http://www.todopic.com.ar/foros/index.php?topic=2256.0

Saludos,
Roberto