Fuente digital controlada desde un teclado matricial

Buenas.... les pido una mano, para la ejecucion de este proyecto; lo que se trata de lograr hacer es un sistema mediante el cual teclees el voltaje que desees obtener, se visualice en el display y mande una orden a un potenciometro digital... el voltaje debe estar dentro del rango {0-24}v.
el problema que tengo es que estuve modificando el siguiente codigo para ajustarlo a mis necesidades.... todo arrancaba bien hasta la comparcion del primer caracter ingresado... cuando quiero seguir comparando con el segundo caracter ingresado, ya no funciona el programa salen rutinas inesperadas en el lcd. creo que es por que se llena la Rom del pic o a que se debera?
Agradeceria su comentario y ayuda... ya que segun lo que pienso necesitaria 24 mensajes diferentes.. y luego comunicarlo mediante el I2C, Para gobernar 8 bits del potenciometro
Código:
	LIST		P=16F84A
	INCLUDE		<P16F84A.INC>
	__CONFIG	_CP_OFF &  _WDT_OFF & _PWRTE_ON & _XT_OSC
	
	CBLOCK  0x0C
	ContadorTeclasPulsadas
	GuardaValor
	Operando1
	Operando2
	ENDC

; ZONA DE CÓDIGOS ********************************************************************

VisualizaHex	MACRO	Operando,Caracter
	movf	GuardaValor,W			; Recupera el valor y lo visualiza.
	movwf	Operando				; Lo guarda para sumar después.
	call	LCD_Nibble				; Visualiza el valor en la pantalla	; Visualiza el signo '+' ó '-' según corresponda.
	incf	ContadorTeclasPulsadas,F
	ENDM

	ORG	0
	goto 	Inicio
	ORG	4
	goto	ServicioInterrupcion
Inicio
	call	LCD_Inicializa
	call	Teclado_Inicializa
	clrf	ContadorTeclasPulsadas	; Resetea este contador.
	movlw	b'10001000'				; Habilita la interrupción RBI y la general.
	movwf	INTCON
Principal
	sleep							; Espera en modo bajo consumo que pulse.
	goto	Principal

; Subrutina "ServicioInterrupcion" ------------------------------------------------------
;
ServicioInterrupcion
	call	Teclado_LeeHex			; Obtiene el valor hexadecimal de la tecla pulsada.
	movwf	GuardaValor				; Guarda el valor.
	movf	ContadorTeclasPulsadas,W; Según el número de tecla pulsada realiza una
	addwf	PCL,F					; función distinta.
	goto	PrimeraTeclaPulsada
	goto	SegundaTeclaPulsada
	goto	Comparador
PrimeraTeclaPulsada
	call	LCD_Borra				; Borra la pantalla anterior.
	movlw	MensajeDigite				; En pantalla el mensaje "Hex:"
	call	LCD_Mensaje
	VisualizaHex Operando1,'+'
	goto	FinInterrupcion
SegundaTeclaPulsada
	VisualizaHex Operando2,'+'
	goto	FinInterrupcion
Comparador
	movlw '='
	call LCD_Caracter
	movf	Operando1,W				; Procede a la suma de los tres valores.
	call	LCD_Nibble
	movf	Operando2,W
	call	LCD_Nibble
	movlw	MensajeVolt				; En pantalla el mensaje "Dec:"
	call	LCD_Mensaje

