Hi,
So, let us suppose I have sampled two signals Vin and Vout using the ADC modules of my 16 bit dsPIC, and using the integer format (meaning sampled values range from 0 to 1023). I want to compute the duty cycle (which will update the duty cycle register of the PWM module) according to the equation:
duty = Vin/(Vin + Vout); //duty therefore has a value between 0 and 1.
According to the data sheet, the value to be fed to the duty cycle register must be calculated according to the equation:
duty_cycle_register_value = 7.48*duty*PWM_period/(7.37*1.04nanoseconds)
Where PWM_period is 6microseconds.
Given that all calculations must be done in fixed point, what is the best way(s) to go about it while minimizing instruction cycle usage?
Thanks for your help.
So, let us suppose I have sampled two signals Vin and Vout using the ADC modules of my 16 bit dsPIC, and using the integer format (meaning sampled values range from 0 to 1023). I want to compute the duty cycle (which will update the duty cycle register of the PWM module) according to the equation:
duty = Vin/(Vin + Vout); //duty therefore has a value between 0 and 1.
According to the data sheet, the value to be fed to the duty cycle register must be calculated according to the equation:
duty_cycle_register_value = 7.48*duty*PWM_period/(7.37*1.04nanoseconds)
Where PWM_period is 6microseconds.
Given that all calculations must be done in fixed point, what is the best way(s) to go about it while minimizing instruction cycle usage?
Thanks for your help.