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

論壇索引


Board index » All Posts (lxyz1127)




尋找 orange0915 前輩!!
#41
高級會員
高級會員


我想問ㄧ下前輩因為我現在的ad值進來會ㄧ直改變 所以我現在程式第一筆資料要放在A4第二筆後才放在A2裡
*A4=A2;意思就是*A4接收A2舊的資料 新的資料放入A2 我ㄧ直在測試指標部分好像有問題正在研究中!!不知道前輩能否給ㄧ下建言


//******************************************************
// calculate
//********************************************************
void calculate(int A2,int *A4)
{
int b;
int e,a;
a=1;
b=(A2-*A4);

e=b/a;
if(e>205) //10bit 1v=1023/5=205
{
RB1=0;
}
else
{
RB1=1;
}
*A4=A2;
}

//***************************************
//* Program Main ( ) *
//***************************************
void main(void)
{
int A4, temp,A2;
unsigned int j;
Init_IO();
Init_Adc();
while(1)
{

A2D(); // Get 10-bit A/D result from CH1
A4=temp; /temp is AD value
for(j=1;j<65534;j++)
{
A2=temp;

calculate(A2,&A4);
}
}
}

發表於: 2007/6/28 16:59
頂部


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


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

發表於: 2007/6/28 14:24
頂部


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


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

發表於: 2007/6/27 16:13
頂部


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


為何我只有輸入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
頂部


Re: 計算問題
#45
高級會員
高級會員


不好意思 我現在只有一個a/d的值 另一個為我設定

發表於: 2007/6/23 16:32
頂部


計算問題
#46
高級會員
高級會員


我現在用c寫了有關 於 e=p(n)-p(n-1)/v(n)-v(n-1)這樣的一個式子 因為我利用a/d的方式將資料放在我所設定的暫存器中(也就是p 和v的值)我利用了 *和&讓 新資料和舊資料相減但是我測試結果就是無法無預期 不知道有人有這樣經驗ㄇ?可以討論依下

#include <pic.h> // processor if/def file
#include "cnfig877a.h"
unsigned char i ;

//***************************
// A/D延遲
//*****************************
void ADdelay(unsigned char i)
{
while(i--);
}
//**********************************
//* Function Prototype Declaration
//**********************************
void Init_IO(void);
void Init_Adc_1( void );
void A2D_1(void);
void calculate(float A2, float *A4);

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

unit
int AD_10bit_1;
struct
{
char AD_LSB_1;
char AD_MSB_1;
}
AD_Byte_1;
}
AD_Int_1;

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

void Init_IO(void)
{
ADCON1=0b00000110; TRISD=0x00;
PORTD=0x80; TRISA0=1; }

/*****************************************
Initialize A/D & Comparator Module
******************************************/
void Init_Adc_1( void )
{
ADCON0=0b10000001; ADCON1=0b00000100; ADFM=1;
}


/***********************************
Convert A/D Channel
************************************/
void A2D_1(void )
{
float temp_1;
ADGO = 1;
while (ADGO) ;
AD_Int_1.AD_Byte_1.AD_MSB_1=ADRESH;
AD_Int_1.AD_Byte_1.AD_LSB_1=ADRESL;
temp_1= ADRESH *256+ ADRESL;
}
//*******************************************
// calculate
//*******************************************
void calculate(float A2, float *A4)
{

float a,b;
float e;
a=2;
b=(A2-*A4);
e=b/a;
if(e<0)
{
RB1=1;
}
else
{
RB1=0;
}
*A4=A2;
}





//***************************************
//* Program Main ( ) *
//***************************************
void main(void)
{
float A2, A4,temp_1;
unsigned int j;
Init_IO();

while(1)
{
Init_Adc_1();
ADdelay(2);
A2D_1();
A4=temp_1;


for( j=1; j<65535; j++)
{
A2=temp_1;
calculate(A2, &A4);

}
}
}

發表於: 2007/6/23 16:31
頂部


訊號問題???
#47
高級會員
高級會員


請問ㄧ下各位前輩:

我現在輸出產生的訊號一個週期內可能是high訊號可能是low的訊號 也有可能是ㄧ個週期都是high訊號也有可能都是low訊號 這樣方式不知道有前輩可以提供一下意見~~~(因為我輸出的訊號是要驅動升壓電路的mos晶體)

發表於: 2007/6/14 17:05
頂部


Re: 16f877a duty cycle問題??
#48
高級會員
高級會員


Thank~~~~

發表於: 2007/6/14 16:58
頂部


Re: pwm執行問題
#49
高級會員
高級會員


自己已經解決 thank~~~

發表於: 2007/6/12 13:34
頂部


Re: pwm執行問題
#50
高級會員
高級會員


請問ㄧ下您說的設定部份要從哪裡去設定阿???

發表於: 2007/6/12 13:13
頂部



« 1 2 3 4 (5) 6 7 8 »



:::

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

教育訓練中心

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