Я студент инженерного факультета, и я немного запутался в этой программе.Может ли кто-нибудь помочь мне заполнить оставшиеся комментарии для каждой строки в программе?Я новичок в этом программировании.
#INCLUDE<P16F88.INC> ; PIC definitions
SET_UPPER EQU 0x20
SET_LOWER EQU 0x21
READ_UPPER EQU 0x22
READ_LOWER EQU 0x23
P_gain EQU 0x24
I_gain EQU 0x25
D_gain EQU 0x26
Prop EQU 0x27
Int EQU 0x28
Diff EQU 0x29
DError EQU 0x30
IError EQU 0x31
temp EQU 0x32
ORG 0h
;****************************
; INITIZLIZATION
;****************************
BANKSEL TRISA ;SELECT TRISA BANL
MOVLW B'00000011' ;MAKE PIN0 AND 1 INPUT
MOVWF TRISA ;Writing to TRISA register
BANKSEL ANSEL
MOVLW B'00000011' ;MAKE PA0 AND PA1 ANALOG INPUT
MOVWF ANSEL
BANKSEL PORTA
MOVLW 0x80 ;FOSC/32 AND CHANNEL0
MOVWF ADCON0
MOVLW 0x00
CLRF ADCON1 ;LEFT JUSTIFIED ADC VALUE
CLRF CCP1CON ;PWM MODULE
CLRF TRISB ;MAKE PORT B O/P FOR PWM
MOVLW 0xFF
MOVWF PR2
CLRF CCPR1L ;0 DUTY CYCLE AT START
MOVLW 0x01
MOVWF T2CON ;PRESCALER 4 AND POSTSCALAR 1
BSF T2CON,TMR2ON ;SWITCH ON TIMER
;****************************
; MAIN
;****************************
MAIN
CALL SET_POINT ;READ SET POINT
CALL READ_TEMP ;READ TEMPERTAURE
CALL COMPARE ;COMPARE AND FIND GAIN VALUE
CALL CONTROL ;MAP GAIN TO DUTY CYCLE
GOTO MAIN
;****************************
; READ SET PT.
;****************************
SET_POINT
MOVLW 0x80
MOVWF ADCON0 ;CHANNEL 0 ADC
BSF ADCON0,ADON ;SWITCH ON ADC
NOP ;WAIT ACQUISITION TIME
NOP
NOP
NOP
NOP
BSF ADCON0,GO
ADC
BTFSC ADCON0,GO ;WAIT TILL CONVERSION IS COMPLETE
GOTO ADC
MOVF ADRESH,W ;READ ADC VALUES
MOVWF SET_UPPER
BANKSEL ADRESL
MOVF ADRESL,W
MOVWF SET_LOWER
BANKSEL PORTA
RETURN
;****************************
; READ TEMPERATURE
;****************************
READ_TEMP
MOVLW 0x88 ;ADC CHANNEL 1 SELECT
MOVWF ADCON0
BSF ADCON0,ADON ;SWITCH ON ADC
NOP ;WAIT ACQUSITION TIME
NOP
NOP
NOP
NOP
BSF ADCON0,GO ;START CONVERSION
ADC0
BTFSC ADCON0,GO ;WAIT TILL CONVERSION IS COMPLETE
GOTO ADC0
MOVF ADRESH,W
MOVWF READ_UPPER ;READ ADC VALUE
BANKSEL ADRESL
MOVF ADRESL,W
MOVWF READ_LOWER
BANKSEL PORTA
RETURN
;******************************
; COMPUTE ERROR AND GAINS
;******************************
COMPARE
MOVF SET_UPPER,W
SUBWF READ_UPPER,W ;SUBTRACT READ VALUE FROM SET POINT
SUBWF DError,F ;COMPUTE INTEGRAL ERROR
ADDWF IError,F ;COMPUTE DIFFERENTIAL ERROR
MOVWF Prop ;MOVE COMPUTED ERROR TO PROP
MOVF P_gain,W
MOVWF temp
MOVF Prop,W
Prop_loop
ADDWF Prop,F ;ADD PRPORTIONAL ERROR PROPORTIONAL GAIN TIMES
DECFSZ temp,F
GOTO Prop_loop
MOVF IError,W
MOVWF Int
MOVF I_gain,W
MOVWF temp
MOVF Int,W
Int_loop
ADDWF Int,F ;ADD INTEGRAL ERROR INTEGRAL GAIN TIMES
DECFSZ temp,F
GOTO Int_loop
MOVF DError,W
MOVWF Diff
MOVF D_gain,W
MOVWF temp
MOVF Diff,W
Diff_loop
ADDWF Diff,F ;ADD DIFFERENTIAL ERROR DIFFERENTIAL GAIN TIMES
DECFSZ temp,F
GOTO Diff_loop
RETURN
;***************************
; MAP GAIN TO PWM VALUE
;***************************
CONTROL
MOVF Prop,W ;ADD ALL THREE COMPUTED VALUES
ADDWF Int,W
ADDWF Diff,W
MOVWF CCPR1L ;MOVE TO CCPR1L TO MAKE IT HI TIME OF PWM
RETURN
END