call	LCD_Linea2				; Ahora visualiza la segunda línea.
movlw	b'00000000'
subwf Operando1,W
btfss STATUS,Z
goto $+2
goto CERO
movlw	b'00000001'
subwf Operando1,W
btfss STATUS,Z
goto $+2
goto VOLTAJEFALLIDO
movlw	b'00000010'
subwf Operando1,W
btfss STATUS,Z
goto VOLTAJEFALLIDO
goto VOLTAJEFALLIDO
CERO 
movlw b'00000000'
subwf Operando2,W
btfss STATUS,Z
goto $+2
goto VOLTAJEFALLIDO
movlw b'00000001'
subwf Operando2,W
btfss STATUS,Z
goto $+2
goto VOLTAJE1
movlw b'00000010'
subwf Operando2,W
btfss STATUS,Z
goto $+2
goto VOLTAJE2
movlw b'00000011'
subwf Operando2,W
btfss STATUS,Z
goto $+2
goto VOLTAJE3
movlw b'00000100'
subwf Operando2,W
btfss STATUS,Z
goto $+2
goto VOLTAJE4
movlw b'00000101'
subwf Operando2,W
btfss STATUS,Z
goto $+2
goto VOLTAJE5
movlw b'00000110'
subwf Operando2,W
btfss STATUS,Z
goto $+2
goto VOLTAJE5
movlw b'00000111'
subwf Operando2,W
btfss STATUS,Z
goto $+2
goto VOLTAJE5
movlw b'00001000'
subwf Operando2,W
btfss STATUS,Z
goto $+2
goto VOLTAJE5
movlw b'00001001'
subwf Operando2,W
btfss STATUS,Z
goto $+2
goto VOLTAJE5
movlw b'00001010'
subwf Operando2,W
btfss STATUS,Z
goto $+2
goto VOLTAJEFALLIDO
movlw b'00001011'
subwf Operando2,W
btfss STATUS,Z
goto $+2
goto VOLTAJEFALLIDO

VOLTAJEFALLIDO
movlw	MensajeFALLIDO				; En pantalla el mensaje "Dec:"
call	LCD_Mensaje
clrf	ContadorTeclasPulsadas	; Resetea este contador.
	goto	FinInterrupcion
VOLTAJE1
movlw	Mensaje1				; En pantalla el mensaje "Dec:"
call	LCD_Mensaje
clrf	ContadorTeclasPulsadas	; Resetea este contador.
		goto	FinInterrupcion
VOLTAJE2
movlw	Mensaje2				; En pantalla el mensaje "Dec:"
call	LCD_Mensaje
clrf	ContadorTeclasPulsadas	; Resetea este contador.
			goto	FinInterrupcion
VOLTAJE3
movlw	Mensaje3				; En pantalla el mensaje "Dec:"
call	LCD_Mensaje
clrf	ContadorTeclasPulsadas	; Resetea este contador.
			goto	FinInterrupcion
VOLTAJE4
movlw	Mensaje4				; En pantalla el mensaje "Dec:"
call	LCD_Mensaje
clrf	ContadorTeclasPulsadas	; Resetea este contador.
		goto	FinInterrupcion
VOLTAJE5
movlw	Mensaje5				; En pantalla el mensaje "Dec:"
call	LCD_Mensaje
clrf	ContadorTeclasPulsadas	; Resetea este contador.
			goto	FinInterrupcion
VOLTAJE6
movlw	Mensaje5				; En pantalla el mensaje "Dec:"
call	LCD_Mensaje
clrf	ContadorTeclasPulsadas	; Resetea este contador.
			goto	FinInterrupcion

FinInterrupcion
	call	Teclado_EsperaDejePulsar; Espera  a que levante el dedo.
	bcf		INTCON,RBIF
	retfie	

; "Mensajes" ----------------------------------------------------------------------------

Mensajes
	addwf	PCL,F
MensajeDigite
	DT	"DIGITE:", 0x0
MensajeCorrecto
	DT	"CORRECTO", 0x0
MensajeVolt
	DT	" Volt ", 0x0
MensajeFALLIDO
	DT	"FUERA DE RANGO", 0x0
Mensaje1
	DT	"1 VOLTIOS", 0x0
Mensaje2
	DT	"2 VOLTIO", 0x0
Mensaje3
	DT	"3 VOLTIOS", 0x0
Mensaje4
	DT	"4 VOLTIOS", 0x0
Mensaje5
	DT	"5 VOLTIO", 0x0



	INCLUDE  <TECLADO.INC>
	INCLUDE  <LCD_4BIT.INC>
	INCLUDE  <LCD_MENS.INC>
	INCLUDE  <RETARDOS.INC>
	INCLUDE  <BIN_BCD.INC>
	END
 
