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

Software PWM

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



Joined: 13 Jan 2007
Posts: 91

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

Software PWM
PostPosted: Sun Feb 25, 2007 8:37 am     Reply with quote

Guys

I am on the lookout for an all software PWM with perhaps 8 bit resolution (256 states).

The frequency is ofcourse sub khz - definitely around 500Hz.

What I wanted to know is what is the range of PWM freq available using software methods ? Will it change with clock frequency.

Also, how will the performance of the peripherals - like USART, ADC, CCP, etc be affected with such a technique. And how many channels of PWM I can have this way ?

I am led to believe that the output created using software PWM is as good as that of the hardware PWM - atleast for 8 bit resolution.

How true is it ?

Please note that I am not as interested in the code rightaway (I located LOTS of soft PWM code here AND google) - I wanted to hear what you guys have to say about this.

My needs are to generate sub khz (around 100 to 500Hz - not all at same time) WITH adjustable duty cycle (minimum 10% to 90%) to drive a DC Motor control system. (I am NOT on the lookout for DDS !)

If possible I should be able to leave the TIMER free because this same IC will be used for quadrature decoding.

I will heavily prefer a technique that does not use 18F parts and will work nicely on a 16F like the 628a/877a.

4/8 channels of PWM will be nice because I will be able to implement locked anti phase control instead of signed magnitude.

Keep the suggestions flowing in ! Oh - ofcourse they must be in CCS C Smile

Cheers

Vimal
vsmguy



Joined: 13 Jan 2007
Posts: 91

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

PostPosted: Mon Feb 26, 2007 8:25 am     Reply with quote

I read 00654a.pdf titled "PWM, a Software Solution for the PIC16CXXX".

It's definitely an interesting read.

Anyone coded that already in C ? The code need not necessarily be tested, or even compiling for that matter.
SimpleAsPossible



Joined: 19 Jun 2004
Posts: 21

View user's profile Send private message

Well, you asked for random thoughts
PostPosted: Mon Feb 26, 2007 8:03 pm     Reply with quote

I recently rejected a software PWM on a project. Not that my needs match yours....

Random thoughts:

For true 8 bit resolution, don't you need ( 500 Hz * 256 counts ) = 128 kHz timer ticks? Are you sure you don't want a hardware solution? It's so very convenient to set a timer compare value and just let the interrupt happen when it happens. Of course, I'm a brute force kind of programmer. No elegance from me.

If you want 1% steps, you're still looking at ( 500 Hz * 100 counts ) = 50 kHz. It's doable but not fun to code.

Mmmm....donuts..... (hey, I said they were random!)

Could you live with a "sidecar" 8-pin PIC with built-in PWM? Or even one of those little 6-pin SOT-23 devices? I guess that wouldn't work for very many outputs.

What about the motor-specific PICs? Or (pardon the heresy) one of the other brands of microcontrollers that have devices specifically intended for motor PWM?

Mmmm....chocolate.....

I think you can have pretty much any number of outputs. It should just cost you some RAM and a little bit of processing time for each one.
vsmguy



Joined: 13 Jan 2007
Posts: 91

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

PostPosted: Mon Feb 26, 2007 9:57 pm     Reply with quote

I believe I can use 250Hz.. infact I want to use from 25Hz to 250Hz

I will devote an entire PIC for the MCS. This PIC will do :

1. Dual channel PWM
2. Current sensing (ADC)
3. Quadrature decoding
3. Interface to the ControlUnit via SPI/I2C

Smaller PICs have single channel PWM. Using 3 PICs to control 2 motors is not only wasteful financially but board space too besides consuming more power.

I am sure a software PWM is the way to go UNLESS someone shows me it's not...
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