99久久全国免费观看_国产一区二区三区四区五区VM_久久www人成免费看片中文_国产高清在线a视频大全_深夜福利www_日韩一级成人av

  • 回復
  • 收藏
  • 點贊
  • 分享
  • 發新帖

用PIC設計的數字溫度計---實用!!

含電路圖和源程序

http://m.daogou-taobao.cn/blog/blog_comment_list.php?blar_id=77970

我的電源網博客新開張,希望大家有空去逛逛!!

謝謝!
全部回復(3)
正序查看
倒序查看
LV.1
2
2008-01-02 16:49
電路圖
500) {this.resized=true; this.width=500; this.alt='這是一張縮略圖,點擊可放大。\n按住CTRL,滾動鼠標滾輪可自由縮放';this.style.cursor='hand'}" onclick="if(!this.resized) {return true;} else {window.open('http://u.dianyuan.com/bbs/u/61/163911199263730.jpg');}" onmousewheel="return imgzoom(this);">
0
回復
LV.1
3
2008-01-03 17:31
@
電路圖[圖片]500){this.resized=true;this.width=500;this.alt='這是一張縮略圖,點擊可放大。\n按住CTRL,滾動鼠標滾輪可自由縮放';this.style.cursor='hand'}"onclick="if(!this.resized){returntrue;}else{window.open('http://u.dianyuan.com/bbs/u/61/163911199263730.jpg');}"onmousewheel="returnimgzoom(this);">
以下是程序,編程器用的是微都自動測試設備工作室的WD_PP20編程器(PIC,AVR兩用+實驗板).編譯器是CCS.

///////////////////////////////////////////////////////////////////////
//Filename: tsensor.c                                                //
//Revision: A                                                        //
//Creator: LourenceGuo                                               //
//Created Date: 2007-12-31                                           //
//                                                                   //
//Function:                                                          //
//This is a program to display the temperature w/ 5s bklight function//
//When open the machine, display:    Welcome !                       //
//                                Microchip MCU                   //
//Then display: Temperature:                                         //
//              XXXX Cdegree                                         //
//                                                                   //
//I/O and peripheral equipment:                                      //
//Temperature sensor: LM61, T=(V-500mV)/10                           //
//ADC PIN: AN1                                                       //
//AN0,AN1 ANALOG; A3 REF                                             //
//backlight control: B0                                              //
//LCD: 16PIN 1602LCD w/ backlight                                    //
///////////////////////////////////////////////////////////////////////


#include <16F873A.h>
#device ADC=10
#fuses HS,NOWDT,PROTECT,NOLVP
#use delay(clock=20000000)

#include "lcd.c"

float ad_value;
signed int ad_result;

int16 bk_light_counter=0;
int1 bk_light_flag=1;



#define PSW_KEY input(PIN_C0)
#define UP_KEY input(PIN_C1)
#define DOWN_KEY input(PIN_C2)

#define BK_LIGHT PIN_B0


void init();
void temp_ad();
void display();
void key_detection();


//============================================================================================================
#INT_TIMER1
void clock1_isr()
{
   set_timer1(0x3CAF);         // Interrupt every (0xFFFF-0x3CAF) * 0.2us = 50000 * 0.2us = 10ms

   // back light couter
   // ----------------------------------------------------------------------------
   if((bk_light_flag == 1) && (bk_light_counter < 500)) bk_light_counter ++;  // about 5 second
   else if(bk_light_counter==500)
      {
         output_low(BK_LIGHT);        // turn off back light
         bk_light_flag = 0;         // reset back light flag
      }
}
//============================================================================================================


//Detect any key press down
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
void key_detection()
{
   if((PSW_KEY==0)||(UP_KEY==0)||(DOWN_KEY==0))
   {
      output_high(BK_LIGHT);
      bk_light_flag=1;
      bk_light_counter=0;
   }
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////



//Initialize the LCD panel
//*************************************************************************************************************
void init()
{
   setup_adc_ports(RA0_RA1_ANALOG_RA3_REF);         // A0 A1 Ref=A3 for 16F873A, now Vref = 3.3V
   setup_adc(ADC_CLOCK_INTERNAL);

   setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);      // setup interrupt timer1

   enable_interrupts(INT_TIMER1);      // Turn on interrupt timer1
   enable_interrupts(GLOBAL);          // Enabled all interruptions.

   output_high(BK_LIGHT);
   lcd_init();                         // Initialize lcd
   delay_ms(10);
   lcd_gotoxy( 1, 1);                  // go to the start position of the first line
   lcd_putc ("    Welcome !   ");      // display string in the first line
   delay_ms(1);
   lcd_gotoxy( 1, 2);                  // go to the start position of the second line
   lcd_putc (" Microchip MCU  ");      // display string in the second line

   delay_ms(2000);

}
//**************************************************************************************************************


// read temperature A/D data, AN1
// temperature calculator expression is: (ad_vaule(mv) - 500) / 10
void temp_ad()
{
      int8 tt;
      int16 ad_data ;
      {
         ad_data = 0;
         for(tt=0;tt<5;tt++)
         {
            set_adc_channel(1);                 //AN1
            delay_us(10);                       //Delay is need to wait A/D conversion over
            ad_data = ad_data + read_adc();     //add 5 times
         }

         ad_value = ad_data * 0.66;              // 3.3 / 5times
         ad_value = ad_value / 1.024;
         ad_value = (ad_value - 500) / 10;
         ad_result = ad_value;
       }

}

