pwmout glitch

RobertN

Member
A previous thread mentioned an output glitch occurs when pwmout updates. A comment was made there maybe a work around by poking a register. The application can stand a glitch in the duty cycle but not frequency. Can anyone elaborate on this?
 

boriz

Senior Member
Yep. What he said. AFAIK PWMDUTY was added to the firmware retrospectively in order to address this very problem.
 

AllyCat

Senior Member
use a 08M2 for a VCO 40 to 70 KHz. Is this even feasable? Output frequency jitter in not acceptable.
Hi Robert,

Just at those two frequencies, or with (how many) steps in between?

How are you defining frequency jitter? AFAIK, if you change the frequency, you cannot (instantly) keep the duty cycle the same (even with a "raw" PIC) because different/additional registers need to be updated to restore the duty cycle. So there must be "jitter" at least on the falling or rising edge of the output waveform.

So, probably not feasable using the PWM output. But you may be able to "build" your own VCO with a 08M2 using other on-chip hardware (supported by SFR commands) such as the SR flip-flop, Comparator, D/A converter (and probably an external capacitor).

Cheers, Alan.
 

Goeytex

Senior Member
The Picaxe is quite good at a lot of things, but a glitch free VCO is not one of them. For a decent budget VCO I would consider using an inexpensive 74HC4046. These can be programmed with resistors to operate within a specified frequency range.

For example: 2v to 4v in = 40Khz to 70Khz out.

Cost about 50c each.
 

westaust55

Moderator
The Picaxe is quite good at a lot of things, but a glitch free VCO is not one of them. For a decent budget VCO I would consider using an inexpensive 74HC4046. These can be programmed with resistors to operate within a specified frequency range.

For example: 2v to 4v in = 40Khz to 70Khz out.

Cost about 50c each.
And with the sugegsted 74HC4046, as the two resistors R1 and R2 have one end tied to ground one could consider a couple of digital pots with I2C or SPI interface to achieve the required resistance values to given frequencies.
A 100 KOhm digital pot with 256 steps would have steps of approx 390 Ohms.
For a 10 kOhm digital pot with 256 steps the resistance increments would be around 39 Ohms.

A fixed cap of around 10 or 12 pF and a 10 kOhm digital pot for R1 looks like it could give you the range 40 kHz to 70 kHz using the digital pot from 1 Kohm to 10 kOhm.
 

hippy

Ex-Staff (retired)
If you were happy with 50:50 duty cycle you could perhaps run the PWMOUT into a flip-flop and then duty glitches would not matter.

Setting an internal timer for some other mode than PWM using POKESFR may be another option.
 
Top