Y'all know you might as well be talking Chinese for all the good your comments will do MrDEB.
The basics. As Nigel said, you need an RC low pass filter. He suggested 1k and 10uF, which gives a cutoff frequency of 15.9 Hz. I might suggest 1k and 1 uF to make the capacitor smaller, which gives a cutoff frequency of 159 Hz.
The PWM frequency should be 10× the cutoff frequency or greater.
This calculator will show the options for a given clock speed. Pick one that's greater than 10× the cutoff frequency and plug the whole number (i.e., integer value) into the PWM module SetFreq() command. (You can probably plug in any value you want without calculating a value, but using a calculated value assures it's within the possible range).
Include the PWM2 module (available on the Swordfish page if you don't have it already).
Steps – figure out the exact syntax by looking in the PWM2 module (sorry, not at my computer):
Set frequency
Set duty cycle from 0 to 100%
Start PWM
Varying duty cycle from 0 to 100 will vary voltage from 0 to 5 volts (supply voltage).
DO NOT change FREQUENCY. It stays fixed.
Another
useful calculator is here.
Back on ignore mode for MrDEB.