Software Controlled PWM

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 7.

Moderator: Benj

User avatar
Steve001
Valued Contributor
Valued Contributor
Posts: 1086
Joined: Wed Dec 31, 2008 3:37 pm
Has thanked: 440 times
Been thanked: 492 times
Contact:

Software Controlled PWM

Postby Steve001 » Mon Jun 10, 2019 12:46 pm

Afternoon All,

Looking at an application that I would like 3 PWM channels my device only has two available only a cursory look on microchips part selector reviled that 4 channels tend to be on the high pin count devices. So thought of doing it in software have seen the software PWW example of a night rider LED chaser but this didn't make much sense, couldn't see how it was working.

A software PWM search - returned too many results "software" & "pwm"

Anybody got an example ?

I have toyed with the idea of a two timer approach using timer0 and timer2

Steve
Success always occurs in private and failure in full view.

User avatar
Benj
Matrix Staff
Posts: 14363
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4444 times
Been thanked: 4144 times
Contact:

Re: Software Controlled PWM

Postby Benj » Mon Jun 10, 2019 1:01 pm

Hi Steve,

A single timer may be all that is required.

There is a software PWM example here that should hopefully help.
https://www.matrixtsl.com/wiki/index.ph ... Interrupts

Let us know how you're getting on.
These users thanked the author Benj for the post:
Steve001 (Mon Jun 10, 2019 7:07 pm)
Rating: 5.26%
 

User avatar
Steve001
Valued Contributor
Valued Contributor
Posts: 1086
Joined: Wed Dec 31, 2008 3:37 pm
Has thanked: 440 times
Been thanked: 492 times
Contact:

Re: Software Controlled PWM

Postby Steve001 » Mon Jun 10, 2019 7:07 pm

Hi Ben

Might be a few weeks before i can get back to you mega busy at work at the moment :(

Why do you say only 1 timer ?

was thinking on the lines of timer2 for the PWM frequency timer0 for the duty or is this OTT and heading on the lines of generating a headache ?

looking for a 0 - 240 count where 240 = 100% duty (trying to make the maths easy)

Steve
Success always occurs in private and failure in full view.

User avatar
Steve001
Valued Contributor
Valued Contributor
Posts: 1086
Joined: Wed Dec 31, 2008 3:37 pm
Has thanked: 440 times
Been thanked: 492 times
Contact:

Re: Software Controlled PWM

Postby Steve001 » Sat Jul 06, 2019 4:48 pm

Afternoon All

After mooching around RS for some parts had a go with their part selector found a couple of suitable devices had another go with MPAS these parts didn't appear

Have found the following devices - so will order them and have a go. 4 PWM channels too and supported by V7 :mrgreen:

PIC16F1828-I/P

https://uk.rs-online.com/web/p/microcontrollers/7154393/

PIC16F1825-E/P

https://uk.rs-online.com/web/p/microcontrollers/7434700/

Steve
Success always occurs in private and failure in full view.