implementeting PID in mikroC for pic

Status
Not open for further replies.

Vlad.

Full Member level 3
Joined
Jun 4, 2012
Messages
179
Helped
3
Reputation
6
Reaction score
4
Trophy points
1,298
Location
Bucharest/Romania
Activity points
2,568
Hey guys, i try to make a code in mikroC but i can make the PID controoler to work. ok here is the code to genetare pwm and control the duty cycle.
Code: Select all
unsigned short DutyCycle=0;
unsigned int adc_value;


void main() {


PWM1_Init(10000);
PWM1_Start();
PWM1_Set_Duty(DutyCycle);
do {
adc_value = ADC_Read(0);
DutyCycle = adc_value >> 2; // Convert 10-bit ADC value to 8-bit
PWM1_Set_Duty(DutyCycle);
} while(1);
}


I want to read a voltage from a curent sense rezistor series with the source of the mosfet.
Who can help me with a code? Thanks.
 

If you have a very low value resistor in line you can read the voltage across the resistor.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…