View previous topic :: View next topic |
Author |
Message |
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
|
dsPIC30F2020 PWM frequency |
Posted: Tue Sep 21, 2010 3:09 am |
|
|
I'm working with the dsPIC30F2020 and have been struggling to get the PWM module to work the way I want. I've used the 30F2010 earlier and had to write my own functions to use the PWM since the version of PCD our lab has doesn't properly support the motor control PWM module.
My dsPIC runs at 96Mhz (6Mhz,PLL x16). I need to produce four 50Hz PWM signals to drive brushless ESCs (actually, any frequency between 200Hz and 50Hz will do). From what I gather after reading the 30F202x datasheet (http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en026339) , I can produce a minimum frequency of 11.7kHz (which is way too high). However the dsPIC30F family reference manual says I can use a PTMR prescaler (which will allow me to drop this to below 200Hz). The problem is that I don't find any mention of a PTMR prescaler in the '2020 datasheet.
One way to generate 200Hz would be to reduce the PLL or the crystal speed. But then that would slow my entire processor down. So is there any way I can produce a four channel 200Hz hobby servo signal?
Rohit |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Tue Sep 21, 2010 4:08 am |
|
|
The prescaler mentioned in the dsPIC family mentioned reference manual is controlled by PTCKPS bits in the PTCON register. As you can see from the dsPIC30F2020 manual, PTCON has a different layout here, beside other changes lacking the prescaler feature.
In my opinion, although it would be convenient of course, a hardware PWM isn't actually required at a very low frequency of 50 Hz. You should consider to implement it based on a timer interrupt. |
|
|
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
|
|
Posted: Thu Sep 23, 2010 3:15 am |
|
|
Thanks for the reply Frank. I'm going to be doing some heavy math (PID, Kalman, etc) and use the PIC for a lot of other system management, so I want all the processor time I can get. To use a timer for my PWM _and_ do all if the other stuff I'd need some really tight code. So to save myself a headache I'm switching to a different PIC that I have lying around, and that'll give me hardware PWM :-)
Rohit |
|
|
|