Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Inverter battery charging problem

Status
Not open for further replies.

swapan

Full Member level 4
Joined
Feb 20, 2009
Messages
199
Helped
27
Reputation
54
Reaction score
24
Trophy points
1,298
Location
Kolkata
Activity points
2,806
Hi experts

I am new in the world of microcontroller. Recently I have developed a program to charge an inverter battery using TRIAC and controlling firing angle with MCU (16F72). The charger operates properly. but some times the TRIAC gets shorted. During operation of about 2 months, the TRIAC got shorted thrice. A sketch of the schematic as well as the code is given for your perusal and kind guidance thereon. I have not utilised TMR0/TMR1/Interrupt etc. I expect from experts some tip on using those for this purpose.


regards,

swapan

Code:
RESET_VECTOR      CODE    0x0000      ; processor reset vector
    goto    start                                        ; go to beginning of program

INT_VECTOR        CODE    0x0004               ; interrupt vector location




MAIN_PROG         CODE

start

clrf		PORTA
clrf		PORTB
clrf		PORTC
bsf		STATUS,RP0
movlw	b'00111111'
movwf	TRISA
movlw	b'10010001'
movwf	TRISB
movlw	b'11000000'
movwf	TRISC
movlw	b'00000000'
movwf	ADCON1
movlw	b'10000111'
movwf	OPTION_REG
bcf		STATUS,RP0
;;;;;;;;;;;

main_on:
clrf		PORTC
clrf		PORTB
bsf		PORTB,1		;  Mains LED ON
btfsc		PORTC,7		;  Main presence check
goto		inv
movlw	d'30'			;  Delay for charging start.
movwf	count18	
bcf		INTCON,2
btfsc		PORTC,7		;  Main presence check
goto		inv
btfss		INTCON,2	
goto		$-3
decfsz	count18,1
goto		$-6
movlw	d'240'			;  Initial firing angle near 180°/360°
movwf	count13
movlw	b'00001000'	
movwf	PORTC		;  Fan on. 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
first_step:
movlw	d'15'		         ;  For blinking Charging LED.
movwf	count17
bcf		INTCON,2
		
init_1:	

btfsc		PORTC,7	        ;  Main presence check
goto		inv
btfss		PORTB,0
goto		$-3
	
call		delay_4	        ;  Firing angle delay.
movlw	b'00001001'  	: Trigger Pulse ON
movwf	PORTC
call		dly_3		        ;  Required pulse width to latch TRIAC.
movlw	b'00001001' 	; Trigger Pulse OFF
movwf	PORTC

btfsc		PORTC,7	        ;  Main presence check
goto		inv

call		adc_5		;  Measure charging current
btfsc		PORTC,7	        ;  Main presence check
goto		inv

movlw	d'190'		       ;  Compare charging current.
subwf		adv_chg,0	       ;  If  it is low, decrease the  
btfsc		STATUS,C          ;  firing angle
goto		$+5		       ;  such that it does not
movf		count13,0	       ;  come below a certain (10)
xorlw		d'10'		       ; limit
btfss		STATUS,Z
decf		count13,1
movlw	d'200'		        ;  If charging current is high
subwf		adv_chg,0	        ;  increase the firing angle
btfss		STATUS,C    	;  such that it does not cross
goto		$+5		        ;  a certain limit (250)
movf		count13,0
xorlw		d'250'
btfss		STATUS,Z          ;  
incf		count13,1
btfsc		PORTC,7	        ;  Main presence check
goto		inv
movlw	d'255'    	        ;  Check if charging current         
subwf		adv_chg,0	        ;  is extremely high
btfsc		STATUS,C	        ;  then stop charging 
goto		error_chg	        ;  for some time and resume.
call		hi_lo_check	        ; Check mains level.
decfsz	count17,1	        ;  LED blinking rate.
goto		init_1
movlw	b'00001000'   	;  Toggle Charging LED.
xorwf		PORTB,1
call		adc_3		;  Check battery level
movlw	d'190'		        ;  If it is charged to a certain
subwf		adv_bat,0	        ;  level,
btfsc		STATUS,C	        ;  start charging at lower 
goto		second_step	;  rate.
goto		first_step
	


