Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PWM formula confused

Status
Not open for further replies.
I have seen the following formula for dpsic30f4011 formula for PDC duty cycle resolution calculation. What is the significance of this formula? Why should i do this calculation. I am asking this as i want to arrive the value from PTPER period register which is simple i assume. Do I need to do this calculation? please suggest. Another doubt i have is suppose if i want pwm frequency of 1KHz. The formula is Fcy/Fpwm - 1, so it is 20Mhz/1k -1 = 19999 PTPER value. So every count value corresponds to 0.05 Hz?

upload_2017-6-18_13-48-16.png
 
You don't do the calculation!!! That formula shows how you determine resolution ( the micro does it automatically ) from the Tcy and the tpwm.. When you select your period (PTPER) and your cycle count (PTMR) for the given tosc (Tcy) then the resolution will be X and X can be worked out using that formula..
 
Thank you very much for the reply. Actually in one of my programs i was doing that calculations, now i can safely remove those calculations. But i am not loading any value into PTMR register. Is it OK? One doubt i have for a long time is PWM in any way related to any of timers (in any of pic families) that is if i disable all the timers, the PWM will still work? I have seen some example programs in some pic families where PWM and timer 0 are referred together. Please advise.
 
Okay... Basics! You load the PTPER with a value the PTMR will start to count... When the count matches the value in the PTPER the period ends... IF you are doing central align then bit 15 of the PTPER will allow a count down to end the period.. either way the period can be the size of a 15 bit register 0~32767..

The duty cycle is controlled by the PDC registers PDC1~ PDC3 as up to three outputs are available..
This way you can produce 3 phase ac outputs..

The PTMR should run when the PTEN is set...

Lastly!!! Remember the ancillary registers... The OVDCON register and ensure polarity is correct!!

I am assuming you are controlling a BLDC motor... I can't see any hall inputs on this model!! I think you need to control the PEN bits manually!!
 
If you want you can use others tools like PIC Compiler for example. The setup and development of the project is more easy and you save time.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top