• slider image 514
  • slider image 516
  • slider image 517
  • slider image 518
  • slider image 519
:::


Browsing this Thread:   1 Anonymous Users






Re: 如何使用30F4011的PWM
#3
新會員
新會員


查看用戶資訊
真的真的太感謝您了~~~~原來除了使用dspic30f4011的pwm內定的time中斷之外.原來還要多設一組time中斷 .我會去試試看.感嗯啊...果然是高手,我已經了解了,謝謝啊!!

發表於: 2008/7/6 21:01
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 如何使用30F4011的PWM
#2
新會員
新會員


查看用戶資訊
通常以馬達控制而言

需以PWM 中斷設定為最高優先權

因此 如果以 call delay 方式

來當作時間延遲控制方法是錯誤的

需要再設定一組較低優先權的TIMER

當作COUNTER BASE 因此 

整個正反轉控制方式 會變成:

假定 PWM period = 10khz.

0.3 sec = 300 ms

假定設定 timer1 = 1ms  中斷

那麼當 timer1 內部變數記數300 之後 

改變PWM 輸出狀態

===========

如果使用 call delay 方式  你會發現

你的CPU 無法再做其他的事情了

因為所有的資源都在記數 delay counter.

所以 假想你的程式 應該會變成

先使PWM 輸出 之后 call delay

 然後馬達就無法控制了 也無法改變PWM duty.

因為所有的資源都在記數 delay counter.
_______________________________

如果要做到馬達有運轉順暢效果 

還要做電流感測補償 改變PWM DUTY

這樣才能夠做到 較精確的控制

直流馬達 實際上容易做到 轉矩輸出控制


發表於: 2008/7/4 0:00
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


如何使用30F4011的PWM
#1
新會員
新會員


查看用戶資訊
各位大大好:
我是個PIC新手,想請問有關曾百由老師的PWM程式.
我應用在直流馬達上.當pwm輸出0.3s後.反轉pwm的相位再0.3s .重複動作. 使用1組pwm腳位: PWM1H(PIN37) & PWM1L(PIN36)...
我是用兩組PWM.PWM1程式來做正反轉 . 因為我用這樣去試 . 一直無法做正反轉 . 而且只會跑單一方向 .改了很多次. 都做不出來 .

int main(void) //主程式開始
{
ADPCFG=0xFFFF;
while(1)
{
if(flag_a==0) //旗標判斷
{
Init_MCPWM( ); //呼叫PWM.

for (i=0;i<200;i++) //延遲時間
for(j=0;j<100;j++)
flag_a=1; //跑完0.3s. 設定為1
;
}
else
{
Init_MCPWM1( );} //呼叫PWM1
for (i=0;i<200;i++) //延遲時間
for(j=0;j<100;j++)
flag_a=0; //跑完0.3s. 設定為0 ;
}

}
以上就為主程式的迴圈
下面為PWM的設定.就是照著曾老師的程式修改而已

//*******************************************
//*與 MCPWM1() 相同 .只有改變 dutycycle的數值 使其輸出剛好相反. *****
//*******************************************
void Init_MCPWM(void)
{
/* Holds the PWM interrupt configuration value*/
unsigned int config;

/* Holds the value to be loaded into dutycycle register */
unsigned int period;

/* Holds the value to be loaded into special event compare register */
unsigned int sptime;

/* Holds PWM configuration value */
unsigned int config1;

/* Holds the value be loaded into PWMCON1 register */
unsigned int config2;

/* Holds the value to configure the special event trigger postscale and dutycycle */
unsigned int config3;

/* The value of ‘dutycyclereg’ determines the duty cycle register(PDCx) to be written */
unsigned int dutycyclereg;
unsigned int dutycycle;
unsigned char updatedisable;

/* Configure pwm interrupt enable/disable and set interrupt priorties */

config = (PWM_INT_DIS & PWM_FLTA_DIS_INT & PWM_INT_PR1& PWM_FLTA_INT_PR0);
ConfigIntMCPWM( config );

/* Configure PWM to generate square wave of 50% duty cycle */
dutycyclereg = 1;

dutycycle = 0x0059;

updatedisable = 0;
SetDCMCPWM(dutycyclereg,dutycycle,updatedisable);

period = 0x002e;
sptime = 0x0;
DTCON1=0x00f;

config1 = (PWM_EN & PWM_IDLE_STOP & PWM_OP_SCALE16
& PWM_IPCLK_SCALE16 &PWM_MOD_UPDN);

config2 = (PWM_MOD1_COMP &PWM_PDIS3H & PWM_PDIS2H & PWM_PEN1H &
PWM_PDIS3L & PWM_PDIS2L & PWM_PEN1L);

config3 = (PWM_SEVOPS1 & PWM_OSYNC_PWM & PWM_UEN);

OpenMCPWM(period,sptime,config1,config2,config3);

}

//*****************************************************************************
//********** 與 MCPWM() 相同 .只有改變 dutycycle的數值 使其輸出剛好相反. *****
//*****************************************************************************
void Init_MCPWM1(void)
{
/* Holds the PWM interrupt configuration value*/
unsigned int config;

/* Holds the value to be loaded into dutycycle register */
unsigned int period;

/* Holds the value to be loaded into special event compare register */
unsigned int sptime;

/* Holds PWM configuration value */
unsigned int config1;

/* Holds the value be loaded into PWMCON1 register */
unsigned int config2;

/* Holds the value to configure the special event trigger postscale and dutycycle */
unsigned int config3;

/* The value of ‘dutycyclereg’ determines the duty cycle register(PDCx) to be written */
unsigned int dutycyclereg;
unsigned int dutycycle;
unsigned char updatedisable;

/* Configure pwm interrupt enable/disable and set interrupt priorties */
config = (PWM_INT_DIS & PWM_FLTA_DIS_INT & PWM_INT_PR1
& PWM_FLTA_INT_PR0);

ConfigIntMCPWM( config );

/* Configure PWM to generate square wave of 50% duty cycle */
dutycyclereg = 1;

dutycycle = 0x0003;
updatedisable = 0;
SetDCMCPWM(dutycyclereg,dutycycle,updatedisable);

period = 0x002b;
sptime = 0x0;
DTCON1=0x000f;


config1 = (PWM_EN & PWM_IDLE_STOP & PWM_OP_SCALE16& PWM_IPCLK_SCALE16 &PWM_MOD_UPDN);

config2 = (PWM_MOD1_COMP &PWM_PDIS3H & PWM_PDIS2H & PWM_PEN1H &PWM_PDIS3L & PWM_PDIS2L & PWM_PEN1L);

config3 = (PWM_SEVOPS1 & PWM_OSYNC_PWM & PWM_UEN);

OpenMCPWM(period,sptime,config1,config2,config3);
}
基本上PWM與PWM1的程式都是照著曾老師的程式做修改.想說先試著修改程式人後能更深入了解應用.馬達單一方向的都OK.但是要做更改轉向就不行...請各位大大可以跟我說是我邏輯有錯嗎?還是PWM可以不可以用迴圈的方式設定延遲時間嗎 ?謝謝~!感恩

發表於: 2008/6/29 21:27
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------