|
本帖最後由 antlu 於 2013-6-14 01:54 AM 編輯
最近除了忙家務之外,就是想要完成 電源供應器, 使用 LM317 作一個 15V 1A的電路,電路比較特殊的是使用 MCU來控制,由於功力有限所以使用兩個 獨立的 MCU 來作,STC15F204EA 有 A/D功能用來當作 顯示(電表) STC89C52RC 就當作傳統的 D/A 控制,控制8BIT 電流設定與 8BIT電壓設定, LM324 作為電流檢出 電壓 電流控制 D/A電壓放大
使用4個VR
1. D/A電壓轉換輸出
2. D/A電流轉換輸出
3. A/D 電壓顯示調整
4. 電流檢出比例調整
這期間遇到的問題有 STC15F204EA 的顯示不正常,原來是 4BIT 顯示的參數設定錯誤.
還有移植舊有程式時 接腳設定忘了改,無法顯示!! 以及漏了焊接幾條線...
程式的技巧純粹"土法煉鋼" 毫無技巧可言!! 還好 MCU記憶體很大都很夠用!!
先前本來打算使用 PWM來控制 D/A 後來發現除非使用 有 PWM 的MCU否則 程式很難搞!! 於是決定使用傳統的 D/A轉換,之所以捨棄手頭的 74LS373而上網購買 74HC573的原因是,使用 OK線連接用 74LS373 和 74HC573 相比有如 天堂地獄!! 於是一口氣買了30個(一個才5元)...感謝雄爸給的電流感應器,目前還沒使用,等下一版改進之後再使用!!
目前只把電壓輸出調整完成,電流方面的調校還需進一步的進行!!
控制部分使用 8952
/*20130612 利用 74hc573 2組以 P1為DATA PORT P2^0 電壓,P2^1 電流 輸出栓鎖 R-2R 產生的 D/A 輸出給 OPA 來控制 LM317的參考電壓 V I 可電電阻把 D/A值作衰減給OPA 經過 電晶體的導通使得LM317動作.
1. 定時執行 顯示動作
2. 定時執行 按鍵掃描動作
3. 顯示位置以及增加減少動作
*/
#include<reg52.h>
#include<stdio.h>
#include <intrins.h>
#include <delay.h>
#include <i2c.h>
#define DataPort P0//P0.0~P0.7 1602 LCM
#define DAPort P1//P1.0~P1.7 74573 8bit
#define _Nop() _nop_() //空指令
#define RS_CLR RS=0// LCM 控制
#define RS_SET RS=1
#define RW_CLR RW=0
#define RW_SET RW=1
#define EN_CLR EN=0
#define EN_SET EN=1
#define V_SET LTH1=1 //設定電壓數值
#define V_CLR LTH1=0 //
#define I_SET LTH0=1 //設定電流數值
#define I_CLR LTH0=1 //
sbit LTH0 = P2^0;//74hc573 latch bit
sbit LTH1 = P2^1;//74hc573 latch bit
sbit RS = P2^7;//LCM指令Lo/資料Hi
sbit RW = P2^6;//READ Hi/WRITELo
sbit EN = P2^5;//ENABLE Hi>>Lo
sbit STRP = P3^2;//控制輸出電壓的打開/關斷
sbit VoI = P3^3;//選擇電壓或是電流 VoI_flag=1 volt,0 current
sbit Inc = P3^4;//inc V/I set
sbit Dec= P3^5;//dec V/I set
sbit Lsft= P3^6;//Left shift
sbit Rsft = P3^7;//Right shift
bit Startflag;//start 1/ stop 0
bit VoI_flag;//volt 1 /current 0
bit Ts_flag;// down count second no use
bit TimeFlag; //T0 counter
char DisplayWord[16];//LCM display buffer
unsigned char counter; //T0counter
unsigned char Tcounter;//T1 counter no use
unsigned char Idata;//current setting data send to DAPort then I_SET & I_CLR
unsigned char Vdata;//volt setting data send to DAPort then V_SET & V_CLR
unsigned char Idigt;// LCM 3bit 0.00 ~ 1.00 000~100
unsigned char Vdigt;//LCM V 3bit 00.0~15.0 000~150
float I_factor,V_factor;//factor for D/A Port no use
void DelayMs(unsigned char);
void DelayUs2x(unsigned char);
void Init_Timer0(void);//initial timer0
void LCD_Write_String(char x,char y, char *s);
void LCD_Write_Char(char x,char y,char Data);
void LCD_Clear(void);
/*------------ LCM control routine-------*/
bit LCD_Check_Busy(void) //busy check
{
DataPort= 0xFF;
RS_CLR; //
RW_SET; //
EN_CLR; //***special**** from LO to HI **************
_nop_();
EN_SET; //***special**** from LO to HI **************
return (bit)(DataPort & 0x80);//check bit7 =0 write data
}
/*void LCD_Write_Com(char com) //
{
while(LCD_Check_Busy()); //busy then wait 1=while loop still;
RS_CLR; //
RW_CLR; //
EN_SET; //
DataPort= com; //
_nop_();
EN_CLR;//
}*/
void LCD_Write_Com(char com) // 4bit
{
while(LCD_Check_Busy()); //busy then wait 1=while loop still;
RS_CLR; //
RW_CLR; //
EN_SET; //
DataPort= com; //
_nop_();
EN_CLR;//
com<<=4;
EN_SET; //
_nop_();
DataPort= com; //
EN_CLR;//
}
/*
void LCD_Write_Data(char Data)
{
while(LCD_Check_Busy());
RS_SET;
RW_CLR;
EN_SET;
DataPort= Data;
_nop_();
EN_CLR;
}
*/
void LCD_Write_Data(char Data) //4bit
{
while(LCD_Check_Busy());
RS_SET;
RW_CLR;
EN_SET;
DataPort= Data;
_nop_();
EN_CLR;
Data<<=4;
EN_SET;
DataPort= Data;
_nop_();
EN_CLR;
}
void LCD_Clear(void)
{
LCD_Write_Com(0x01);
DelayMs(5);
}
void LCD_Write_String(char x,char y, char *s)
{
if (y == 0)
{
LCD_Write_Com(0x80 + x);
}
else
{
LCD_Write_Com(0xC0 + x);
}
while (*s)
{
LCD_Write_Data( *s);
s ++;
}
}
void LCD_Write_Char(char x, char y, char Data)
{
if (y == 0)
{
LCD_Write_Com(0x80 + x);
}
else
{
LCD_Write_Com(0xC0 + x);
}
LCD_Write_Data( Data);
}
void LCD_Write_FChar(unsigned char x,unsigned char y)
{ //write cursor flash
if (y == 0)
{
LCD_Write_Com(0x80 + x);
}
else
{
LCD_Write_Com(0xC0 + x);
}
LCD_Write_Com(0x0f);
}
void LCD_Init(void)
{
LCD_Write_Com(0x28);//38>>28 for 4bit
DelayMs(5);
LCD_Write_Com(0x28); //38>>28 for 4bit data 2 line 5x7 character.
DelayMs(5);
LCD_Write_Com(0x28); //38>>28
DelayMs(5);
LCD_Write_Com(0x28);
LCD_Write_Com(0x08); /*no display*/
LCD_Write_Com(0x01); /*clean screen*/
LCD_Write_Com(0x06); /*cursor control*/
DelayMs(5);
LCD_Write_Com(0x0C); /*display on cursor set*/
}
void DelayUs2x(unsigned char t)
{
while(t--);
}
void DelayMs(unsigned char t)
{
while(t--);
{
DelayUs2x(245);//from245>>45
DelayUs2x(245);
}
}
//--------------------------------------------------------------------------------------------
void Init_Timer0(void)
{
TMOD |= 0x01; //mode 1,16bit timer "|"can "OR"operation
TH0= (65536-2000)/256; // 0x0D8 2ms if 12Mcristal
TL0= (65536-2000)%256;// 0x0F0
EA=1;
ET0=1;
TR0=1;
}
//--------------------------------------------------------------------------------------------
void Timer0_isr(void) interrupt 1
{
TH0= (65536-2000)/256; // 0x0D8 2ms if 12Mcristal
TL0= (65536-2000)%256;// 0x0F0
counter++;//counter is Global variable.
if(counter>170) //140ms update 1 time
{
TimeFlag=1; //
counter=0;
}//if(counter>70)
//WDT_CONTR = 0x3d;//watch dog no use
}
void Display_pros(void)
{
// if(Dflag) DisplayWord[0]='+';
// else DisplayWord[0]='-';
DisplayWord[1]='A';
DisplayWord[2]='n';
DisplayWord[3]='t';
DisplayWord[4]='l';
DisplayWord[5]= 'u';
DisplayWord[6]= ' ';
DisplayWord[7]= 'P';
DisplayWord[8]= 'S';
// else DisplayWord[8]= 'P';//????
DisplayWord[9]= ' ';
DisplayWord[10]= 'O';
if(Startflag) DisplayWord[11]='N',DisplayWord[12]= ' ';
else DisplayWord[11]= 'F', DisplayWord[12]= 'F';;
DisplayWord[13]= ' ';
DisplayWord[14]= ' ';
DisplayWord[15]= ' ';
LCD_Write_String(0,0, DisplayWord);
DisplayWord[0]=' ';
DisplayWord[1]='V';
DisplayWord[2]='=';
DisplayWord[3]= Vdata/100+'0';
DisplayWord[4]= Vdata /10%10+'0';
DisplayWord[5]= '.';
DisplayWord[6]= Vdata %10%10+'0';
DisplayWord[7]= 'V';
DisplayWord[8]= ' ';
DisplayWord[9]= 'I';
DisplayWord[10]= '=';
DisplayWord[11]= Idata/100+'0';
DisplayWord[12]= '.';
DisplayWord[13]= Idata /10%10+'0';
DisplayWord[14]= Idata %10%10+'0';
DisplayWord[15]='A';
LCD_Write_String(0,1, DisplayWord);//??????
if(VoI_flag)
{
if(Vdigt==2) LCD_Write_FChar(3,1);
else if(Vdigt==1) LCD_Write_FChar(4,1);
else LCD_Write_FChar(6,1);
}
else
{
if(Idigt==2) LCD_Write_FChar(11,1);
else if(Idigt==1) LCD_Write_FChar(13,1);
else LCD_Write_FChar(14,1);
}
}
void OP(bit K)//output control
{
if (K)// data op =set
{
DAPort=Vdata;// volt & current data sent to i/o and latch
V_SET;
V_CLR;
DAPort=Idata;
I_SET;
I_CLR;
}
else //data output=0
{
DAPort=0x00;// reset volt & current data sent to i/o and latch
V_SET;
V_CLR;
DAPort=0x00;
I_SET;
I_CLR;
}
}
void Check_STRP(void) //check start/stop key press
{
if(!STRP)//key press
DelayMs(5);
if(!STRP)
{
while(!STRP);
Startflag=!Startflag; // change state
}
}
void Check_VOI(void)//V/I select key press
{
if(!VoI) //key pressed
DelayMs(5);
if(!VoI)
{
while(!VoI);
{
VoI_flag=~ VoI_flag;
}//Volt or Current will flash
}
}
void Check_LR(void)// check L/R shift key be pressed
{
if(!Lsft)
DelayMs(5);
if(!Lsft)
{
while(!Lsft);//Key depress
if(VoI_flag)
{
Vdigt++;
if(Vdigt>2) Vdigt=0;
}
else
{
Idigt++;
if(Idigt>2) Idigt=0;
}
}
if(!Rsft)
DelayMs(5);
if(!Rsft)
{
while(!Rsft);//Key depress
if(VoI_flag)
{
Vdigt--;
if(Vdigt==255) Vdigt=2;
}
else
{
Idigt--;
if(Idigt>255) Idigt=2;
}
}
}
void Check_inc(void) //inc/dec key press check
{
if(!Inc) //+ key press
DelayMs(5);
if(!Inc)
{
while(!Inc);//Key + depress
if(VoI_flag) //volt
{
if(Vdigt==0) Vdata=Vdata++;
if(Vdigt==1) Vdata=Vdata+10;
if(Vdigt==2) Vdata=Vdata+100;
if(Vdata>250) Vdata=250;
}
else
{
if(Idigt==0) Idata=Idata++;
if(Idigt==1) Idata=Idata+10;
if(Idigt==2) Idata=Idata+100;
if(Idata>210) Idata=210;
}
}
if(!Dec) //- key press
DelayMs(5);
if(!Dec)
{
while(!Dec);//Key - depress
if(VoI_flag) //volt
{
if(Vdigt==0) Vdata=Vdata--;
if(Vdigt==1) Vdata=Vdata-10;
if(Vdigt==2) Vdata=Vdata-100;
if(Vdata>250) Vdata=0;
}
else
{
if(Idigt==0) Idata=Idata--;
if(Idigt==1) Idata=Idata-10;
if(Idigt==2) Idata=Idata-100;
if(Idata>210) Idata=0;
}
}
}
void main(void)
{
Init_Timer0();//initial timer0
LCD_Init();// LCM initial
LCD_Clear();//LCM clear
OP(0);//initial output
while(1)
{
if(TimeFlag==1)//140ms update
{
TimeFlag=0;
Display_pros();//display data
}
if(Startflag)
{
OP(1); //out put on
}
else
{
OP(0); //output set volt & current to 0
}
DelayMs(100);
Check_STRP();//on/off key process
Check_VOI();//V/I key process
Check_LR();// shift L/R process
Check_inc();//+/- process
}
}//finish
顯示部分使用 STC15F204EA 它只負責顯示而已
//#include<STC15F204EA.h>
/* ????????? 20130611 no internal timer just delay for A/D read to avoid data chang fast use 10times average for nc power */
#include <reg52.h>
#include<intrins.h>
sfr ADC_CONTR = 0xBC; //0000,0000 A/Dת»»¿ØÖƼĴæÆ÷
sfr ADC_RES = 0xBD; //0000,0000 A/Dת»»½á¹û¸ß8λ
sfr ADC_RESL = 0xBE; //0000,0000 A/Dת»»½á¹ûµÍ2λ
sfr P1M0 = 0x92; //0000,0000 Ë¿Ú1ģʽ¼Ä´æÆ÷0
sfr P1M1 = 0x91; //0000,0000 Ë¿Ú1ģʽ¼Ä´æÆ÷1
sfr P1ASF = 0x9D; //0000,0000 Ë¿Ú1Ä£Ä⹦ÄÜÅäÖüĴæÆ÷
sbit RS = P3^7; //©w…óºÝ¤f
sbit RW = P3^6;
sbit EN = P3^5;
char displayword[16];
#define RS_CLR RS=0
#define RS_SET RS=1
#define RW_CLR RW=0
#define RW_SET RW=1
#define EN_CLR EN=0
#define EN_SET EN=1
#define DataPort P2 //STC15F204EA P1 A/D P2 LCM P3^7--RS P3^6--W/R P3^5--E
//unsigned char d[5];
unsigned int R,L,M,N,Q,I;//unsigned int R,M,N;//Y©w…ó¦¨uchar«´N¥u¯àF¥Ü2.5V¥H¤Uªº‡ÛÈ
signed int SV,AV;//´«ºâ«áªº³]©w•Å«×sv=100/V ´«ºâ«áªº¼ö°¸•Å«×av=100/V
signed int Difv;
/*------------------------------------------------
uS©µƒº¨ç‡Û¡A§t¦³‰r¤Jƒò‡Û unsigned char t¡AÆÓªð¦^È
unsigned char O©w…óÆӲņA¦r²Å@q¡A¨äȪºS„ÏO
0~255 „±¨½¨Ï¥Î´¹®12M¡AºëÚÌ©µƒºˆ[¨Ï¥Î…¹ˆC,¤jP©µƒº
ƒc«×¦p¤U T=tx2+5 uS
------------------------------------------------*/
void DelayUs2x(unsigned char t)
{
while(--t);
}
/*------------------------------------------------
mS©µƒº¨ç‡Û¡A§t¦³‰r¤Jƒò‡Û unsigned char t¡AÆÓªð¦^È
unsigned char O©w…óÆӲņA¦r²Å@q¡A¨äȪºS„ÏO
0~255 „±¨½¨Ï¥Î´¹®12M¡AºëÚÌ©µƒºˆ[¨Ï¥Î…¹ˆC
------------------------------------------------*/
void DelayMs(unsigned char t)
{
while(t--)
{
//¤jP©µƒº1mS
DelayUs2x(245);
DelayUs2x(245);
}
}
/*------------------------------------------------
§P¦£¨ç‡Û
------------------------------------------------*/
bit LCD_Check_Busy(void)
{
DataPort= 0xFF;
RS_CLR;
RW_SET;
EN_CLR;
_nop_();
EN_SET;
return (bit)(DataPort & 0x80);
}
void LCD_Write_Com(char com) //©R¥O¼g¤J 4bit
{
while(LCD_Check_Busy()); //¦£ƒhµ¥«Ý 1=while loop still;
RS_CLR; //«ü¥O¥\¯à
RW_CLR; //¼g¤J
EN_SET; //¤U°½t ¥ÑHIÅܦ¨LO
DataPort= com; // «ü¥O³]©w
_nop_();
EN_CLR;//
com<<=4;
EN_SET; //¤U°½t ¥ÑHIÅܦ¨LO
_nop_();
DataPort= com; // «ü¥O³]©w
EN_CLR;//
DelayMs(1);
}
void LCD_Write_Data(char Data) //¸ê®Æ¼g¤J4bit
{
while(LCD_Check_Busy()); //¦£ƒhµ¥«Ý
RS_SET; // ¸ê®Æ³B²z
RW_CLR;// ¼gªº°Ê§@
EN_SET; // ±Ò°Ê¤U½tIJµo
DataPort= Data; //¿é¤J»Ýn¼g¤Jªº¸ê®Æ
_nop_();//©µ«á¤@Ӯɡ
EN_CLR;//
Data<<=4;
EN_SET; // ±Ò°Ê¤U½tIJµo
DataPort= Data; //¿é¤J»Ýn¼g¤Jªº¸ê®Æ
_nop_();//©µ«á¤@Ӯɡ
EN_CLR;//
DelayMs(1);//µ¹ 1T MCU ¨Ï¥Î
}
/*------------------------------------------------
²M«Ì¨ç‡Û
------------------------------------------------*/
void LCD_Clear(void)
{
LCD_Write_Com(0x01);
DelayMs(5);
}
/*------------------------------------------------
‡À¤J¦r²Å¦ê¨ç‡Û
------------------------------------------------*/
void LCD_Write_String(unsigned char x,unsigned char y,unsigned char *s)
{
if (y == 0)
{
LCD_Write_Com(0x80 + x);
}
else
{
LCD_Write_Com(0xC0 + x);
}
while (*s)
{
LCD_Write_Data( *s);
s ++;
}
}
/*------------------------------------------------
‡À¤J¦r²Å¨ç‡Û
------------------------------------------------*/
void LCD_Write_Char(unsigned char x,unsigned char y,unsigned char Data)
{
if (y == 0)
{
LCD_Write_Com(0x80 + x);
}
else
{
LCD_Write_Com(0xC0 + x);
}
LCD_Write_Data( Data);
}
/*------------------------------------------------
ªì©l¤Æ¨ç‡Û
------------------------------------------------*/
void LCD_Init(void)
{
LCD_Write_Com(0x28); /*F¥Ü¼Ò4bit„¦¸m*/
DelayMs(5);
LCD_Write_Com(0x28);
DelayMs(5);
LCD_Write_Com(0x28);
DelayMs(5);
LCD_Write_Com(0x28);
LCD_Write_Com(0x08); /*F¥Ü‹×„¸*/
LCD_Write_Com(0x01); /*F¥Ü²M«Ì*/
LCD_Write_Com(0x06); /*F¥Ü¥ú‡á²¾ƒð„¦¸m*/
DelayMs(5);
LCD_Write_Com(0x0C); /*F¥Ü…{¤Î¥ú‡á„¦¸m*/
}
/*******************************************************************
¨ç‡Û¦W¡GADCªì©l¤Æ¤Î8¦ìA/D‹H„ã¨ç‡Û
ªð¦^È¡G8¦ìªºADC‡ÛÕu
…C ªG¡GŒÝ¥X«ü©wADC±µ¤fªºA/D‹H„ãÈ¡A¦}ªð¦^‡ÛÈ
„ ª`¡GÓì¥Î¤_STC12C2052AD¨t¦C„ˤùÉó¡]¥²…§¨Ï¥ÎSTC12C2052AD.h‰³¤å¥ó¡^
*******************************************************************/
unsigned char Read (unsigned char CHA)
{
unsigned char AD_FIN=0; //¦s‰ÉA/D‹H„ã‡á§Ó;Y¦b¨ç‡Û¥~©w…ó¦¹@qƒh¤£¯à±o¨ì„²Œ¢@¤Æªº¼Ò‰ÞqªºF¥Ü
/******¥H¤UƒoADCªì©l¤Æµ{§Ç****************************/
CHA &= 0x07; //‰uˆáADCªº8ƒª±µ¤f¤¤ªº¤@ƒª¡]0000 0111 ²M0°ª5¦ì¡^
ADC_CONTR = 0x60; //ADC‹H„㪺³t«×¡]0XX0 0000 ¨ä¤¤XX±±¨î³t«×¡Aˆ[®ÚÕu‡ÛÕu¤â•ä„¦¸m¡^
_nop_();
ADC_CONTR |= CHA; //‰uˆáA/D…å«e³q¹D
_nop_();
ADC_CONTR |= 0x80; //„QƒðA/D†z•½
DelayMs(1); //¨Ï‰r¤J†z‰Í†c¨ì‹®©w¡]1ms§Y¥i?
/******¥H¤UƒoADCƒù¦æµ{§Ç****************************/
ADC_CONTR |= 0x08; //„QƒðA/D‹H„ã¡]0000 1000 ¥OADCS = 1¡^
_nop_();
_nop_();
_nop_();
_nop_();
while (AD_FIN ==0){ //µ¥«ÝA/D‹H„ã…C§ô
AD_FIN = (ADC_CONTR & 0x10); //0001 0000„ò†IA/D‹H„ã…C§ô§_
}
ADC_CONTR &= 0xE7; //1111 0111 ²MADC_FLAG¦ì, ‹×„¸A/D‹H„ã,
//return (ADC_DATA); //ªð¦^A/D‹H„ã…CªG¡]8¦ì¡^
return(ADC_RES);
}
unsigned int Mavg(unsigned char an)
// read 10 times data and average
// an for analog input no.
{
unsigned char at;
unsigned int M;
M=0;
for (at=0;at<10;at++)
{
M=Read(an)+M;//analog 3 input
DelayMs(250);
}
M=M/10;
return M;
}
/******************************************************************
F¥Ü¨ç‡Û‹H„ã¨ç‡Û¡G
M=¼Ò‰Þqªö‡ÞÈ¡AN=°òã†z‰Í•½ªö‡ÞÈ¡]¥»¨Òƒo2.5V¡^¡AR=¼Ò‰Þq‰r¤JÈ¡]«ÝF¥ÜÈ¡^
N=256*2.5/Vcc¡F@§Î¦Z±oVcc=256*2.5/N¡F ¥N¤JM=256*R/Vcc¡F±o¨ìM=R*N/2.5¡F@§Î¦Z±oR=M*2.5/N
1ƒo‰r¤JºÝ¤À‰Í¤ñ¡C
******************************************************************/
void transfer(void){
L= Mavg(0);//Read(0); // read volt analog
I= Mavg(1);//read (1) read current analog
N=Read(2);//P1.2¤f2.5V°òã†z‰Í•½ªö‡Þ¡]‹H„ã¡^
Q=(L*2.58/N)*100; //Q=display volt data
//R=((I*2.58)/(N))*10;//R=display current data 1V=.1A
R=((I*2.58)/(N))*100;//R=display current data 1V=1A ??10:1 ??
}
void display(void)
{
displayword[0]=' ';
// if(Kon) displayword[0]='1';
displayword[1]='V';//Tab[IRcord[0]/16];
displayword[2]='=';//Tab[IRcord[0]%16];
displayword[3]= Q/100+'0';
displayword[4]= (Q%100)/10+'0';
displayword[5]= '.';
displayword[6]=(Q%10)+'0';
displayword[7]='V';
displayword[8]= ' ';
displayword[9]= 'I';
displayword[10]='=';
displayword[11]= R/100+'0';
displayword[12]= '.';
displayword[13]=(R%100)/10+'0';
displayword[14]=R%10+'0';
displayword[15]='A';
LCD_Write_String(0,0, displayword);//Åã¥Ü¦b²Ä¤G¦æ
/* displayword[0]='S';
displayword[1]='E';
displayword[2]='T';
displayword[3]=':';
displayword[4]= Q/1000+'0';
Q=Q%1000;
displayword[5]=Q/100+'0';
Q=Q%100;
displayword[6]=Q/10+'0';
displayword[7]=Q%10+'0';
displayword[8]= ' ';
displayword[9]= 'T';
displayword[10]='C';
displayword[11]=':';
displayword[12]=R/1000+'0';
R=R%1000;
displayword[13]=R/100+'0';
R=R%100;
displayword[14]=R/10+'0';
displayword[15]=R%10+'0';
LCD_Write_String(0,1, displayword);//Åã¥Ü¦b²Ä¤G¦æ
*/
}
void main(void)
{
P1M0 = 0xff; //P1.0/P1.1¡G1111 1111¡]°ªªý¡^//ª`•N¡G§ó§ïADC³q¹Dƒº…§¦Pƒº’â†Á‰ØªºIO±µ¤fקïƒo°ªªý‰r¤J¡C
P1M1 = 0x00; //P1.0/P1.1¡G0000 0000
P1ASF=0xff; //all analog in put mode
LCD_Init();
LCD_Clear();//²M«Ì
//Difv=0;
//SV=0;
//LCD_Write_String(0,0,"IRON Temp Contrl");
while (1)
{
transfer();//do ADC & putto display
DelayMs(250);
display();
}
}
亂碼大家請包涵我也沒辦法!! |
評分
-
7
查看全部評分
-
|