This may be outside the realm of this forum a bit, not sure. I want to find a way to generate a sawtooth (ramp) waveform from a pulse-width-modulated signal using the 12F683. Its easy enough to generate a repeating, ascending PWM signal and taylor it to a frequency, but filtering it to a sawtooth is where I'm running into a problem. Has anyone tried this before?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Managed to mostly solve my own problem yet again, lol. Set up a for-next loop to generate the ascending duty cycle, using a step clause at the end of the FOR statement to raise or lower sawtooth frequency, and ran the PWM output a low-pass filter (into a 4.7k-ohm resistor in series with three paralleled .1uf capacitors to ground). I tied the output of the filter through a transistor to ground, pulsed on briefly by gpio.0 at the end of each for-next loop completion after turning off the pwm signal, to discharge the filter caps and bring the output voltage to zero as quickly as possible. The waveform is quite linear with the exception of the transistion after returning to zero. There is a VERY brief flat-line period before the voltage begins to rise again. Over-all, good results.
Last edit: Dave B 2016-05-10
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This may be outside the realm of this forum a bit, not sure. I want to find a way to generate a sawtooth (ramp) waveform from a pulse-width-modulated signal using the 12F683. Its easy enough to generate a repeating, ascending PWM signal and taylor it to a frequency, but filtering it to a sawtooth is where I'm running into a problem. Has anyone tried this before?
Managed to mostly solve my own problem yet again, lol. Set up a for-next loop to generate the ascending duty cycle, using a step clause at the end of the FOR statement to raise or lower sawtooth frequency, and ran the PWM output a low-pass filter (into a 4.7k-ohm resistor in series with three paralleled .1uf capacitors to ground). I tied the output of the filter through a transistor to ground, pulsed on briefly by gpio.0 at the end of each for-next loop completion after turning off the pwm signal, to discharge the filter caps and bring the output voltage to zero as quickly as possible. The waveform is quite linear with the exception of the transistion after returning to zero. There is a VERY brief flat-line period before the voltage begins to rise again. Over-all, good results.
Last edit: Dave B 2016-05-10