Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Can we Generate two PWM waves with a phase difference of 180degrees using ATmega16??

Status
Not open for further replies.

drtvskuthsav

Member level 2
Joined
Apr 7, 2010
Messages
46
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,630
Hi everyone,
Can we generate two PWM waves with a phase difference of 180degrees using AtMega16/32 MCU?? If yes, please explain how to do it. Else suggest any other AVR Micro-controller for the same purpose.
 

yes....just NOR you port pin output on the second pin of your micro-controller....it will give you PWM shifted on second pin with 180 degree shift but at same frequency with some clock cycle delay....but if you want have different frequency for PWM then it is tricky....how ever it is possible but one need to write two different section or functions to generate the PWM and use interrupt timer or RTOS for getting exact timing of Port

Good Luck

- - - Updated - - -

yes....just NOR you port pin output of first pin on the second pin of your micro-controller....it will give you PWM shifted on second pin with 180 degree shift but at same frequency with some clock cycle delay....but if you want have different frequency for PWM then it is tricky....how ever it is possible but one need to write two different section or functions to generate the PWM and use interrupt timer or RTOS for getting exact timing of Port

Good Luck
 

yes....just NOR you port pin output on the second pin of your micro-controller....it will give you PWM shifted on second pin with 180 degree shift but at same frequency with some clock cycle delay....

Good Luck

Hey Milind,
Can you explain me how it works..With block diagram/circuit.
 

I thought of the query is related to code ....any way....Let consider you are using two port pins PA0 and PA1 where PA0 gives PWM at some frequency and PA1 need to give 180 degree phase shift in PWM output of PA0 then the simple way to generate this in code will be some thing like this

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Void main( void)
{
// Deceleration of Dealy function and initialization of Micro-controller  
 
int i=0;
for ( i=0;i<10;i++)
{
if(i<5)
{
PA0=1;
PA1=~PA0;
Dealy((i+1)*100);
PA0=0;
PA1=~PA0;
Dealy((i+1)*100);
}
else
{
PA0=1;
PA1=~PA0;
Dealy(((10-i)+1)*100);
PA0=0;
PA1=~PA0;
Dealy(((10-i)+1)*100);
 
}
}
}
void delay( int i)
{
int k=0;
for(k=0;k<i;k++)
{
}
}



Hope you will get an idea....

Good Luck
 
Last edited by a moderator:

Hi,

Instead of doing it in coding, we can use the wave generation operation using the timers.
Atmega 16/32/8535 has 2 eight bit timer and 1 sixteen bit timer. So totally 4 pins can be
used to generate PWM.

I think this controller is enough as per your requirement.

Two PWM waves with a phase difference of 180degrees in two pin also possible.

Try to use this option.
 

Hi everyone,
Can we generate two PWM waves with a phase difference of 180degrees using AtMega16/32 MCU?? If yes, please explain how to do it. Else suggest any other AVR Micro-controller for the same purpose.

Lets first be precise by what you mean by 180 deg phase difference PWM. A few diagrams of your expected waveform will help clarify to yourself and everyone here what you are looking for. Its worth it ....

cheers!
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top