Re: 程式請教
|
||||
---|---|---|---|---|
初級會員
|
我明白了!
謝謝您詳細的說明 ^^ 我再嘗試看看
發表於: 2009/4/8 12:12
|
|||
|
Re: 程式請教
|
||||
---|---|---|---|---|
初級會員
|
TO:jason680
為何兩者要減RPM1 是跟啥有關? 謝謝!
發表於: 2009/4/8 9:19
|
|||
|
Re: 程式請教
|
||||
---|---|---|---|---|
初級會員
|
TO:OuO
如果要做PID控制 那以您這樣的敘訴可以嗎? 不是要命令和迴授相減才對?
發表於: 2009/4/8 9:16
|
|||
|
請問.....
|
||||
---|---|---|---|---|
初級會員
|
捕捉頻率和PWM duty兩個訊號
可同時使用同一個timer嗎?
發表於: 2009/4/6 17:06
|
|||
|
Re: 如何計算timer的值
|
||||
---|---|---|---|---|
初級會員
|
那麼同時捕捉頻率和PWM duty兩個訊號
可同時使用同一個timer嗎?
發表於: 2009/4/6 14:53
|
|||
|
如何計算timer的值
|
||||
---|---|---|---|---|
初級會員
|
FCY 7372800 * 2
OpenTimer1( T1_ON & T1_IDLE_STOP & T1_GATE_OFF & // Timer1 的 Period 設為每 200 ms T1_PS_1_64 & T1_SYNC_EXT_OFF & T1_SOURCE_INT , (long)((FCY/ 1000)* 200 )/64 ) ; 怎麼計算Timer1的Period為200ms? 我算過(((7372800x2)/1000)*200)/64)=46080 1/46080=0.217us 這樣的設定有什麼功能?
發表於: 2009/4/2 16:22
|
|||
|
如何學好控制器?
|
||||
---|---|---|---|---|
初級會員
|
想用dsPIC30f4011
寫一個迴授與基準比較然後輸出調節PWM的功能 但無奈我是初學者 很多事都剛起步 想請問各位 大家是如何學好控制器 並且利用它來完成想要的功能 觀念是什麼?重點在哪?必須知道哪些事? 當初大家在學控制器時,有沒有遇到什麼困難? 還有當語法錯誤時,該如何解決?(我是用C語言) 唉~有點灰心...T_T
發表於: 2009/4/1 16:02
|
|||
|
Re: 輸入捕捉
|
||||
---|---|---|---|---|
初級會員
|
那他的範例程式該如何修改?
我有試著去改,但一直都改不出來 == define __dsPIC30F4011__ #include <p30F4011.h> #include "C30EVM_LCD.h" // 將函式的原型宣告檔案含入 #include <timer.h> #include <InCap.h> #define FCY 7372800 * 2 // 因為使用頻率為將外部 7.3728 MHz * 8 的模式 , 每一指令週期需 4 個 clock // 所以 FCY = (7.3728 * 8 / 4 ) MHz = 7372800* 2 _FOSC(CSW_FSCM_OFF & XT_PLL8); // XT with 8xPLL oscillator, Failsafe clock off _FWDT(WDT_OFF); // Watchdog timer disabled _FBORPOR(PBOR_OFF & MCLR_EN); // Brown-out reset disabled, MCLR reset enabled _FGS(CODE_PROT_OFF); // Code protect disabled const char My_String1[]=" Capture" ; // 宣告字串於 Program Memory const char My_String2[]="Duty Cycle: %" ; // 宣告字串於 Data Memory void uitoa( unsigned char * , unsigned int ) ; int Interrupt_Count = 0 , Int_flag; unsigned int timer_edge[4]; unsigned char phase, phase2, phase3, Convert_Buf[10]; void _ISR _IC7Interrupt(void) { Interrupt_Count++; switch(Interrupt_Count) // 根據輸入捕捉的次數決定執行的動作 { case(1): // 第一次,儲存訊號的電位狀態 phase = PORTBbits.RB4 ; break; case(2): // 第二次,儲存訊號的電位狀態 phase2 = PORTBbits.RB4 ; break; case(3): ReadCapture7(timer_edge); // 第三次,將所有的輸入捕捉暫存器數值讀出 phase3 = PORTBbits.RB4 ; // 並儲存訊號的電位狀態 break; } Int_flag = 1; IFS1bits.IC7IF = 0; } int main(void) { unsigned int period1, period2; unsigned int duty; ADPCFG = 0xffff; // Set All Analog Pins as Digital IO OpenLCD( ) ; // 使用 OpenLCD( )對 LCD 模組作初始化設定 // 4 bits Data mode // 5 * 7 Character setcurLCD(0,0) ; // 使用 setcurLCD( ) 設定游標於 (0,0) putrsLCD( My_String1 ) ; // 將存在 Program Memory 的字串使用 // putrsLCD( ) 印出至 LCD setcurLCD(0,1) ; putrsLCD( My_String2 ) ; // 使用 setcurLCD( ) 設定游標於 (0,1) // 將存在 Data Memory 的字串使用 // putsLCD( ) 印出至 LCD T3CON = 0x8000; /* Timer 3 On */ /* Configure the InputCapture in stop in idle mode , Timer 3 as source , interrupt on capture 1, I/C on every edge */ OpenCapture7(IC_IDLE_STOP & IC_TIMER3_SRC & IC_INT_1CAPTURE & IC_EVERY_EDGE); /* Enable Timer1 Interrupt and Priority to '1' */ ConfigIntCapture7(IC_INT_PRIOR_7 & IC_INT_ON); Int_flag = 0; while(1) { while(!Int_flag); /* wait here till first capture event */ Int_flag = 0; while(!Int_flag); /* wait here till next capture event */ Int_flag = 0; while(!Int_flag); /* wait here till last capture event */ DisableIntIC7; Int_flag = 0; /* calculate time count between two capture events */ if( timer_edge[1] >= timer_edge[0]) period1 = timer_edge[1] - timer_edge[0]; else period1 = 65536 + timer_edge[1] - timer_edge[0]; /* calculate time count between two capture events */ if( timer_edge[2] >= timer_edge[1]) period2 = timer_edge[2] - timer_edge[1]; else period2 = 65536 + timer_edge[2] - timer_edge[1]; if (phase) duty = 100*((float)period1/(period1+period2)); else duty = 100*((float)period2/(period1+period2)); uitoa ( Convert_Buf , duty ) ; setcurLCD(12,1) ; putrsLCD( " " ) ; setcurLCD(12,1) ; putsLCD( Convert_Buf ) ; Interrupt_Count = 0; IFS1bits.IC7IF = 0; ReadCapture7(timer_edge); EnableIntIC7; } CloseCapture7(); } void uitoa( unsigned char *ASCII_Buf , unsigned int IntegerValue ) { unsigned int TempValue ; unsigned char ZeroDisable ; unsigned int BaseQty ; unsigned int Loop ; ZeroDisable = 1 ; BaseQty = 10000 ; for ( Loop = 0 ; Loop < 4 ; Loop ++) { TempValue = IntegerValue / BaseQty ; if ( TempValue > 0) { *ASCII_Buf++ = (unsigned char)TempValue + '0' ; ZeroDisable = 0 ; } else if ( ZeroDisable == 0 ) *ASCII_Buf++ = '0' ; IntegerValue = IntegerValue - ( TempValue * BaseQty ) ; BaseQty = BaseQty / 10 ; } *ASCII_Buf++ = (unsigned char)IntegerValue + '0' ; *ASCII_Buf = (unsigned char) 0x00 ; }
發表於: 2009/3/30 18:59
|
|||
|
輸入捕捉
|
||||
---|---|---|---|---|
初級會員
|
請問使用輸入捕捉模組
要捕捉到 PWM duty cycle 0.1% 的變化 而且可以顯示到LCD上 該如何寫程式 我使用的是dsPIC30F4011 APP020的板子 我有買曾百由老師寫的書 跑了範例程式 但它沒有顯示到0.1%的變化 我試著改它的程式 但始終改不出來 請問各位高手 我該如何修改呢?
發表於: 2009/3/30 11:11
|
|||
|