//display temprature value on the LCD
//////////////////////////////////////////////////////////////////////////////////////
void display()
{
  delay_ms(10);
  lcd_gotoxy( 1, 1);                      // go to the start position of the first line
  lcd_putc ("\fTemperature:    \n");      // \f--clear display,\n--go to start position of second line
  delay_ms(1);
  lcd_putc ("     Cdgree     ");
  delay_ms(1);

  lcd_gotoxy( 1, 2);                     // go to the start position of the second line
  lcd_putf (ad_result,4);                // display the temperature value, 4 digital

  //lcd_gotoxy( 1, 2);
  //lcd_putf (0xb7,1);

  delay_ms(1000);
}

//////////////////////////////////////////////////////////////////////////////////////


void main() {

  init();
  do
    {
      key_detection();
      temp_ad();
      display();
    }while(true);
}
0
回復
LV.1
4
2008-02-16 09:56
@
以下是程序,編程器用的是微都自動測試設備工作室的WD_PP20編程器(PIC,AVR兩用+實驗板).編譯器是CCS./////////////////////////////////////////////////////////////////////////Filename:tsensor.c                                                ////Revision:A                                                        ////Creator:LourenceGuo                                              ////CreatedDate:2007-12-31                                          ////                                                                  ////Function:                                                          ////Thisisaprogramtodisplaythetemperaturew/5sbklightfunction////Whenopenthemachine,display:    Welcome!                      ////                                MicrochipMCU                  ////Thendisplay:Temperature:                                        ////              XXXXCdegree                                        ////                                                                  ////I/Oandperipheralequipment:                                      ////Temperaturesensor:LM61,T=(V-500mV)/10                          ////ADCPIN:AN1                                                      ////AN0,AN1ANALOG;A3REF                                            ////backlightcontrol:B0                                              ////LCD:16PIN1602LCDw/backlight                                    /////////////////////////////////////////////////////////////////////////#include#deviceADC=10#fusesHS,NOWDT,PROTECT,NOLVP#usedelay(clock=20000000)#include"lcd.c"floatad_value;signedintad_result;int16bk_light_counter=0;int1bk_light_flag=1;#definePSW_KEYinput(PIN_C0)#defineUP_KEYinput(PIN_C1)#defineDOWN_KEYinput(PIN_C2)#defineBK_LIGHTPIN_B0voidinit();voidtemp_ad();voiddisplay();voidkey_detection();//============================================================================================================#INT_TIMER1voidclock1_isr(){  set_timer1(0x3CAF);        //Interruptevery(0xFFFF-0x3CAF)*0.2us=50000*0.2us=10ms  //backlightcouter  //----------------------------------------------------------------------------  if((bk_light_flag==1)&&(bk_light_counter<500))bk_light_counter++;  //about5second  elseif(bk_light_counter==500)      {        output_low(BK_LIGHT);        //turnoffbacklight        bk_light_flag=0;        //resetbacklightflag      }}//============================================================================================================//Detectanykeypressdown///////////////////////////////////////////////////////////////////////////////////////////////////////////////voidkey_detection(){  if((PSW_KEY==0)||(UP_KEY==0)||(DOWN_KEY==0))  {      output_high(BK_LIGHT);      bk_light_flag=1;      bk_light_counter=0;  }}/////////////////////////////////////////////////////////////////////////////////////////////////////////////////InitializetheLCDpanel//*************************************************************************************************************voidinit(){  setup_adc_ports(RA0_RA1_ANALOG_RA3_REF);        //A0A1Ref=A3for16F873A,nowVref=3.3V  setup_adc(ADC_CLOCK_INTERNAL);  setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);      //setupinterrupttimer1  enable_interrupts(INT_TIMER1);      //Turnoninterrupttimer1  enable_interrupts(GLOBAL);          //Enabledallinterruptions.  output_high(BK_LIGHT);  lcd_init();                        //Initializelcd  delay_ms(10);  lcd_gotoxy(1,1);                  //gotothestartpositionofthefirstline  lcd_putc("    Welcome!  ");      //displaystringinthefirstline  delay_ms(1);  lcd_gotoxy(1,2);                  //gotothestartpositionofthesecondline  lcd_putc("MicrochipMCU  ");      //displaystringinthesecondline  delay_ms(2000);}//**************************************************************************************************************//readtemperatureA/Ddata,AN1//temperaturecalculatorexpressionis:(ad_vaule(mv)-500)/10voidtemp_ad(){      int8tt;      int16ad_data;      {        ad_data=0;        for(tt=0;tt
我的博客更新更多新程序和資料,新增變壓器設計專題,歡迎大家來看一看.
0
回復
主站蜘蛛池模板: 日韩在线高清 | xxx.在线观看 | 亚洲午夜免费福利视频 | 91天天爽 | 国产成人无精品久久久 | 亚洲一区欧美一区 | 激情国产AV做激情国产爱 | 国产精品视频1区2区3区 | 欧美xxxx色视频在线观看 | 国产首页天堂在线 | 99久久国产免费 | 久久中文字幕网站 | 久久国产热视频 | 林雅诗三级无删减在线观看 | 中文字幕高清视频 | 亚洲免费视频中文字幕 | 91视频一区二区三区 | 精品久久久一 | 中文字幕无码乱码人妻系列蜜桃 | 久久综合久久自在自线精品自 | 最新国产精品视频 | 久久99精品久久久久久水蜜桃 | 欧美日韩中文字幕一区二区高清 | 午夜精品 | 黄色免看| 免费国产一区二区 | 久久香蕉精品 | caoporn最新 | 久久精品无码专区免费东京热 | 成人国产一区二区三区精品麻豆 | 懂色一区二区三区免费观看 | 永久免费看啪啪网址入口 | 午夜a级 | 欧美一级久久久猛烈a大片 国产吹潮视频在线观看 | 久久久二 | 欧美不卡视频 | 日韩人妻无码AV一区二区三区 | 国产精品高潮久久 | 51精品国产人成在线观看 | 第一区在线 | 97国产情侣爱久久免费观看 |