praveen_palaparthi
Full Member level 1
- Joined
- Feb 15, 2008
- Messages
- 98
- Helped
- 3
- Reputation
- 6
- Reaction score
- 2
- Trophy points
- 1,288
- Activity points
- 2,214
How can we know without any information about your "logic" or hardware? It even can't be seen, if we have an oscillation of the output filter or the control loop. You have to provide basic information to get a meaningful answer.Suggest me if have to change my logic.
void interrupt ACDC(void)
{
if(T0IF)
{
T0IF = 0;
T0CS = 0; // set up timer0
TMR0=0x5B;
PSA=0;
PS2=0;
PS1=0;
PS0=1;
// Get reference voltage
ref_voltage = sine_table[sine_table_count];
// make reference negative on second half cycle
if (half_cycle_count) ref_voltage = -ref_voltage; // 16 bit signed
// Update counters
sine_table_count ++;
if (sine_table_count >= 0x24)
{
sine_table_count = 0;
if (half_cycle_count) half_cycle_count = 0;
else half_cycle_count = 1;
}
// Do PI calculation
x = ref_voltage - output_voltage; // 16 bit signed
integral += ki * x; // 32 bit signed
proportional = kp * x; // 32 bit signed
// Scale down from 32 bits. This reduces rounding error by doing this last
PI_output = (integral + proportional) >> (10 + 6); // 32 bit signed to 16 bit signed
// Check if positive or negative
if (PI_output >= 0)
{
// Positive values
duty_cycle = PI_output;
if (duty_cycle > 0x1F0) duty_cycle = 0x1F0
PR2 = 0x80;
T2CON = 0x04;
CCPR2L = Duty_cycle >> 2;
CCP2CON = ((Duty_cycle & 0x03) << 4) + 0x0C;
CCP1CON = 0x00;
}
else
{
// Negative values
duty_cycle = -PI_output;
if (duty_cycle > 0x1F0) duty_cycle = 0x1F0
PR2 = 0x80;
T2CON = 0x04;
CCPR1L = Duty_cycle>>2;
CCP1CON = ((Duty_cycle & 0x03) << 4) + 0x0C;
CCP2CON = 0x00;
}
}
}
if(duty_cycle>1023)
duty_cycle=1023;
if(duty_cycle>1023)
{
duty_cycle=1023;
DiagOutputHigh(); // Set you test output high
}
else
{
DiagOutputLow(); // Set your test output low
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?