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.

[SOLVED] Sine wave inverter with pic16f72 and if2110

Status
Not open for further replies.
Dear naseerak sir

Can you please help me to understand (LED)

1. the modified area of the code by you.
2. the timer and CCP / PWM register initialization description ...

- - - Updated - - -

I am try to understand PWM:
Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Copyright (c) 2013 Manolis Agkopian		    ;
	;See the file LICENCE for copying permission.	    ;
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	; THE FOLLOWING STEPS SHOULD BE TAKEN WHEN CONFIGURING THE CCP MODULE FOR PWM OPERATION: ;
	;                                                                                        ;
	; 1. SET THE PWM PERIOD BY WRITING TO THE PR2 REGISTER.                                  ;
	; 2. SET THE PWM DUTY CYCLE BY WRITING TO THE CCPR1L REGISTER AND CCP1CON<5:4> BITS.     ;
	; 3. MAKE THE CCP1 PIN AN OUTPUT BY CLEARING THE TRISC<2> BIT.                           ;
	; 4. SET THE TMR2 PRESCALE VALUE AND ENABLE TIMER2 BY WRITING TO T2CON.                  ;
	; 5. CONFIGURE THE CCP1 MODULE FOR PWM OPERATION.                                        ;
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;	PROCESSOR '16F876A'
	INCLUDE <P16F876A.INC>

	__CONFIG _XT_OSC & _WDT_OFF & _PWRTE_OFF & _CP_OFF & _LVP_OFF & _BODEN_OFF

	CBLOCK 0x20
	D1
	D2
	FADE_STATE ;IF = 0x00 INCREMENT CCPR1L ELSE DECREMENT CCPR1L
	ENDC
	
	ORG 0x0000
INIT:
	;PWM PERIOD = [(PR2)+1] * 4 * TOSC * (TMR2 PRESCALE VALUE) ;PR2 = TMR2 PERIOD REGISTER, TOSC = PIC CLOCK PERIOD (FOSC = 1 / TOSC)
	;PWM DUTY CYCLE = (CCPR1L:CCP1CON<5:4>) * TOSC * (TMR2 PRESCALE VALUE)
	
	;;;SET PWM FREQUENCY;;;
	BSF STATUS, RP0 ;SELECT BANK 01
	MOVLW D'128' ;SET PR2 TO 128 DECIMAL SO THE PWM PERIOD = 2064uS => PWM FREQUENCY = 484Hz
	MOVWF PR2
	BCF STATUS, RP0 ;SELECT BANK 00
	
	;;;SET PWM STARTING DUTY CYCLE;;;
	CLRF CCPR1L

	MOVLW B'00001100' ;SET PWM MODE, BITS 5 AND 4 ARE THE TWO LSBs OF THE 10BIT DUTY CYCLE REGISTER (CCPR1L:CCP1CON<5:4>)
	MOVWF CCP1CON
	
	;;;SET PWM PIN TO OUTPUT MODE;;;
	BSF STATUS, RP0 ;SELECT BANK 01
	BCF TRISC, 2 ;SET RC2 AS OUTPUT, TO USE FOR PWM
	BCF STATUS, RP0  ;SELECT BANK 00
	
	;;;SET TIMER 2 PRESCALE VALUE;;;
	;PRESCALE = 16 SO THE PWM PERIOD = 2064uS => PWM FREQUENCY = 484Hz
	MOVLW B'00000010'
	MOVWF T2CON
	
	;;;CLEAR TIMER 2 MODULE;;;
	CLRF TMR2
	
	;;;ENABLE TIMER 2 MODULE;;;
	BSF T2CON, TMR2ON
	
	CLRF FADE_STATE
	
MAIN:
	CALL DELAY
	MOVLW 0x00
	IORWF FADE_STATE, W
	
	BTFSS STATUS, Z ;IF FADE_STATE == 0 GOTO INC_CCPR1L
	GOTO DEC_CCPR1L ;ELSE GOTO DEC_CCPR1L
	
INC_CCPR1L:
	INCFSZ CCPR1L ;INCREMENT CCPR1L
	GOTO MAIN
	GOTO CHANGE_STATE_0 ;IF WE HAVE AN OVERFLOW GOTO CHANGE_STATE
	
DEC_CCPR1L:
	DECFSZ CCPR1L ;DECREMENT CCPR1L
	GOTO MAIN
	;IF WE HAVE AN OVERFLOW GOTO CHANGE_STATE
	
CHANGE_STATE:
	COMF FADE_STATE, F ;TOGLE FADE_STATE BITS
	INCFSZ CCPR1L
	GOTO MAIN
	
