PDA

View Full Version : Darrel's Multiple Software PWM



passion1
- 30th May 2007, 09:52
I just came across Darrel Taylor's multiple software PWM at http://www.darreltaylor.com/DT_INTS-14/SPWM.html

EXCELLENT piece of coding!!
However, I cannot find the file "DT_INTS-14.bas".
His site allows one to download SPWM_Int.bas and Test_SPWM.pbp
These files call the include file DT_INTS-14.bas which I can find nowhere?
Thus I cannot compile and test the example Test_SPWM.pbp.
Please help! Thank you!

Passion1

paul borgmeier
- 30th May 2007, 13:15
http://www.picbasic.co.uk/forum/showthread.php?t=3251

Edit: you are right - not there .. Darrel's site was hacked recently and he probably has not got it all back together.

Sean_Goddard
- 30th May 2007, 14:35
I have these files somewhere. if I can find them I will post them (if that's OK with Darrel)

mister_e
- 30th May 2007, 17:32
I've uploaded the whole package few weeks ago
http://www.picbasic.co.uk/forum/showpost.php?p=38268&postcount=210

passion1
- 31st May 2007, 07:13
Steve

Thank you for pointing me in the right direction!

I just realized that Darrel's code is a slow SPWM and cannot handle high frequencies (e.g. up to 20KHz).

I would like to generate two frequencies simultaneously where the one is a
multiple of the other, e.g Freq 1 = 10 kHz, Freq 2 = 20KHz
I do not need to vary the duty cycle. I only need a duty cycle of 50%, thus
either on or off.

Darrel's code would have been perfect if it could handle higher frequencies.

I cannot use the hardware PWM because all PICs with multiple PWM outputs that I know of, share the same timebase.
Thus the frequency must be the same on all the outputs, but the duty cycles are individually controllable. I don't know of a PIC that's an exception

In short, I am looking for a software PWM that is capable of handling 2 different frequencies simultaneously, where each frequency may vary up to 20KHz. I have looked everywhere but could not find any example code to this.

I will appreciate any help or suggestions.

paul borgmeier
- 31st May 2007, 17:03
Are the two fequencies always a factor of 2X apart? (10kHz and 20kHz)
What else does this PIC need to do?
Do the two PWM need to be in phase?

Sean_Goddard
- 1st June 2007, 00:17
PWM and maybe a programmable divider OR a divider and a MUX to select the appropriate frequency multiple.

Whats your application btw please??

passion1
- 1st June 2007, 07:00
Thank you guys.
I got the following clever code from MeLabs support, that solves my problem. It produce simultaneous frequencies of 20KHz, 10KHz, and 5KHz:

DEFINE OSC 20 ' Use a 20MHz crystal for best results

freq_delay VAR WORD

freq_delay = 25 ' 25uS for 20KHz top frequency ((1/20K)/2)
TRISB = %11111000 ' freq pins to outputs

' Output 20KHz on RB0, 10KHz on RB1, 5KHz on RB2
' Adjust freq_delay to compensate for loop overhead
loop:
PAUSEUS freq_delay
PORTB = (PORTB & %00000111) + 1 ' count binary 000 to 111
GOTO loop

deanjhon530
- 18th May 2013, 11:11
This program allows you to have MANY Pulse Width Modulation's being generated as an interrupt driven Background process with PicBasic Pro. It's a complete Re-Write of the original Multi-SPWM with new features added. So be sure to read this article before trying to use it.
Features:

Multiple Slow Speed PWM outputs simultaneously on 1 chip, limited only by the processor speed, and SPWM frequency/resolution configuration.
Works on just about any chip. 18F or 14-bit core's.
Each SPWM output can be assigned to ANY General I/O pin on any Port
PWM has a maximum resolution of 8-bit (0-255) 0=Always Low, 255=Always High, but lower resolutions are also available.
It's an Include file, for easy implementation in your program.
Some Error checking is built in, and supplies Messages detailing the problems. Although it won't find everything you can mess up.

johnson123
- 17th June 2013, 11:41
Sorry, this program will only produce PWM with all channels having the same phase. I'm sure it can be done, but just not with this program.

Darrel Taylor
- 15th October 2013, 15:21
You can get DT_INTS-14 from here ... http://www.darreltaylor.com/DT_INTS-14/intro.html