PWM:
btfsc switch ; Check Inv. switch ON/OFF.
goto inv_off
bsf chanel1 ; Channel A set to high
call delay_fxd ; Fixed pulse width of 5 ms.
Call delay_var ; Variable delay.
movlw b'10011001' ; Take sample of load current
movwf ADCON0
call delay_3
bsf ADCON0,GO
btfsc ADCON0,GO
goto $-1
movlw d’35’ ; Check if AD value of load current is
subwf ADRES,W ; less than maximum i.e. d’35’.
btfsc STATUS,C
goto loop_1
clrf count1
movf ADRES,W
movwf count1 ; If it is less that 35, place it to count1.
goto loop_11
loop_1:
clrf count1
movlw d'35' ; If it is more that maximum, place the maximum
movwf count1 ; allowable count i.e. d’35’ to count1.
loop_11:
bcf chanel1 ; Channel A set to Low.
Call delay_TMR ; This is the TMR0 used as 5 ms interrupt.
btfsc switch ; Check Inv. switch ON/OFF.
goto inv_off
bsf chanel2 ; Channel B set to high
call delay_fxd ; Fixed pulse width of 5 ms.
Call delay_var ; Variable delay
movlw b'10011001' ; Take sample of load current
movwf ADCON0
call delay_3
bsf ADCON0,GO
btfsc ADCON0,GO
goto $-1
movlw d’35’ ; Check if AD value of load current is
subwf ADRES,W ; less than maximum i.e. d’35’.
btfsc STATUS,C
goto loop_2
clrf count1
movf ADRES,W
movwf count1 ; If it is less that 35, place it to count1.
goto loop_22
loop_2:
clrf count1
movlw d'35' ; If it is more that maximum, place the maximum
movwf count1 ; allowable count i.e. d’35’ to count1.
loop_22:
bcf chanel2 ; Channel B set to Low.
Call delay_TMR ; This is the TMR0 used as 5 ms interrupt.
goto PWM
delay_var:
movf count1,W
movwf count2
decfsz count2,1
goto $-1
return