標(biāo)題:
TLC2543+51單片機(jī)數(shù)字電壓表Proteus仿真程序
[打印本頁]
作者:
v帆帆帆帆
時(shí)間:
2019-7-24 10:23
標(biāo)題:
TLC2543+51單片機(jī)數(shù)字電壓表Proteus仿真程序
本文介紹了基于STC89C51單片機(jī)為核心的,以AD0809數(shù)模轉(zhuǎn)換芯片作為采樣,以四位八段數(shù)碼管作為顯示的具有測量功能的具有一定精度的數(shù)字電壓表。在實(shí)現(xiàn)基礎(chǔ)功能的情況下,另外還可以擴(kuò)展串行口通信,時(shí)鐘,等其他一系列功能,使系統(tǒng)達(dá)到了良好的設(shè)計(jì)效果和要求。本課題主要解決A/D轉(zhuǎn)換,數(shù)據(jù)處理及顯示控制等三個(gè)模塊。
主要系統(tǒng):STC89C51;數(shù)字電壓表;模數(shù)轉(zhuǎn)換;數(shù)字信號(hào)
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)
0.png
(18.42 KB, 下載次數(shù): 44)
下載附件
2019-7-24 14:16 上傳
單片機(jī)源程序如下:
#define TLC2543_GLOBAL
#include "TLC2543.h"
uint read_TLC2543(uchar channel)
{
register uchar i;
uint tempAD = 0;
while(!TLC2543GetEoc()); //wait TLC2543 free
_delay_us(3);
channel <<= 4;
TLC2543Clk(TLC2543_CLR);
TLC2543_Cs(TLC2543_SET);
TLC2543_Cs(TLC2543_CLR); //_CS TLC2543 select
_delay_us(3);
for( i = 0; i < 12; i ++ )
{
tempAD <<= 1;
if( TLC2543GetDo() ) //read value
{
tempAD |= 0x01;
}
if( channel&0x80 )
{
TLC2543Di(TLC2543_SET);
}
else
{
TLC2543Di(TLC2543_CLR);
}
channel <<= 1;
TLC2543Clk(TLC2543_SET);
nop();
TLC2543Clk(TLC2543_CLR);
}
TLC2543_Cs(TLC2543_SET); //TLC2543 close
_delay_us(1);
return tempAD;
}
void _delay_us(uint us)
{
uchar delayi;
while(--us)
{
for(delayi=0;delayi<10;delayi++);
}
}
復(fù)制代碼
#include "led.h"
#include "TLC2543.h"
const uchar code displayMode=0x0f;
uchar displayBuff[4]={0x7e,0x7e,0x7e,0x7e}; //數(shù)碼管顯示緩沖區(qū),低兩位為時(shí)間,最高位為搶答號(hào)
const uchar code digitalNumber[10]={0x7e,0x06,0x6d,0x79,0x33,0x5b,0x5f,0x70,0x7f,0x73};
void main()
{
uint voltageReadTemp;
uint voltageRead;
uchar temp;
uchar i,j;
init_led();
while(1)
{
ledSweepDisplay(displayBuff,displayMode,4);
voltageRead=read_TLC2543(0x05);
voltageRead=voltageRead*0x05;
for(i=4;i>0;i--)
{
temp=(uchar)(voltageRead/0x0fff);
if(i==4)
displayBuff[i-1]=digitalNumber[temp]|0x80;
else
displayBuff[i-1]=digitalNumber[temp];
voltageRead=voltageRead%0x0fff;
voltageReadTemp=voltageRead<<1;
voltageRead=0x0000;
for(j=0;j<5;j++)
voltageRead+=voltageReadTemp;//voltageRead=voltageRead*10
}
}
}
復(fù)制代碼
所有資料51hei提供下載:
數(shù)字電壓表.zip
(25.75 KB, 下載次數(shù): 66)
2019-7-24 10:19 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
作者:
lgh987
時(shí)間:
2020-5-12 19:34
垃圾,什么玩意了
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1