新聞中心

        EEPW首頁 > 測試測量 > 設計應用 > 基于mikroC和microchip的TC74的溫度測量方案

        基于mikroC和microchip的TC74的溫度測量方案

        作者: 時間:2017-01-09 來源:網絡 收藏

        三、電路圖

        我在這里用的是芯片PIC18F2550,它可以與任何其他規模較小的PIC微控制器實現I2C通信。溫度由TC74傳感器讀取并顯示在LCD字符。別忘 了把兩個上拉電阻(1K)連接在SDA和SCL線I2C總線上。在本實驗中采用PIC18F2550單片機PIC板來自于StartUSB for PIC board.。

        圖4 電路圖

        圖5 實物圖

        圖6 TC74溫度傳感器

        四、軟件

        PIC18F2550固件是在C使用MikroC Pro for PIC編譯開發的。MikroC Pro for PIC編譯器提供的內置支持I2C庫。單片機讀取TC74內部溫度寄存器溫度字并顯示在LCD。下面的程序顯示,TC74的整個工作范圍內在40 至125°C。

        程序:

        /* Project: Using TC74 with PIC microcontroller

        for temperature measurement

        MCU: PIC18F2550 on-board StartUSB for PIC

        Clock 48.0 MHz using HS + PLL

        MCLR Enabled

        */

        // Define LCD module connections.

        sbit LCD_RS at RC6_bit;

        sbit LCD_EN at RC7_bit;

        sbit LCD_D4 at RB4_bit;

        sbit LCD_D5 at RB5_bit;

        sbit LCD_D6 at RB6_bit;

        sbit LCD_D7 at RB7_bit;

        sbit LCD_RS_Direction at TRISC6_bit;

        sbit LCD_EN_Direction at TRISC7_bit;

        sbit LCD_D4_Direction at TRISB4_bit;

        sbit LCD_D5_Direction at TRISB5_bit;

        sbit LCD_D6_Direction at TRISB6_bit;

        sbit LCD_D7_Direction at TRISB7_bit;

        // End LCD module connection definition

        unsigned char Temp;

        unsigned short num;

        const int TC74A0 = 0x90;

        void check_device(unsigned short dev_address){ I2C1_Start();

        if (I2C1_Wr(dev_address)){ Lcd_Out(1,1,"Device not found");

        }

        else Lcd_Out(1,1,"TC74 device");

        I2C1_Stop();

        }

        unsigned short Read_Temp(){

        unsigned short result; I2C1_Start(); // Issue start signal

        I2C1_Wr(TC74A0); // Address + Write bit

        I2C1_Wr(0x00); // Read Temp

        I2C1_Repeated_Start(); // Issue start signal

        I2C1_Wr(TC74A0+1); // Address + Read bit

        result = I2C1_Rd(0u); return result;

        }



        評論


        技術專區

        關閉
        主站蜘蛛池模板: 芷江| 上思县| 静乐县| 白城市| 科技| 台前县| 左云县| 海南省| 海兴县| 岐山县| 吉木萨尔县| 平湖市| 西贡区| 锡林郭勒盟| 彰化县| 庆安县| 嘉禾县| 淮南市| 乌兰浩特市| 东海县| 突泉县| 元氏县| 视频| 泾阳县| 桃源县| 建宁县| 滁州市| 疏勒县| 广宁县| 林州市| 娱乐| 枣阳市| 湾仔区| 青岛市| 苗栗市| 五莲县| 成安县| 平泉县| 兴隆县| 江门市| 绵阳市|