pwm 2+2

Bobes
Posts: 36
Joined: Wed Nov 25, 2009 11:27 am
Location: Brno, CZE
Contact:

pwm 2+2

Postby Bobes » Mon Dec 28, 2009 10:36 pm

Hello,
this is more of a PIC specialist question:
I am using dsPIC33fj128mc802, and I need to generate 4 PWM signals:
to drive 2 DC brushed motors (same frequency around 10 kHz but independent duty cycle)
and 2 "modeller" servos (same frequency 50Hz but independent duty cycle)

my question is: is it possible to generate 2 PWM on one PWM module each with different frequency?
I have tried it out, but I have got error from the compiler (I do not have my DevKit with me right now, so HW testing is not possible at the moment).

Please excuse me, I am quite a beginner...
I will appreciate any help and/or advices
Thanks
Kind regards
Josef

UPDATE: I have tried removing second servo PWM (removed PWM2_motor block) and it was compiled without an error (having on PWM1_motor block 3 channels with 2 different frequencies) On one hand this may mean that it can be done, but on the other: I am more confused: why it does not work?
Attachments
Vejlupek_CAR4_dsPIC33_AxleControl_bckup_R091228_R02.mdl
this one returns an error: "gmake:.... Error 255"
when I remove second PWM module, which I would like to use to drive second servo, compiler will finish
(47.12 KiB) Downloaded 165 times
Vejlupek_CAR4_dsPIC33_AxleControl.mdl
this one I am able to compile
(38.81 KiB) Downloaded 128 times

Bobes
Posts: 36
Joined: Wed Nov 25, 2009 11:27 am
Location: Brno, CZE
Contact:

Re: pwm 2+2

Postby Bobes » Tue Jan 19, 2010 12:37 pm

update: it is not possible to run one PWM module with two different frequencies. :(

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

Re: pwm 2+2

Postby LubinKerhuel » Tue Jan 19, 2010 1:12 pm

Hi Josef,

It may not be possible to get two different PWM period from one "PWM motor" peripheral. However, you may use an Output Compare block that is capable to generate PWM signals with different periods.

I just updated the PWM help page http://www.kerhuel.eu/wiki/Block/PWM_Mo ... ut#Periode
Please feel free to complete wiki help page for others usefull informations.

Lubin

Bobes
Posts: 36
Joined: Wed Nov 25, 2009 11:27 am
Location: Brno, CZE
Contact:

Re: pwm 2+2

Postby Bobes » Tue Jan 19, 2010 1:31 pm

Hello Lubin,
yes... I have reached this conclusion as well.

However I have now something else: I was trying to set the period externally, but I was asked for uint16. Is this correct?
Thanks

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

Re: pwm 2+2

Postby LubinKerhuel » Tue Jan 19, 2010 1:59 pm

Bobes wrote:However I have now something else: I was trying to set the period externally, but I was asked for uint16. Is this correct?

Yes, That is correct.
Input value must be :

requestedTime (in s) * { PWMmax (variable defined in the workspace) / Periode set in the block (in s) }

You'll get a large value that you may round off. See the many example for more details.

Lubin


Return to “dsPIC Peripherals”

Who is online

Users browsing this forum: No registered users and 2 guests