Última edición por un moderador:
Buenas.... les pido una mano, para la ejecucion de este proyecto; lo que se trata de lograr hacer es un sistema mediante el cual teclees el voltaje que desees obtener, se visualice en el display y mande una orden a un potenciometro digital... el voltaje debe estar dentro del rango {0-24}v.
el problema que tengo es que estuve modificando el siguiente codigo para ajustarlo a mis necesidades.... todo arrancaba bien hasta la comparcion del primer caracter ingresado... cuando quiero seguir comparando con el segundo caracter ingresado, ya no funciona el programa salen rutinas inesperadas en el lcd. creo que es por que se llena la Rom del pic o a que se debera?
Agradeceria su comentario y ayuda... ya que segun lo que pienso necesitaria 24 mensajes diferentes.. y luego comunicarlo mediante el I2C, Para gobernar 8 bits del potenciometro

Código:
LIST		P=16F84A
	INCLUDE		<P16F84A.INC>
	__CONFIG	_CP_OFF &  _WDT_OFF & _PWRTE_ON & _XT_OSC
	
	CBLOCK  0x0C
	ContadorTeclasPulsadas
	GuardaValor
	Operando1
	Operando2
	ENDC

; ZONA DE CÓDIGOS ********************************************************************

VisualizaHex	MACRO	Operando,Caracter
	movf	GuardaValor,W			; Recupera el valor y lo visualiza.
	movwf	Operando				; Lo guarda para sumar después.
	call	LCD_Nibble				; Visualiza el valor en la pantalla	; Visualiza el signo '+' ó '-' según corresponda.
	incf	ContadorTeclasPulsadas,F
	ENDM

	ORG	0
	goto 	Inicio
	ORG	4
	goto	ServicioInterrupcion
Inicio
	call	LCD_Inicializa
	call	Teclado_Inicializa
	clrf	ContadorTeclasPulsadas	; Resetea este contador.
	movlw	b'10001000'				; Habilita la interrupción RBI y la general.
	movwf	INTCON
Principal
	sleep							; Espera en modo bajo consumo que pulse.
	goto	Principal

; Subrutina "ServicioInterrupcion" ------------------------------------------------------
;
ServicioInterrupcion
	call	Teclado_LeeHex			; Obtiene el valor hexadecimal de la tecla pulsada.
	movwf	GuardaValor				; Guarda el valor.
	movf	ContadorTeclasPulsadas,W; Según el número de tecla pulsada realiza una
	addwf	PCL,F					; función distinta.
	goto	PrimeraTeclaPulsada
	goto	SegundaTeclaPulsada
	goto	Comparador
PrimeraTeclaPulsada
	call	LCD_Borra				; Borra la pantalla anterior.
	movlw	MensajeDigite				; En pantalla el mensaje "Hex:"
	call	LCD_Mensaje
	VisualizaHex Operando1,'+'
	goto	FinInterrupcion
SegundaTeclaPulsada
	VisualizaHex Operando2,'+'
	goto	FinInterrupcion
Comparador
	movlw '='
	call LCD_Caracter
	movf	Operando1,W				; Procede a la suma de los tres valores.
	call	LCD_Nibble
	movf	Operando2,W
	call	LCD_Nibble
	movlw	MensajeVolt				; En pantalla el mensaje "Dec:"
	call	LCD_Mensaje

call	LCD_Linea2				; Ahora visualiza la segunda línea.
movlw	b'00000000'
subwf Operando1,W
btfss STATUS,Z
goto $+2
goto CERO
movlw	b'00000001'
subwf Operando1,W
btfss STATUS,Z
goto $+2
goto VOLTAJEFALLIDO
movlw	b'00000010'
subwf Operando1,W
btfss STATUS,Z
goto VOLTAJEFALLIDO
goto VOLTAJEFALLIDO
CERO 
movlw b'00000000'
subwf Operando2,W
btfss STATUS,Z
goto $+2
goto VOLTAJEFALLIDO
movlw b'00000001'
subwf Operando2,W
btfss STATUS,Z
goto $+2
goto VOLTAJE1
movlw b'00000010'
subwf Operando2,W
btfss STATUS,Z
goto $+2
goto VOLTAJE2
movlw b'00000011'
subwf Operando2,W
btfss STATUS,Z
goto $+2
goto VOLTAJE3
movlw b'00000100'
subwf Operando2,W
btfss STATUS,Z
goto $+2
goto VOLTAJE4
movlw b'00000101'
subwf Operando2,W
btfss STATUS,Z
goto $+2
goto VOLTAJE5
movlw b'00000110'
subwf Operando2,W
btfss STATUS,Z
goto $+2
goto VOLTAJE5
movlw b'00000111'
subwf Operando2,W
btfss STATUS,Z
goto $+2
goto VOLTAJE5
movlw b'00001000'
subwf Operando2,W
btfss STATUS,Z
goto $+2
goto VOLTAJE5
movlw b'00001001'
subwf Operando2,W
btfss STATUS,Z
goto $+2
goto VOLTAJE5
movlw b'00001010'
subwf Operando2,W
btfss STATUS,Z
goto $+2
goto VOLTAJEFALLIDO
movlw b'00001011'
subwf Operando2,W
btfss STATUS,Z
goto $+2
goto VOLTAJEFALLIDO

