FORUM TOPIC · READ ONLY

pwm 2+2

pwm 2+2

Forum : dsPIC Peripherals

5 message(s) · archive en lecture seule

Bobes
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?

Pièce jointe : Vejlupek_CAR4_dsPIC33_AxleControl.mdl

Pièce jointe : Vejlupek_CAR4_dsPIC33_AxleControl_bckup_R091228_R02.mdl

Bobes

Re: pwm 2+2

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

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
Bobes

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
LubinKerhuel

Re: pwm 2+2

Citation : Bobes

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