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


Browsing this Thread:   2 Anonymous Users






Re: 請問如何用PIC18F8722來打出SinPWM
#4
版主
版主


查看用戶資訊
加個 RC 濾波器後再看一下。
Sin0度的起始點應該是126 開始,126 ~255~126 為 0 度到180度的正半週; 126 ~ 0 ~126 為負半週 (180 度 ~ 0 度)
所以你的表要重建,不然無法輸出負半週。

發表於: 2007/8/7 15:06
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問如何用PIC18F8722來打出SinPWM
#3
新會員
新會員


查看用戶資訊
用示波器沒外加濾波器去看有類似SIN PWM的形狀
我指的是不曉得這樣的做法對不對..
因為我sin table只建了半週期
而且進入中斷的時間也是固定的10800Hz
不像用DSP由一組三角波與正弦波來決定high或low
所以感覺怪怪的

發表於: 2007/8/7 14:52
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問如何用PIC18F8722來打出SinPWM
#2
版主
版主


查看用戶資訊
你所謂怪怪的不像正玄波,有沒有PWM1的輸出外加RC濾波器?

發表於: 2007/8/7 14:38
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


請問如何用PIC18F8722來打出SinPWM
#1
新會員
新會員


查看用戶資訊
我想用PIC18來打出sinPWM
我的做法不知道對不對??
請高手給予一點指教
1.建立sin table(180度劃分成0-255)
2.載波頻率60Hz,所以中斷頻率60*180=10800Hz
3.PR2週期也設定約10800Hz
4.進中斷後依sintable丟Duty時間

這樣不知道對不對,感覺就是怪怪的
不像是一般的sinPWM

以下是我寫的程式,煩請指教一下

#include <p18f8722.h>
#include <timers.h>
#include <pwm.h>
#include <adc.h>
#pragma config OSC=HSPLL,PWRT=OFF,BOREN=OFF,BORV=2,WDT=OFF,LVP=OFF
#define TMR1_VAL 65535-926
//10799Hz
unsigned char per[180]={0, 4, 9, 13, 18, 22, 27, 31, 35, 40, 44, 49, 53, 57, 62, 66, 70, 75, 79, 83, 87, 91, 96, 100, 104, 108, 112, 116, 120, 124, 127, 131, 135, 139, 143, 146, 150, 153, 157, 160, 164, 167, 171, 174, 177, 180, 183, 186, 190, 192, 195, 198, 201, 204, 206, 209, 211, 214, 216, 219, 221, 223, 225, 227, 229, 231, 233, 235, 236, 238, 240, 241, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 253, 254, 254, 254, 255, 255, 255, 255, 255, 255, 255, 254, 254, 254, 253, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 241, 240, 238, 236, 235, 233, 231, 229, 227, 225, 223, 221, 219, 216, 214, 211, 209, 206, 204, 201, 198, 195, 192, 190, 186, 183, 180, 177, 174, 171, 167, 164, 160, 157, 153, 150, 146, 143, 139, 135, 131, 127, 124, 120, 116, 112, 108, 104, 100, 96, 91, 87, 83, 79, 75, 70, 66, 62, 57, 53, 49, 44, 40, 35, 31, 27, 22, 18, 13, 9, 4};
int i=0;

void timer1_isr (void);

#pragma code low_vector=0x18
void low_interrupt (void)
{
_asm goto timer1_isr _endasm
}
#pragma code
#pragma interruptlow timer1_isr

void timer1_isr (void)
{
PIR1bits.TMR1IF=0; //清除中斷旗標
WriteTimer1(TMR1_VAL); //寫入timer1預設值
CCPR1L=per[i];
i++;
if (i==180)
i=0;
}


void main(void)
{

//****I/O****
TRISCbits.TRISC2=0; //設定P1A輸出


//***PWM****
PR2 =230 ; //
T2CON =0b00000101; //開啟timer2
CCP1CON =0b00001100; //開啟ECCP1:單輸出
//**********

T1CON = 0b10001001; //設定timer1
PIE1bits.TMR1IE=1;
WriteTimer1(TMR1_VAL); //寫入timer1預設值
INTCONbits.PEIE=1;
INTCONbits.GIE=1;

while(1);
//End while
}//End main

發表於: 2007/8/7 14:26
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... ]

教育訓練中心

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