找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

帖子
查看: 3610|回復(fù): 1
打印 上一主題 下一主題
收起左側(cè)

TLC2543+51單片機(jī)數(shù)字電壓表Proteus仿真程序

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
本文介紹了基于STC89C51單片機(jī)為核心的,以AD0809數(shù)模轉(zhuǎn)換芯片作為采樣,以四位八段數(shù)碼管作為顯示的具有測(cè)量功能的具有一定精度的數(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仿真工程文件可到本帖附件中下載)


單片機(jī)源程序如下:
  1. #define TLC2543_GLOBAL
  2. #include "TLC2543.h"

  3. uint read_TLC2543(uchar channel)
  4. {
  5.     register uchar i;
  6.     uint tempAD = 0;

  7.     while(!TLC2543GetEoc());        //wait TLC2543 free
  8.         _delay_us(3);
  9.     channel <<= 4;

  10.     TLC2543Clk(TLC2543_CLR);
  11.     TLC2543_Cs(TLC2543_SET);
  12.     TLC2543_Cs(TLC2543_CLR);                //_CS TLC2543 select

  13.         _delay_us(3);
  14.     for( i = 0; i < 12; i ++ )
  15.     {
  16.         tempAD <<= 1;
  17.         if( TLC2543GetDo() )        //read value
  18.         {
  19.             tempAD |= 0x01;
  20.         }
  21.         if( channel&0x80 )
  22.         {
  23.             TLC2543Di(TLC2543_SET);
  24.         }
  25.         else
  26.         {
  27.             TLC2543Di(TLC2543_CLR);
  28.         }
  29.         channel <<= 1;
  30.         TLC2543Clk(TLC2543_SET);
  31.         nop();
  32.         TLC2543Clk(TLC2543_CLR);
  33.     }

  34.     TLC2543_Cs(TLC2543_SET);                //TLC2543 close
  35.         _delay_us(1);

  36.     return tempAD;
  37. }
  38. void _delay_us(uint us)
  39. {
  40.    uchar delayi;
  41.    while(--us)
  42.    {
  43.          for(delayi=0;delayi<10;delayi++);
  44.    }
  45. }                                                                                                                          
復(fù)制代碼
  1. #include "led.h"
  2. #include "TLC2543.h"
  3. const uchar code displayMode=0x0f;
  4. uchar displayBuff[4]={0x7e,0x7e,0x7e,0x7e};   //數(shù)碼管顯示緩沖區(qū),低兩位為時(shí)間,最高位為搶答號(hào)
  5. const uchar code digitalNumber[10]={0x7e,0x06,0x6d,0x79,0x33,0x5b,0x5f,0x70,0x7f,0x73};
  6. void main()
  7. {         
  8.   uint voltageReadTemp;
  9.   uint voltageRead;
  10.   uchar temp;
  11.   uchar i,j;
  12.   init_led();
  13.   while(1)
  14.   {
  15.     ledSweepDisplay(displayBuff,displayMode,4);
  16.     voltageRead=read_TLC2543(0x05);
  17.         voltageRead=voltageRead*0x05;
  18.         for(i=4;i>0;i--)
  19.         {
  20.           temp=(uchar)(voltageRead/0x0fff);
  21.           if(i==4)
  22.             displayBuff[i-1]=digitalNumber[temp]|0x80;
  23.           else
  24.             displayBuff[i-1]=digitalNumber[temp];
  25.           voltageRead=voltageRead%0x0fff;
  26.           voltageReadTemp=voltageRead<<1;
  27.           voltageRead=0x0000;
  28.           for(j=0;j<5;j++)
  29.             voltageRead+=voltageReadTemp;//voltageRead=voltageRead*10
  30.           
  31.         }

  32.   }

  33. }
復(fù)制代碼


所有資料51hei提供下載:
數(shù)字電壓表.zip (25.75 KB, 下載次數(shù): 66)


分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏3 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

沙發(fā)
ID:750218 發(fā)表于 2020-5-12 19:34 | 只看該作者
垃圾,什么玩意了
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表