![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Heliophagus
Joined: 30 Oct 2008 Posts: 4
|
Maximum 8-channel PWM frequency? |
Posted: Thu Oct 30, 2008 10:23 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
![](templates/subSilver/images/spacer.gif) |
John P
Joined: 17 Sep 2003 Posts: 331
|
|
Posted: Thu Oct 30, 2008 4:14 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|