TODOPIC
Microcontroladores PIC => * PROYECTOS * => Mensaje iniciado por: BINARIO en 03 de Agosto de 2007, 12:55:10
-
Buenos colegas, hice este pequeño semaforo para el hijo de una amiga, para un trabajo del colegio del niño, no calcule los delays, ni logre hacer parpadear el semaforo peatonal verde, pero es una buena punta para alguno que andaba buscando un proyecto similar, es secillo, progrmaado a lo bestia, o sea sin mascara de bits ni nada muy complicado, solo seteo o reseteo el bit que necesito, a ver que les parece gente.
Es la primera vez que trabajo con este micro, es mas sencillo que el 877, bueno que esten bien espero opiniones :-/ :-/
LIST p=16F84 ; PIC16F844 procesador
#include "P16F84.INC" ; header file
CBLOCK 0x10 ; Almacenamiento
l1
l2
ENDC
org 0 ;
goto setports ;
org 4 ;
retfie ;
setports clrw ;
movwf PORTA ;
movwf PORTB ;
bsf STATUS,RP0 ;
clrw ;
movwf TRISB ;
bcf STATUS,RP0 ;
loop clrwdt
bsf PORTB, 6
nop
bsf PORTB, 0
nop
bsf PORTB, 3
call retverde
bcf PORTB, 6
nop
bsf PORTB, 5
call retamarillo
bcf PORTB, 5
nop
bsf PORTB, 4
call retpaso
bcf PORTB, 3
nop
bsf PORTB, 7
nop
bcf PORTB, 0
nop
bsf PORTB, 2
call retrojo
bcf PORTB, 2
nop
bsf PORTB, 1
call retamarillo
bcf PORTB, 1
nop
bsf PORTB, 0
call retamarillo
bsf PORTB, 3
nop
bcf PORTB, 7
nop
bcf PORTB, 4
goto loop ;
;
;
;
;
;--------------------------------------------------------------------
retpaso movlw 2
movwf l1
a1 call retpaso2
decfsz l1
goto a1
return
retpaso2 clrf l2
a2 decfsz l2
goto a2
return
;--------------------------------------------------------------------
retverde movlw 8
movwf l1
x1 call retverde2
decfsz l1
goto x1
return
retverde2 clrf l2
x2 decfsz l2
goto x2
return
;--------------------------------------------------------------------
retamarillo movlw 4
movwf l1
y1 call retamarillo2
decfsz l1
goto y1
return
retamarillo2 clrf l2
y2 decfsz l2
goto y2
return
;---------------------------------------------------------------------
retrojo movlw 10
movwf l1
z1 call retrojo2
decfsz l1
goto z1
return
retrojo2 clrf l2
z2 decfsz l2
goto z2
return
;---------------------------------------------------------------------
END
-
Bueno o chequean las respuestas o no te puedo responder envio de nuevo por las dudas.(Si ya salio perdon pero no lo veia)
En una epoca apenas empezaba (para atajarme de los golpes del código) habia hecho un semáforo de cuatro tiempos en asm.
Lo unico que creo que le falta es recalcular los tiempos (Hay dos tiempos uno corto = amarillo y otro largo = verde y rojo ).
Te lo adjunto junto con la simulacion del proteus que pese a que se hizo para un cristal de 4Mhz el tiempo esta cambiado en el proteus.
-
Aca dejo la ultima version del programa logre hacer titilar los semaforos peatonales de paso aunque aun lo estoy modificando, lo proximo que quiero es colocar un buzzer para ayudar a los invidentes a cruzar la calle espero que les guste esta actualizacin y acepto criticas de todo tipo un abrazo gente
LIST p=16F84 ; PIC16F844 procesador
#include "P16F84.INC" ; header file
CBLOCK 0x10 ; Almacenamiento
l1
l2
ENDC
org 0 ;
goto setports ;
org 4 ;
retfie ;
setports clrw ;
movwf PORTA ;
movwf PORTB ;
bsf STATUS,RP0 ;
clrw ;
movwf TRISB
movwf TRISA ;
bcf STATUS,RP0 ;
loop clrwdt
bsf PORTA, 1
nop
bsf PORTB, 6
nop
bsf PORTB, 0
nop
bsf PORTB, 3
call retverde
bcf PORTB, 6
nop
bsf PORTB, 5
call retpeaton
bcf PORTA, 1
nop
bcf PORTB, 5
nop
bsf PORTA, 0
nop
bsf PORTB, 4
call retpaso
bcf PORTB, 3
nop
bsf PORTB, 7
nop
bcf PORTB, 0
nop
bsf PORTB, 2
call retrojo
bcf PORTB, 2
nop
bsf PORTB, 1
call retpeaton2
bcf PORTB, 1
nop
bcf PORTB, 7
nop
bsf PORTB, 3
nop
bsf PORTB, 0
call retpaso
nop
bcf PORTB, 4
goto loop ;
;
;
;--------------------------------------------------------------------
miniret movlw 1
movwf l1
b1 call miniret2
decfsz l1
goto b1
return
miniret2 clrf l2
b2 decfsz l2
goto b2
return
;--------------------------------------------------------------------
retpeaton2 bcf PORTB, 7
call miniret
bsf PORTB, 7
call miniret
call miniret
call miniret
bcf PORTB, 7
call miniret
bsf PORTB, 7
call miniret
call miniret
call miniret
bcf PORTB, 7
call miniret
bsf PORTB, 7
call miniret
call miniret
call miniret
bcf PORTB, 7
call miniret
bsf PORTB, 7
call miniret
call miniret
call miniret
bcf PORTB, 7
call miniret
bsf PORTB, 7
call miniret
call miniret
call miniret
bcf PORTB, 7
call miniret
bsf PORTB, 7
call miniret
call miniret
call miniret
bcf PORTB, 7
call miniret
bsf PORTB, 7
call miniret
call miniret
call miniret
bcf PORTB, 7
call miniret
bsf PORTB, 7
call miniret
call miniret
call miniret
bcf PORTB, 7
call miniret
bsf PORTB, 7
call miniret
call miniret
call miniret
bcf PORTB, 7
call miniret
bsf PORTB, 7
call miniret
call miniret
call miniret
bcf PORTB, 7
call miniret
bsf PORTB, 7
call miniret
call miniret
call miniret
bcf PORTB, 7
call miniret
bsf PORTB, 7
call miniret
call miniret
call miniret
return
;--------------------------------------------------------------------
retpeaton bcf PORTA, 1
call miniret
bsf PORTA, 1
call miniret
call miniret
call miniret
bcf PORTA, 1
call miniret
bsf PORTA, 1
call miniret
call miniret
call miniret
bcf PORTA, 1
call miniret
bsf PORTA, 1
call miniret
call miniret
call miniret
bcf PORTA, 1
call miniret
bsf PORTA, 1
call miniret
call miniret
call miniret
bcf PORTA, 1
call miniret
bsf PORTA, 1
call miniret
call miniret
call miniret
bcf PORTA, 1
call miniret
bsf PORTA, 1
call miniret
call miniret
call miniret
bcf PORTA, 1
call miniret
bsf PORTA, 1
call miniret
call miniret
call miniret
bcf PORTA, 1
call miniret
bsf PORTA, 1
call miniret
call miniret
call miniret
bcf PORTA, 1
call miniret
bsf PORTA, 1
call miniret
call miniret
call miniret
bcf PORTA, 1
call miniret
bsf PORTA, 1
call miniret
call miniret
call miniret
bcf PORTA, 1
call miniret
bsf PORTA, 1
call miniret
call miniret
call miniret
bcf PORTA, 1
call miniret
bsf PORTA, 1
call miniret
call miniret
call miniret
return
;--------------------------------------------------------------------
retpaso movlw 10
movwf l1
a1 call retpaso2
decfsz l1
goto a1
return
retpaso2 clrf l2
a2 decfsz l2
goto a2
return
;--------------------------------------------------------------------
retverde movlw 50
movwf l1
x1 call retverde2
decfsz l1
goto x1
return
retverde2 clrf l2
x2 decfsz l2
goto x2
return
;--------------------------------------------------------------------
;retamarillo movlw 30
; movwf l1
;y1 call retamarillo2
; decfsz l1
; goto y1
; return
;retamarillo2 clrf l2
;y2 decfsz l2
; goto y2
; return
;---------------------------------------------------------------------
retrojo movlw 60
movwf l1
z1 call retrojo2
decfsz l1
goto z1
return
retrojo2 clrf l2
z2 decfsz l2
goto z2
return
;---------------------------------------------------------------------
END
-
hola amigo yo hice lo mismo pero en ASM e inclui los delays si estas interesado escribeme a mi email:
windowsyunxin@hotmail.com
-
ehhhh que esto no es asm ???