I implemented dc motor speed control project but there is one problem which i am not able to figure out .The problem is that my pid output which is float when assigned to short data type gives unexpected answer.since PWM inbuilt function in mikroc allows only short type dutycycle there is a need of float to short conversion. please help i am using pic16F877A.
example float to short conversion: float pid_out; short duty=(short)pid_out; outputs: if my pid_out<=100 then duty=pid_out; and if my pid_out>100 duty=65535
for pid_out values less than or equal to hundred it gives same value for duty whereas for pid_out values greater than 100 it gives duty value in the range of 65500. please help unable to understand what is the mistake. For reading the values i used virtual terminal and uart.