Page 1 of 1

OC minimum to maximum range

Posted: Thu Jun 16, 2011 9:03 pm
by resodad
Hello Lubin and all,
I would like to produce a 1kHz PWM signal that varies in duty cycle from 0 to 100% in 10% steps.
Please see attached simulink file.
I control the duty cycle by counting presses of a button from 0 to 10.
OC produces the correct signal except at 100%.
At 100%, the wave form is high for 995 microseconds and the frequency drops to 380 Hz.
What's wrong?
Regards,
John

Re: OC minimum to maximum range

Posted: Fri Jun 17, 2011 7:39 am
by LubinKerhuel
resodad wrote:At 100%, the wave form is high for 995 microseconds and the frequency drops to 380 Hz.
OC block compute a signal using interrupt and change during the interrupt values for the next event to appears... Thus very fast event such as 1% or 99% might not work properly. (due to software handling)
Anyway, for 100% and 0% typical value, I thought added tricky code to make theses special value owrking. Perhaps that it does not work with PIC32. (mainly tested with 16 bits pic).

Anyway, could you give a try replacing the OC block with the OC_HW block ?

Thus, I'll try to have a closer look on your question, but it is difficult for me to do it before the end of next week. I apologize for the delay...
Lubin