Output Compare block

deepak223
Posts: 1
Joined: Sun Nov 11, 2007 10:08 pm

Output Compare block

Postby deepak223 » Sun Nov 18, 2007 3:01 am

Lubin, I want to generate a PWM signal using the output compare block. I looked at the examples provided in the toolbox (Servo_ADC.mdl,Servo_sinus.mdl) but it is entirely clear to me how to set OCxR and PRy registers in dsPIC33f.
How to define the PWM period and duty cycle in the block.

thanks
Deepak

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Marseille - France
Contact:

Postby LubinKerhuel » Tue Nov 20, 2007 12:26 am

Configure the channel to 'Up - Period' (5)
The Up input (uint 16) of the block set the Duty Cycle, and the Period input (uint 16) of the block set the period.

You must define the max period you will use in 'Max / Channel'.

One uint 16 variable is automaticaly defined in the matlab workspace : OC?max (where ? is the channel number).
This variable corresponds to the time of the max period defined for that channel. This value must be used to scale the Duty cycle and the Period.

for example, if you define 'Max / Channel' = 10e-3 (for 10ms)
Then if you define the Period Input as OC1max, this will produce a period of 10e-3.
if you define the Period Input as round(OC1max/2), this will produce a period of 5e-3.

The Duty Cycle time is defines in the same way...

Help is available on the web page : http://www.kerhuel.eu/RTWdsPIC/Blocks/OutputCompare.html


Return to “dsPIC Peripherals”

Who is online

Users browsing this forum: No registered users and 2 guests