• 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: 請求指導
#4
資深會員
資深會員


查看用戶資訊
顯示內容如果變動很大的話 建議0.5 秒再更新一次
一因為 LCD 的反應似乎很慢 ( SDEC 2E16D 的經驗 )
如電壓提高一點 反應時間感覺上會快一點(當然不要超過 SPEC )

發表於: 2007/5/12 2:14
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請求指導
#3
版主
版主


查看用戶資訊
如果是 LCD 亮度在閃動代表 Update LCD 的速度太頻繁,可以考慮每 100mS 去寫一次 LCD。

如果是ADC的數值在跳動,那就是 AD 轉換有干擾,取平均值看看。

發表於: 2007/5/10 14:20
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請求指導
#2
高級會員
高級會員


查看用戶資訊
我已經了解啦 但是不知道為何我的輸入用電池的電壓但是LCD的值卻ㄧ直跳動 那是怎回事呢

發表於: 2007/5/7 22:08
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


請求指導
#1
高級會員
高級會員


查看用戶資訊


#include <pic.h> / processor if/def file
#include "cnfig877a.h"
#include "mid_lcd.h"

//**********************************
//* Function Prototype Declaration
//**********************************
void Init_IO(void);
void Init_Adc( void );
void A2D( unsigned char );
void LCD_ItoA(unsigned int);
unsigned char Set_BCD_ASCII(unsigned char);

// ================================================================
// **** Establish PIC16F877A Configuration Word
// **** == HS Oscillator Mode
// **** == Brown-Out Detect Enabled
// **** == Watch-Dog Timer Off
// **** == Code Protect Off
// **** == Low Voltage Programming Off
// **** == ICD2 Debug Mode On

__CONFIG ( HS_OSC & BODEN_ON & WDT_OFF & CP_OFF & LVP_OFF & DEBUG_ON );

// =================================================================


const char LCD_Msg1[]=" A/D Result: ";
const char LCD_Msg2[]=" MSB: LSB: ";

unsigned int AD_Temp;
bit DS_Zero_Flag;

union {
int AD_10bit;
struct {
char AD_LSB;
char AD_MSB;
}AD_Byte;
}AD_Int;


/*****************************
INITIALIZE I/O PORT
*****************************/

void Init_IO(void)
{
ADCON1=0b00000110; // Disable A/D Function
TRISD=0x00; // Set PortD for Output
PORTD=0x80; // Initila LED display = 0x80
TRISA0=1; // Set SW2 for input
//TRISE1=1; // Set SW6 for Input
}


/*****************************************
Initialize A/D & Comparator Module
******************************************/

void Init_Adc( void )
{
CMCON=0b000000111; // Analog comparator disable
ADCON1=0b00001110; // AN0 is A/D input
ADFM=1; // Right justified
ADCON0=0b10000001; // Selext CH0 , A/D on
}

/***********************************
Convert A/D Channel
************************************/

void A2D( unsigned char channel )
{
unsigned char temp; // Temp storage

temp = channel << 3; // Shift channel value three bits left
ADCON0 &= 0b11000111; // Clear channel select bits in ADCON0
ADCON0 |= temp; // Logically OR shifted channel value into place in ADCON0

ADGO = 1; // Initiate conversion on selected channel
while (ADGO) ; // Poll ADGO bit until it clears, indicating conv. done
AD_Int.AD_Byte.AD_MSB=ADRESH;
AD_Int.AD_Byte.AD_LSB=ADRESL;
}

//***************************************
//* Program Main ( ) *
//***************************************
void main(void)
{
Init_IO();
Init_Adc();
OpenLCD();
LCD_Set_Cursor(0,0);
putrsLCD(LCD_Msg1);
LCD_Set_Cursor(0,1);
putrsLCD(LCD_Msg2);

while(1)
{
A2D(0x00); // Get 10-bit A/D result from CH0
LCD_Set_Cursor(12,0);
LCD_ItoA(AD_Int.AD_10bit);
LCD_Set_Cursor(6,1);
puthexLCD(AD_Int.AD_Byte.AD_MSB);
LCD_Set_Cursor(13,1);
puthexLCD(AD_Int.AD_Byte.AD_LSB);
}

}

void LCD_ItoA(unsigned int AD_Data)
{
AD_Temp=AD_Data;
DS_Zero_Flag=1;

putcLCD(Set_BCD_ASCII(AD_Data/1000)); // 顯示千位數
AD_Temp=AD_Temp%1000; // 取出百位以後的數

putcLCD(Set_BCD_ASCII(AD_Temp/100)); // 顯示百位數
AD_Temp=AD_Temp%100;

putcLCD(Set_BCD_ASCII(AD_Temp/10)); // 顯示十位數
AD_Temp=AD_Temp%10;

putcLCD(AD_Temp+='0'); // 顯示個位數
}

unsigned char Set_BCD_ASCII(unsigned char BCD_Data)
{
if (BCD_Data==0)
{
if (DS_Zero_Flag) return ' '; // 居先零抑制
else return '0'; // 顯示一般的零
}
else
{
DS_Zero_Flag=0; // 取消居先零的抑制
return (BCD_Data +='0'); // 並傳回 ASCII Code
}
}


我想請問一下 這是MICROCHIP的範例 但是我不了解他的類比輸入的部分次從哪裡ㄚ 還是說他是內建的 因為我現在要改成外部輸入 但依職看不懂 可以指導我一下 >>>



發表於: 2007/5/7 20:53
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... ]

教育訓練中心

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