I am going to use this thread to post free code that others can use or customize as they wish.
Attached is a software PWM snippet I worked on last night. The software PWM has some advantages over the Hardware PWM. It can be used to program more complex waveforms than the Arduino can normally produce and has good quality up to about 3 Khz. It will go higher, 100Khz+, but like any software PWM it has the usual limitations which is precision and the higher it goes the less precise the frequency and duty cycle you are requesting. I specifically wrote this one to produce as little "jitter" as possible. While it is not reasonable to expect a 16Mhz 8-bit device to produce perfect high frequency wave forms. It can be improved by running at higher Mhz and recoding it in assembly, however, there are limits to how perfect these improvements can be. Also, this is not the best implementation of a AVR software PWM, but rather it was the implementation that I needed for my purposes..