What is an Inverter?
An inverter converts the DC voltage to an AC voltage. In most cases, the input DC voltage is usually lower while the output AC is equal to the grid supply voltage of either 120 volts, or 240 Volts depending on the country.
The inverter may be built as standalone equipment for applications such as solar power, or to work as a backup power supply from batteries which are charged separately.
The other configuration is when it is a part of a bigger circuit such as a power supply unit, or a UPS. In this case, the inverter input DC is from the rectified mains AC in the PSU, while from either the rectified AC in the in the UPS when there is power, and from the batteries whenever there is a power failure.
There are different types of inverters based on the shape of the switching waveform. These have varying circuit configurations, efficiencies, advantages and disadvantages
An inverter provides an ac voltage from dc power sources and is useful in powering electronics and electrical equipment rated at the ac mains voltage. In addition they are widely used in the switched mode power supplies inverting stages. The circuits are classified according the switching technology and switch type, the waveform, the frequency and output waveform.
Basic inverter operation
The basic circuits include an oscillator, control circuit, drive circuit for the power devices, switching devices, and a transformer.
The conversion of dc to alternating voltage is achieved by converting energy stored in the dc source such as the battery, or from a rectifier output, into an alternating voltage. This is done using switching devices which are continuously turned on and off, and then stepping up using the transformer. Although there are some configurations which do not use a transformer, these are not widely used.
The DC input voltage is switched on and off by the power devices such as MOSFETs or power transistors and the pulses fed to the primary side of the transformer. The varying voltage in the primary induces an alternating voltage at secondary winding. The transformer also works as an amplifier where it increases the output voltage at a ratio determined by the turn’s ratio. In most cases the output voltage is raised from the standard 12 volts supplied by the batteries to either 120 Volts or 240 volts AC.
The three commonly used Inverter output stages are, a push-pull with centre tap transformer, push-pull half-bridge, or push-pull full bridge. The push pull with centre tap is most popular due to its simplicity and, guaranteed results; however, it uses a heavier transformer and has a lower efficiency.
Modified sine wave inverter using pic microcontroller
Modified sine wave inverter is designed to using pic microcontroller and push pull topology. MOSFET used as a switches in Push pull operated through control circuit in such a way that iron core transformer produced step up battery voltage having modified sine wave form. PIC16F877A microcontroller is used to generated control signal to derive. Control circuit is also discussed at the end of this article. MOSFET driver tlp250 is used as a MOSFET driver to drive both low side mosfet. If you don’t have idea about MOSFET driver tlp250, I recommend you to go through following article to know how to use MOSFET driver tlp250 as a low /high side MOSFET driver.Control Circuit :
Control circuit is used to generate signals for MOSFET driver which turn on and turn off MOSFET of push pull high voltage transformer is such a way that Modified sine wave is produced at the output of high voltage step up transformer. PIC16F877A microcontroller is used to generate control signal.Push pull circuit and transformer selection:
Push pull topology and iron core transformer is used to in this project to generate modified sine wave. Circuit diagram of push pull transformer is shown below. MOSFET driver tlp250 is used for both high/low side MOSFET drivers. Because to operate MOSFETS fully we need to give gate signal of 10 volt and voltage level of control signals from control circuit is about 5 about which is not enough to drive MOSFETS fully. That’s why MOSFET driver is used to driver low side MOSFETS. Remember I have used only one MOSFET with legs of push pull transformer. You should connect MOSFETS in parallel according to power rating of your inverter and also use proper heat sinks for MOSFET.
NOTE: Use separate heat sinks for MOSFETS connect to upper and lower leg of push pull transformer.Otherwise drains of both sides will become short and short circuit will occur.
Output wave from of modified sine wave inverter :
CODING :
Code is written in Mplab and 16Mhz crystal is used. I have also explained the code with comments, but if you still have any issue, you can ask me by commenting on this post. Share this article with your friends.
LIST P=16F877a,
i
__FUSES _HS_OSC & _PWRTE_ON & _WDT_OFF & _CP_ALL
errorlevel -301,-302
; ***** Variables Definitions *****
selfcheck macro a, bxx
movlw bxx
xorwf a,0
btfsc status,z
endm
selfcheckR macro C,D
movf C,0
xorwf D,0
btfsc status,z
endm
;***** RAM Ddefination ********
PW EQU 0X20
CHG_I EQU 0X21
r_22 EQU 0X22
r_23 EQU 0X23
chg_on EQU 0X24
VOLT EQU 0X25
COUNT_1 EQU 0X26
COUNT_2 EQU 0X27
OL_TRIP EQU 0X28
R_29 EQU 0X29
CHG_DUTY EQU 0X2A
CHG EQU 0X2B
r_2C EQU 0X2C
; EQU 0X2D
; EQU 0X2E
r_2F EQU 0X2F
r_30 EQU 0X30
r_31 EQU 0X31
S_TEMP EQU 0X32
PC_TEMP EQU 0X33
TEMP EQU 0X34
r_35 EQU 0X35
r_36 EQU 0X36
R_37 EQU 0X37 ;FOR DELAY_1S COUNT
R_38 EQU 0X38 ;FOR DELAY_1S COUNT
r_39 EQU 0X39
r_3A EQU 0X3A
r_3B EQU 0X3B
r_3C EQU 0X3C
r_3D EQU 0X3D
r_3E EQU 0X3E
r_3F EQU 0X3F
r_40 EQU 0X40
r_41 EQU 0X41
r_42 EQU 0X42
r_43 EQU 0X43
; EQU 0X44
r_45 EQU 0X45
r_46 EQU 0X46
r_47 EQU 0X47
r_48 EQU 0X48
r_49 EQU 0X49
r_4A EQU 0X4A
r_4B EQU 0X4B
r_4C EQU 0X4C
r_4D EQU 0X4D
r_4F EQU 0X4F
r_50 EQU 0X50
r_51 EQU 0X51
r_53 EQU 0X53
r_54 EQU 0X54
r_56 EQU 0X56
r_58 EQU 0X58
r_59 EQU 0X59
r_70 EQU 0X70
r_71 EQU 0X71
r_72 EQU 0X72
r_73 EQU 0X73
r_74 EQU 0X74
r_75 EQU 0X75
DUTY EQU 0X76
BAT_VOLT EQU 0X77
OV_LOAD EQU 0X78
AC_MAIN EQU 0X79
CHG_STAGE EQU 0X7A
CHG_DELAY EQU 0X7B
r222 equ 0X5A
r333 EQU 0X5B
r444 EQU 0X5C
r555 EQU 0X5D
r666 EQU 0X5E
R777 EQU 0X5F
Rxxx EQU 0X60
PW_TIMER EQU 0X7C
PW_BIT EQU 0X7D
;*******DEFINATION*****************
#DEFINE INV_SW PORTB,1
#DEFINE trickle PORTB,2
#DEFINE MAIN_LED PORTB,3
#DEFINE INV_LED PORTB,4
#DEFINE LB_LED PORTB,5
#DEFINE OL_LED PORTB,6
#DEFINE CHG_LED PORTB,7
#DEFINE UPS PORTC,4
#DEFINE BUZZER PORTC,5
#DEFINE FAN PORTC,6
#DEFINE RELAY PORTC,7
;********************************
; 0.0196V=1 byte *
;********************************
ORG 0x0000
GOTO MAIN_START
ORG 0x0004
;BTFSC CHG,1
;GOTO LED_IND
MOVWF R_72
MOVF STATUS,W
MOVWF R_70 ;satus_temp
MOVF PCLATH,W ;pc_temp
MOVWF R_71
CLRF PCLATH
BTFSC STATUS,RP0
GOTO Label_0002
GOTO Label_0004
Label_0002 MOVF R_72,W
BCF STATUS,RP0
MOVWF R_72
BSF STATUS,RP0
MOVF R_70,W
BCF STATUS,RP0
MOVWF R_70
BSF STATUS,RP0
MOVF R_71,W
BCF STATUS,RP0
MOVWF R_71
Label_0004 BTFSC R_22,5
GOTO Label_000B
MOVLW 0x81
BSF STATUS,RP0
MOVWF T2CON
BCF STATUS,RP0
BCF R_22,6
CLRF R_48
GOTO Label_000C
Label_000B BCF STATUS,Z
movlw 0X0B ;added for table read
subwf duty,w
BTFSS STATUS,Z
GOTO Label_000C
BCF STATUS,Z
MOVF 0x48,W
BTFSC STATUS,Z
BCF R_22,6
BTFSC STATUS,Z
GOTO Label_000C
MOVWF R_41
BSF R_22,6
BSF STATUS,RP0
INCF T2CON,f
BCF STATUS,RP0
Label_000C BCF STATUS,Z
movlw 0X01
subwf duty,w ;added for table read
BTFSS STATUS,Z
GOTO Label_000D
BTFSS R_43,0
GOTO Label_000E
BCF PORTC,2 ;CCP1 out
CLRF CCP1CON
CLRF CCPR1L
CLRF CCPR1H
MOVLW 0x0C
MOVWF CCP1CON
BCF R_43,0
BCF PORTC,1
BSF PORTC,3
MOVF R_45,W
MOVWF R_46
BTFSC R_43,1
BSF R_43,2
BTFSS R_43,1
BCF R_43,2
BTFSC R_22,1
GOTO Label_000F
DECFSZ R_4A,f
BTFSS R_43,2
BSF R_22,1
BTFSS R_43,2
GOTO Label_000F
DECF R_51,f
;MOVLW 0x79
MOVLW 0x40 ;64.8% DUTY
SUBWF R_51,W
;MOVLW 0x79
MOVLW 0x40 ;64.8% DUTY
BTFSS STATUS,C
MOVWF R_51
GOTO Label_000D
Label_000E BCF PORTC,2
CLRF CCP1CON
CLRF CCPR1L
CLRF CCPR1H
MOVLW 0x0C
MOVWF CCP1CON
BSF PORTC,1
BCF PORTC,3
BSF R_43,0
MOVF 0x45,W
MOVWF R_46
BTFSC R_43,1
BSF R_43,2
BTFSS R_43,1
BCF R_43,2
BTFSS R_22,1
GOTO Label_000D
Label_000F BCF STATUS,C
RRF R_46,f
BCF STATUS,C
RRF R_46,f
BTFSS R_43,2
GOTO Label_0010
MOVF R_46,W
SUBWF R_51,f
;MOVLW 0x79
MOVLW 0x40 ;64.8% DUTY
BTFSS STATUS,C
MOVWF R_51
MOVF R_51,W
SUBLW 0x3F
;SUBLW 0x78
;MOVLW 0x79
MOVLW 0x40 ;64.8% DUTY ??????????
BTFSC STATUS,C
MOVWF 0x51
GOTO Label_000D
Label_0010 MOVF R_46,W
ADDWF R_51,f
BTFSC STATUS,C
GOTO Label_0011
MOVLW 0xFF
SUBWF R_51,W
BTFSS STATUS , C
GOTO Label_000D
MOVLW 0xFE
MOVWF R_51
Label_000D CLRF R_53
movlw 0X07
movwf pclath
call table1
MOVWF R_3A
BCF STATUS,C
RRF R_3A,f
BCF STATUS,C
RRF R_3A,W
MOVWF R_3B
BCF STATUS,C
RRF R_3B,W
MOVWF R_3C
BCF STATUS,C
RRF R_3C,W
MOVWF R_3D
BCF STATUS,C
RRF R_3D,W
MOVWF R_3E
BCF STATUS,C
RRF R_3E,W
MOVWF R_3F
BCF STATUS,C
RRF R_3F,W
MOVWF R_40
COMF R_51,W
MOVWF R_58
DECF R_58,f
;movlw 0X60 ;?????????????????
MOVLW 0x80
SUBWF R_58,W
BTFSC STATUS,C
GOTO Label_0012
Label_001A MOVLW 0x40
SUBWF R_58,W
BTFSC STATUS,C
GOTO Label_0013
Label_001B MOVLW 0x20
SUBWF R_58,W
BTFSC STATUS,C
GOTO Label_0014
Label_001C MOVLW 0x10
SUBWF R_58,W
BTFSC STATUS,C
GOTO Label_0015
Label_001D MOVLW 0x08
SUBWF R_58,W
BTFSC STATUS,C
GOTO Label_0016
Label_001E MOVLW 0x04
SUBWF R_58,W
BTFSC STATUS,C
GOTO Label_0017
Label_001F MOVLW 0x02
SUBWF R_58,W
BTFSC STATUS,C
GOTO Label_0018
GOTO Label_0019
Label_0012 MOVF R_3A,W
ADDWF R_53,f
BTFSC STATUS,C
GOTO Label_0011
MOVLW 0x80
SUBWF R_58 , f
GOTO Label_001A
Label_0013 MOVF R_3B,W
ADDWF R_53,f
BTFSC STATUS,C
GOTO Label_0011
MOVLW 0x40
SUBWF R_58,f
GOTO Label_001B
Label_0014 MOVF R_3C,W
ADDWF R_53,f
BTFSC STATUS , C
GOTO Label_0011
MOVLW 0x20
SUBWF R_58,f
GOTO Label_001C
Label_0015 MOVF R_3D,W
ADDWF R_53,f
BTFSC STATUS,C
GOTO Label_0011
MOVLW 0x10
SUBWF R_58,f
GOTO Label_001D
Label_0016 MOVF R_3E,W
ADDWF R_53,f
BTFSC STATUS,C
GOTO Label_0011
MOVLW 0x08
SUBWF R_58,f
GOTO Label_001E
Label_0017 MOVF R_3F,W
ADDWF R_53,f
BTFSC STATUS,C
GOTO Label_0011
MOVLW 0x04
SUBWF R_58,f
GOTO Label_001F
Label_0018 MOVF R_40,W
ADDWF R_53,f
BTFSC STATUS,C
GOTO Label_0011
Label_0019 BTFSC R_43,0
GOTO Label_0020
BCF PORTC,2 ;CCP1 out
CLRF CCPR1L
MOVF R_53,W
MOVWF CCPR1L
GOTO Label_0021
Label_0020 BCF PORTC,2
CLRF CCPR1L
MOVF R_53,W
MOVWF CCPR1L
Label_0021 movf duty,w
BCF STATUS,Z
sublw 0X4D
BTFSS STATUS,Z
GOTO Label_0022
movlw 0X00
movwf duty ;added for table read
Label_0022 incf duty,f ;added for table read
BCF STATUS,Z
movf duty,w
sublw 0X29
BTFSS STATUS,Z
GOTO Label_0023
BTFSS R_43,0
GOTO Label_0023
PWM_REG MOVLW b'10001001' ;RA1 for OUTPUT REGULATION
MOVWF ADCON0
MOVLW 0x1A
MOVWF R_42
LOOP_11 DECFSZ R_42,f
GOTO LOOP_11
BSF ADCON0,GO
Label_0025 BSF R_22,7
BTFSC ADCON0,GO
GOTO Label_0025
MOVF ADRES,W
SUBWF R_23,W
BTFSC STATUS,C
BSF R_43,01
BTFSS STATUS,C
BCF R_43,01
MOVWF R_45
BTFSS R_43,01
GOTO Label_0026
BTFSS R_22,01
GOTO Label_0027
SUBWF R_47,W
BTFSS STATUS,C
DECFSZ R_2F,f
GOTO Label_0027
;GOTO Label_0028 ;FOR SHT-CKT TRIP(close for no trip)
Label_0026 MOVLW 0x02
MOVWF R_2F
COMF R_45,f
INCF R_45,f
GOTO Label_0027 ;end_int_2
Label_0023 BCF PIR1,1 ;no TMR2 to PR2 match
BTFSS R_22,6
GOTO Label_0006
DECFSZ R_41,f
GOTO Label_0006
BSF STATUS,RP0 ;SELECT BANK1
DECF T2CON,f ; not known
BCF STATUS,RP0 ;SELECT BANK0
BCF R_22,6
Label_0027 BCF PIR1,1 ;;no TMR2 to PR2 match
Label_0006 BCF STATUS,RP0
BCF STATUS,RP1
MOVF R_70,W
MOVWF STATUS
MOVF R_71,W
MOVWF PCLATH
MOVF R_72,W
RETFIE
MAIN_START:
BSF STATUS,RP0 ;SELECT BANK1
MOVLW b'00000011' ;RB0/RB2:i/p, RB1/RB3 - RB7:o/p
MOVWF TRISB
MOVLW b'11111111' ;RA0 - RA5 are O/P
MOVWF TRISA
MOVLW b'00010000'
MOVWF TRISC ; all portc are output,RC4 IS I/P
MOVLW b'00000010'
MOVWF ADCON1
BCF STATUS ,RP0 ;select bank0
BCF BUZZER ;PORTC,5
BCF FAN ;PORTC,6
BCF RELAY ;PORTC,7
BCF MAIN_LED ;PORTB,3
BCF INV_LED ;PORTB,4
BCF LB_LED ;PORTB,5
BCF OL_LED ;PORTB,6
BCF CHG_LED ;PORTB,7
CLRF OL_TRIP
CLRF CHG_STAGE
;***WELCOME GOLI BUZZER **************
MOVLW 0XFF
MOVWF R444
G2_BUZZER:
MOVLW 0X05
MOVWF R333
P11: BSF BUZZER
MOVLW 0XFF
MOVWF R222
P22: DECFSZ R222,1
GOTO P22
BCF BUZZER
MOVLW 0XFF
MOVWF R222
P33: DECFSZ R222,1
GOTO P33
DECFSZ R333,1
GOTO P11
DECFSZ R444,1
GOTO G2_BUZZER
BCF BUZZER
GOTO MAIN_LOOP ;SKIP WELCOME B-20 BUZZER
w_buzzer: BSF BUZZER ;USING B-20 BUZZER
MOVLW 0X00
MOVWF R_74
MOVLW 0X3C
MOVWF R_75
LP_4 MOVLW 0X20
MOVWF R_73
LP_5 DECFSZ R_73,F
GOTO LP_5
DECFSZ R_74,F
GOTO LP_4
DECFSZ R_75,F
GOTO LP_4
BCF BUZZER ;PORTC,5
MAIN_LOOP CLRF R_42
CLRF PORTB
CLRF PORTA
CLRF R_70
CLRF R_72
CLRF R_3A
CLRF R_3B
CLRF R_3C
CLRF R_3D
CLRF R_3E
CLRF R_3F
CLRF R_40
MOVLW 0x81 ;d129'
MOVWF R_23
MOVLW 0x32
MOVWF R_47
BCF R_22,5
BCF R_22,1
BCF R_22,4
CLRF R_43
BCF STATUS, RP0 ;select bank0
CLRF CCPR1L
CLRF R_45
CLRF R_46
MOVLW 0xFF
MOVWF R_4A
MOVLW 0x02
MOVWF R_2F
BCF PORTC,0
BCF PORTC,1
BCF PORTC,2
BCF PORTC,3
BCF BUZZER ;PORTC,5
BCF FAN ;PORTC,6
BCF RELAY ;PORTC,7
BCF MAIN_LED ;PORTB,3
BCF INV_LED ;PORTB,4
BCF LB_LED ;PORTB,5
BCF OL_LED ;PORTB,6
BCF CHG_LED ;PORTB,7
bcf trickle
PORT_CHECK:
CALL DELAY5MSL
MAIN_CHECK_3:
CLRF R_42
MOVLW 0XFF ;SENSING BATT VOLT FOR L.B
MOVWF R_42
LP_53 DECFSZ R_42,1
GOTO LP_53
MOVLW b'10000001' ;SELECTED RA0,PIN2
MOVWF ADCON0
MOVLW 0X1A
MOVWF R_42
LP_54 DECFSZ R_42,1
GOTO LP_54
BSF ADCON0,GO
LP_55 BTFSC ADCON0,GO
GOTO LP_55
MOVF ADRES,W
CLRF AC_MAIN
MOVWF AC_MAIN
BTFSC UPS ;PORTC,4
GOTO H_UPS_RESTORE_3
GOTO UPS_RESTORE_3
UPS_RESTORE_3:
MOVF AC_MAIN,W
BCF STATUS,C
SUBLW d'62' ;190V
BTFSS STATUS,C
GOTO MAIN_ON ;>185V
GOTO LP_56 ;<185V
H_UPS_RESTORE_3:
MOVF AC_MAIN,W
BCF STATUS,C
SUBLW d'46' ;d'65' ;140V / 1.24V at pin2
BTFSS STATUS,C
GOTO MAIN_ON ;>140V
;GOTO LP_3 ;<140V
LP_56: BTFSS INV_SW ;PORTB,2
GOTO INVERTER_ON
GOTO PORT_CHECK
INVERTER_ON:
CLRF CHG_STAGE
BTFSC UPS ;PORTC,4
GOTO INSTANT_START
GOTO DELAY_START
INV_ON: movlw 0X02
movwf duty
bcf trickle
;BSF BUZZER ;PORTC,5 BUZZER ON
BSF INV_LED ;PORTB,4
BSF FAN ;PORTC,6 FAN ON
BSF RELAY ;PORTC,7 RELAY ON
BCF LB_LED ;PORTB,5
BCF OL_LED ;PORTB,6
BSF PORTC, 01 ;CH-1 ON
BCF PORTC, 02 ;PWM OFF
BSF R_43 , 00
BSF PORTC, 00 ;High/Lo LOGIC
BCF PORTC, 03 ;CH-2 OFF
BSF R_43 , 02
BSF STATUS,RP0 ;select bank1
BSF OPTION_REG, INTEDG ;interrupt on rising edge at RB0
MOVLW b'10000001' ;prescaler 4,TMR2 is off(bit-2)
MOVWF T2CON ;T2CON
BSF PIR1, 01 ;TMR2 to PR2 match occurred
BCF STATUS, RP0
BCF STATUS, RP1
MOVLW b'00001100'
MOVWF ccp1con ;pwm mode,
MOVLW b'00110001' ;enable TMR1,int-clk,sync ext clk i/p
MOVWF T1CON ;osc is shut,1:8 prescale
CLRF TMR2
BCF PIR1,1 ;TMR2 to PR2 match NOT occurred
BSF T2CON,0 ;prescaler 1:4
BSF T2CON,2 ;timer2 is ON
BSF INTCON,6 ;enable all unmasked peripheral INT
BCF INTCON,INTE ;disable RB0 INT
BSF INTCON,GIE ;enable all unmasked INT
LP_3 CALL DELAY5MSL
BTFSS INV_SW ;PORTB,2
goto delay_loop
GOTO INVERTER_OFF
delay_loop:
MOVLW 0X64
MOVWF R_74
MOVLW 0X64 ;0X3C/0X10
MOVWF R_75
LP_37 MOVLW 0X32 ;0X64
MOVWF R_73
LP_38 DECFSZ R_73,F
GOTO LP_38
BTFSC INV_SW ;PORTB,2
GOTO INVERTER_OFF
DECFSZ R_74,F
GOTO LP_37
DECFSZ R_75,F
GOTO LP_37
lo_batt_checK:
CLRF R_42
MOVLW 0XFF ;SENSING BATT VOLT FOR L.B
MOVWF R_42
LP_39 DECFSZ R_42,1
GOTO LP_39
MOVLW b'10010001' ;SELECTED RA2,PIN4
MOVWF ADCON0
MOVLW 0X1A
MOVWF R_42
LP_40 DECFSZ R_42,1
GOTO LP_40
BSF ADCON0,GO
LP_41 BTFSC ADCON0,GO
GOTO LP_41
MOVF ADRES,W
MOVWF BAT_VOLT
MOVF BAT_VOLT,W
BCF STATUS,C
SUBLW d'125' ;VOLT SELECTED 10.V(Tested 10.25V)
BTFSS STATUS,C
GOTO OVER_LOAD_CHECK ;>10.5V
goto lo_batt_trip ;volt<9.5 (Testd 9.6V)
OVER_LOAD_CHECK:
CLRF R_42
MOVLW 0X13 ;SENSING OVERLOAD
MOVWF R_42
LP_31 DECFSZ R_42,1
GOTO LP_31
MOVLW b'10100001' ;SELECTED RA5,PIN7
MOVWF ADCON0
MOVLW 0X1A
MOVWF R_42
LP_32 DECFSZ R_42,1
GOTO LP_32
BSF ADCON0,GO
LP_33 BTFSC ADCON0,GO
GOTO LP_33
MOVF ADRES,W
MOVWF OV_LOAD
MOVF OV_LOAD,W
BCF STATUS,C
SUBLW d'102' ;VOLT SELECTED 2V
BTFSS STATUS,C
GOTO OVER_LOAD_TRIP ;>2V
MAIN_CHECK_1:
CLRF R_42
MOVLW 0XFF ;SENSING BATT VOLT FOR L.B
MOVWF R_42
LP_42 DECFSZ R_42,1
GOTO LP_42
MOVLW b'10000001' ;SELECTED RA0,PIN2
MOVWF ADCON0
MOVLW 0X1A
MOVWF R_42
LP_43 DECFSZ R_42,1
GOTO LP_43
BSF ADCON0,GO
LP_44 BTFSC ADCON0,GO
GOTO LP_44
MOVF ADRES,W
CLRF AC_MAIN
MOVWF AC_MAIN
BTFSC UPS ;PORTC,4
GOTO H_UPS_RESTORE
GOTO UPS_RESTORE
UPS_RESTORE:
MOVF AC_MAIN,W
BCF STATUS,C
SUBLW d'62' ;190V / 1.66V at pin2
BTFSS STATUS,C
GOTO MAIN_ON ;>185V
GOTO LP_3 ;<185V
H_UPS_RESTORE:
MOVF AC_MAIN,W
BCF STATUS,C
SUBLW d'46' ;140V / 1.24V at pin2
BTFSS STATUS,C
GOTO MAIN_ON ;>140V
GOTO LP_3 ;<140V
lo_batt_trip:
bsf LB_LED ;portb,5
bcf FAN ;portc,6 fan off
BCF OL_TRIP,1
goto inv_trip
OVER_LOAD_TRIP:
BSF OL_LED ;PORTB,6
bcf FAN ;portc,6 fan off
;GOTO INV_TRIP
BTFSC OL_TRIP,1
GOTO OL_RESET
BSF OL_TRIP,1
MOVLW 0X05 ;NO OF OL AUTO RESET
MOVWF R_29
GOTO OL_RESET
OL_RESET:
DECFSZ R_29,1
GOTO INV_TRIP
CLRF OL_TRIP
CLRF R_29
BSF OL_LED ;PORTB,6
GOTO INV_TRIP
INVERTER_RESTORE: ;for over load restore
BCF INTCON,GIE
BCF STATUS,RP0
CLRF CCPR1L
CLRF CCP1CON
BCF INV_LED ;PORTB,4
BCF PORTC,0
BCF PORTC,1
BCF PORTC,2
BCF PORTC,3
CALL DELAY5MSL
CLRF R_42
CLRF PORTB
CLRF PORTA
CLRF R_70
CLRF R_72
CLRF R_3A
CLRF R_3B
CLRF R_3C
CLRF R_3D
CLRF R_3E
CLRF R_3F
CLRF R_40
MOVLW 0x81 ;d129'
MOVWF R_23
MOVLW 0x32
MOVWF R_47
BCF R_22,5
BCF R_22,1
BCF R_22,4
CLRF R_43
BCF STATUS, RP0 ;select bank0
CLRF CCPR1L
CLRF R_45
CLRF R_46
MOVLW 0xFF
MOVWF R_4A
MOVLW 0x02
MOVWF R_2F
BCF PORTC,0
BCF PORTC,1
BCF PORTC,2
BCF PORTC,3
BCF BUZZER ;PORTC,5
BCF FAN ;PORTC,6
BCF RELAY ;PORTC,7
BCF MAIN_LED ;PORTB,3
BCF INV_LED ;PORTB,4
BCF LB_LED ;PORTB,5
BCF OL_LED ;PORTB,6
BCF CHG_LED ;PORTB,7
bcf trickle
GOTO INVERTER_ON
BUZZER_BEEP_2:
BTFSC BUZZER ;PORTC,5
GOTO BUZ_OFF_2
BCF LB_LED ;PORTB,5
BSF BUZZER ;PORTC,5
MOVLW 0X64
MOVWF R_74
MOVLW 0X64 ;0X3C/0X10
MOVWF R_75
LP_27 MOVLW 0X19 ;0X64
MOVWF R_73
LP_28 DECFSZ R_73,F
GOTO LP_28
BTFSC INV_SW ;PORTB,2
GOTO INVERTER_OFF
DECFSZ R_74,F
GOTO LP_27
DECFSZ R_75,F
GOTO LP_27
;GOTO LP_RET
BUZ_OFF_2
BCF BUZZER ;PORTC,5
BSF LB_LED ;PORTB,5
MOVLW 0X00
MOVWF R_74
MOVLW 0X3C ;0X3C
MOVWF R_75
LP_29 MOVLW 0X64
MOVWF R_73
LP_30 DECFSZ R_73,F
GOTO LP_30
BTFSC INV_SW ;PORTB,2
GOTO INVERTER_OFF
DECFSZ R_74,F
GOTO LP_29
DECFSZ R_75,F
GOTO LP_29
BCF LB_LED ;PORTB,5
GOTO LP_3
INVERTER_OFF: ;IN BATTERY MODE ONLYthis is not shut_dn
BCF INTCON,GIE
BCF STATUS,RP0
CLRF CCPR1L
CLRF CCP1CON
BCF INV_LED ;PORTB,4
BCF FAN
BCF PORTC,0 ;H-L LOGIC LOWW
BCF PORTC,1 ;CH-1 LO
BCF PORTC,2 ;PWM LO
BCF PORTC,3 ;CH-2 LO
CLRF OL_TRIP
CALL DELAY5MSL
GOTO MAIN_LOOP
PORT_TEST:
CALL DELAY5MSL
BTFSS INV_SW ;PORTB,2
;GOTO LP_6
GOTO LP_3
GOTO INVERTER_OFF
DELAY_START:
MOVLW 0xFE ;0XFE for delay/0X79 for instant PWM
MOVWF R_51
GOTO INV_ON
INSTANT_START:
MOVLW 0x40
;MOVLW 0x79 ;0XFE for delay/0X79 for instant PWM
MOVWF R_51
GOTO INV_ON
;********INVERTER TRIP*********
INV_TRIP:
CLRF CCPR1L
CLRF CCP1CON
BCF PORTC,0 ;H/L LOGIC
BCF PORTC,1 ;CH-1
BCF PORTC,2 ;PWM
BCF PORTC,3 ;CH-2
BCF FAN
BCF INTCON,GIE
BCF STATUS,RP0
CALL DELAY5MSL
CLRF R_42
CLRF R_70
CLRF R_72
CLRF R_3A
CLRF R_3B
CLRF R_3C
CLRF R_3D
CLRF R_3E
CLRF R_3F
CLRF R_40
MOVLW 0x81 ;d129'
MOVWF R_23
MOVLW 0x32
MOVWF R_47
BCF R_22,5
BCF R_22,1
BCF R_22,4
CLRF R_43
BCF STATUS, RP0 ;select bank0
CLRF CCPR1L
CLRF R_45
CLRF R_46
MOVLW 0xFF
MOVWF R_4A
MOVLW 0x02
MOVWF R_2F
;movlw 0x06
;movwf R_42 ;no of trip buzzer
;goto trip_buzzer
movlw 0XFF
movwf r444
movlw 0X09 ;NO OF GOLI BUZZER BEEP
movwf r555
goto goli_buzzer
trip_buzzer:
BTFSC BUZZER ;PORTC,5
GOTO BUZ_OFF_1
BSF BUZZER ;PORTC,5
MOVLW 0X64
MOVWF R_74
MOVLW 0X64 ;0X3C/0X10
MOVWF R_75
LP_23 MOVLW 0X19 ;0X64
MOVWF R_73
LP_24 DECFSZ R_73,F
GOTO LP_24
BTFSC INV_SW ;PORTB,2
GOTO INVERTER_OFF
DECFSZ R_74,F
GOTO LP_23
DECFSZ R_75,F
GOTO LP_23
;GOTO LP_RET
BUZ_OFF_1
BCF BUZZER ;PORTC,5
MOVLW 0X00
MOVWF R_74
MOVLW 0X64 ;0X3C
MOVWF R_75
LP_25 MOVLW 0X64
MOVWF R_73
LP_26 DECFSZ R_73,F
GOTO LP_26
BTFSC INV_SW ;PORTB,2
GOTO INVERTER_OFF
DECFSZ R_74,F
GOTO LP_25
DECFSZ R_75,F
GOTO LP_25
DECFSZ R_42,1
GOTO trip_buzzer
LP_END CALL DELAY5MSL
MAIN_CHECK_2:
CLRF R_42
MOVLW 0XFF ;SENSING BATT VOLT FOR L.B
MOVWF R_42
LP_50 DECFSZ R_42,1
GOTO LP_50
MOVLW b'10000001' ;SELECTED RA0,PIN2
MOVWF ADCON0
MOVLW 0X1A
MOVWF R_42
LP_51 DECFSZ R_42,1
GOTO LP_51
BSF ADCON0,GO
LP_52 BTFSC ADCON0,GO
GOTO LP_52
MOVF ADRES,W
CLRF AC_MAIN
MOVWF AC_MAIN
BTFSC UPS ;PORTC,4
GOTO H_UPS_RESTORE_2
GOTO UPS_RESTORE_2
UPS_RESTORE_2:
MOVF AC_MAIN,W
BCF STATUS,C
SUBLW d'62' ;190V / 1.66V at pin2
BTFSS STATUS,C
GOTO MAIN_ON ;>185V
GOTO LP_49 ;<185V
H_UPS_RESTORE_2:
MOVF AC_MAIN,W
BCF STATUS,C
SUBLW d'46' ;140V / 1.24V at pin2
BTFSS STATUS,C
GOTO MAIN_ON ;>140V
;GOTO LP_3 ;<140V
LP_49 BTFSC INV_SW ;PORTB,2
GOTO INVERTER_OFF
BTFSC OL_TRIP,1
GOTO INVERTER_RESTORE
GOTO LP_END
;*********GOLI BUZZER ROUTINE**************
GOLI_BUZZER:
;BSF TRIP,1
movlw 0X03
MOVWF R333
lp_0 bsf BUZZER
movlw 0XFF
movwf r222
lp_110 decfsz r222,1
goto lp_110
bcf BUZZER
movlw 0XFF
movwf r222
lp_210 decfsz r222,1
goto lp_210
DECFSZ R333,F
GOTO LP_0
DECFSZ R444,1
GOTO GOLI_BUZZER
BCF BUZZER
MOVLW 0XFF
MOVWF R444
CALL DELAY_2S
btfsc INV_SW
goto INVERTER_OFF
CALL DELAY_2S
btfsc INV_SW
goto INVERTER_OFF
CALL DELAY_2S
btfsc INV_SW
goto INVERTER_OFF
CALL DELAY_2S
btfsc INV_SW
goto INVERTER_OFF
CALL DELAY_2S
btfsc INV_SW
goto INVERTER_OFF
CALL DELAY_2S
btfsc INV_SW
goto INVERTER_OFF
CALL DELAY_2S
btfsc INV_SW
goto INVERTER_OFF
CALL DELAY_2S
btfsc INV_SW
goto INVERTER_OFF
CALL DELAY_2S
btfsc INV_SW
goto INVERTER_OFF
CALL DELAY_2S
btfsc INV_SW
goto INVERTER_OFF
CALL DELAY_2S
btfsc INV_SW
goto INVERTER_OFF
CALL DELAY_2S
btfsc INV_SW
goto INVERTER_OFF
CALL DELAY_2S
btfsc INV_SW
goto INVERTER_OFF
CALL DELAY_2S
btfsc INV_SW
goto INVERTER_OFF
CALL DELAY_2S
btfsc INV_SW
goto INVERTER_OFF
CALL DELAY_2S
btfsc INV_SW
goto INVERTER_OFF
CALL DELAY_2S
btfsc INV_SW
goto INVERTER_OFF
CALL DELAY_2S
btfsc INV_SW
goto INVERTER_OFF
CALL DELAY_2S
btfsc INV_SW
goto INVERTER_OFF
CALL DELAY_2S
btfsc INV_SW
goto INVERTER_OFF
CALL DELAY_2S
btfsc INV_SW
goto INVERTER_OFF
CALL DELAY_2S
btfsc INV_SW
goto INVERTER_OFF
CALL DELAY_2S
btfsc INV_SW
goto INVERTER_OFF
CALL DELAY_2S
LP_311 btfsc INV_SW
goto INVERTER_OFF
DECFSZ R555,1
GOTO GOLI_BUZZER
BCF BUZZER
goto main_check_2
MAIN_ON:
bcf trickle
BCF INTCON,GIE
BCF STATUS,RP0
CLRF CCPR1L
CLRF CCP1CON
CALL DELAY5MSL
CLRF R_42
CLRF R_70
CLRF R_72
CLRF R_3A
CLRF R_3B
CLRF R_3C
CLRF R_3D
CLRF R_3E
CLRF R_3F
CLRF R_40
MOVLW 0x81 ;d129'
MOVWF R_23
MOVLW 0x32
MOVWF R_47
BCF R_22,5
BCF R_22,1
BCF R_22,4
CLRF R_43
;CLRF OL_TRIP
BCF STATUS, RP0 ;select bank0
CLRF CCPR1L
CLRF R_45
CLRF R_46
MOVLW 0xFF
MOVWF R_4A
MOVLW 0x02
MOVWF R_2F
BCF PORTC,0 ;H/L LOGIC
BCF PORTC,1 ;CH-1
BCF PORTC,2 ;PWM
BCF PORTC,3 ;CH-2
BCF FAN ;PORTC,6 FAN OFF
CLRF R_42
MOVLW 0XFF
MOVWF R_42
LP_45 DECFSZ R_42,1
GOTO LP_45
nop
BCF LB_LED ;PORTB,5
BCF OL_LED ;PORTB,6
BSF MAIN_LED ;PORTB,3 MAIN LED ON
BCF INV_LED ;PORTB,4
BCF RELAY ;PORTC,7 RELAY OFF
CALL DELAY_1S
CHARGING:
BSF FAN ;PORTC,6 FAN ON
BSF CHG,1 ;set chg bit to ensure charging is ON
BSF CHG_ON,1 ;make chg.on bit high
BSF CHG_LED ;PORTB,7 chg-led on
MOVLW d'01'
MOVWF PW
BCF VOLT,1
BSF STATUS,RP0
MOVLW d'166' ;6kHz CHARGING PWM
MOVWF PR2
BCF STATUS,RP0
;MOVLW d'40' ;d'85' 50% DUTY/d'40' 24% DUTY
MOVF PW,W
MOVWF CCPR1L
BCF CCP1CON,4
BCF CCP1CON,5
BCF CCP1CON,0
BCF CCP1CON,1
BSF CCP1CON,2
BSF CCP1CON,3
MOVLW b'00000101'
MOVWF T2CON
BSF PORTC,1 ;CH-1
BSF PORTC,3 ;CH-2
MOVLW d'255'
MOVWF COUNT_1
MOVLW d'03'
MOVWF COUNT_2
BSF CHG_STAGE,1
MOVLW 0XFF ;0X64 FOR DELAY CHARGING
MOVWF CHG_DELAY
movlw 0X80 ;Rxx PW DELAY VALUE
movwf Rxxx
CHARGING_SET:
BTFSS CHG,1
;goto trickle_chg ;??????? trickle
GOTO CHG_RESTORE
BTFSS CHG_LED ;PORTB,7
GOTO LED_OFF
LP_1F DECFSZ COUNT_1,1
GOTO PUTU ;GOTO LP_1F
MOVLW d'255'
MOVWF COUNT_1
DECFSZ COUNT_2,1
GOTO PUTU
BCF CHG_LED ;PORTB,7
MOVLW d'255'
MOVWF COUNT_1
MOVLW d'03'
MOVWF COUNT_2
GOTO PUTU
LED_OFF:
DECFSZ COUNT_1,1
GOTO PUTU ;GOTO LED_OFF
MOVLW d'255'
MOVWF COUNT_1
DECFSZ COUNT_2,1
GOTO PUTU
BSF CHG_LED ;PORTB,7
MOVLW d'255'
MOVWF COUNT_1
MOVLW d'03'
MOVWF COUNT_2
GOTO PUTU ;CHECK THE CHG STAGE
CHARGING_SET_3: ;1st - STEP / DELAY START
MOVLW b'10011001'
MOVWF ADCON0 ;FOSC/8,A-D is ON,RA-3,Channel-3 selected
CLRF ADRES
MOVLW 0X1A
MOVWF R_42
LP_1DA DECFSZ R_42,1
GOTO LP_1DA
BSF ADCON0,GO
LP_1EA BTFSC ADCON0,GO
GOTO LP_1EA
MOVF ADRES,W
MOVWF CHG_I
BCF STATUS,C
BCF STATUS,Z
BCF STATUS,DC
MOVF CHG_I,W
SUBLW d'51' ;d'102' ;MAX CHARGING VALUE
BTFSC STATUS,C
GOTO INC_PW_1
BCF CHG_STAGE,1
GOTO CHARGING_SET_2
PUTU: BTFSC CHG_STAGE,1 ;BIT SET WHEN DELAY CHG
GOTO CHARGING_SET_3
GOTO CHARGING_SET_2
INC_PW_1:
DECFSZ CHG_DELAY,1
GOTO MAIN_FAILURE_CHECK
MOVLW 0XFF ;0X64 DELAY CHG TIME
MOVWF CHG_DELAY
SELFCHECK PW,d'100' ;MAX ALLOWABLE PW 95% d'140'
GOTO CHARGING_SET_2
INCF PW,1
MOVF PW,W
MOVWF CCPR1L
GOTO MAIN_FAILURE_CHECK
CHARGING_SET_2:
BTFSC PW_BIT,1
GOTO GULTI
BSF PW_BIT,1
MOVLW 0X80
MOVWF PW_TIMER
GULTI DECFSZ PW_TIMER,1
GOTO BATT_CHG_STATUS
BCF PW_BIT,1
MOVLW b'10011001'
MOVWF ADCON0 ;FOSC/8,A-D is ON,RA-3,Channel-3 selected
CLRF ADRES
MOVLW 0X1A
MOVWF R_42
LP_1D DECFSZ R_42,1
GOTO LP_1D
BSF ADCON0,GO
LP_1E BTFSC ADCON0,GO
GOTO LP_1E
MOVF ADRES,W
MOVWF CHG_I
BCF STATUS,C
BCF STATUS,Z
BCF STATUS,DC
MOVF CHG_I,W
SUBLW d'51' ;d'102' ;MAX CHARGING CURRENT VALUE
BTFSC STATUS,C
GOTO INC_PW
GOTO DEC_PW
INC_PW:
SELFCHECK pw,d'100' ;original PW,d'110' ;MAX ALLOWABLE PW 95% d'140'
GOTO BATT_CHG_STATUS
;call delay1u6
INCF PW,1
MOVF PW,W
MOVWF CCPR1L
;CALL DELAY40
GOTO BATT_CHG_STATUS
DEC_PW:
SELFCHECK pw,d'40' ;original value PW,d'80'
GOTO BATT_CHG_STATUS
;call delay1u6
DECF PW,1
MOVF PW,W
MOVWF CCPR1L
;CALL DELAY40
GOTO BATT_CHG_STATUS
BATT_CHG_STATUS:
CLRF R_42
MOVLW 0XFF ;SENSING BATT VOLT FOR CHG_CUT
MOVWF R_42
LP_1H DECFSZ R_42,1
GOTO LP_1H
MOVLW b'10010001' ;SELECTED RA2,PIN4
MOVWF ADCON0
MOVLW 0X1A
MOVWF R_42
LP_1I DECFSZ R_42,1
GOTO LP_1I
BSF ADCON0,GO
LP_1J BTFSC ADCON0,GO
GOTO LP_1J
MOVF ADRES,W
MOVWF BAT_VOLT
MOVF BAT_VOLT,W
BCF STATUS,C
;SUBLW d'187' ;VOLT SELECTED 14.2V
SUBLW d'178' ;VOLT SELECTED 13.5V
BTFSS STATUS,C
GOTO CHG_OFF ;>13.5V / 14V
;goto trickle_chg ;????? trickle
MAIN_FAILURE_CHECK: ;<13.5V
CLRF R_42
MOVLW 0XFF ;SENSING MAIN_VOLT
MOVWF R_42
LP_46 DECFSZ R_42,1
GOTO LP_46
MOVLW b'10000001' ;SELECTED RA0,PIN2
MOVWF ADCON0
MOVLW 0X1A
MOVWF R_42
LP_47 DECFSZ R_42,1
GOTO LP_47
BSF ADCON0,GO
LP_48 BTFSC ADCON0,GO
GOTO LP_48
MOVF ADRES,W
CLRF AC_MAIN
MOVWF AC_MAIN
BTFSC UPS ;PORTC,4
GOTO H_UPS_MODE
GOTO UPS_MODE
UPS_MODE:
MOVF AC_MAIN,W
BCF STATUS,C
SUBLW d'53' ;d'76' ;175V / 1.5V at pin2
BTFSS STATUS,C
GOTO CHARGING_SET
GOTO INV_START ;<175V
H_UPS_MODE: ;INVERTER MODE
MOVF AC_MAIN,W
BCF STATUS,C
SUBLW d'27' ;d'49' ;120V / 1.24V at pin2
BTFSS STATUS,C
GOTO CHARGING_SET ;>120V
GOTO INV_START ;<120V
CHG_OFF:
bsf trickle
BCF CHG,1
BSF CHG_LED ;PORTB,7 CHG LED ON
BCF FAN ;PORTC,6 FAN OFF
CLRF CCPR1L
CLRF CCP1CON
CLRF T2CON
BCF PORTC,1
BCF PORTC,2
BCF PORTC,3
GOTO MAIN_FAILURE_CHECK
TRICKLE_CHG:
BCF CHG,1
BSF CHG_LED ;PORTB,7 CHG LED ON
BCF FAN ;PORTC,6 FAN OFF
movlw 0X80
movwf Rxxx
read_amp:
CLRF R_42
MOVLW 0XFF ;SENSING CHG CURRENT
MOVWF R_42
LP_1C2 DECFSZ R_42,1
GOTO LP_1C2
MOVLW b'10011001'
MOVWF ADCON0 ;FOSC/8,A-D is ON,RA-3,Channel-3 selected
CLRF ADRES
MOVLW 0X1A
MOVWF R_42
LP_1D2 DECFSZ R_42,1
GOTO LP_1D2
BSF ADCON0,GO
LP_1E2 BTFSC ADCON0,GO
GOTO LP_1E2
MOVF ADRES,W
MOVWF CHG_I
BCF STATUS,C
MOVF CHG_I,W
SUBLW d'127' ;MAX CHARGING VALUE
BTFSC STATUS,C
GOTO DEC_PW_2
read_volt:
CLRF R_42
MOVLW 0XFF ;SENSING BATT VOLT FOR CHG_CUT
MOVWF R_42
LP_1H2 DECFSZ R_42,1
GOTO LP_1H2
MOVLW b'10010001' ;SELECTED RA2,PIN4
MOVWF ADCON0
MOVLW 0X1A
MOVWF R_42
LP_1I2 DECFSZ R_42,1
GOTO LP_1I2
BSF ADCON0,GO
LP_1J2 BTFSC ADCON0,GO
GOTO LP_1J2
MOVF ADRES,W
MOVWF BAT_VOLT
MOVF BAT_VOLT,W
BCF STATUS,C
SUBLW d'175' ;VOLT SELECTED 14V
;SUBLW d'168' ;d'163' ;VOLT SELECTED 13.5V
BTFSS STATUS,C
GOTO DEC_TRICKLE_DUTY ;>13.5V / 14V
GOTO INC_TRICKLE_DUTY
GOTO MAIN_FAILURE_CHECK
DEC_PW_2:
;SELFCHECK PW,d'01'
;GOTO READ_VOLT
DECF PW,1
MOVF PW,W
MOVWF CCPR1L
CALL DELAY40
GOTO READ_VOLT
INC_TRICKLE_DUTY:
SELFCHECK PW,d'110'
GOTO MAIN_FAILURE_CHECK
call delay1u6
decfsz Rxxx,1
incf pw,1
movf pw,w
movwf ccpr1l
call delay40
goto main_failure_check
DEC_TRICKLE_DUTY:
SELFCHECK PW,d'01'
GOTO MAIN_FAILURE_CHECK
call delay1u6
decfsz Rxxx,1
decf pw,1
movf pw,w
movwf ccpr1l
call delay40
goto main_failure_check
CHG_RESTORE:
;CLRF R_42
;MOVLW 0XFF ;SENSING BATT VOLT FOR CHG RESTORE
;MOVWF R_42
LP_1K ;DECFSZ R_42,1
;GOTO LP_1K
MOVLW b'10010001' ;SELECTED RA2,PIN4
MOVWF ADCON0
MOVLW 0X1A
MOVWF R_42
LP_1L DECFSZ R_42,1
GOTO LP_1L
BSF ADCON0,GO
LP_1M BTFSC ADCON0,GO
GOTO LP_1M
MOVF ADRES,W
MOVWF BAT_VOLT
MOVF BAT_VOLT,W
BCF STATUS,C
SUBLW d'146' ;VOLT SELECTED 12V
BTFSS STATUS,C
GOTO MAIN_FAILURE_CHECK ;>12V CLOSED FOR TRICKLE
;GOTO TRICKLE_CHG
;BCF TRICKLE
GOTO CHARGING ;CLOSED WHEN CHG-OFF
INV_START:
CLRF R_42
;CLRF PORTB
;CLRF PORTA
CLRF R_70
CLRF R_72
CLRF R_3A
CLRF R_3B
CLRF R_3C
CLRF R_3D
CLRF R_3E
CLRF R_3F
CLRF R_40
MOVLW 0x81 ;d129'
MOVWF R_23
MOVLW 0x32
MOVWF R_47
BCF R_22,5
BCF R_22,1
BCF R_22,4
CLRF R_43
BCF STATUS, RP0 ;select bank0
CLRF CCPR1L
CLRF R_45
CLRF R_46
MOVLW 0xFF
MOVWF R_4A
MOVLW 0x02
MOVWF R_2F
BCF PORTC,0
BCF PORTC,1
BCF PORTC,2
BCF PORTC,3
BCF BUZZER ;PORTC,5
BCF FAN ;PORTC,6
BCF RELAY ;PORTC,7
BCF MAIN_LED ;PORTB,3
BCF INV_LED ;PORTB,4
BCF LB_LED ;PORTB,5
BCF OL_LED ;PORTB,6
BCF CHG_LED ;PORTB,7
;GOTO INSTANT_START
BTFSS INV_SW ;PORTB,2
GOTO INSTANT_START
GOTO INVERTER_OFF
LABEL_0028:
CALL LABEL_0052
;BSF PORTC
GOTO LABEL_0053
LABEL_0011:
CALL LABEL_0052
GOTO LABEL_0053
Label_0053 BTFSC BUZZER ;portC,5 buzzer out
GOTO Label_0054
BSF BUZZER ;portC,5 buzzer ON
GOTO Label_0055
Label_0054 BCF BUZZER ;portC,5
Label_0055 DECFSZ 0x4E ,f
GOTO Label_0056
BCF BUZZER ;portC,5
Label_0057 GOTO Label_0057
Label_0056 MOVLW 0xFA
MOVWF r_4B
MOVLW 0xFA
MOVWF r_4C
MOVLW 0x40
BTFSC r_22 ,3
MOVLW 0x05
MOVWF r_4D
loop10 DECFSZ r_4B ,f
GOTO loop10
GOTO Label_0053
Label_0052 BCF INTCON ,GIE
BCF STATUS ,RP0
CLRF ccpr1l
CLRF CCP1CON
CLRF portC
CLRF PORTB
CLRF r_22
RETURN
;*********************
;delay routines here *
;*********************
DELAY40
MOVLW 0XFF
MOVWF R_31
DLOOP1:
DECFSZ R_31,1
GOTO DLOOP1
RETURN
;*********************
DELAY5MSL
MOVLW 0X7D
MOVWF R_56
DLOOP2:
CALL DELAY40
DECFSZ R_56,1
GOTO DLOOP2
RETURN
DELAY_1S:
MOVLW 0X1E
MOVWF R_38
LP_1B MOVLW 0XFF
MOVWF R_37
LP_1A CALL DELAY40
DECFSZ R_37,1
GOTO LP_1A
DECFSZ R_38,1
GOTO LP_1B
RETURN
DELAY_1A
MOVLW 0XFF
MOVWF R666
KALU: CALL DELAY1U6
DECFSZ R666,1
GOTO KALU
RETURN
DELAY_2S:
CALL DELAY_1A
;CALL DELAY_1A
;CALL DELAY_1A
;CALL DELAY_1A
RETURN
DELAY1U6
MOVLW 0X80 ;0XFF
MOVWF R777
HODU: DECFSZ R777,1
GOTO HODU
RETURN
;*************************************************************************
ORG 0X700
TABLE1 ;SINEWAVE VALUE_1/2 CYCLE(77-STEPS)
MOVF DUTY,W
ADDWF PCL,1
RETLW 0X00 ;d'00'
RETLW 0X0A ;d'10'
RETLW 0X15 ;d'21'
RETLW 0X1F ;d'31'
RETLW 0X29 ;d'41'
RETLW 0X34 ;d'52'
RETLW 0X3E ;d'62'
RETLW 0X48 ;d'72'
RETLW 0X52 ;d'82'
RETLW 0X5C ;d'92'
RETLW 0X65 ;d'101'
RETLW 0X6F ;d'111'
RETLW 0X78 ;d'120'
RETLW 0X81 ;d'129'
RETLW 0X8A ;d'138'
RETLW 0X92 ;d'146'
RETLW 0X9B ;d'155'
RETLW 0XA3 ;d'163'
RETLW 0XAB ;d'171'
RETLW 0XB2 ;d'178'
RETLW 0XBA ;d'186'
RETLW 0XC1 ;d'193'
RETLW 0XC7 ;d'199'
RETLW 0XCE ;d'206'
RETLW 0XD4 ;d'212'
RETLW 0XD9 ;d'217'
RETLW 0XDF ;d'223'
RETLW 0XE3 ;d'227'
RETLW 0XE8 ;d'232'
RETLW 0XEC ;d'236'
RETLW 0XF0 ;d'240'
RETLW 0XF3 ;d'243'
RETLW 0XF6 ;d'246'
RETLW 0XF9 ;d'249'
RETLW 0XFB ;d'251'
RETLW 0XFC ;d'252'
RETLW 0XFE ;d'254'
RETLW 0XFF ;d'255'
RETLW 0XFF ;d'255'
RETLW 0XFF ;d'255'
RETLW 0XFF ;d'255'
RETLW 0XFE ;d'254'
RETLW 0XFC ;d'252'
RETLW 0XFB ;d'251'
RETLW 0XF9 ;d'249'
RETLW 0XF6 ;d'246'
RETLW 0XF3 ;d'243'
RETLW 0XF0 ;d'240'
RETLW 0XEC ;d'236'
RETLW 0XE8 ;d'232'
RETLW 0XE3 ;d'227'
RETLW 0XDF ;d'223'
RETLW 0XD9 ;d'217'
RETLW 0XD4 ;d'212'
RETLW 0XCE ;d'206'
RETLW 0XC7 ;d'199'
RETLW 0XC1 ;d'193'
RETLW 0XBA ;d'186'
RETLW 0XB2 ;d'178'
RETLW 0XAB ;d'171'
RETLW 0XA3 ;d'163'
RETLW 0X9B ;d'155'
RETLW 0X92 ;d'146'
RETLW 0X8A ;d'138'
RETLW 0X81 ;d'129'
RETLW 0X78 ;d'120'
RETLW 0X6F ;d'110'
RETLW 0X65 ;d'101'
RETLW 0X5C ;d'92'
RETLW 0X52 ;d'82'
RETLW 0X48 ;d'72'
RETLW 0X3E ;d'62'
RETLW 0X34 ;d'52'
RETLW 0X29 ;d'41'
RETLW 0X1F ;d'31'
RETLW 0X15 ;d'21'
RETLW 0X0A ;d'10'
RETLW 0X00 ;d'00'
END
///////////////////////////////////////////////////////////////////////////////
No comments:
Post a Comment