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

Maximum 8-channel PWM frequency?

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



Joined: 30 Oct 2008
Posts: 4

View user's profile Send private message

Maximum 8-channel PWM frequency?
PostPosted: Thu Oct 30, 2008 10:23 am     Reply with quote

Greetings! New member with an odd question.

I need 8 PWM channels, 10-bit resolution, preferably using a single PIC. Using a very simple algorithm, such as
Code:

int16 LoopCount = 0;
while (true)
{
output_bit(Pin_B0,(PWM1 < LoopCount))
output_bit(Pin_B1,(PWM2 < LoopCount))
// etc.
++LoopCount
LoopCount%=1024
}

...on a PIC18F2523 using a 32 MHz clock I get nice PWM, but the repetition frequency is only about 100 Hz. Ideally I'd like it to be much, much faster (ultrasonic if possible). Does anyone have any suggestions for a better algorithm, or might it be necessary to use multiple PICs with their two hardware PWMs each? Or a 16-bit PIC?
Any helpful suggestions would be greatly appreciated.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Oct 30, 2008 11:03 am     Reply with quote

http://www.dattalo.com/technical/theory/pwm.html
http://www.dattalo.com/technical/software/pic/pwm8.asm
John P



Joined: 17 Sep 2003
Posts: 331

View user's profile Send private message

PostPosted: Thu Oct 30, 2008 4:14 pm     Reply with quote

It seems clear that if you want a 10-bit resolution, you'd have a frequency of 1024 * the instruction time, or about 8KHz. If that's not fast enough, then you need to look elsewhere for a processor.

I can't imagine a scheme which would allow you to change outputs in an arbitrary pattern, with only one instruction time between successsive changes. Even a broadside load of the output port would take two instructions.

Suppose the requirement is that at time 0, all the outputs go on, then at time 1, output 0 and output 1 go off, at time 2 outputs 2 and 3 go off and so forth. If there's a way to do this, even if the pattern never changed, I can't see how it could work.
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