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 support@ccsinfo.com

PIC 18F452 PWM

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



Joined: 07 Sep 2003
Posts: 40
Location: Adelaide, Australia

View user's profile Send private message

PIC 18F452 PWM
PostPosted: Tue Jan 25, 2005 7:56 pm     Reply with quote

Hi there,

I'm about to start using the 18F series for the first time, my first chip will be 18F452 in QFN44 package. To date I've only ever used 16F876. I only have an old version of PCM v3.168, so when my 18F hardware design is finished I'll probably purchase PCWH.

Anyway, to my question. There are two PWM outputs on the 18F452 on CCP1 and CCP2. The datasheet table 14-2 on pg 120 states that they both run at the same frequency becuase they both run off Timer-2. Am I misinterpreting this, and is it possible to run them at diff frequencies? I want to use one output to pulse a solenoid with PWM modulation (low frequencies around 100Hz-200Hz) and another output to modulate an LED brighness (much higher frequency, not sure but presume around a few kilohertz). This LED is actually the backlight on a LCD character module.

If diff freq for each PWM are not possible, should I just use the CCP1 PWM module for the LED brightness, and just use a timer interrupt and software to implement my own low freq PWM for the solenoid?

Are there any other gotchas with using 18F452 I should watch out for? I'm planning on using 8MHz crystal and using the 4x PLL clock multiplier.

Sorry for long post.

Thanks
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Tue Jan 25, 2005 8:53 pm     Reply with quote

Same frequencies for the PWM but you can use the modules in the compare mode and generate your own frequencies. Basically you get an int whenever the CCP value matches that of timer1 (or timer3 refer to the datasheet). There is even a special feature to toggle the output pin on match.
pat



Joined: 07 Sep 2003
Posts: 40
Location: Adelaide, Australia

View user's profile Send private message

PostPosted: Tue Jan 25, 2005 10:00 pm     Reply with quote

Thanks that sounds ok. So the PWM module just saves a bit of coding and variable use compared to your suggestion?
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Wed Jan 26, 2005 7:10 am     Reply with quote

pat wrote:
Thanks that sounds ok. So the PWM module just saves a bit of coding and variable use compared to your suggestion?


Depends on how you use the CCP. If set to toggle the output and you can get away with allowing the timer1 (or timer3) to run free then there is not really any extra software needed or interrupt. Everything is done in hardware. This of course would be for a 50% duty cycle. If you need to change the duty cycle, then you would need to change the ccp value on each interrupt. Not much code at all.
Jerry I



Joined: 14 Sep 2003
Posts: 96
Location: Toronto, Ontario, Canada

View user's profile Send private message

PostPosted: Wed Jan 26, 2005 6:15 pm     Reply with quote

Quote:
Anyway, to my question. There are two PWM outputs on the 18F452 on CCP1 and CCP2. The datasheet table 14-2 on pg 120 states that they both run at the same frequency becuase they both run off Timer-2. Am I misinterpreting this, and is it possible to run them at diff frequencies? I want to use one output to pulse a solenoid with PWM modulation (low frequencies around 100Hz-200Hz) and another output to modulate an LED brighness (much higher frequency, not sure but presume around a few kilohertz). This LED is actually the backlight on a LCD character module.


The two output frequencies will be thw same. But I don't see it being very important to have the LED PWM to be any higher than 100-200Hz that is needed for output pulse for your solenoid. Any frequency over 60Hz to the LED, you will not see it flicker. What is important when changing the brightness is the ON and OFF time of the PWM output.

good luck Smile
pat



Joined: 07 Sep 2003
Posts: 40
Location: Adelaide, Australia

View user's profile Send private message

PostPosted: Wed Jan 26, 2005 6:48 pm     Reply with quote

Thanks, I will try running the LED dimmer at the low frequency.

Thanks also to Mark, I have some ideas to work with now.

Patrick
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