Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

The range and performance of software PWM

Status
Not open for further replies.

vsmGuy

Advanced Member level 2
Joined
Jun 26, 2006
Messages
503
Helped
44
Reputation
88
Reaction score
15
Trophy points
1,298
Location
VddVss
Activity points
3,882
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

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.

Cheers
 

soft pwm ccs

If I understand what I've read so far, you will need a timed interrupt and no other interrupts.

First update the PWM values, then poll the USART and anything else that needs to be serviced.

A few lines of code will be needed for each channel of PWM, and it will be limited to the low speeds. Let us assume you want 500Hz and 8 bit resolution. You will need to service it every 7.8uS (2mS/255values). With a 20MHz crystal you will need to do everything in a 39 cycle instruction loop.

I hope this helps.
 

    vsmGuy

    Points: 2
    Helpful Answer Positive Rating
software pwm

After poking around with the motors, I see I do well with 250Hz...

Anyone got some code to do that ?
 

Software PWM

Guys,

will it be possible to design hardware using 74xx logic to divide frequency by a known factor, BUT maintaining the duty cycle.

For example, such a circuit would divide a input of y Hz @ x % duty to (y/k) Hz at x % duty (we have divided by k)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top