delay_3:

movlw	d'10'
movwf	count7
decfsz	count7,1
goto		$-1
return

delay_4:
        
movf		count13,0
movwf	count16
movlw	d'6'
movwf	count12
btfsc		PORTC,7	;  Main presence check
goto		inv
decfsz	count12,1
goto		$-3
decfsz	count16,1
goto		$-7
return


adc_3:

clrf		adv_bat
movlw	b'01100001'
movwf	ADCON0
call		delay_3
bsf		ADCON0,GO
btfsc		ADCON0,GO
goto		$-1
movf		ADRES,0
movwf	adv_bat
return	

adc_4:

clrf		adv_main
movlw	b'01000001'
movwf	ADCON0
call		delay_3
bsf		ADCON0,GO
btfsc		ADCON0,GO
goto		$-1
movf		ADRES,0
movwf	adv_main
return	

adc_5:

clrf		adv_chg
movlw	b'01011001'
movwf	ADCON0
call		delay_3
bsf		ADCON0,GO
btfsc		ADCON0,GO
goto		$-1
movf		ADRES,0
movwf	adv_chg
return

hi_lo_check:

call		adc_4
movlw	d'60'		; If the mains level is very low
subwf		adv_main,0	;  switch over to inverter
btfss		STATUS,C	;  stage.
goto		inv
movlw	d'100'		;  If mains level is very high
subwf		adv_main,0	;  switch over to inverter
btfsc		STATUS,C	;  stage.
goto		inv
return

error_chg:

clrf		PORTC

movlw	d'75'		;  Delay for resume charging.
movwf	count21	
bcf		INTCON,2
btfsc		PORTC,7	;  Main presence check
goto		inv
btfss		INTCON,2	
goto		$-3
decfsz	count21,1
goto		$-6
goto		main_on

END                           ; directive 'end of program'


 

There's something about switching current through a coil that seems to bring out glitchy behavior.

Did you examine operation under all conditions to see if voltage spikes occur?

At startup? With and without a battery connected?

In operation? When you connect and disconnect a battery?

Can a small spike on the low voltage side get multiplied backwards through the transformer and become a catastophic spike on the high voltage side?

Or perhaps you've eliminated serious spikes. However the triac might break down after a number of moderate spikes.

Etc.

Just speculating wildly here. You say your design works, so the cause of the breakdown must be in the realm where unpredictable gotchas occur.
 
The code seems that you are not utilizing the zero crossing interrupt, which is necessary to firing the triac at correct phase.
 

Code:
call		delay_4	        ;  Firing angle delay.
movlw	b'00001001'  	: Trigger Pulse ON
movwf	PORTC
call		dly_3		        ;  Required pulse width to latch TRIAC.
movlw	b'00001001' 	; Trigger Pulse OFF[COLOR="#FF0000"]  ? It is same as pulse ON[/COLOR]
 

Code:
call		delay_4	        ;  Firing angle delay.
movlw	b'00001001'  	: Trigger Pulse ON
movwf	PORTC
call		dly_3		        ;  Required pulse width to latch TRIAC.
movlw	b'00001001' 	; Trigger Pulse OFF  ? It is same as pulse ON
Code:
call		dly_3
During dly_3, = delay time RC0,RC3 bits are also low along with other bits.
 

Code:
delay_3:

movlw	d'10'
movwf	count7
decfsz	count7,1
goto		$-1
return
It is only a delay routine. It does not reset PortC 0 and 3 pins.

Code:
call		delay_4	        ;  Firing angle delay.
movlw	b'00001001'  	: Trigger Pulse ON
movwf	PORTC
call		dly_3		        ;  Required pulse width to latch TRIAC.
movlw	b'00001001' 	; Trigger Pulse OFF
movwf	PORTC
movlw b'00001001' ; Trigger Pulse OFF
Should be like this if pins 0 and 3 of PortC be low.
movlw b'00000000' ; Trigger Pulse OFF
 
  • Like
Reactions: pnjbtr

    pnjbtr

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top