新聞中心

        EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 單片機(jī)可控0-30V可調(diào)電源

        單片機(jī)可控0-30V可調(diào)電源

        作者: 時(shí)間:2016-11-30 來(lái)源:網(wǎng)絡(luò) 收藏
        CPU電路圖



        顯示電路


        控制板電路圖


        程序
        #include // 包含型號(hào)頭文件

        本文引用地址:http://www.104case.com/article/201611/324014.htm
        //#include
        #include // 包含"位"操作頭文件
        #include
        #include
        #include
        #include
        #include
        #include

        #define uchar unsigned char
        #define uint unsigned int

        #define TRUE 1
        #define FALSE 0

        #define ad_Temp_flag 0x03 // 溫度轉(zhuǎn)換通道
        #define ad_Vout_flag 0x04 // 電壓轉(zhuǎn)換通道
        #define ad_Iout_flag 0x05 // 電流轉(zhuǎn)換檢測(cè)


        #define FAN_ON (PORTB_Bit3 = 1) // FAN 開(kāi)
        #define FAN_OFF (PORTB_Bit3 = 0) // FAN 關(guān)

        #define D1_ON (PORTA_Bit0 = 0) // D1 開(kāi)
        #define D1_OFF (PORTA_Bit0 = 1) // D1 關(guān)

        #define D2_ON (PORTA_Bit1 = 0) // D2 開(kāi)
        #define D2_OFF (PORTA_Bit1 = 1) // D2 關(guān)

        #define D3_ON (PORTA_Bit2 = 0) // D3 開(kāi)
        #define D3_OFF (PORTA_Bit2 = 1) // D3 關(guān)

        #define D4_ON (PORTB_Bit2 = 0) // D4 開(kāi)
        #define D4_OFF (PORTB_Bit2 = 1) // D4 關(guān)

        #define D5_ON (PORTA_Bit6 = 0) // D5 開(kāi)
        #define D5_OFF (PORTA_Bit6 = 1) // D5 關(guān)

        #define D6_ON (PORTA_Bit7 = 0) // D6 開(kāi)
        #define D6_OFF (PORTA_Bit7 = 1) // D6 關(guān)

        #define DATA164_ON (PORTB_Bit1 = 1) // 74HC164 DATA=1
        #define DATA164_OFF (PORTB_Bit1 = 0) // 74HC164 DATA=0

        #define CLK164_ON (PORTB_Bit0 = 1) //
        #define CLK164_OFF (PORTB_Bit0 = 0) //


        #define Temp_out_lo 0x339 // -5℃ 41.56K
        #define Temp_out_hi 0x10e // 50℃ 3.588K

        uint ad_Temp_result; // 溫度轉(zhuǎn)換結(jié)果
        uint ad_Vout_result; // 電壓轉(zhuǎn)換結(jié)果
        uint ad_Iout_result; // 電流轉(zhuǎn)換結(jié)果

        uint Vout_disp;
        uint Iout_disp;

        uint Iout_adj;

        uchar time_cnt1;
        uchar adc_get_flag;

        //#pragma vector=0x10;
        //__interrupt void TIMER2_OVF_Server(void);

        void mcu_init(void); // I/O初始化,PWM初始化
        void adc_init(void); // ADC初始化
        uint adc_get(uchar adc_ch); // 啟動(dòng)AD轉(zhuǎn)換,并返回轉(zhuǎn)換值
        void Vout_adc_get(void); // 電壓檢測(cè)
        void Temp_adc_get(void); // 溫度檢測(cè)
        void Iout_adc_get(void); // 電流檢測(cè)
        //數(shù)碼管顯示代碼定義
        __flash uchar disp_led[10] @0x0040 =
        {
        0x0a, // 0
        0x7b, // 1
        0x4c, // 2
        0x58, // 3
        0x39, // 4
        0x98, // 5
        0x88, // 6
        0x5b, // 7
        0x08, // 8
        0x18, // 9
        };
        上一頁(yè) 1 2 下一頁(yè)

        評(píng)論


        技術(shù)專區(qū)

        關(guān)閉
        主站蜘蛛池模板: 原平市| 阳西县| 通道| 拉萨市| 鞍山市| 南和县| 武鸣县| 赤峰市| 四川省| 砚山县| 屯留县| 诸暨市| 泸定县| 察隅县| 大厂| 镇原县| 巴林左旗| 万荣县| 长白| 铜梁县| 兰坪| 改则县| 太康县| 濮阳市| 苍山县| 桂阳县| 桐庐县| 互助| 炎陵县| 绩溪县| 东乌| 通城县| 临漳县| 天峨县| 高邑县| 隆回县| 开远市| 罗城| 大荔县| 英吉沙县| 秦安县|