CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

dsPIC30F2020 PWM frequency

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Rohit de Sa



Joined: 09 Nov 2007
Posts: 282
Location: India

View user's profile Send private message Visit poster's website

dsPIC30F2020 PWM frequency
PostPosted: Tue Sep 21, 2010 3:09 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Sep 21, 2010 4:08 am     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Thu Sep 23, 2010 3:15 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group