Autor Tema: No me alcanza la memoria de prog. del 877A y aún no termino. Ahora que hago?  (Leído 3072 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado gesteva

  • PIC12
  • **
  • Mensajes: 52
Saludos a Todos, mi problema es que ya he llenado la memoria de programa del pic y aún no termino el diseño, me he tratado de cambiar a un pic mas grande en memoria, el pic18F452, pero la verdad no lo he podido programar ya que supongo que tendrá algunas diferencias que desconozco, y que seguramente ustedes me sabran orientar al respecto.

Seguramente habran algunos registros que configurar para que funcione el mismo codigo que hasta la fecha llevo hecho.

He pensado en optimisar el codigo programando algunas partes en asm pero la verdad no soy muy bueno en ese lenguaje y entiendo que en lenguaje C, segun la encuesta en este foro, genera mas código aún.

Comento que busque el PIC18F452 porque tiene el doble de la memoria de programa que el PIC16F877A, pero la verdad no he podido compilar el mismo codigo para el nuevo micro.

¿Alguna Sugerencia? de seguro sera bienvenida!

Rebotado

Desconectado jorgeansuini

  • PIC18
  • ****
  • Mensajes: 340
RE: No me alcanza la memoria de prog. del 877A y aún no termino. Ahora que hago?
« Respuesta #1 en: 07 de Marzo de 2005, 11:18:00 »
Buenas:

Para ver que se puede hacer ,lo interesante sería que pusieras el código ,sino es muy dificil sugerir algo.-

Saludos
Jorge

Desconectado gesteva

  • PIC12
  • **
  • Mensajes: 52
RE: No me alcanza la memoria de prog. del 877A y aún no termino. Ahora que hago?
« Respuesta #2 en: 07 de Marzo de 2005, 20:27:00 »
Bien.. aqui tienes, a ver que hacemos:

DEFINE LCD_DREG PORTD
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTE
DEFINE LCD_RSBIT 0
DEFINE LCD_EREG PORTE
DEFINE LCD_EBIT 1
DEFINE LCD_LINES 4

TRISA = %00000000
TRISB = %11110000
TRISC = %00000000
TRISD = %00000000
TRISE = %01000000

B1 VAR WORD

DATO VAR BYTE
PASSW VAR BYTE
TIEMPO VAR BYTE

ZONA1 VAR BYTE
ZONA2 VAR BYTE
ZONA3 VAR BYTE
ZONA4 VAR BYTE
ZONA5 VAR BYTE
ZONA6 VAR BYTE
ZONA7 VAR BYTE
ZONA8 VAR BYTE

DIG1 VAR BYTE
DIG2 VAR BYTE
DIG3 VAR BYTE
DIG4 VAR BYTE
DIG5 VAR BYTE
DIG6 VAR BYTE

RESET VAR WORD

CLV1 VAR BYTE
CLV2 VAR BYTE
CLV3 VAR BYTE
CLV4 VAR BYTE
CLV5 VAR BYTE
CLV6 VAR BYTE

DATW VAR BYTE      " REGISTRO DE TRABAJO PARA MOVER DATOS GENERALES

CONT1 VAR BYTE      " PARA CONTAR CUANTAS VECES SE COMETE UNA EQUIVOCACION AL METER LA CLAVE
BEEP VAR BYTE      " GRABA SI EL BEEP ESTA ON O OFF
beep1 VAR BYTE      " GRABA SI EL BEEP ESTA ON O OFF

   B1 = 0
   CONT1 = 3      " cantidad de intentos - 1 para introducir la clave

   ADCON1 = %00000110

   TIEMPO = 15
   PORTA.0 = 0

   PAUSE 3000
   LCDOut $fe, 1 " Limpia la LCD

   DATO = 1

   SEROUT PORTC.6 , 9600 , [DATO, 0]
   PAUSE 200
   SEROUT PORTC.6 , 9600 , [DATO, 0]
   PAUSE 200

   read 00,RESET
   IF RESET = $FF then bienve " si el sistema esta de fabrica invita a configurarlo
   GOTO inicio

bienve:

   LCDOut $fe, 2 " Posiciona el cursor en el inicio
   LCDOut          "*  Bienvenido  *" " escrebe
   LCDOut $fe,$C0, "*  Por Favor   *"
   LCDOut $fe,$90, "* Configure su *"
   LCDOut $fe,$D0, "*   Sistema    *"
   PAUSE 3000   

   write 00,1     " indica que el sistema se inicia la segunda vez o mas...
   PAUSE 100   
    WRITE 01,1      " GRABA EL ESTADO DEL BUZZER, ON O OFF
   PAUSE 100   
   WRITE 02,0      " PARA SABER QUIEN VA A UTILIZAR LA RUTINA DE PASSWORD
   PAUSE 100
   WRITE 03,15      " PARA GUARDAR EL TIEMPO DE RETARDO DE ACTIVACION DE LA CENTRAL
   PAUSE 100
   WRITE 10,1       " PRIMER DIGITO DE LA CLAVE "el numero indica la posicion de la tecla"
   PAUSE 100
   WRITE 11,2
   PAUSE 100
   WRITE 12,3
   PAUSE 100
   WRITE 13,5
   PAUSE 100
   WRITE 14,6
   PAUSE 100
   WRITE 15,7      " ULTIMO DIGITO DE LA CLAVE "el numero indica la posicion de la tecla"
   PAUSE 100

   LCDOut $fe, 1 " Limpia la LCD

password:

   read 10, CLV1
   pause 100
   read 11, CLV2
   pause 100
   read 12, CLV3
   pause 100
   read 13, CLV4
   pause 100
   read 14, CLV5
   pause 100
   read 15, CLV6
   pause 100

   LCDOut $fe, 1 " Limpia la LCD

passconf:

   LCDOut $fe, 2 " Posiciona el cursor en el inicio
   LCDOut          "Introduzca su   " " escrebe
   LCDOut $fe,$C0, "Clave de Acceso:"

   pause 400

   READ 01,beep1

consult1:

   CALL teclado
   IF B1 = 0 THEN consult1
   IF B1 = 13 THEN inicio
   DIG1 = B1
   if beep1 = 1 THEN CALL buzzer   " PREGUNTA SI EL BUZZER SONARA O NO SONARA
   if DIG1 = CLV1 then consult2
   if DIG1 <> CLV1 then error

consult2:
   LCDOut $fe, 2 " Posiciona el cursor en el inicio
   LCDOut          "Introduzca su   " " escrebe
   LCDOut $fe,$C0, "Clave de Acceso:"
   LCDOut $fe,$90, "  *             "


   pause 400

   READ 01,beep1
consul2:
    CALL teclado
   IF B1 = 0 THEN consul2
   DIG2 = B1
   IF beep1 = 1 THEN CALL buzzer   " PREGUNTA SI EL BUZZER SONARA O NO SONARA
   if DIG2 = CLV2 then consult3
   if DIG2 <> CLV2 then error
   goto consult2


consult3:
   LCDOut $fe, 2 " Posiciona el cursor en el inicio
   LCDOut          "Introduzca su   " " escrebe
   LCDOut $fe,$C0, "Clave de Acceso:"
   LCDOut $fe,$90, "  * *           "


   pause 400

   READ 01,beep1
consul3:
    CALL teclado
   IF B1 = 0 THEN consul3
   DIG3 = B1
   IF beep1 = 1 THEN CALL buzzer   " PREGUNTA SI EL BUZZER SONARA O NO SONARA
   if DIG3 = CLV3 then consult4
   if DIG3 <> CLV3 then error
   goto consult3


consult4:
   LCDOut $fe, 2 " Posiciona el cursor en el inicio
   LCDOut          "Introduzca su   " " escrebe
   LCDOut $fe,$C0, "Clave de Acceso:"
   LCDOut $fe,$90, "  * * *         "

   pause 400

   READ 01,beep1
consul4:
    CALL teclado
   IF B1 = 0 THEN consul4
   DIG4 = B1
   IF beep1 = 1 THEN CALL buzzer   " PREGUNTA SI EL BUZZER SONARA O NO SONARA
   if DIG4 = CLV4 then consult5
   if DIG4 <> CLV4 then error
   goto consult4

consult5:
   LCDOut $fe, 2 " Posiciona el cursor en el inicio
   LCDOut          "Introduzca su   " " escrebe
   LCDOut $fe,$C0, "Clave de Acceso:"
   LCDOut $fe,$90, "  * * * *       "

   pause 400

   READ 01,BEEP
consul5:
    CALL teclado
   IF B1 = 0 THEN consul5
   DIG5 = B1
   IF beep1 = 1 THEN CALL buzzer   " PREGUNTA SI EL BUZZER SONARA O NO SONARA
   if DIG5 = CLV5 then consult6
   if DIG5 <> CLV5 then error
   goto consult5

consult6:
   LCDOut $fe, 2 " Posiciona el cursor en el inicio
   LCDOut          "Introduzca su   " " escrebe
   LCDOut $fe,$C0, "Clave de Acceso:"
   LCDOut $fe,$90, "  * * * * *     "

   pause 400

   READ 01,beep1
consul6:
    CALL teclado
   IF B1 = 0 THEN consul6
   DIG6 = B1
   IF beep1 = 1 THEN CALL buzzer   " PREGUNTA SI EL BUZZER SONARA O NO SONARA
   if DIG6 = CLV6 then config
   if DIG6 <> CLV6 then error
   goto consult6

config:

   LCDOut $fe, 2 " Posiciona el cursor en el inicio
   LCDOut          "Introduzca su   " " escrebe
   LCDOut $fe,$C0, "Clave de Acceso:"
   LCDOut $fe,$90, "  * * * * * *   "
   LCDOut $fe,$D0, "      OK        "

   pause 1500

   LCDOut $fe, 1 " Limpia la LCD

   READ 02,PASSW

   if PASSW = 0 then config2
   if PASSW = 1 then armar_r
   if PASSW = 2 then desarmar_r   


config2:

   LCDOut $fe, 2 " Posiciona el cursor en el inicio
   LCDOut          "Menu de Config. " " escrebe
   LCDOut $fe,$C0, "1.Reiniciar Sis."
   LCDOut $fe,$90, "2.Cambiar Clave."
   LCDOut $fe,$D0, "3.Beep On/Off.  "
   PAUSE 200

   READ 01,beep1
WAIT0:
   call teclado
   IF B1 = 0 THEN WAIT0
   DATW = B1
   IF beep1 = 1 THEN CALL buzzer   " PREGUNTA SI EL BUZZER SONARA O NO SONARA
   IF DATW = 1 THEN reiniciar
   IF DATW = 2 THEN clave_new
   IF DATW = 3 THEN beep_on_off
   IF DATW = 8 THEN prox_pant
   goto config2

prox_pant:

   LCDOut $fe, 1 " Limpia la LCD

prox_pant1:

   LCDOut $fe, 2 " Posiciona el cursor en el inicio
   LCDOut          "Menu de Config. " " escrebe
   LCDOut $fe,$C0, "4.Numeros Telef."
   LCDOut $fe,$90, "5.Tiempos/Retar."
   LCDOut $fe,$D0, "6.Salir.        "
   PAUSE 200

   READ 01,beep1
WAIT3:
   call teclado
   IF B1 = 0 THEN WAIT3
   DATW = B1
   IF beep1 = 1 THEN CALL buzzer   " PREGUNTA SI EL BUZZER SONARA O NO SONARA
   IF B1 = 4 then config2
   IF B1 = 6 then tiempo_arm
   IF DATW = 7 then inicio
   goto prox_pant1

tiempo_arm:

   READ 03,TIEMPO
   PAUSE 100

tiempo_ar1:

   LCDOut $fe, 2 " Posiciona el cursor en el inicio
   LCDOut          "Use las Flechas " " escrebe
   LCDOut $fe,$C0, "para cambiar el "
   LCDOut $fe,$90, "retardo:        "
   LCDOut $fe,$D0, "Tiempo: ",#TIEMPO," Seg."


WAIT5:
   call teclado
   if B1 = 0 then WAIT5
   IF B1 = 4 THEN aumenta
   IF B1 = 8 THEN disminuye
   IF B1 = 16 THEN grava_tie
   goto WAIT5

aumenta:

   TIEMPO = TIEMPO + 1
   CALL buzzer
   IF TIEMPO = 241 then TIEMPO = 240
   GOTO tiempo_ar1

disminuye:

   TIEMPO = TIEMPO - 1
   CALL buzzer
   IF TIEMPO = 0 then TIEMPO = 1
   GOTO tiempo_ar1

grava_tie:

   DATO = 40
   SEROUT PORTC.6 , 9600 , [DATO, 0]
   PAUSE 500
   SEROUT PORTC.6 , 9600 , [TIEMPO, 0]    
   PAUSE 100
   WRITE 03,TIEMPO
   PAUSE 100
   GOTO prox_pant


error:

   LCDOut $fe, 1 " Limpia la LCD
   CONT1 = CONT1 - 1

error1:
   LCDOut $fe, 2 " Posiciona el cursor en el inicio
   LCDOut          "     Error!     " " escrebe
   LCDOut $fe,$C0, "Dispone de ",#CONT1
   LCDOut $fe,$90, "intentos para"
   LCDOut $fe,$D0, "evitar Alarma"
   pause 3000

   if CONT1 = 0 then bloqueo
   goto password   

bloqueo:
   LCDOut $fe, 1 " Limpia la LCD
bloqueo1:
   LCDOut $fe, 2 " Posiciona el cursor en el inicio
   LCDOut          " Sistema Armado  " " escrebe
   LCDOut $fe,$C0, " "
   LCDOut $fe,$90, " "
   LCDOut $fe,$D0, " "
   goto bloqueo1


reiniciar:

   LCDOut $fe, 2 " Posiciona el cursor en el inicio
   LCDOut          "Esta seguro que " " escrebe
   LCDOut $fe,$C0, "desea Reiniciar "
   LCDOut $fe,$90, "el Sistema?     "
   LCDOut $fe,$D0, "1.SI        2.No"
   pause 700   

   READ 01,beep1
espera0:
   call teclado
   if B1 = 0 then espera0
   DATW = B1
   IF beep1 = 1 THEN CALL buzzer   " PREGUNTA SI EL BUZZER SONARA O NO SONARA   
   if DATW = 1 then reini_sys
   if DATW = 2 then config2
   goto reiniciar
 
clave_new:
   LCDOut $fe, 1 " Limpia la LCD
clave_new1:
   LCDOut $fe, 2 " Posiciona el cursor en el inicio
   LCDOut          "Por Favor       " " escrebe
   LCDOut $fe,$C0, "Introduzca la   "
   LCDOut $fe,$90, "Nueva Clave:    "
   LCDOut $fe,$D0, "Clave: "
   PAUSE 200

   READ 01,beep1
esper1:   
   call teclado
   if B1 = 0 then esper1
   DIG1 = B1
   WRITE 10,DIG1
   if B1 = 5 then DIG1 = 4
   if B1 = 6 then DIG1 = 5
   if B1 = 7 then DIG1 = 6
   if B1 = 9 then DIG1 = 7
   if B1 = 10 then DIG1 = 8
   if B1 = 11 then DIG1 = 9
   if B1 = 14 then DIG1 = 0

   pause 400
   
   IF beep1 = 1 THEN CALL buzzer   " PREGUNTA SI EL BUZZER SONARA O NO SONARA
   
   LCDOut $fe,$D0, "Clave: ",#DIG1

   READ 01,beep1
esper2:
   call teclado
   if B1 = 0 then esper2
   DIG2 = B1
   WRITE 11,DIG2
   if B1 = 5 then DIG2 = 4
   if B1 = 6 then DIG2 = 5
   if B1 = 7 then DIG2 = 6
   if B1 = 9 then DIG2 = 7
   if B1 = 10 then DIG2 = 8
   if B1 = 11 then DIG2 = 9
   if B1 = 14 then DIG2 = 0

   pause 400

   IF beep1 = 1 THEN CALL buzzer   " PREGUNTA SI EL BUZZER SONARA O NO SONARA

   LCDOut $fe,$D0, "Clave: ",#DIG1,#DIG2

   READ 01,beep1
esper3:   
   call teclado
   if B1 = 0 then esper3
   DIG3 = B1
   WRITE 12,DIG3
   if B1 = 5 then DIG3 = 4
   if B1 = 6 then DIG3 = 5
   if B1 = 7 then DIG3 = 6
   if B1 = 9 then DIG3 = 7
   if B1 = 10 then DIG3 = 8
   if B1 = 11 then DIG3 = 9
   if B1 = 14 then DIG3 = 0

   pause 400

   IF beep1 = 1 THEN CALL buzzer   " PREGUNTA SI EL BUZZER SONARA O NO SONARA

   LCDOut $fe,$D0, "Clave: ",#DIG1,#DIG2,#DIG3

   READ 01,beep1
esper4:
   call teclado
   if B1 = 0 then esper4
   DIG4 = B1
   WRITE 13,DIG4
   if B1 = 5 then DIG4 = 4
   if B1 = 6 then DIG4 = 5
   if B1 = 7 then DIG4 = 6
   if B1 = 9 then DIG4 = 7
   if B1 = 10 then DIG4 = 8
   if B1 = 11 then DIG4 = 9
   if B1 = 14 then DIG4 = 0

   pause 400

   IF beep1 = 1 THEN CALL buzzer   " PREGUNTA SI EL BUZZER SONARA O NO SONARA

   LCDOut $fe,$D0, "Clave: ",#DIG1,#DIG2,#DIG3,#DIG4

   READ 01,beep1
esper5:   
   call teclado
   if B1 = 0 then esper5
   DIG5 = B1
   WRITE 14,DIG5
   if B1 = 5 then DIG5 = 4
   if B1 = 6 then DIG5 = 5
   if B1 = 7 then DIG5 = 6
   if B1 = 9 then DIG5 = 7
   if B1 = 10 then DIG5 = 8
   if B1 = 11 then DIG5 = 9
   if B1 = 14 then DIG5 = 0

   pause 400

   IF beep1 = 1 THEN CALL buzzer   " PREGUNTA SI EL BUZZER SONARA O NO SONARA

   LCDOut $fe,$D0, "Clave: ",#DIG1,#DIG2,#DIG3,#DIG4,#DIG5

   READ 01,beep1
esper6:
   call teclado
   if B1 = 0 then esper6
   DIG6 = B1
   WRITE 15,DIG6
   if B1 = 5 then DIG6 = 4
   if B1 = 6 then DIG6 = 5
   if B1 = 7 then DIG6 = 6
   if B1 = 9 then DIG6 = 7
   if B1 = 10 then DIG6 = 8
   if B1 = 11 then DIG6 = 9
   if B1 = 14 then DIG6 = 0

   pause 400

   IF beep1 = 1 THEN CALL buzzer   " PREGUNTA SI EL BUZZER SONARA O NO SONARA

   LCDOut $fe,$D0, "Clave: ",#DIG1,#DIG2,#DIG3,#DIG4,#DIG5,#DIG6
   pause 1000

enter:
   read 01,beep1
enterw:
   call teclado
   if B1 = 0 then enterw

   IF beep1 = 1 THEN CALL buzzer   " PREGUNTA SI EL BUZZER SONARA O NO SONARA

   if B1 = 16 then config2
   if B1 = 13 then clave_new
   goto enter


beep_on_off:

   READ 01,BEEP
   PAUSE 100
   IF BEEP = 0 THEN enciende
   IF BEEP = 1 THEN apaga

enciende:
   write 01,1
   pause 100
   LCDOut $fe, 1 " Limpia la LCD
   LCDOut $fe, 2 " Posiciona el cursor en el inicio
   LCDOut          "****************" " escrebe
   LCDOut $fe,$C0, "*   BUZZER ON  *"
   LCDOut $fe,$90, "****************"

   PAUSE 3000
   goto config2

apaga:
   write 01,0
   pause 100
   LCDOut $fe, 1 " Limpia la LCD
   LCDOut $fe, 2 " Posiciona el cursor en el inicio
   LCDOut          "****************" " escrebe
   LCDOut $fe,$C0, "*  BUZZER OFF  *"
   LCDOut $fe,$90, "****************"

   PAUSE 3000
   goto config2

reini_sys:

   LCDOut $fe, 1 " Limpia la LCD

   write 00,01     " indica que el sistema se inicia la segunda vez o mas...
   PAUSE 100   
    WRITE 01,00      " GRABA EL ESTADO DEL BUZZER, ON O OFF
   PAUSE 100   
   WRITE 10,1       " PRIMER DIGITO DE LA CLAVE "el numero indica la posicion de la tecla"
   PAUSE 100
   WRITE 11,2
   PAUSE 100
   WRITE 12,3
   PAUSE 100
   WRITE 13,5
   PAUSE 100
   WRITE 14,6
   PAUSE 100
   WRITE 15,7      " ULTIMO DIGITO DE LA CLAVE "el numero indica la posicion de la tecla"
   PAUSE 100


   LCDOut $fe, 2 " Posiciona el cursor en el inicio
   LCDOut          "Sist. Reiniciado" " escrebe
   LCDOut $fe,$C0, "   Ingresando   "
   LCDOut $fe,$90, "   valores de   "
   LCDOut $fe,$D0, "   fabrica.     "
   Pause 3000

   goto bienve   

inicio:

   LCDOut $fe, 2 " Posiciona el cursor en el inicio
   LCDOut          "*.Seleccione:   " " escrebe
   LCDOut $fe,$C0, "1.Activar Alarma"
   LCDOut $fe,$90, "2.Serv. Nocturno"
   LCDOut $fe,$D0, "3.Configuracion "

   read 01,beep1
   goto WAIT1

inicio1:

   LCDOut $fe, 2 " Posiciona el cursor en el inicio
   LCDOut          "*.Seleccione:   " " escrebe
   LCDOut $fe,$C0, "                "
   LCDOut $fe,$90, "2.Desarmar Alarm"
   LCDOut $fe,$D0, "                "

   read 01,beep1
   goto WAIT2

WAIT1:
   call teclado
   if B1 = 0 then WAIT1
   IF beep1 = 1 THEN CALL buzzer   " PREGUNTA SI EL BUZZER SONARA O NO SONARA
   if B1 = 1 then armar
   if B1 = 2 then nocturno
   if B1 = 3 then configurar
   goto WAIT1

WAIT2:
   call teclado
   if B1 = 0 then WAIT2
   IF beep1 = 1 THEN CALL buzzer   " PREGUNTA SI EL BUZZER SONARA O NO SONARA
   if B1 = 2 then desarmar
   goto WAIT2

armar:
   write 02,1
   pause 100
   GOTO password
armar_r:
   DATO = 50
   SEROUT PORTC.6 , 9600 , [DATO, 0]
   PAUSE 200
   goto inicio1

desarmar:
   write 02,2
   pause 100
   GOTO password
desarmar_r:
   DATO = 60
   SEROUT PORTC.6 , 9600 , [DATO, 0]
   PAUSE 200
   goto inicio

configurar:
   write 02,3
   pause 200
   goto password

nocturno:

   LCDOut $fe, 2 " Posiciona el cursor en el inicio
   LCDOut          "*.Seleccione:   " " escrebe
   LCDOut $fe,$C0, "1.Activar Zonas."
   LCDOut $fe,$90, "2.Elegir Zonas. "
   LCDOut $fe,$D0, "3.Volver.       "

   read 01,beep1

WAIT4:
   call teclado
   if B1 = 0 then WAIT4
   IF beep1 = 1 THEN CALL buzzer   " PREGUNTA SI EL BUZZER SONARA O NO SONARA
   if B1 = 1 then zonas
   if B1 = 2 then elegir_z
   if B1 = 3 then inicio
   goto WAIT4

zonas:

   GOTO inicio

elegir_z:

   LCDOut $fe, 2 " Posiciona el cursor en el inicio
   LCDOut          "Ingrese zonas  "      " escrebe
   LCDOut $fe,$C0, "a ser activadas"
   LCDOut $fe,$90, "y pulse enter: "
   LCDOut $fe,$D0, "               "


   read 01,beep1

WAIT6:
   call teclado
   IF B1 = 13 THEN nocturno
   if B1 = 0 then WAIT6
   IF beep1 = 1 THEN CALL buzzer   " PREGUNTA SI EL BUZZER SONARA O NO SONARA
   IF B1 = 1 THEN ZONA1 = 1
   IF B1 = 2 THEN ZONA1 = 2
   IF B1 = 3 THEN ZONA1 = 3
   IF B1 = 5 THEN ZONA1 = 4
   IF B1 = 6 THEN ZONA1 = 5
   IF B1 = 7 THEN ZONA1 = 6
   IF B1 = 9 THEN ZONA1 = 7
   IF B1 = 10 THEN ZONA1 = 8
   LCDOut $fe,$D0, #ZONA1

WAIT7:
   call teclado
   IF B1 = 13 THEN nocturno
   if B1 = 16 then nocturno
   if B1 = 0 then WAIT7
   IF beep1 = 1 THEN CALL buzzer   " PREGUNTA SI EL BUZZER SONARA O NO SONARA
   IF B1 = 1 THEN ZONA2 = 1
   IF B1 = 2 THEN ZONA2 = 2
   IF B1 = 3 THEN ZONA2 = 3
   IF B1 = 5 THEN ZONA2 = 4
   IF B1 = 6 THEN ZONA2 = 5
   IF B1 = 7 THEN ZONA2 = 6
   IF B1 = 9 THEN ZONA2 = 7
   IF B1 = 10 THEN ZONA2 = 8
   LCDOut $fe,$D0, " ",#ZONA1," ",#ZONA2

WAIT8:
   call teclado
   IF B1 = 13 THEN nocturno
   if B1 = 16 then nocturno
   if B1 = 0 then WAIT8
   IF beep1 = 1 THEN CALL buzzer   " PREGUNTA SI EL BUZZER SONARA O NO SONARA
   IF B1 = 1 THEN ZONA3 = 1
   IF B1 = 2 THEN ZONA3 = 2
   IF B1 = 3 THEN ZONA3 = 3
   IF B1 = 5 THEN ZONA3 = 4
   IF B1 = 6 THEN ZONA3 = 5
   IF B1 = 7 THEN ZONA3 = 6
   IF B1 = 9 THEN ZONA3 = 7
   IF B1 = 10 THEN ZONA3 = 8
   LCDOut $fe,$D0, " ",#ZONA1," ",#ZONA2," ",#ZONA3

WAIT9:
   call teclado
   IF B1 = 13 THEN nocturno
   if B1 = 16 then nocturno
   if B1 = 0 then WAIT9
   IF beep1 = 1 THEN CALL buzzer   " PREGUNTA SI EL BUZZER SONARA O NO SONARA
   IF B1 = 1 THEN ZONA4 = 1
   IF B1 = 2 THEN ZONA4 = 2
   IF B1 = 3 THEN ZONA4 = 3
   IF B1 = 5 THEN ZONA4 = 4
   IF B1 = 6 THEN ZONA4 = 5
   IF B1 = 7 THEN ZONA4 = 6
   IF B1 = 9 THEN ZONA4 = 7
   IF B1 = 10 THEN ZONA4 = 8
   LCDOut $fe,$D0, " ",#ZONA1," ",#ZONA2," ",#ZONA3," ",#ZONA4


   pause 2000

   GOTO inicio


teclado:

   B1 = 0

   portb.0 = 1
   portb.1 = 0
   portb.2 = 0
   portb.3 = 0
   if portb.4 = 1 then B1 = 1       " tecla "1"
   if portb.5 = 1 then B1 = 5       " tecla "4"
   if portb.6 = 1 then B1 = 9      " tecla "7"
   if portb.7 = 1 then B1 = 13      " tecla "clear"

   portb.0 = 0
   portb.1 = 1
   portb.2 = 0
   portb.3 = 0
   if portb.4 = 1 then B1 = 2       " tecla "2"
   if portb.5 = 1 then B1 = 6      " tecla "5"
   if portb.6 = 1 then B1 = 10       " tecla "8"
   if portb.7 = 1 then B1 = 14      " tecla "0"

   portb.0 = 0
   portb.1 = 0
   portb.2 = 1
   portb.3 = 0
   if portb.4 = 1 then B1 = 3      " tecla "3"
   if portb.5 = 1 then B1 = 7      " tecla "6"
   if portb.6 = 1 then B1 = 11      " tecla "9"
   if portb.7 = 1 then B1 = 15      " TECLA "HELP"

   portb.0 = 0
   portb.1 = 0
   portb.2 = 0
   portb.3 = 1
   if portb.4 = 1 then B1 = 4       " tecla "flecha arriba"
   if portb.5 = 1 then B1 = 8      " tecla "flecha abajo"
   if portb.6 = 1 then B1 = 12      " tecla "2ND"
   if portb.7 = 1 then B1 = 16      " tecla "enter"

   RETURN

buzzer:

   porta.0 = 1
   pause 150
   porta.0 = 0
   return   

   End


Saludos... y Gracias!

Desconectado RGL

  • Colaborador
  • PIC24F
  • *****
  • Mensajes: 634
RE: No me alcanza la memoria de prog. del 877A y aún no termino. Ahora que hago?
« Respuesta #3 en: 08 de Marzo de 2005, 06:42:00 »
Lo que te está comiendo mucha memoria son los textos en el display.

He observado que repites mucho código como LCDOUT "Escribe la clave"

Puedes hacer una pequeña rutina y llamarla cada vez que tengas que escribir eso en la misma linea del display. con esto ahorrarás unos bytes que quizás sean suficientes para poder terminar.

Saludos,
Ricky

Desconectado RGL

  • Colaborador
  • PIC24F
  • *****
  • Mensajes: 634
RE: No me alcanza la memoria de prog. del 877A y aún no termino. Ahora que hago?
« Respuesta #4 en: 08 de Marzo de 2005, 06:48:00 »
Lo mismo te sucede con los comandos write y pause.

Puedes hacer

temporizar: "rutina temporizar
     Pause tiempo
     Return

"Programa principal
......
.....
tiempo=100
Gosub temporizar
...........
...........

Lo mismo con write

Si haces esto seguro que puedes meter un programa como el doble del que tienes

Esto no quiere decir que lo que tienes no valga, pero se puede optimizar para que te quepa más.

Saludos,
Ricky

Desconectado jorgeansuini

  • PIC18
  • ****
  • Mensajes: 340
RE: No me alcanza la memoria de prog. del 877A y aún no termino. Ahora que hago?
« Respuesta #5 en: 08 de Marzo de 2005, 09:22:00 »
Hola:

Algo le he optimizado y has recuperado un poco de memoria.-
Una progunta ¿Para que los pause despu¿es de cada read o write?

bueno te mando el código:

"****************************************************************
"*  Name    : prueba de memoria                                    *
"*  Author  : [select VIEW...EDITOR OPTIONS]                    *
"*  Notice  : Copyright (c) 2005 [select VIEW...EDITOR OPTIONS] *
"*          : All Rights Reserved                               *
"*  Date    : 08/03/2005                                        *
"*  Version : 1.0                                               *
"*  Notes   :                                                   *
"*          :                                                   *
"****************************************************************
DEFINE LCD_DREG PORTD
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTE
DEFINE LCD_RSBIT 0
DEFINE LCD_EREG PORTE
DEFINE LCD_EBIT 1
DEFINE LCD_LINES 4

TRISA = %00000000
TRISB = %11110000
TRISC = %00000000
TRISD = %00000000
TRISE = %01000000

B1 VAR WORD

DATO VAR BYTE
PASSW VAR BYTE
TIEMPO VAR BYTE

ZONA1 VAR BYTE
ZONA2 VAR BYTE
ZONA3 VAR BYTE
ZONA4 VAR BYTE
ZONA5 VAR BYTE
ZONA6 VAR BYTE
ZONA7 VAR BYTE
ZONA8 VAR BYTE

DIG1 VAR BYTE
DIG2 VAR BYTE
DIG3 VAR BYTE
DIG4 VAR BYTE
DIG5 VAR BYTE
DIG6 VAR BYTE

RESET VAR WORD

CLV1 VAR BYTE
CLV2 VAR BYTE
CLV3 VAR BYTE
CLV4 VAR BYTE
CLV5 VAR BYTE
CLV6 VAR BYTE

DATW VAR BYTE " REGISTRO DE TRABAJO PARA MOVER DATOS GENERALES

CONT1 VAR BYTE " PARA CONTAR CUANTAS VECES SE COMETE UNA EQUIVOCACION AL METER LA CLAVE
BEEP VAR BYTE " GRABA SI EL BEEP ESTA ON O OFF
beep1 VAR BYTE " GRABA SI EL BEEP ESTA ON O OFF

B1 = 0
CONT1 = 3 " cantidad de intentos - 1 para introducir la clave

ADCON1 = %00000110

TIEMPO = 15
PORTA.0 = 0
PAUSE 3000
LCDOut $fe, 1 " Limpia la LCD

DATO = 1

SEROUT PORTC.6 , 9600 , [DATO, 0]
PAUSE 200
SEROUT PORTC.6 , 9600 , [DATO, 0]
PAUSE 200

read 00,RESET
IF RESET = $FF then bienve " si el sistema esta de fabrica invita a configurarlo
GOTO inicio

bienve:

LCDOut $fe, 2 " Posiciona el cursor en el inicio
LCDOut "* Bienvenido *" " escrebe
LCDOut $fe,$C0, "* Por Favor *"
LCDOut $fe,$90, "* Configure su *"
LCDOut $fe,$D0, "* Sistema *"
PAUSE 3000

write 00,1 " indica que el sistema se inicia la segunda vez o mas...
;PAUSE 100
WRITE 01,1 " GRABA EL ESTADO DEL BUZZER, ON O OFF
;PAUSE 100
WRITE 02,0 " PARA SABER QUIEN VA A UTILIZAR LA RUTINA DE PASSWORD
;PAUSE 100
WRITE 03,15 " PARA GUARDAR EL TIEMPO DE RETARDO DE ACTIVACION DE LA CENTRAL
;PAUSE 100
WRITE 10,1 " PRIMER DIGITO DE LA CLAVE "el numero indica la posicion de la tecla"
;PAUSE 100
WRITE 11,2
;PAUSE 100
WRITE 12,3
;PAUSE 100
WRITE 13,5
;PAUSE 100
WRITE 14,6
;PAUSE 100
WRITE 15,7 " ULTIMO DIGITO DE LA CLAVE "el numero indica la posicion de la tecla"
;PAUSE 100

LCDOut $fe, 1 " Limpia la LCD

password:

read 10, CLV1
;pause 100
read 11, CLV2
;pause 100
read 12, CLV3
;pause 100
read 13, CLV4
;pause 100
read 14, CLV5
;pause 100
read 15, CLV6
;pause 100

LCDOut $fe, 1 " Limpia la LCD

passconf:

gosub pantalla

pause 400

READ 01,beep1

consult1:

CALL teclado
IF B1 = 0 THEN consult1
IF B1 = 13 THEN inicio
DIG1 = B1
if beep1 = 1 THEN CALL buzzer " PREGUNTA SI EL BUZZER SONARA O NO SONARA
if DIG1 = CLV1 then consult2
if DIG1 <> CLV1 then error

consult2:
gosub pantalla
LCDOut $fe,$90, " * "


pause 400

READ 01,beep1
consul2:
CALL teclado
IF B1 = 0 THEN consul2
DIG2 = B1
IF beep1 = 1 THEN CALL buzzer " PREGUNTA SI EL BUZZER SONARA O NO SONARA
if DIG2 = CLV2 then consult3
if DIG2 <> CLV2 then error
goto consult2


consult3:
gosub pantalla
LCDOut $fe,$90, " * * "


pause 400

READ 01,beep1
consul3:
CALL teclado
IF B1 = 0 THEN consul3
DIG3 = B1
IF beep1 = 1 THEN CALL buzzer " PREGUNTA SI EL BUZZER SONARA O NO SONARA
if DIG3 = CLV3 then consult4
if DIG3 <> CLV3 then error
goto consult3


consult4:
gosub pantalla
LCDOut $fe,$90, " * * * "

pause 400

READ 01,beep1
consul4:
CALL teclado
IF B1 = 0 THEN consul4
DIG4 = B1
IF beep1 = 1 THEN CALL buzzer " PREGUNTA SI EL BUZZER SONARA O NO SONARA
if DIG4 = CLV4 then consult5
if DIG4 <> CLV4 then error
goto consult4

consult5:
gosub pantalla
LCDOut $fe,$90, " * * * * "

pause 400

READ 01,BEEP
consul5:
CALL teclado
IF B1 = 0 THEN consul5
DIG5 = B1
IF beep1 = 1 THEN CALL buzzer " PREGUNTA SI EL BUZZER SONARA O NO SONARA
if DIG5 = CLV5 then consult6
if DIG5 <> CLV5 then error
goto consult5

consult6:
gosub pantalla
LCDOut $fe,$90, " * * * * * "

pause 400

READ 01,beep1
consul6:
CALL teclado
IF B1 = 0 THEN consul6
DIG6 = B1
IF beep1 = 1 THEN CALL buzzer " PREGUNTA SI EL BUZZER SONARA O NO SONARA
if DIG6 = CLV6 then config
if DIG6 <> CLV6 then error
goto consult6

config:

gosub pantalla
LCDOut $fe,$90, " * * * * * * "
LCDOut $fe,$D0, " OK "

pause 1500

LCDOut $fe, 1 " Limpia la LCD

READ 02,PASSW

if PASSW = 0 then config2
if PASSW = 1 then armar_r
if PASSW = 2 then desarmar_r


config2:

LCDOut $fe, 2 " Posiciona el cursor en el inicio
LCDOut "Menu de Config. " " escrebe
LCDOut $fe,$C0, "1.Reiniciar Sis."
LCDOut $fe,$90, "2.Cambiar Clave."
LCDOut $fe,$D0, "3.Beep On/Off. "
PAUSE 200

READ 01,beep1
WAIT0:
call teclado
IF B1 = 0 THEN WAIT0
DATW = B1
IF beep1 = 1 THEN CALL buzzer " PREGUNTA SI EL BUZZER SONARA O NO SONARA
IF DATW = 1 THEN reiniciar
IF DATW = 2 THEN clave_new
IF DATW = 3 THEN beep_on_off
IF DATW = 8 THEN prox_pant
goto config2

prox_pant:

LCDOut $fe, 1 " Limpia la LCD

prox_pant1:

LCDOut $fe, 2 " Posiciona el cursor en el inicio
LCDOut "Menu de Config. " " escrebe
LCDOut $fe,$C0, "4.Numeros Telef."
LCDOut $fe,$90, "5.Tiempos/Retar."
LCDOut $fe,$D0, "6.Salir. "
PAUSE 200

READ 01,beep1
WAIT3:
call teclado
IF B1 = 0 THEN WAIT3
DATW = B1
IF beep1 = 1 THEN CALL buzzer " PREGUNTA SI EL BUZZER SONARA O NO SONARA
IF B1 = 4 then config2
IF B1 = 6 then tiempo_arm
IF DATW = 7 then inicio
goto prox_pant1

tiempo_arm:

READ 03,TIEMPO
PAUSE 100

tiempo_ar1:

LCDOut $fe, 2 " Posiciona el cursor en el inicio
LCDOut "Use las Flechas " " escrebe
LCDOut $fe,$C0, "para cambiar el "
LCDOut $fe,$90, "retardo: "
LCDOut $fe,$D0, "Tiempo: ",#TIEMPO," Seg."


WAIT5:
call teclado
if B1 = 0 then WAIT5
IF B1 = 4 THEN aumenta
IF B1 = 8 THEN disminuye
IF B1 = 16 THEN grava_tie
goto WAIT5

aumenta:

TIEMPO = TIEMPO + 1
CALL buzzer
IF TIEMPO = 241 then TIEMPO = 240
GOTO tiempo_ar1

disminuye:

TIEMPO = TIEMPO - 1
CALL buzzer
IF TIEMPO = 0 then TIEMPO = 1
GOTO tiempo_ar1

grava_tie:

DATO = 40
SEROUT PORTC.6 , 9600 , [DATO, 0]
PAUSE 500
SEROUT PORTC.6 , 9600 , [TIEMPO, 0]
PAUSE 100
WRITE 03,TIEMPO
PAUSE 100
GOTO prox_pant


error:

LCDOut $fe, 1 " Limpia la LCD
CONT1 = CONT1 - 1

error1:
LCDOut $fe, 2 " Posiciona el cursor en el inicio
LCDOut " Error! " " escrebe
LCDOut $fe,$C0, "Dispone de ",#CONT1
LCDOut $fe,$90, "intentos para"
LCDOut $fe,$D0, "evitar Alarma"
pause 3000

if CONT1 = 0 then bloqueo
goto password

bloqueo:
LCDOut $fe, 1 " Limpia la LCD
bloqueo1:
LCDOut $fe, 2 " Posiciona el cursor en el inicio
LCDOut " Sistema Armado " " escrebe
LCDOut $fe,$C0, " "
LCDOut $fe,$90, " "
LCDOut $fe,$D0, " "
goto bloqueo1


reiniciar:

LCDOut $fe, 2 " Posiciona el cursor en el inicio
LCDOut "Esta seguro que " " escrebe
LCDOut $fe,$C0, "desea Reiniciar "
LCDOut $fe,$90, "el Sistema? "
LCDOut $fe,$D0, "1.SI 2.No"
pause 700

READ 01,beep1
espera0:
call teclado
if B1 = 0 then espera0
DATW = B1
IF beep1 = 1 THEN CALL buzzer " PREGUNTA SI EL BUZZER SONARA O NO SONARA
if DATW = 1 then reini_sys
if DATW = 2 then config2
goto reiniciar

clave_new:
LCDOut $fe, 1 " Limpia la LCD
clave_new1:
LCDOut $fe, 2 " Posiciona el cursor en el inicio
LCDOut "Por Favor " " escrebe
LCDOut $fe,$C0, "Introduzca la "
LCDOut $fe,$90, "Nueva Clave: "
LCDOut $fe,$D0, "Clave: "
PAUSE 200

READ 01,beep1
esper1:
call teclado
if B1 = 0 then esper1
DIG1 = B1
WRITE 10,DIG1
if B1 = 5 then DIG1 = 4
if B1 = 6 then DIG1 = 5
if B1 = 7 then DIG1 = 6
if B1 = 9 then DIG1 = 7
if B1 = 10 then DIG1 = 8
if B1 = 11 then DIG1 = 9
if B1 = 14 then DIG1 = 0

pause 400

IF beep1 = 1 THEN CALL buzzer " PREGUNTA SI EL BUZZER SONARA O NO SONARA

LCDOut $fe,$D0, "Clave: ",#DIG1

READ 01,beep1
esper2:
call teclado
if B1 = 0 then esper2
DIG2 = B1
WRITE 11,DIG2
if B1 = 5 then DIG2 = 4
if B1 = 6 then DIG2 = 5
if B1 = 7 then DIG2 = 6
if B1 = 9 then DIG2 = 7
if B1 = 10 then DIG2 = 8
if B1 = 11 then DIG2 = 9
if B1 = 14 then DIG2 = 0

pause 400

IF beep1 = 1 THEN CALL buzzer " PREGUNTA SI EL BUZZER SONARA O NO SONARA

LCDOut $fe,$D0, "Clave: ",#DIG1,#DIG2

READ 01,beep1
esper3:
call teclado
if B1 = 0 then esper3
DIG3 = B1
WRITE 12,DIG3
if B1 = 5 then DIG3 = 4
if B1 = 6 then DIG3 = 5
if B1 = 7 then DIG3 = 6
if B1 = 9 then DIG3 = 7
if B1 = 10 then DIG3 = 8
if B1 = 11 then DIG3 = 9
if B1 = 14 then DIG3 = 0

pause 400

IF beep1 = 1 THEN CALL buzzer " PREGUNTA SI EL BUZZER SONARA O NO SONARA

LCDOut $fe,$D0, "Clave: ",#DIG1,#DIG2,#DIG3

READ 01,beep1
esper4:
call teclado
if B1 = 0 then esper4
DIG4 = B1
WRITE 13,DIG4
if B1 = 5 then DIG4 = 4
if B1 = 6 then DIG4 = 5
if B1 = 7 then DIG4 = 6
if B1 = 9 then DIG4 = 7
if B1 = 10 then DIG4 = 8
if B1 = 11 then DIG4 = 9
if B1 = 14 then DIG4 = 0

pause 400

IF beep1 = 1 THEN CALL buzzer " PREGUNTA SI EL BUZZER SONARA O NO SONARA

LCDOut $fe,$D0, "Clave: ",#DIG1,#DIG2,#DIG3,#DIG4

READ 01,beep1
esper5:
call teclado
if B1 = 0 then esper5
DIG5 = B1
WRITE 14,DIG5
if B1 = 5 then DIG5 = 4
if B1 = 6 then DIG5 = 5
if B1 = 7 then DIG5 = 6
if B1 = 9 then DIG5 = 7
if B1 = 10 then DIG5 = 8
if B1 = 11 then DIG5 = 9
if B1 = 14 then DIG5 = 0

 
pause 400

IF beep1 = 1 THEN CALL buzzer " PREGUNTA SI EL BUZZER SONARA O NO SONARA

LCDOut $fe,$D0, "Clave: ",#DIG1,#DIG2,#DIG3,#DIG4,#DIG5

READ 01,beep1
esper6:
call teclado
if B1 = 0 then esper6
DIG6 = B1
WRITE 15,DIG6
if B1 = 5 then DIG6 = 4
if B1 = 6 then DIG6 = 5
if B1 = 7 then DIG6 = 6
if B1 = 9 then DIG6 = 7
if B1 = 10 then DIG6 = 8
if B1 = 11 then DIG6 = 9
if B1 = 14 then DIG6 = 0

pause 400

IF beep1 = 1 THEN CALL buzzer " PREGUNTA SI EL BUZZER SONARA O NO SONARA

LCDOut $fe,$D0, "Clave: ",#DIG1,#DIG2,#DIG3,#DIG4,#DIG5,#DIG6
pause 1000

enter:
read 01,beep1
enterw:
call teclado
if B1 = 0 then enterw

IF beep1 = 1 THEN CALL buzzer " PREGUNTA SI EL BUZZER SONARA O NO SONARA

if B1 = 16 then config2
if B1 = 13 then clave_new
goto enter


beep_on_off:

READ 01,BEEP
PAUSE 100
IF BEEP = 0 THEN enciende
IF BEEP = 1 THEN apaga

enciende:
write 01,1
pause 100
LCDOut $fe, 1 " Limpia la LCD
LCDOut $fe, 2 " Posiciona el cursor en el inicio
LCDOut "****************" " escrebe
LCDOut $fe,$C0, "* BUZZER ON *"
LCDOut $fe,$90, "****************"

PAUSE 3000
goto config2

apaga:
write 01,0
pause 100
LCDOut $fe, 1 " Limpia la LCD
LCDOut $fe, 2 " Posiciona el cursor en el inicio
LCDOut "****************" " escrebe
LCDOut $fe,$C0, "* BUZZER OFF *"
LCDOut $fe,$90, "****************"

PAUSE 3000
goto config2

reini_sys:

LCDOut $fe, 1 " Limpia la LCD

write 00,01 " indica que el sistema se inicia la segunda vez o mas...
;PAUSE 100
WRITE 01,00 " GRABA EL ESTADO DEL BUZZER, ON O OFF
;PAUSE 100
WRITE 10,1 " PRIMER DIGITO DE LA CLAVE "el numero indica la posicion de la tecla"
;PAUSE 100
WRITE 11,2
;PAUSE 100
WRITE 12,3
;PAUSE 100
WRITE 13,5
;PAUSE 100
WRITE 14,6
;PAUSE 100
WRITE 15,7 " ULTIMO DIGITO DE LA CLAVE "el numero indica la posicion de la tecla"
;PAUSE 100


LCDOut $fe, 2 " Posiciona el cursor en el inicio
LCDOut "Sist. Reiniciado" " escrebe
LCDOut $fe,$C0, " Ingresando "
LCDOut $fe,$90, " valores de "
LCDOut $fe,$D0, " fabrica. "
Pause 3000

goto bienve

inicio:

LCDOut $fe, 2 " Posiciona el cursor en el inicio
LCDOut "*.Seleccione: " " escrebe
LCDOut $fe,$C0, "1.Activar Alarma"
LCDOut $fe,$90, "2.Serv. Nocturno"
LCDOut $fe,$D0, "3.Configuracion "

read 01,beep1
goto WAIT1

inicio1:

LCDOut $fe, 2 " Posiciona el cursor en el inicio
LCDOut "*.Seleccione: " " escrebe
LCDOut $fe,$C0, " "
LCDOut $fe,$90, "2.Desarmar Alarm"
LCDOut $fe,$D0, " "

read 01,beep1
goto WAIT2

WAIT1:
call teclado
if B1 = 0 then WAIT1
IF beep1 = 1 THEN CALL buzzer " PREGUNTA SI EL BUZZER SONARA O NO SONARA
if B1 = 1 then armar
if B1 = 2 then nocturno
if B1 = 3 then configurar
goto WAIT1

WAIT2:
call teclado
if B1 = 0 then WAIT2
IF beep1 = 1 THEN CALL buzzer " PREGUNTA SI EL BUZZER SONARA O NO SONARA
if B1 = 2 then desarmar
goto WAIT2

armar:
write 02,1
pause 100
GOTO password
armar_r:
DATO = 50
SEROUT PORTC.6 , 9600 , [DATO, 0]
PAUSE 200
goto inicio1

desarmar:
write 02,2
pause 100
GOTO password
desarmar_r:
DATO = 60
SEROUT PORTC.6 , 9600 , [DATO, 0]
PAUSE 200
goto inicio

configurar:
write 02,3
pause 200
goto password

nocturno:

LCDOut $fe, 2 " Posiciona el cursor en el inicio
LCDOut "*.Seleccione: " " escrebe
LCDOut $fe,$C0, "1.Activar Zonas."
LCDOut $fe,$90, "2.Elegir Zonas. "
LCDOut $fe,$D0, "3.Volver. "

read 01,beep1

WAIT4:
call teclado
if B1 = 0 then WAIT4
IF beep1 = 1 THEN CALL buzzer " PREGUNTA SI EL BUZZER SONARA O NO SONARA
if B1 = 1 then zonas
if B1 = 2 then elegir_z
if B1 = 3 then inicio
goto WAIT4

zonas:

GOTO inicio

elegir_z:

LCDOut $fe, 2 " Posiciona el cursor en el inicio
LCDOut "Ingrese zonas " " escrebe
LCDOut $fe,$C0, "a ser activadas"
LCDOut $fe,$90, "y pulse enter: "
LCDOut $fe,$D0, " "


read 01,beep1

WAIT6:
call teclado
IF B1 = 13 THEN nocturno
if B1 = 0 then WAIT6
IF beep1 = 1 THEN CALL buzzer " PREGUNTA SI EL BUZZER SONARA O NO SONARA
IF B1 = 1 THEN ZONA1 = 1
IF B1 = 2 THEN ZONA1 = 2
IF B1 = 3 THEN ZONA1 = 3
IF B1 = 5 THEN ZONA1 = 4
IF B1 = 6 THEN ZONA1 = 5
IF B1 = 7 THEN ZONA1 = 6
IF B1 = 9 THEN ZONA1 = 7
IF B1 = 10 THEN ZONA1 = 8
LCDOut $fe,$D0, #ZONA1

WAIT7:
call teclado
IF B1 = 13 THEN nocturno
if B1 = 16 then nocturno
if B1 = 0 then WAIT7
IF beep1 = 1 THEN CALL buzzer " PREGUNTA SI EL BUZZER SONARA O NO SONARA
IF B1 = 1 THEN ZONA2 = 1
IF B1 = 2 THEN ZONA2 = 2
IF B1 = 3 THEN ZONA2 = 3
IF B1 = 5 THEN ZONA2 = 4
IF B1 = 6 THEN ZONA2 = 5
IF B1 = 7 THEN ZONA2 = 6
IF B1 = 9 THEN ZONA2 = 7
IF B1 = 10 THEN ZONA2 = 8
LCDOut $fe,$D0, " ",#ZONA1," ",#ZONA2

WAIT8:
call teclado
IF B1 = 13 THEN nocturno
if B1 = 16 then nocturno
if B1 = 0 then WAIT8
IF beep1 = 1 THEN CALL buzzer " PREGUNTA SI EL BUZZER SONARA O NO SONARA
IF B1 = 1 THEN ZONA3 = 1
IF B1 = 2 THEN ZONA3 = 2
IF B1 = 3 THEN ZONA3 = 3
IF B1 = 5 THEN ZONA3 = 4
IF B1 = 6 THEN ZONA3 = 5
IF B1 = 7 THEN ZONA3 = 6
IF B1 = 9 THEN ZONA3 = 7
IF B1 = 10 THEN ZONA3 = 8
LCDOut $fe,$D0, " ",#ZONA1," ",#ZONA2," ",#ZONA3

WAIT9:
call teclado
IF B1 = 13 THEN nocturno
if B1 = 16 then nocturno
if B1 = 0 then WAIT9
IF beep1 = 1 THEN CALL buzzer " PREGUNTA SI EL BUZZER SONARA O NO SONARA
IF B1 = 1 THEN ZONA4 = 1
IF B1 = 2 THEN ZONA4 = 2
IF B1 = 3 THEN ZONA4 = 3
IF B1 = 5 THEN ZONA4 = 4
IF B1 = 6 THEN ZONA4 = 5
IF B1 = 7 THEN ZONA4 = 6
IF B1 = 9 THEN ZONA4 = 7
IF B1 = 10 THEN ZONA4 = 8
LCDOut $fe,$D0, " ",#ZONA1," ",#ZONA2," ",#ZONA3," ",#ZONA4


pause 2000

GOTO inicio


teclado:

B1 = 0
portb=1
;portb.0 = 1
;portb.1 = 0
;portb.2 = 0
;portb.3 = 0
if portb.4 = 1 then B1 = 1 " tecla "1"
if portb.5 = 1 then B1 = 5 " tecla "4"
if portb.6 = 1 then B1 = 9 " tecla "7"
if portb.7 = 1 then B1 = 13 " tecla "clear"
 portb=2
;portb.0 = 0
;portb.1 = 1
;portb.2 = 0
;portb.3 = 0
if portb.4 = 1 then B1 = 2 " tecla "2"
if portb.5 = 1 then B1 = 6 " tecla "5"
if portb.6 = 1 then B1 = 10 " tecla "8"
if portb.7 = 1 then B1 = 14 " tecla "0"
portb=4
;portb.0 = 0
;portb.1 = 0
;portb.2 = 1
;portb.3 = 0
if portb.4 = 1 then B1 = 3 " tecla "3"
if portb.5 = 1 then B1 = 7 " tecla "6"
if portb.6 = 1 then B1 = 11 " tecla "9"
if portb.7 = 1 then B1 = 15 " TECLA "HELP"
portb=8
;portb.0 = 0
;portb.1 = 0
;portb.2 = 0
;portb.3 = 1
if portb.4 = 1 then B1 = 4 " tecla "flecha arriba"
if portb.5 = 1 then B1 = 8 " tecla "flecha abajo"
if portb.6 = 1 then B1 = 12 " tecla "2ND"
if portb.7 = 1 then B1 = 16 " tecla "enter"

RETURN

buzzer:

porta.0 = 1
pause 150
porta.0 = 0
return
 
pantalla:
    LCDOut $fe, 2 ,"Introduzca su "" Posiciona el cursor en el inicio  
    LCDOut $fe,$C0, "Clave de Acceso:"
return

End



Seguramente se puede mejorar tal como dice ricky ,haciendo llamadas a subrutinas.-

Saludos

Jorge

Desconectado manex_1987

  • Colaborador
  • PIC24H
  • *****
  • Mensajes: 1127
RE: No me alcanza la memoria de prog. del 877A y aún no termino. Ahora que hago?
« Respuesta #6 en: 08 de Marzo de 2005, 12:52:00 »
Le he dado un vistazo, y el primer fallo de optimizacion que encuentro es, el referente a la introduccion de la clave.

Lo que tu haces es, recibir datos secuencialmente. Es decir:
Esperardato1
Print "*"
Esperardato2
Print"**"
EsperardatoX
Print"*****...***"

Eso, bajo mi punto de vista, es MUY basto, y puedes ahorrar mucha memoria si optimizas esa parte. Como? Pues declarando el password como un array, y la clave igualmente, y luego asi ( te lo pongo descriptivamente) :

CLAVE[6]="PRUEBA"
PASSWORD[6]=""
x=1
-------BUCLE:
EsperarDato
  • <---almacena dato en password

  • x=x+1
    Añadir_asterisco_al_lcd
    ------- SI X=6 SALIR DEL BUCLE

    X=0
    CORRECTO=1
    -------BUCLE:
    X=X+1
    SI PASSWORD
  • <> CLAVE
  •  ENTONCES CORRECTO=0
    ------- SI X=6 SALIR DEL BUCLE

    SI CORRECTO=1 ENTONCES PASSWORD ES OK!


    salu2!

    PD: en este mismo momento, tengo la duda, de si pbpro (o pbplus si lo fuere) tiene notacion array ARRAY
  • = A[0]...A[x-1] o es ARRAY
  • =A[1]...A
  • , por lo que el programa podria variarse en este sentido.

Desconectado manex_1987

  • Colaborador
  • PIC24H
  • *****
  • Mensajes: 1127
RE: No me alcanza la memoria de prog. del 877A y aún no termino. Ahora que hago?
« Respuesta #7 en: 08 de Marzo de 2005, 13:00:00 »
Otra...

Las rutinas ENCIENDE y APAGA, se podrian implementar de este modo:

ENCIENDEFLAG var BOOLEAN

encienderutina:
lcdout"*************"
if enciendeflag=1 then lcdout "* encendido *" else lcdout "* apagado *"
lcdout"*************"
return

Seria cuestion de llamar a la rutina, con el flag en 1 o en 0, segun el resultado que queramos. Y si queremos ser mas "tacaños" con codigo, y mas "generosos" con el tiempo de ejecucion, concentra todos los LCDOUT identicos en una rutina, y llamalos en caso de necesidad.

Dudo que el compilador corrijiera esto por ti...

En fin, me doy cuenta de que si el programa ocupa tanto codigo es, porque muchas rutinas son muy repetitivas. 1 Concentra todas los comandos identicos en una rutina y llamala segun necesidad .  2 Usa flags y variables para agrupar rutinas "parecidas" (la correcion que te hice es buen ejemplo) en una sola rutina.

salu2

Desconectado gesteva

  • PIC12
  • **
  • Mensajes: 52
RE: No me alcanza la memoria de prog. del 877A y aún no termino. Ahora que hago?
« Respuesta #8 en: 08 de Marzo de 2005, 13:19:00 »
Ok, estaré trabajando un poco en base a sus sugerencias, aunque no tengo nada de practica con los arrays, voy a practicar unas rutinas.

Creo que ahora veo cosas que antes no.

Saludos... Rebotado

Desconectado daruim

  • PIC10
  • *
  • Mensajes: 1
RE: No me alcanza la memoria de prog. del 877A y aún no termino. Ahora que hago?
« Respuesta #9 en: 29 de Marzo de 2005, 10:50:00 »
Hola. A mi tambien me pasó el tema de quedarme sin memoria con el 877A. Lo que hice fué pasarme a los pics de la familia 18. concretamente al 18f542 que es totalmente compatile con el 877a (al menos su version dip de 40 pines). La única precaución es que la configuración debes realizarla en ensamblador por la complejidad de los swites internos del pic. para ello ésta familia cuenta con 7 registros de 16 bits de configuración. Si no te aclaras con ellos te paso el código. pero en la ayuda del proton te viene explicado si buscas la palabra CONFIG.

Otra posibilidad que manejé fué el empleo de una memoria flash o eeprom externa donde pueda cargar mi programa. Éxiste un modelo de pic que no tiene memoria interna de programa y que está especialmente indicado para aplicaciones de memoria externa. Así tienes hasta 512k. Él modelo del pic sin eeprom no me acuerdo pero lo tienes en la web de micrchip. Espero servirte de ayuda.

SALUDOS

Desconectado gesteva

  • PIC12
  • **
  • Mensajes: 52
RE: No me alcanza la memoria de prog. del 877A y aún no termino. Ahora que hago?
« Respuesta #10 en: 02 de Abril de 2005, 10:23:00 »
Gracias por la observación, he estado optimizando el programa pero aún veo que me quedo corto de memoria de programa. Yo tengo el 18f442 y el 18f458, y ninguno de los dos los he podido programar, la verdad no entiendo a que te refieres con la configuración en ensamblador. Quizá me puedas dar una mano con esto.
Con respecto a los micros que utilizan memoria de programa externa, me interesó bastante... voy a investigar en la web de microchip.

Espero sus comentarios...

Gracias! Rebotado


 

anything