;  PROGRAMM SOLDERING STANTION  
	list	P=PIC16F84A		
;(LP      32768 )
#include <P16F84A.INC>
; 
OZUMS         	equ    	10h ;     
UPCH		equ	11h ;  . UP
DNCH		equ	12h ;  . DWN
TEMPA		equ	13h ; 	
cnt1		equ	14h
cnt2 		equ	15h
OFFH		equ	16h ;  . OFF
OFCH		equ	17h
DLLO		equ	18h
DLHI		equ	19h
SOCH		equ	1Ah ;  
MODE		equ	1Bh ; 
CNTMIN		equ	1Ch ; 
CNTSMIN	equ	1Dh ; ,  . 
tmp		equ	1Eh
; 
DEL1		equ	D'35'
punkt		equ	D'80'
shtrih		equ	D'240'
;	 :
;	-RA0- 1 -   
;	      0 -  
;	-RA1- 0 -   "UP"
;	-RA2- 0 -   "DWN"
;	-RA3- 0 -   "OFF"
;
;	 
;	-RA4- 1 -  
;	-RB0-  "Stand by"
;	-RB1-  "60%"
;	-RB2-  "70%"
;	-RB3-  "80%"
;	-RB4-  "90%"
;	-RB5-  (LED) "100%"
;	-RB6-  "OFF"
;	-RB7- 
;           PIC-
		org 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;     
	clrf PORTB
	clrf PORTA
	bsf STATUS, RP0	; bank1
	movlw b'00001111'
	movwf TRISA ^80h	;RA0-3   , 					;RA4  
	movlw b'00000000'  
	movwf TRISB ^80h	; b   
	
	movlw b'00000000'	;  						;OPTION	
	movwf OPTION_REG ^80h
	bcf STATUS, RP0	;bank0
	movlw b'01000000'	; 
	movwf PORTB
	movlw b'00000000'	;  						;INTCON
	movwf INTCON
;    
	clrf CNTMIN
	clrf CNTSMIN
	CLRF TEMPA	
	clrf MODE
	movlw DEL1
	movwf SOCH
	movwf DNCH
	movwf UPCH
	movwf OFFH
;   
clrmin	macro
	movlw .71		;   
      movwf cnt1 		; 
	clrf cnt2
	endm		
;**************************************************
;  PILIK
pilik	macro dlit
	local pilic
	MOVLW dlit
      MOVWF tmp
pilic	bsf	PORTB, 7
	nop
	nop
	nop
	bcf	PORTB, 7
	DECFSZ tmp,f
	GOTO 	pilic
     	endm
;**************************************************
;  PAUSE

pause	macro del
	local paus
	MOVLW del
     	MOVWF tmp
paus	nop
	nop
	nop
	nop
	nop
	DECFSZ	tmp,f
	GOTO 	paus
	endm     
;   4
      movlw .251 
      movwf OFCH
;
	bsf PORTA, 4		; 
Slb	call sec_05
	btfsc PORTA, 0	;.  ?
	goto main		;,  . 
	incfsz OFCH, f	;, 4 SOS  
	goto Wit	
	bcf PORTA, 4		; Relay OFF
	goto $			; OFF
Wit	bsf PORTB, 5		;  
	call sos
	bcf PORTB, 5
	call sec_05
	goto Slb
; 
main	clrmin
	movlw b'00100000'
	movwf PORTB		;  100%
	bsf MODE,2		; 2 
	call hello
begin	movf PORTB, W
	andlw 0x3f
	movwf TEMPA		; 
;***************************************************
				;  
				;
Sold	btfsc PORTA, 0	;.   ?
	goto Mod		;
	bcf MODE,0		;,   0, 					; . 
	btfss TEMPA, 0	;  Stand by?
	goto Dnb		;
	movlw b'00100000'	;,
	movwf PORTB		;  100%
	bsf MODE,1		; 1 .
	clrf CNTMIN		;  1
	clrmin
	goto Dnb
Mod	bsf MODE,0		;  1,
				; . 
	clrf CNTSMIN		;  2
	goto Dnb
;Dnbf	clrf CNTMIN		;  1
;	clrmin	
;****************************************************
	;  DWN
