FORUM TOPIC · READ ONLY

OC minimum to maximum range

OC minimum to maximum range

Forum : dsPIC Peripherals

2 message(s) · archive en lecture seule

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

Pièce jointe : Pushbutton_to_PWMv2.mdl

Pièce jointe : Push_to_PWM.jpg

LubinKerhuel

Re: OC minimum to maximum range

Citation : resodad
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