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?
pwm 2+2
pwm 2+2
- 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 1034 times
-
- Vejlupek_CAR4_dsPIC33_AxleControl.mdl
- this one I am able to compile
- (38.81 KiB) Downloaded 973 times
Re: pwm 2+2
update: it is not possible to run one PWM module with two different frequencies. 

-
- Site Admin - Expert
- Posts: 616
- Joined: Wed Mar 07, 2007 11:23 pm
- Location: Bayonne- France
- Contact:
Re: pwm 2+2
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
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
Re: pwm 2+2
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
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
-
- Site Admin - Expert
- Posts: 616
- Joined: Wed Mar 07, 2007 11:23 pm
- Location: Bayonne- France
- Contact:
Re: pwm 2+2
Yes, That is correct.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?
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
Who is online
Users browsing this forum: No registered users and 8 guests