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

multiple PWM outputs

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



Joined: 07 Oct 2003
Posts: 66
Location: England

View user's profile Send private message

multiple PWM outputs
PostPosted: Fri Mar 26, 2004 8:59 am     Reply with quote

Good day! Very Happy

I am using a 16f876 and want to set up at least three independant pwm outputs. Can I do this using the internal pwm module - how many outputs is it possible to have?
Many thanks.

Dave
Mystery
Guest







PWM units
PostPosted: Fri Mar 26, 2004 9:04 am     Reply with quote

if you look at the datasheet for your pic, you will see that it has got

maximum of 2 PWM units - CCP, CCP2

There is nothing stopping you fropm creating one manually:

Start: output_a(0x01);
delay_ms(X);
output_a(0x00);
delay_ms(Y);
goto Start;

The above method is very crude, but you should get the idea!!

Hope this helps!
davt



Joined: 07 Oct 2003
Posts: 66
Location: England

View user's profile Send private message

PostPosted: Fri Mar 26, 2004 9:26 am     Reply with quote

Thanks for your reply!

Is there a 16fxxx which will give me 3 PWM outputs using the internal module?

Dave
mvaraujo



Joined: 20 Feb 2004
Posts: 59
Location: Brazil

View user's profile Send private message

PostPosted: Fri Mar 26, 2004 11:38 am     Reply with quote

As said before, you have only two internal PWMs to use.

I had a situation that I needed 4 PWMs outputs to control fluids and gases from a simple interface using keyboard (plus and minus keys for each gas/fluid of the process). I used a super simple 16F84 using interrupts to catch a time base por the PWM and six control variables to allow duty cycle control.

This is the key to multiple processes and reliable PWMs outputs. I have only assembly stuff of this, if you think it's ok I can post it.
John P



Joined: 17 Sep 2003
Posts: 331

View user's profile Send private message

PostPosted: Fri Mar 26, 2004 1:56 pm     Reply with quote

I've done this with a 16F877 for 8 independent outputs.

But butbutbut

not using the built-in PWM routines, and for a very slow output, only 60Hz and with 100 potential duty cycles. Just set up a 6Khz timer, and do what comes naturally...

It didn't keep the processor 100% busy. There was time left over for handling a serial link, reading 8 A-D's, calculating a feedback algorithm for each channel and modifying the outputs all within a cycle. It depends on what you need.
xav27
Guest







Multiple PWM "hardware"
PostPosted: Fri Mar 26, 2004 2:10 pm     Reply with quote

Is there a 16fxxx which will give me 3 PWM outputs using the internal module?

Yes the PIC16F767for example wich give 3 PWM.

I have had 3 sample from microchip Smile nice !


You can see specification on microchip web site


Xavier27
Ttelmah
Guest







Re: multiple PWM outputs
PostPosted: Sat Mar 27, 2004 5:12 am     Reply with quote

davt wrote:
Good day! Very Happy

I am using a 16f876 and want to set up at least three independant pwm outputs. Can I do this using the internal pwm module - how many outputs is it possible to have?
Many thanks.

Dave

It is worth saying, that though the chip you mention only supports two PWM signals, it may be possible to get what you want via 'trickery'. There are a number of routes depending on the performance needed from the PWM signals. The first (obvious, and mentioned allready), option, is if the PWM signals do not need any great speed, you may be able to use some form of 'soft' PWM. For instance, if you have an interrupt called at perhaps 100uSec intervals, and three single byte 'down' counters, and simply operate three pins according to the counter values. Have a fourth 'interval' counter, that sets all the pins, and reloads the counters. Using this approach, you can have three PWM signals at a frequency of about 40Hz, with the pulse widths setable in 100uSec intervals.
The second option though is less obvious. If the repetition 'rate' of the counters is less important, but the 'width' requires accurate setting, but never needs to rise above some small percentage of the total 'loop' time, you can multiplex the output from one PWM to multiple destinations. The 'trick', is to use the two CCP timers, run them both at the same 'period', and start one before the other, with the time delay between the starts, being determined by the interrupt latency involved in reaching it's 'handler'. When the first CCP interrupts, you load the time required for the next pulse on the second CCP (which has not yet timed out because it starts this amount latter), and then operate the multiplexer to switch the next pulse to it's required destination. The multiplexer hardware, has to use the edge of the second CCP, to trigger the switch. You don't enable interrupts for the second CCP. Then each successive pulse from the second CCP, can be routed to a different target!.
I have used this approach, on a 40MHz 18F processor, and using my own 'int global' handler, to reduce the interrupt latency massively, managed to have four pulse trains, each having a pulse varying between 1/50000th second, and 1/10000000th second, in 200 steps, and with a repetition interval of 1/12500th second, without working too hard...
It really depends massively on what the pulses actually need to do.

Best Wishes
ghanka
Guest







16F7x7: One PWM or three?
PostPosted: Sun Mar 28, 2004 5:39 pm     Reply with quote

According to the 16F7x7 press release, it has three PWM. However my datasheet only mentions one PWM channel , though it discusses three capture/compare channels . Anyone know what's up with this?

gordon
loh



Joined: 14 Jun 2004
Posts: 3
Location: Taiwan ROC, Taipei.

View user's profile Send private message

PostPosted: Sun Jun 20, 2004 12:02 am     Reply with quote

mvaraujo wrote:
As said before, you have only two internal PWMs to use.

I had a situation that I needed 4 PWMs outputs to control fluids and gases from a simple interface using keyboard (plus and minus keys for each gas/fluid of the process). I used a super simple 16F84 using interrupts to catch a time base por the PWM and six control variables to allow duty cycle control.

This is the key to multiple processes and reliable PWMs outputs. I have only assembly stuff of this, if you think it's ok I can post it.


Yes, please post it here, it will be helpful!!
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