CHANGE_STATE_0:
	COMF FADE_STATE, F ;TOGLE FADE_STATE BITS
	DECFSZ CCPR1L
	GOTO MAIN
	

DELAY
	;9993 CYCLES
	MOVLW	0xCE
	MOVWF	D1
	MOVLW	0x08
	MOVWF	D2
DELAY_0
	DECFSZ	D1, F
	GOTO	$ + 2
	DECFSZ	D2, F
	GOTO	DELAY_0

	;3 CYCLES
	GOTO	$ + 1
	NOP

	;4 CYCLES (INCLUDING CALL)
	RETURN
	
	END
 
Last edited by a moderator:

hello

please can i use 20mhz instead off 16mhz

Yes you can use 20 mhz if you need output with 60 hz.
For 50 hz output with 20mhz crystal you also need to modify value in timer register.
 

Dear pnjbtr sir

Please help me to get idea about PWM sign part of the code...
 

Yes you can use 20 mhz if you need output with 60 hz.
For 50 hz output with 20mhz crystal you also need to modify value in timer register.


How can we modify the frequency to 20kHz on inverter mode?

- - - Updated - - -

How can we modify the frequency to 20kHz on inverter mode?

Which part of the code can we change So as the pwm will be 20kHz?
 

You will need to change the value of the period register (PR2). Use the formular above to calculate PR2.

Lookout for this App. MistrE PICMulticalc it will save you a lot of headache in punching calculations. plus you get other freebies from it like UART, PWM and timer calculation.

Hope it helps

Tunde.

- - - Updated - - -

How can we modify the frequency to 20kHz on inverter mode?

- - - Updated - - -



Which part of the code can we change So as the pwm will be 20kHz?

You will need to change the value of the period register (PR2). Use the formular above to calculate PR2.

Lookout for this App. MistrE PICMulticalc it will save you a lot of headache in punching calculations. plus you get other freebies from it like UART, PWM and timer calculation.

Hope it helps

Tunde.
 

sorry to say I am not conversant with ASM
 

You will need to change the value of the period register (PR2). Use the formular above to calculate PR2.

Lookout for this App. MistrE PICMulticalc it will save you a lot of headache in punching calculations. plus you get other freebies from it like UART, PWM and timer calculation.

Hope it helps

Tunde.

- - - Updated - - -



You will need to change the value of the period register (PR2). Use the formular above to calculate PR2.

Lookout for this App. MistrE PICMulticalc it will save you a lot of headache in punching calculations. plus you get other freebies from it like UART, PWM and timer calculation.

Hope it helps

Tunde.



Which part of the code needs to be altered So as the frequency of the pwm will increase to 20khz
 

please each time i try to verify the hex it says error please what can i do
 

@ naseerak,
I have done a practical simulation of the hex file you provided and its working well. Pls kindly provide me with LCD connection or circuit. I will appreciate if any member of this forum can assist in this regard.
 
@siktec kindly please give me the hexcode mine is not working
 

@tommy212,
use the hex code in thread #53.
 

@siktec i mean the hexcode for the pure sine wave inverter
 

please i tried all the hex code none his working please i need a good working hex code
 

something strange i notice in this schematic diagram the bootstrap capacitor used in this design was 220uf which i believe is too high and the bootstrap diode also instead of high freq diode to be used 1n4007 was used i am asking members here do you think this values were ok?
the bootstrap capacitor values in determine by the switching frequency according to the datasheets but with this inverter switching frequency the capacitor value shouldn't be high like this...
 

please can anyone give me a good asm file or good hex code for the inverter
 

something strange i notice in this schematic diagram the bootstrap capacitor used in this design was 220uf which i believe is too high and the bootstrap diode also instead of high freq diode to be used 1n4007 was used i am asking members here do you think this values were ok?
the bootstrap capacitor values in determine by the switching frequency according to the datasheets but with this inverter switching frequency the capacitor value shouldn't be high like this...



Use 22uf as the boostrap, 1n4007 is okay
 

@adamhenry please can u give me the hex code or the asm file thanks
 

I tried all the codes given in thread #53 and my inverter is not working,please I want to know if anyone here has built this inverter and get it working,which code do you use,and which modifications were made to get it working,please help,ready to give gives million thanks for that.
 

Hi everyone,
The code in thread #53 works well and perfect. I have implemented it and its okay. Ensure your feedback control voltage is less than 1.6v. My only problem is the connection of the LCD to the circuit. its not in the schematic provided. Can someone help me with that please.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top