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

論壇索引


Board index » All Posts (hello074)




Re: 程式請教
#11
初級會員
初級會員


我明白了!

謝謝您詳細的說明 ^^

我再嘗試看看

發表於: 2009/4/8 12:12
頂部


Re: 程式請教
#12
初級會員
初級會員


TO:jason680

為何兩者要減RPM1

是跟啥有關?

謝謝!

發表於: 2009/4/8 9:19
頂部


Re: 程式請教
#13
初級會員
初級會員


TO:OuO

如果要做PID控制

那以您這樣的敘訴可以嗎?

不是要命令和迴授相減才對?

發表於: 2009/4/8 9:16
頂部


程式請教
#14
初級會員
初級會員


如下程式

我將命令轉速(RPM1)和實際轉速(RPM2)作迴授比較

進而控制PWM duty

我設定命令轉速小於實際轉速

然而在跑程式時

其狀態都處在OC1RS=588.8

不是應該會執行OC1RS=147.2這行才對嗎?

我有注意到溢位的情形

請問,我的程式哪行敘訴有錯?

謝謝!

if((RPM1-RPM2)<RPM1)
OC1RS=588.8;
else if ((65536+(RPM1-RPM2))>(65536-RPM1))
OC1RS=147.2;

發表於: 2009/4/7 18:43
頂部


請問.....
#15
初級會員
初級會員


捕捉頻率和PWM duty兩個訊號

可同時使用同一個timer嗎?

發表於: 2009/4/6 17:06
頂部


Re: 如何計算timer的值
#16
初級會員
初級會員


那麼同時捕捉頻率和PWM duty兩個訊號

可同時使用同一個timer嗎?

發表於: 2009/4/6 14:53
頂部


如何計算timer的值
#17
初級會員
初級會員


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
頂部


如何學好控制器?
#18
初級會員
初級會員


想用dsPIC30f4011

寫一個迴授與基準比較然後輸出調節PWM的功能

但無奈我是初學者

很多事都剛起步

想請問各位

大家是如何學好控制器

並且利用它來完成想要的功能

觀念是什麼?重點在哪?必須知道哪些事?

當初大家在學控制器時,有沒有遇到什麼困難?

還有當語法錯誤時,該如何解決?(我是用C語言)

唉~有點灰心...T_T

發表於: 2009/4/1 16:02
頂部


Re: 輸入捕捉
#19
初級會員
初級會員


那他的範例程式該如何修改?

我有試著去改,但一直都改不出來 ==

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
頂部


輸入捕捉
#20
初級會員
初級會員


請問使用輸入捕捉模組

要捕捉到 PWM duty cycle 0.1% 的變化

而且可以顯示到LCD上

該如何寫程式

我使用的是dsPIC30F4011 APP020的板子

我有買曾百由老師寫的書

跑了範例程式

但它沒有顯示到0.1%的變化

我試著改它的程式

但始終改不出來

請問各位高手

我該如何修改呢?

發表於: 2009/3/30 11:11
頂部



« 1 (2) 3 »



:::

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... ]

教育訓練中心

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