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


Browsing this Thread:   1 Anonymous Users






Re: 各位前輩幫幫忙提供一下意見???
#5
高級會員
高級會員


查看用戶資訊
非常感謝前輩的提供意見我已經照你的方式下去測試已經ok~~~~  謝謝!!!

發表於: 2007/6/28 14:24
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 各位前輩幫幫忙提供一下意見???
#4
中級會員
中級會員


查看用戶資訊
你的程式if else是正常的啊?應該是你產生Hi-Low條件的
問題吧?依你現在程式條件看來,確實是0V才會Hi,不知
你要電壓多少為Hi,多少為Low?
假設AD使用8bit,AD範圍是0-255;AD使用10bit,則AD
範圍是0-1023,所以你可能要換算多少電壓要Hi或Low。
以8bitAD,0-5V來換算AD值,每1v至少也間隔51 AD值
255/5=51,所以你條件只設2,一定是0V才會Hi,這樣了嗎?

發表於: 2007/6/28 8:45
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 各位前輩幫幫忙提供一下意見???
#3
高級會員
高級會員


查看用戶資訊
想請問一下那我這裡需要怎改法才有辦法如我程式 IF ELSE
產生HI LOW 值

發表於: 2007/6/27 16:13
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 各位前輩幫幫忙提供一下意見???
#2
中級會員
中級會員


查看用戶資訊
從你的程式看來,e=b=A4=temp=AD值, 所以
calculate()中,只有0V時轉換後的AD值會小於2,
其餘都大於2,了嗎?

發表於: 2007/6/27 15:39
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


各位前輩幫幫忙提供一下意見???
#1
高級會員
高級會員


查看用戶資訊
為何我只有輸入0v的電壓才有HI的輸出電壓 可以提供我意見ㄇ???


#include <pic.h>
#include "cnfig877a.h"

void ADdelay(unsigned char i)
{
while(i--);
}

//**********************************
//* Function Prototype Declaration
//**********************************
void Init_IO(void);
void Init_Adc( void );
void A2D(void);
void calculate(void);

// ================================================================
// **** 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 );

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

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; TRISD=0x00; PORTD=0x80; TRISA1=1;
TRISB1=0;

}

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

void Init_Adc( void )
{
ADCON0=0b10001001; ADCON1=0b00000000;
ADFM=1; }
/***********************************
Convert A/D Channel
************************************/

void A2D( void )
{
int temp;
ADGO = 1; while (ADGO) ; AD_Int.AD_Byte.AD_MSB=ADRESH;
AD_Int.AD_Byte.AD_LSB=ADRESL;
temp= ADRESH *256+ ADRESL;
}
//******************************************************
// calculate
//********************************************************
void calculate(void)
{
int b,A4;
int e,a;
a=1;
b=A4;

e=b/a;
if(e>=2)
{
RB1=0;
}
else
{
RB1=1;
}

}

//***************************************
//* Program Main ( ) *
//***************************************
void main(void)
{
int A4, temp;

Init_IO();
Init_Adc();
while(1)
{

A2D(); // Get 10-bit A/D result from CH1
A4=temp;
calculate();
}
}

發表於: 2007/6/26 22:58
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... ]

教育訓練中心

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