分為ratio & ratio + HSI
有HSI的對於天花板和地板陰影的誤判可以去除
但是也因此對於淡煙的偵測相對較弱(濃煙應較準確)
2008年8月11日 星期一
[關於vista下的com port]
最近朋友使用了c++寫rs232
要在NB上抓usb com port
可是有問題
後來上google msdn裡有人給了解答
原來是語法問題XD
用dotNet就沒有這個問題了
附記一下有用的網站
1.http://tldp.org/HOWTO/Serial-Programming-HOWTO/index.html
2.linux port
http://www.bigwebmaster.com/General/Howtos/IO-Port-Programming.html
要在NB上抓usb com port
可是有問題
後來上google msdn裡有人給了解答
原來是語法問題XD
用dotNet就沒有這個問題了
附記一下有用的網站
1.http://tldp.org/HOWTO/Serial-Programming-HOWTO/index.html
2.linux port
http://www.bigwebmaster.com/General/Howtos/IO-Port-Programming.html
2008年7月28日 星期一
2008年7月25日 星期五
安裝emesene取代爛爛的aMSN
Ubuntu如果是8.04的話就可以直接安裝:
sudo apt-get install emesene
但是如果版本比較前面的話就要將source list更新如下:
1. 將/etc/apt/sources.list 加入
deb http://apt.emesene.org/ ./
deb-src http://apt.emesene.org/ ./
2. 執行 sudo apt-get install emesene
OK!!
sudo apt-get install emesene
但是如果版本比較前面的話就要將source list更新如下:
1. 將/etc/apt/sources.list 加入
deb http://apt.emesene.org/ ./
deb-src http://apt.emesene.org/ ./
2. 執行 sudo apt-get install emesene
OK!!
2008年7月23日 星期三
8051 lab
lab1
===
寫個while loop 控制P3.5值不斷在 0、1間變化
-----------------------------------
lab2
===
UART設定:
SCON=0x50;
PCON = 0x80;
BRL = 126;
BDRCON = 0x1F;
手動加上下面:
Sfr (BDRCON , 0x92);
Sfr (BRL , 0x91);
-----------------------------------
lab3
學習使用interrupt 與 timer
init_INT: 設定interrupt 並將 keyboard interrupt啟動
init_INT0、init_INT1: 2個不同interval的timer
INTLED0: timer interrupt後將LED作開關動作
INTKeyBoard: keyboard 中斷事件
程式碼如下:
void init_INT()
{
IEN0=0x80;
IEN1=0x10;
KBCON=0x00;
}
void init_INT0()
{
TMOD = (TMOD & 0x0F) | 0x20; /* Set Mode (8-bit timer with reload) */
TH1 = 0; /* Reload TL1 to count 100 clocks */
TL1 = TH1;
ET1 = 1; /* Enable Timer 1 Interrupts */
TR1 = 1; /* Start Timer 1 Running */
EA = 1; /* Global Interrupt Enable */
}
void init_INT1()
{
TMOD = (TMOD & 0x0F) | 0x20;
TH1 = 100;
TL1 = TH1;
ET1 = 1;
TR1 = 1;
EA = 1;
}
void INTLED0 (void) interrupt 3
{
overflow_count++;
if(overflow_count==1000)
{
LED = !LED;
overflow_count =0;
}
}
void delay()
{
int i, j;
i=1000;
while(i!=0)
{
j=100;
while(j!=0)
{
j--;
}
i--;
}
}
void INTKeyBoard(void) interrupt 11 using 1
//使用11號中斷 //library為1
{
int recv = INPUT;
if(FUNC==INPUT)// && mode!=1)
{
ET1 = 0;
TR1 = 0;
init_INT0();
printu("Press FUNC\n");
}
else if(NEXT==INPUT)// && mode!=2)
{
LED = 0;
ET1 = 0;
TR1 = 0;
printu("Press NEXT\n");
}
else if(PREV==INPUT)// && mode!=3)
{
LED = 1;
ET1 = 0;
TR1 = 0;
printu("Press PREV\n");
}
else if(PLAY==INPUT)// && mode!=4)
{
ET1 = 0;
TR1 = 0;
init_INT1();
printu("Press PLAY\n");
}
KBSTA = 0x00;
delay();
}
-----------------------------------
lab4
重點在於必須看懂pdf檔裡面的時序圖
下面是lab4所要加上的code:
void ReadFlashID(unsigned char *MID,unsigned char *DID)
{
K9F_FUN = COMMAND;
K9F5608 = 0x90;
K9F_FUN = ADDRESS;
K9F5608 = 0x00;
K9F_FUN = D_DATA;
*MID = K9F5608;
*DID = K9F5608;
while(!(K9F_FUN & RB));
K9F_FUN = INACTIVE;
}
void ReadPage(unsigned int BlockPage,unsigned char *PageBuf)
{
unsigned int data i;
K9F_FUN = COMMAND;
K9F5608 = 0x00;
K9F_FUN = ADDRESS;
K9F5608 = 0x00;
K9F5608 = BlockPage;
K9F5608 = BlockPage>>8;
K9F_FUN = D_DATA;
i=512;
while(!(K9F_FUN & RB));
while(i--)
*PageBuf++ = K9F5608;
K9F_FUN = D_DATA;
K9F_FUN = INACTIVE;
}
void BlockErase(unsigned int BlockPage)
{
K9F_FUN = COMMAND;
K9F5608 = 0x60;
K9F_FUN = ADDRESS;
// K9F5608 = 0; //A0-A7
K9F5608 = BlockPage; //A9-A16
K9F5608 = BlockPage >> 8; //A17-A24
// K9F_FUN = D_DATA;
K9F_FUN = COMMAND;
K9F5608 = 0xD0;
K9F_FUN = D_DATA;
while(!(K9F_FUN & RB));
K9F_FUN = COMMAND;
K9F5608 = 0x70;
if(K9F5608==0) printu("Block Erase successful\n");
else printu("Block Erase failed\n");
K9F_FUN = INACTIVE;
}
===
寫個while loop 控制P3.5值不斷在 0、1間變化
-----------------------------------
lab2
===
UART設定:
SCON=0x50;
PCON = 0x80;
BRL = 126;
BDRCON = 0x1F;
手動加上下面:
Sfr (BDRCON , 0x92);
Sfr (BRL , 0x91);
-----------------------------------
lab3
學習使用interrupt 與 timer
init_INT: 設定interrupt 並將 keyboard interrupt啟動
init_INT0、init_INT1: 2個不同interval的timer
INTLED0: timer interrupt後將LED作開關動作
INTKeyBoard: keyboard 中斷事件
程式碼如下:
void init_INT()
{
IEN0=0x80;
IEN1=0x10;
KBCON=0x00;
}
void init_INT0()
{
TMOD = (TMOD & 0x0F) | 0x20; /* Set Mode (8-bit timer with reload) */
TH1 = 0; /* Reload TL1 to count 100 clocks */
TL1 = TH1;
ET1 = 1; /* Enable Timer 1 Interrupts */
TR1 = 1; /* Start Timer 1 Running */
EA = 1; /* Global Interrupt Enable */
}
void init_INT1()
{
TMOD = (TMOD & 0x0F) | 0x20;
TH1 = 100;
TL1 = TH1;
ET1 = 1;
TR1 = 1;
EA = 1;
}
void INTLED0 (void) interrupt 3
{
overflow_count++;
if(overflow_count==1000)
{
LED = !LED;
overflow_count =0;
}
}
void delay()
{
int i, j;
i=1000;
while(i!=0)
{
j=100;
while(j!=0)
{
j--;
}
i--;
}
}
void INTKeyBoard(void) interrupt 11 using 1
//使用11號中斷 //library為1
{
int recv = INPUT;
if(FUNC==INPUT)// && mode!=1)
{
ET1 = 0;
TR1 = 0;
init_INT0();
printu("Press FUNC\n");
}
else if(NEXT==INPUT)// && mode!=2)
{
LED = 0;
ET1 = 0;
TR1 = 0;
printu("Press NEXT\n");
}
else if(PREV==INPUT)// && mode!=3)
{
LED = 1;
ET1 = 0;
TR1 = 0;
printu("Press PREV\n");
}
else if(PLAY==INPUT)// && mode!=4)
{
ET1 = 0;
TR1 = 0;
init_INT1();
printu("Press PLAY\n");
}
KBSTA = 0x00;
delay();
}
-----------------------------------
lab4
重點在於必須看懂pdf檔裡面的時序圖
下面是lab4所要加上的code:
void ReadFlashID(unsigned char *MID,unsigned char *DID)
{
K9F_FUN = COMMAND;
K9F5608 = 0x90;
K9F_FUN = ADDRESS;
K9F5608 = 0x00;
K9F_FUN = D_DATA;
*MID = K9F5608;
*DID = K9F5608;
while(!(K9F_FUN & RB));
K9F_FUN = INACTIVE;
}
void ReadPage(unsigned int BlockPage,unsigned char *PageBuf)
{
unsigned int data i;
K9F_FUN = COMMAND;
K9F5608 = 0x00;
K9F_FUN = ADDRESS;
K9F5608 = 0x00;
K9F5608 = BlockPage;
K9F5608 = BlockPage>>8;
K9F_FUN = D_DATA;
i=512;
while(!(K9F_FUN & RB));
while(i--)
*PageBuf++ = K9F5608;
K9F_FUN = D_DATA;
K9F_FUN = INACTIVE;
}
void BlockErase(unsigned int BlockPage)
{
K9F_FUN = COMMAND;
K9F5608 = 0x60;
K9F_FUN = ADDRESS;
// K9F5608 = 0; //A0-A7
K9F5608 = BlockPage; //A9-A16
K9F5608 = BlockPage >> 8; //A17-A24
// K9F_FUN = D_DATA;
K9F_FUN = COMMAND;
K9F5608 = 0xD0;
K9F_FUN = D_DATA;
while(!(K9F_FUN & RB));
K9F_FUN = COMMAND;
K9F5608 = 0x70;
if(K9F5608==0) printu("Block Erase successful\n");
else printu("Block Erase failed\n");
K9F_FUN = INACTIVE;
}
MCU lab1 & lab2
lab1
修改 WAP_LCD.c 檔
找到func LCD_DAT_W_Timing
將 RW 設為 0
在lab2 中把溫度傳回RS232
----------------------------------
使用 WriteUSART(char);
後面要加delay不然會太快
itoa(T2_Buffer,ASCII_String);
Write1USART( ASCII_String[0] );
LCD_S_Delay();
LCD_S_Delay();
LCD_S_Delay();
//itoa(T2_Buffer,ASCII_String);
Write1USART( ASCII_String[1] );
LCD_S_Delay();
LCD_S_Delay();
LCD_S_Delay();
//itoa(T2_Buffer,ASCII_String);
Write1USART( ASCII_String[2] );
LCD_S_Delay();
LCD_S_Delay();
LCD_S_Delay();
在VB裡面的 Timer要在屬性裡面將interval設為20
MSComm 設定 輸入長度為 1
修改 WAP_LCD.c 檔
找到func LCD_DAT_W_Timing
將 RW 設為 0
在lab2 中把溫度傳回RS232
----------------------------------
使用 WriteUSART(char);
後面要加delay不然會太快
itoa(T2_Buffer,ASCII_String);
Write1USART( ASCII_String[0] );
LCD_S_Delay();
LCD_S_Delay();
LCD_S_Delay();
//itoa(T2_Buffer,ASCII_String);
Write1USART( ASCII_String[1] );
LCD_S_Delay();
LCD_S_Delay();
LCD_S_Delay();
//itoa(T2_Buffer,ASCII_String);
Write1USART( ASCII_String[2] );
LCD_S_Delay();
LCD_S_Delay();
LCD_S_Delay();
在VB裡面的 Timer要在屬性裡面將interval設為20
MSComm 設定 輸入長度為 1
訂閱:
文章 (Atom)