VOLTAJEFALLIDO
movlw	MensajeFALLIDO				; En pantalla el mensaje "Dec:"
call	LCD_Mensaje
clrf	ContadorTeclasPulsadas	; Resetea este contador.
	goto	FinInterrupcion
VOLTAJE1
movlw	Mensaje1				; En pantalla el mensaje "Dec:"
call	LCD_Mensaje
clrf	ContadorTeclasPulsadas	; Resetea este contador.
		goto	FinInterrupcion
VOLTAJE2
movlw	Mensaje2				; En pantalla el mensaje "Dec:"
call	LCD_Mensaje
clrf	ContadorTeclasPulsadas	; Resetea este contador.
			goto	FinInterrupcion
VOLTAJE3
movlw	Mensaje3				; En pantalla el mensaje "Dec:"
call	LCD_Mensaje
clrf	ContadorTeclasPulsadas	; Resetea este contador.
			goto	FinInterrupcion
VOLTAJE4
movlw	Mensaje4				; En pantalla el mensaje "Dec:"
call	LCD_Mensaje
clrf	ContadorTeclasPulsadas	; Resetea este contador.
		goto	FinInterrupcion
VOLTAJE5
movlw	Mensaje5				; En pantalla el mensaje "Dec:"
call	LCD_Mensaje
clrf	ContadorTeclasPulsadas	; Resetea este contador.
			goto	FinInterrupcion
VOLTAJE6
movlw	Mensaje5				; En pantalla el mensaje "Dec:"
call	LCD_Mensaje
clrf	ContadorTeclasPulsadas	; Resetea este contador.
			goto	FinInterrupcion

FinInterrupcion
	call	Teclado_EsperaDejePulsar; Espera  a que levante el dedo.
	bcf		INTCON,RBIF
	retfie	

; "Mensajes" ----------------------------------------------------------------------------

Mensajes
	addwf	PCL,F
MensajeDigite
	DT	"DIGITE:", 0x0
MensajeCorrecto
	DT	"CORRECTO", 0x0
MensajeVolt
	DT	" Volt ", 0x0
MensajeFALLIDO
	DT	"FUERA DE RANGO", 0x0
Mensaje1
	DT	"1 VOLTIOS", 0x0
Mensaje2
	DT	"2 VOLTIO", 0x0
Mensaje3
	DT	"3 VOLTIOS", 0x0
Mensaje4
	DT	"4 VOLTIOS", 0x0
Mensaje5
	DT	"5 VOLTIO", 0x0



	INCLUDE  <TECLADO.INC>
	INCLUDE  <LCD_4BIT.INC>
	INCLUDE  <LCD_MENS.INC>
	INCLUDE  <RETARDOS.INC>
	INCLUDE  <BIN_BCD.INC>
	END

Hola JoserOH

Para poder ayudarte, se necesitan 2 cosas:

1 - Un esquema breve de tu circuito
2 - Una explicacion del mismo

Pd: además usa la función CODE del editor de mensajes para anexar código fuente, o adjunta un .txt; Porque analizar tu código cuando está "pegado" de esta manera en el foro ahuyenta la voluntad de colaboración de muchos. (mira como queda si haces lo que te digo)

En cuanto a tu código, para poder detectar los errores, habría que probar el mismo por pedazos, por ejemplo:

- leer perfectamente el teclado matricial
- Controlar el Pot. digital sin errores
- Visualizar correctamente los mensajes en la LCD.
- Conectar las rutinas mediante registros compartidos en la RAM.

Salu2
 
Atrás
Arriba