Re: Trouble with control of PWM using PIC32 and Simulink
Try uploading model whenever possible.
To Scale the Output Compare ducy cycle, multiply the ADC output with a gain with the value: OC1max / 4096 (I suppose the ADC output is set for 12 bits) here.
If you have any doubts with fixed point, maybe convert your calculation to float first.
The block sampling time and Output Compare period is not linked.
If you use the PWM block instead of the Output Compare, and
If the ADC is triggered with the PWM signal, and
If the end of ADC conversion trig the main time step,
==> Then you have to insure that the Simulink model base time step period is equal to the PWM period otherwise your model run with a wrong time base.
This is one subtility. But provided you do not use the PWM block, you do not have to pay attention to this.