• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
  • slider image 488
  • slider image 491
:::


Browsing this Thread:   1 Anonymous Users






Re: 課程302 MCW的Lab5程式問題請教!
#2
版主
版主


查看用戶資訊
建議打個電話與台北FAE葛育中先生聯絡,他是這 MCLV 課程的專業講師。

發表於: 2008/6/20 14:55
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


課程302 MCW的Lab5程式問題請教!
#1
新會員
新會員


查看用戶資訊
關於課程302 MCW的Lab5程式問題請教!
我使用的實驗板是app0099跟igbt-ipm驅動電路,用來驅動200w額定轉速2500RPM極數為8極的無刷馬達
我有先用 lab 4 開迴路程式修改過相關IO設定 跑我的馬達 以可正常驅動!
我現在對Lab 5的程式定義有些問題想說拿出來討論一下 
因為目前跑Lab5 最高轉速沒有照設定的值跑出來
PID係數 我想說等我 最高 與 最低 轉速 都設定完成 再來調控
我把我認為會影響轉速更動的與原始程式貼上來
原始程式為

// Period Calculation
// Period = TMRClock * 6 / RPM
// For example>
// RPM = 6000 (Max Speed)
// Period = (20,000,000 / 64) * 6 / 6000 = 312.5
// RPM = 60 (Min Speed)
// Period = (20,000,000 / 64) * 6 / 60 = 31250
這程式設定最高6000rpm最低也不到60 可是接24V BLDC 實際測出的轉速為3000rpm最低為264rpm
上面的定義是不是有問題?
#define MINPERIOD 313 // For 6000 max rpm and 10 poles motor
#define MAXPERIOD 31250 // For 60 min rpm and 10 poles motor
#define MINABSSPEED 327
#define MAXABSSPEED 32663
#define SFloat_To_SFrac16(Float_Value) (((Float_Value) < 0.0) ? (SFRAC16)(32767 * (Float_Value) - 0.5) : (SFRAC16)(32768 * (Float_Value) + 0.5))
//這一行要更動嗎?
void __attribute__((__interrupt__)) _ADCInterrupt (void)
{
IFS0bits.ADIF = 0;
RefSpeed = (int)(((unsigned int)ADCBUF0) / 2);
//The A/D is using unsigned fraction format.
//Please refer to the user manual too see the detail.
//In this mode, the max A/D is around 65535 which is almost “2” for Q15 format. The PID loop is using Q15 format so the A/D need to be divided by 2 to fit the max limit which is 32767.
if (RefSpeed < 2000)
RefSpeed = 2000; //Q15(2000) = 2000/32768 = 0.061 6000 RPM a 1 0.061*6000RPM = 366 RPM

return;
}

void SixStepComm (int _Sector, int _Voltage)
{

if (_Voltage >= 0)
{

PDC1 = PDC2 = PDC3 = (unsigned int)_Voltage / 16;
//The Voltage is also Q15 format in which the maximum is 32767.
//So divided by 16 is to fit the PDC max value.
if (_Sector == -1)
OVDCON = 0x0000; else
OVDCON = StateLoTable[_Sector];
}
else
{
PDC1 = PDC2 = PDC3 = (unsigned int)(-(_Voltage+1)) / 16;
if (_Sector == -1)
OVDCON = 0x0000;
else
OVDCON = StateLoTable[(_Sector + 3) % 6];
}
return;

我更改為
//馬達為8級
//MINPERIOD 最大轉速設定為2500rpm
//(Timer 1 時脈) x 60/(最大轉速2500rpm) x (馬達級數)=(20,000,000/64)*60/[(2500rpm)*8]=938
//MAXPERIOD 最小轉速設定為150rpm
//(Timer 1 時脈) x 60/(最小轉速150rpm) x (馬達級數)=(20,000,000/64)*60/[(150rpm)x8]=15625

#define MINPERIOD 938
#define MAXPERIOD 15625
#define MINABSSPEED 950
#define MAXABSSPEED 15660

#define SFloat_To_SFrac16(Float_Value) (((Float_Value) < 0.0) ? (SFRAC16)(16384 * (Float_Value) - 0.5) : (SFRAC16)(16384 * (Float_Value) + 0.5)) //這行需要更改嗎?

void __attribute__((__interrupt__)) _ADCInterrupt (void)
{
IFS0bits.ADIF = 0;
RefSpeed = (int)(((unsigned int)ADCBUF0) / 4);
if (RefSpeed < 2000)
RefSpeed = 2000;
// Q15(2000) 2000/16384=0.122 2500*0.122=300 RPM
return;
}

void SixStepComm (int _Sector, int _Voltage)
{

if (_Voltage >= 0)
{

PDC1 = PDC2 = PDC3 = (unsigned int)_Voltage / 16;
//The Voltage is also Q15 format in which the maximum is 32767.
//So divided by 16 is to fit the PDC max value.
if (_Sector == -1)
OVDCON = 0x0000; else
OVDCON = StateLoTable[_Sector];
}
else
{
PDC1 = PDC2 = PDC3 = (unsigned int)(-(_Voltage+1)) / 16;
if (_Sector == -1)
OVDCON = 0x0000;
else
OVDCON = StateLoTable[(_Sector + 3) % 6];
}
return;

發表於: 2008/6/19 21:38
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... ]

教育訓練中心

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