On Mon, Jun 25, 2012 at 11:56 PM, Joep Suijs <[email protected]> wrote:

> Hi John,
>
> As far as I know there are no libraries in jal for 'software pwm'.
> There are however libraries up to CCP9, which suggests there are PICs
> with a lot of PWM pins. But that doesn't help if you already selected
> your target pic...
>
> At one time, I experimented with software pwm, called from a fixed
> ISR.  The basic approach is to have a timer incremented at a fixed
> interval, say 2 kHz, from 0 to 15.  This will give you a pwm frequency
> of 2kHz/16= 125 Hz and a resolution of 16 steps (4 bits). This
> basically points out the limitation of this approach: low resolution
> and low frequency.  If this is a problem depend on the application.
> For my application (robot motor control) it was, so I abandoned it.
>
> It is possible to increase the frequency for many of the values using
> the Bresenham algorithm. On average, this will be much better.
> However, on the extreme, the performance will be similar to the
> previous method.
>

Agree with Joep,

Depends on PWM frequency. With Bresenham you can go as high as you want
with resolution (I'm using usually 100% with 1% step).
I have used two PWM ( lower software + higher hardware generated), see here
in fig8:
https://aece.ro/abstractplus.php?year=2011&number=2&article=8
in which the lowest frequency is generated  by Bresenham algorithm with 1%
step ( 100 steps available for my application)

I've also experimented software generation of two PWM by Bresenham, around
60Hz for higher PWM and 1Hz for lower PWM , where the 1Hz PWM is modulating
the 60Hz PWM.
For complex ISRs I found it's necessary to use high priority interrupts,
else the Jal code written into ISR is adding an offset delay to the higher
frequency PWM pulse generation.

Vasile




>
> An approach similar to the servo library is more complex but provides
> higher frequency and resolution at lower cpu load. What you basically
> do is set the timer to interrupt you when the next event (line toggle)
> is due. The servo lib has the advantage that a servo pulse has only up
> to 12.5% duty cycle, so 8 pulses can put consecutive in one cycle.  If
> all 4 signals can have the full duty cycle range, you have to consider
> them simultaneously.
>
> Hope this helps a bit. If not, please share some details about your
> application and it's requirements in terms of resolution and
> frequency.
>
> Regards,
> Joep
>
> --
> You received this message because you are subscribed to the Google Groups
> "jallib" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/jallib?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jallib?hl=en.

Reply via email to