View previous topic :: View next topic |
Author |
Message |
hakam_saffour
Joined: 14 May 2008 Posts: 13 Location: Germany
|
Center Lined PWM |
Posted: Tue Jul 01, 2008 2:57 am |
|
|
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
|
|
Posted: Wed Jul 02, 2008 2:09 am |
|
|
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
|
|
Posted: Wed Jul 02, 2008 2:44 am |
|
|
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
|
|
Posted: Wed Jul 02, 2008 2:56 am |
|
|
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
|
|
Posted: Wed Jul 02, 2008 3:20 am |
|
|
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
|
|
Posted: Wed Jul 02, 2008 8:26 am |
|
|
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
|
|
Posted: Wed Jul 02, 2008 12:40 pm |
|
|
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
|
|
Posted: Wed Jul 02, 2008 1:52 pm |
|
|
The following 18F PICs have built-in support for center-aligned PWM mode:
Quote: |
18F2331/2431/4331/4431 (with some erratas)
18F1230/1330 |
|
|
|
|