Dnb	btfsc PORTA, 2
	goto Upb
	incfsz DNCH, f
	goto Dnb
	call tiker		;
	
	bcf STATUS, C	;  						;
	rrf TEMPA, F		;  1 
	btfsc STATUS, C	; Stand by ?
	bsf TEMPA, 5		;,  100%
	goto Dunb
;****************************************************
	;  UP

Upb	btfsc PORTA, 1
	goto Offb
	incfsz UPCH, f
	goto Upb
	call tiker		;
	
	bcf STATUS, C	;  						;
	rlf TEMPA, F		;  1 
	btfsc TEMPA, 6	; "100%" ?
	bsf TEMPA, 0		;,  stand by
	bcf TEMPA, 6	
Dunb	movf TEMPA, W
	movwf PORTB
;****************************************************
	; OFF
Offb	btfsc PORTA, 3
	goto Nob
	incfsz OFFH, f
	goto Offb
Offr	call off
	movlw b'01000000'	; 
	movwf PORTB
	bcf PORTA, 4		;Relay off	
	goto $
;*****************************************************
	;    
Nob	
	movlw DEL1
	movwf SOCH
	movwf DNCH
	movwf UPCH
	movwf OFFH
	;goto begin
;*****************************************************
;  
clock           
      decfsz cnt2,f 
      goto $+2 
      decfsz cnt1,f 
      goto begin
	incf CNTMIN, f	; 
	clrmin			;   
         				; 
;******************************************************
;  
	btfsc MODE, 1	;  Stand by?
	goto Lb3		;
Lb9	btfss MODE, 0	;.  ?
	goto Lb8		;,   
	btfss MODE, 2	;  "0"?
	goto Lb1		;
Lb2	
	movf CNTMIN, w
	sublw .2
	btfsc STATUS, Z
	goto Lb3		;  2 
	goto begin		; 

Lb3	bcf MODE,2		;. 
	bcf MODE,1
	clrf CNTMIN		;  1
	movlw b'00000100'	;,  70%
	movwf PORTB
	call tiker
	goto begin
;*****************************************************
;,  .     >5 
Lb1	movf CNTMIN, w		
	sublw .5		;  
	btfsc STATUS, Z
	goto Lb4
	goto Lb5
Lb4	call tiker
	goto begin
;*****************************************************
;   Stand by,   >10 

Lb5	movf CNTMIN, w		
	sublw .10
	btfsc STATUS, Z
	goto Lb6
	goto Lb7
Lb6	movlw b'00000001'	; Stand by
	movwf PORTB
	call tiker
	goto begin
;*****************************************************
;,   >30 
Lb7	movf CNTMIN, w		
	sublw .30
	btfsc STATUS, Z
	goto Offr		;  - OFF
	goto begin
;*********************************************************
;   .   
Lb8	clrf CNTMIN		;  1
	incf CNTSMIN, f	; 
	call tiker		;   						;
	movf CNTSMIN, w
	sublw .5
	btfsc STATUS, Z
	goto Slb		;  OFF
	goto begin
;      TIKER
tiker
	MOVLW .80
      MOVWF OZUMS
TIKER_1        
	bsf	PORTB, 7
	nop
	nop
	nop
	bcf	PORTB, 7
	DECFSZ OZUMS,1
	GOTO TIKER_1
      return
;   0.5 
sec_05
	;
	movlw .3
	movwf DLHI
	clrf DLLO
Del05	; 
	decfsz DLLO,f 
      goto $+2 
      decfsz DLHI,f 
      goto Del05
	return
;  
hello
	pilik shtrih
	pause punkt
	pilik punkt
	pause shtrih
	pilik punkt
	pause punkt
	pilik shtrih
	pause punkt
	pilik shtrih
	pause shtrih
	pilik shtrih
	pause punkt
	pilik punkt
	pause punkt
	pilik punkt
	pause punkt
	pilik punkt
	pause punkt
	pilik shtrih	
	return
;  SOS
sos
	pilik punkt
	pause punkt
	pilik punkt
	pause punkt
	pilik punkt
	pause shtrih
	pilik shtrih
	pause punkt
	pilik shtrih
	pause punkt
	pilik shtrih
	pause shtrih
	pilik punkt
	pause punkt
	pilik punkt
	pause punkt
	pilik punkt
	pause shtrih
	return
; OFF
off
	pilik shtrih
	pause punkt
	pilik punkt
	pause punkt
	pilik shtrih
	pause punkt
	pilik punkt
	return
	END
