Searching \ for '[PIC]: 4 software pwm in C' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/microchip/ios.htm?key=pwm
Search entire site for: '4 software pwm in C'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: 4 software pwm in C'
2003\03\18@161812 by Andre Abelian

picon face
Hi to all engineers,

I need to generate 4 outputs like this and all 4 duty cycle
Get changed at the same time. Even I had 4 hardware PWM in pic
I do not think I could make it start like that.

0d   90d   180d  270d  360d

|-----|-----|-----|-----|


       |------------|
________|            |--

--------|            |--
       |____________|

|-----------|           |
|           |___________|

|           |-----------|
|___________|           |


I use hi-tech c 18f452 any idea or recommendation
Will highly appreciate. I was thinking to use array
But then how to change duty cycle. The frequency is 60hz


andre

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\03\18@172231 by Scott Dattalo

face
flavicon
face
On Tue, 18 Mar 2003, Andre Abelian wrote:

{Quote hidden}

It ain't C, but you should be able to inline it:

http://www.dattalo.com/technical/software/pic/pwm8.asm

Scott

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\03\19@213427 by Eric Bohlman

picon face
3/18/03 3:20:02 PM, Andre Abelian <spam_OUTengelecTakeThisOuTspamEARTHLINK.NET> wrote:

{Quote hidden}

Do they all need the same duty cycle but different phases, or do both the phase and duty cycle
need to be independently adjustable?  If the former, I'd use something along the lines of:

void ontick(void) {
 int i;
 static int duties[4];
 if (++ticks==100)
   ticks=0;
 for (i=0;i<4;++i) {
   if (phases[i]==ticks) {
     //turn output on
     duties[i]=duty;
   }
   else if (duties[i]>0) {
     if (--duties[i]==0)
       //turn output off
   }
 }
}

where phases[] contains the "start point" for each output and duty is the common duty cycle, both
in terms of number of ticks (arbitrarily set to 100 for the total period).  If they need to be
independently adjustable, then do something like:

void ontick(void) {
 int i;
 if (++ticks==100)
   ticks=0;
 for (i=0;i<4;++i) {
   if (starts[i]==ticks)
     //turn output on
   else if (stops[i]==ticks)
       //turn output off
 }
}

where starts[] is like phases[] in the previous example, and stops[] is simply the tick counts for
turning the outputs off; stops[i] can be less than starts[i] for waveforms like your first two
examples (note that it will take one period for things to sync up in that case; if that's a
problem, you'll need to initialize any outputs for which stops[i]<starts[i] to 1 before starting
the PWM).

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2003\03\20@091012 by Bob Ammerman

picon face
What frequency for the PWM?

What else is the processor doing, if anything, while generating the PWM?

Bob Ammerman
RAm Systems

{Original Message removed}

More... (looser matching)
- Last day of these posts
- In 2003 , 2004 only
- Today
- New search...