PDA

View Full Version : How to?????? >> square wave inverter. Feedback option needed



Antorbd04
- 1st April 2014, 17:24
Hi,
I design a Full bride Inverter. But I want to add feedback option to my project. I got 50Hz freq from my full bridge.
plz anyone help me!!!!!!!!!! How I add feedback to my project??????



DEFINE OSC 16
ON INTERRUPT GOTO UPDATE

DIR VAR BYTE
'************************* Assign some Interrupt associated aliases
T0IE VAR INTCON.5 ' TMR0 Overflow Interrupt Enable
T0IF VAR INTCON.2 ' TMR0 Overflow Interrupt Flag
GIE VAR INTCON.7 ' Global Interrupt Enable
PS0 VAR OPTION_REG.0 ' Prescaler ratio bit-0
PS1 VAR OPTION_REG.1 ' Prescaler ratio bit-1
PS2 VAR OPTION_REG.2 ' Prescaler ratio bit-2
PSA VAR OPTION_REG.3 ' Prescaler Assignment (1=assigned to WDT 0=assigned to oscillator)
T0CS VAR OPTION_REG.5 ' Timer0 Clock Source Select (0=Internal clock 1=External PORTA.4)

PWM1 VAR PORTC.5 ' Alias servo pin1
PWM2 VAR PORTC.6 ' Alias servo pin2
TRISC = 000000 ' Configure PORTC as outputs
PORTC = 0 ' Clear PORTB
'********************* Initiate the interrupt
GIE = 0 ' Turn off global interrupts
PSA = 0 ' Assign the prescaler to external oscillator
PS0 = 1 ' Set the prescaler
PS1 = 1 ' to increment TMR0
PS2 = 1 ' every 256th instruction cycle
T0CS = 0 ' Assign TMR0 clock to internal source
TMR0 = 0 ' Clear TMR0 initially
T0IE = 1 ' Enable TMR0 overflow interrupt
GIE = 1 ' Enable global interrupts

MAIN:

GOTO MAIN

DISABLE
UPDATE:
TMR0 = 100
IF DIR = 0 THEN
PWM1 = 1
PWM2 = 0
DIR = 1
ELSE
PWM2 = 1
PWM1 = 0
DIR = 0
ENDIF
T0IF = 0
RESUME
ENABLE

mpgmike
- 4th April 2014, 21:22
Just some observations first:
"PORTC = 0 ' Clear PORTB", your comment says Clear PORTB yet your code states PORTC = 0
"MAIN:

GOTO MAIN" Add a pause in there; "MAIN: : PAUSE 10 : GOTO MAIN"

With that out of the way, what do you wish to look at for feedback? If you have an analog voltage, you can use an ADCIN 0, FB command followed with:
IF FB > X then
take action
endif
IF FB < X then
no action
endif

Let's start there before I type 3 pages and still not answer your question.

Mike