Hi. How can i add PI controller on this circuit? btw this circuit works on Proteus but doesn't work in real life i don't know why, could you help me please?
thank you.
Proteus https://imgur.com/n1MAmAf
[Mod edit: changed to CODE]
thank you.
Proteus https://imgur.com/n1MAmAf
[Mod edit: changed to CODE]
Code:
void main()
{
set_tris_a(0xFF);
set_tris_c(0x01);
setup_timer_2(T2_DIV_BY_1,255,1);
setup_CCP1(CCP_PWM);
int buton_1,buton_2,buton_3,buton_4;
int16 Duty=0;
float YuzdeDuty;
set_pwm1_duty(Duty);
while(TRUE)
{
buton_1=input(pin_A0);
buton_2=input(pin_A1);
buton_3=input(pin_A2);
buton_4=input(pin_A3);
if(buton_1 == 1 && buton_2 == 0 && buton_3 == 0 && buton_4 == 0)
{
delay_ms(20);
Duty=250;
// YuzdeDuty=25;
set_pwm1_duty(Duty);
// output_d(YuzdeDuty);
}
else if(buton_2 == 1 && buton_1 == 0 && buton_3 == 0 && buton_4 == 0)
{
delay_ms(20);
Duty=400;
// YuzdeDuty=50;
set_pwm1_duty(Duty);
//output_d(YuzdeDuty);
}
else if(buton_3 == 1 && buton_1 == 0 && buton_2 == 0 && buton_4 == 0)
{
delay_ms(20);
Duty=600;
//YuzdeDuty=75;
set_pwm1_duty(Duty);
//output_d(YuzdeDuty);
}
else if(buton_4 == 1 && buton_1 == 0 && buton_2 == 0 && buton_3 == 0)
{
delay_ms(20);
Duty=850;
//YuzdeDuty=100;
set_pwm1_duty(Duty);
//output_d(YuzdeDuty);
}
}
}
Last edited by a moderator: