CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Center Lined PWM

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
hakam_saffour



Joined: 14 May 2008
Posts: 13
Location: Germany

View user's profile Send private message

Center Lined PWM
PostPosted: Tue Jul 01, 2008 2:57 am     Reply with quote

Hello,
I am developing a code to control a motor using 'CENTER LINED PWM'.

Mico-controller: PIC18F8520
Compiler: PCWHD Compiler 4.057

I will explain what 'center Lined' means, but let me first give you idea about my project. PIC microcontroller will receive from other controller the Freq. and Duty cycle through RS232 port in order to generate PWM signal to control AC motor.

Frequencies will be one of the following 1KHz, 5KHz, 10KHz.
Duty Cycle =0 to 100.

For power saving purpose and to reduce the heat dissipation, the output PWM has to be center lined.

Center Lined PWM means that the 'ON period' (when output is high) of the output signal has to be in the middle of the period (in classical PWM units it usually starts at the beginning of the period), to make it clear I will give an example:
- Assume Freq=1KHz -----> T= 1000uS
- Duty Cycle = 50%
- In Classical PWM:
from T=0 to 500uS the output signal will be high
from T=500 to 1000uS the output signal will be low
- In Center lined PWM output:
from T=0 to 250uS-->O/P=Low
from T=250 to 750uS-->O/P=High
from T=750 to 1000uS-->O/P=Low

I wrote the following code, but there is something wrong in it (I put only the part which I have problem in it)

Code:
#if defined(__PCH__)
#include <18F8520.h>
#fuses HS,H4,NOWDT,NOPROTECT,NOLVP 
#use delay(clock=40000000)

int8 DC1,AF,ST,FT,on_time;

setup_ccp1(CCP_COMPARE_CLR_ON_MATCH);     // Configure CCP1 in COMPARE mode
setup_timer_1(T1_INTERNAL); // Set up timer to instruction clk (0.1uS/cycle)
//***********This code for 1KHz PWM signal (T=1000uS)*************
                AF=DC1/2; //Add Factor
                ST=(50-AF)*10;// Start Time (in uS)
                FT=(50+AF)*10;//Finish Time (in uS)
                on_time=FT-ST;

                CCP_1=ST*10; //since clock cycle is 0.1uS and 'ST' in uS
                setup_ccp1(CCP_COMPARE_SET_ON_MATCH);//O/P is ON when 'ST*10' has been passed
               
                set_timer1(0);   
                   
                CCP_1=on_time*10;
                setup_ccp1(CCP_COMPARE_CLR_ON_MATCH);//Keep O/P ON for 'on_time*10' uS
 
                delay_us(ST);//To complete the period


I think the problem is in 'set_timer1(0)', but I have to reset the timer in order to enter the new value of CCP_1.

Any idea?
Any suggestion or other approach?

Thanks in advance
_________________
Hakam B Saffour
crystal_lattice



Joined: 13 Jun 2006
Posts: 164

View user's profile Send private message

PostPosted: Wed Jul 02, 2008 2:09 am     Reply with quote

Not trying to be funny here, but that just sounds like normal PWM, you just looking at the waveform with half a period offset. could be wrong but thats what it sounds like to me, your duty at the end of the day will still be the same.
hakam_saffour



Joined: 14 May 2008
Posts: 13
Location: Germany

View user's profile Send private message

PostPosted: Wed Jul 02, 2008 2:44 am     Reply with quote

Yes, you are right...the duty is the same..but the idea to have this duty in the middle of the period not on the begining.
May be it look funny, but for three phases motor, this type of PWM is mcuh better than classical PWM
_________________
Hakam B Saffour
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jul 02, 2008 2:56 am     Reply with quote

The proper phrase is "center aligned".
Do a search with http://www.google.com for this search string
and you will find some articles on it:
Quote:
center aligned PWM "3-phase" motor -patent
crystal_lattice



Joined: 13 Jun 2006
Posts: 164

View user's profile Send private message

PostPosted: Wed Jul 02, 2008 3:20 am     Reply with quote

that sounds better, supose if you said it was with respect to 2 other signals it might have prevented confusion. qouted from microchip website:
Quote:


What is the difference between center-aligned and edge-aligned PWM signals?

Discussion: In edge-aligned multi-phase PWM control all phases switch on at the same time but switch off at different times depending on the duty cycle of each phase. Multiple high current phases switching simultaneously cause a much larger EMI transient than if the phases always changed at different times. Center-aligned switching solves the EMI problem by activating the PWM outputs such that the centers of all the active periods are aligned. For each phase output, half the duty cycle occurs before the center alignment reference followed by the other half.
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Wed Jul 02, 2008 8:26 am     Reply with quote

So this center aligned method has nothing to do with power or heat as the original post implied. It just minimizes EMI. That had me puzzled for a while.
_________________
The search for better is endless. Instead simply find very good and get the job done.
hakam_saffour



Joined: 14 May 2008
Posts: 13
Location: Germany

View user's profile Send private message

PostPosted: Wed Jul 02, 2008 12:40 pm     Reply with quote

Dear PCM programmer Thank you for your correction and advice.

Dear crystal_lattice: Thank you for your hint.

And dear SherpaDoug: the center aligned method minimize the EMI in addition to reducing the heat dissipation of the switching transistors (as per our machines specialist engineer).

Regards'
_________________
Hakam B Saffour
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jul 02, 2008 1:52 pm     Reply with quote

The following 18F PICs have built-in support for center-aligned PWM mode:
Quote:

18F2331/2431/4331/4431 (with some erratas)
18F1230/1330
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group