久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

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

QQ登錄

只需一步,快速開始

搜索
查看: 7440|回復(fù): 8
收起左側(cè)

基于Atmega8的溫度測(cè)控系統(tǒng)設(shè)計(jì)_電路圖+程序+仿真+資料

[復(fù)制鏈接]
ID:159015 發(fā)表于 2017-2-18 09:27 | 顯示全部樓層 |閱讀模式
該設(shè)計(jì)為本人在校期間的綜合設(shè)計(jì)項(xiàng)目,經(jīng)過(guò)調(diào)試與測(cè)試。附件包含電路圖、程序、仿真及相關(guān)資料。
1系統(tǒng)設(shè)計(jì)要求
用單片機(jī)開發(fā)一個(gè)溫度測(cè)量控制系統(tǒng),顯示用16*2的液晶,實(shí)時(shí)顯示測(cè)量溫度,加熱輸出采用PWM控制,用發(fā)光二極管來(lái)模擬,能設(shè)置目標(biāo)溫度,能設(shè)置報(bào)警溫度閾值,超過(guò)了進(jìn)行報(bào)警,報(bào)警采用液晶屏幕顯示。
2系統(tǒng)設(shè)計(jì)總體方案
本系統(tǒng)由單片機(jī)、按鍵、液晶顯示和外圍加熱電路等部分組成,這里用發(fā)光二極管來(lái)模擬。對(duì)溫度進(jìn)行實(shí)時(shí)采集并通過(guò)程序設(shè)定最高溫度、最低溫度,采集到的實(shí)時(shí)溫度通過(guò)串口向單片機(jī)進(jìn)行傳輸,最后將測(cè)得的結(jié)果發(fā)送到液晶,實(shí)時(shí)顯示測(cè)量溫度。該系統(tǒng)對(duì)所測(cè)得的溫度值進(jìn)行分析,當(dāng)溫度高于或者低于設(shè)定的溫度閾值時(shí)自動(dòng)報(bào)警,并控制加熱設(shè)備,以達(dá)到對(duì)溫度智能控制,從而使環(huán)境溫度維持在設(shè)定的有利溫度范圍內(nèi)。

圖片1.png
proteus仿真原理圖:
0.png

pcb: PCB圖.jpg

原理圖:
原理圖 .jpg

0.png

所有資料下載:
綜合設(shè)計(jì).rar (17.23 MB, 下載次數(shù): 98)

評(píng)分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎(jiǎng)勵(lì)!

查看全部評(píng)分

回復(fù)

使用道具 舉報(bào)

ID:1 發(fā)表于 2017-2-18 16:43 | 顯示全部樓層
下面是樓主的主程序:
  1. /*****************************************************
  2. This program was produced by the
  3. CodeWizardAVR V2.05.0 Professional
  4. Automatic Program Generator
  5. ?Copyright 1998-2010 Pavel Haiduc, HP InfoTech s.r.l.

  6. Project :
  7. Version :
  8. Author  : NeVaDa
  9. Company :
  10. Comments:


  11. Chip type               : ATmega48
  12. AVR Core Clock frequency: 8.000000 MHz
  13. Memory model            : Small
  14. External RAM size       : 0
  15. Data Stack size         : 128
  16. *****************************************************/

  17. #include <mega48.h>

  18. #include <delay.h>

  19. // DS18b20 Temperature Sensor functions
  20. #include <ds18b20.h>

  21. // Alphanumeric LCD Module functions
  22. #include <alcd.h>

  23. #define ADC_VREF_TYPE 0x60

  24. #define Temp_Set_Key_Not_Pressed  PIND.6
  25. #define Alarm_Set_Key_Not_Pressed PIND.7

  26. // Read the 8 most significant bits
  27. // of the AD conversion result
  28. unsigned char read_adc(unsigned char adc_input)
  29. {
  30. ADMUX=adc_input | (ADC_VREF_TYPE & 0xff);
  31. // Delay needed for the stabilization of the ADC input voltage
  32. delay_us(10);
  33. // Start the AD conversion
  34. ADCSRA|=0x40;
  35. // Wait for the AD conversion to complete
  36. while ((ADCSRA & 0x10)==0);
  37. ADCSRA|=0x10;
  38. return ADCH;
  39. }

  40. // Declare your global variables here

  41. unsigned char Char_Array[3];
  42. unsigned char AD_Value=0;
  43. int  Temprature;
  44. float  Temp;
  45. unsigned char Temp_Set_Value=20;
  46. unsigned char Alarm_Set_Value=80;

  47. void HEX_To_AscII(int data,unsigned char *P)
  48. {
  49.   P[2]=(data/100)+0x30;
  50.   P[1]=((data%100)/10)+0x30;
  51.   P[0]=(data%10)+0x30;
  52. }

  53. void main(void)
  54. {
  55. // Declare your local variables here

  56. // Crystal Oscillator division factor: 1
  57. #pragma optsize-
  58. CLKPR=0x80;
  59. CLKPR=0x00;
  60. #ifdef _OPTIMIZE_SIZE_
  61. #pragma optsize+
  62. #endif

  63. // Input/Output Ports initialization
  64. // Port B initialization
  65. // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=Out Func1=Out Func0=In
  66. // State7=T State6=T State5=T State4=T State3=T State2=1 State1=1 State0=T
  67. PORTB=0x06;
  68. DDRB=0x06;

  69. // Port C initialization
  70. // Func6=In Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=In
  71. // State6=T State5=1 State4=1 State3=1 State2=1 State1=1 State0=T
  72. PORTC=0x3E;
  73. DDRC=0x3E;

  74. // Port D initialization
  75. // Func7=In Func6=In Func5=In Func4=In Func3=Out Func2=In Func1=In Func0=In
  76. // State7=P State6=P State5=T State4=T State3=1 State2=T State1=T State0=T
  77. PORTD=0xC8;
  78. DDRD=0x08;

  79. // Timer/Counter 0 initialization
  80. // Clock source: System Clock
  81. // Clock value: Timer 0 Stopped
  82. // Mode: Normal top=0xFF
  83. // OC0A output: Disconnected
  84. // OC0B output: Disconnected
  85. TCCR0A=0x00;
  86. TCCR0B=0x00;
  87. TCNT0=0x00;
  88. OCR0A=0x00;
  89. OCR0B=0x00;

  90. // Timer/Counter 1 initialization
  91. // Clock source: System Clock
  92. // Clock value: Timer1 Stopped
  93. // Mode: Normal top=0xFFFF
  94. // OC1A output: Discon.
  95. // OC1B output: Discon.
  96. // Noise Canceler: Off
  97. // Input Capture on Falling Edge
  98. // Timer1 Overflow Interrupt: Off
  99. // Input Capture Interrupt: Off
  100. // Compare A Match Interrupt: Off
  101. // Compare B Match Interrupt: Off
  102. TCCR1A=0x00;
  103. TCCR1B=0x00;
  104. TCNT1H=0x00;
  105. TCNT1L=0x00;
  106. ICR1H=0x00;
  107. ICR1L=0x00;
  108. OCR1AH=0x00;
  109. OCR1AL=0x00;
  110. OCR1BH=0x00;
  111. OCR1BL=0x00;

  112. // Timer/Counter 2 initialization
  113. // Clock source: System Clock
  114. // Clock value: 250.000 kHz
  115. // Mode: Fast PWM top=0xFF
  116. // OC2A output: Disconnected
  117. // OC2B output: Inverted PWM
  118. ASSR=0x00;
  119. TCCR2A=0x33;
  120. TCCR2B=0x03;
  121. TCNT2=0x00;
  122. OCR2A=0x00;
  123. OCR2B=0x00;

  124. // External Interrupt(s) initialization
  125. // INT0: Off
  126. // INT1: Off
  127. // Interrupt on any change on pins PCINT0-7: Off
  128. // Interrupt on any change on pins PCINT8-14: Off
  129. // Interrupt on any change on pins PCINT16-23: Off
  130. EICRA=0x00;
  131. EIMSK=0x00;
  132. PCICR=0x00;

  133. // Timer/Counter 0 Interrupt(s) initialization
  134. TIMSK0=0x00;

  135. // Timer/Counter 1 Interrupt(s) initialization
  136. TIMSK1=0x00;

  137. // Timer/Counter 2 Interrupt(s) initialization
  138. TIMSK2=0x00;

  139. // USART initialization
  140. // USART disabled
  141. UCSR0B=0x00;

  142. // Analog Comparator initialization
  143. // Analog Comparator: Off
  144. // Analog Comparator Input Capture by Timer/Counter 1: Off
  145. ACSR=0x80;
  146. ADCSRB=0x00;
  147. DIDR1=0x00;

  148. // ADC initialization
  149. // ADC Clock frequency: 250.000 kHz
  150. // ADC Voltage Reference: AVCC pin
  151. // ADC Auto Trigger Source: ADC Stopped
  152. // Only the 8 most significant bits of
  153. // the AD conversion result are used
  154. // Digital input buffers on ADC0: Off, ADC1: On, ADC2: On, ADC3: On
  155. // ADC4: On, ADC5: On
  156. DIDR0=0x01;
  157. ADMUX=ADC_VREF_TYPE & 0xff;
  158. ADCSRA=0x85;

  159. // SPI initialization
  160. // SPI disabled
  161. SPCR=0x00;

  162. // TWI initialization
  163. // TWI disabled
  164. TWCR=0x00;

  165. // 1 Wire Bus initialization
  166. // 1 Wire Data port: PORTB
  167. // 1 Wire Data bit: 0
  168. // Note: 1 Wire port settings must be specified in the
  169. // Project|Configure|C Compiler|Libraries|1 Wire IDE menu.
  170. //w1_init();


  171. // Alphanumeric LCD initialization
  172. // Connections specified in the
  173. // Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu:
  174. // RS - PORTB Bit 1
  175. // RD - PORTB Bit 2
  176. // EN - PORTC Bit 1
  177. // D4 - PORTC Bit 2
  178. // D5 - PORTC Bit 3
  179. // D6 - PORTC Bit 4
  180. // D7 - PORTC Bit 5
  181. // Characters/line: 16
  182. lcd_init(16);

  183. lcd_gotoxy(0, 0);
  184. lcd_puts("NBUT");
  185. lcd_gotoxy(0, 1);
  186. if(ds18b20_init(0,-60,80,DS18B20_9BIT_RES))
  187.   lcd_puts("OK!");
  188. else
  189.   lcd_puts("FAULT!");
  190. delay_ms(1000);
  191. lcd_gotoxy(0, 0);
  192. lcd_puts("Temp:");
  193. lcd_gotoxy(0,1);
  194. lcd_puts("AD:");

  195. lcd_gotoxy(8, 1);
  196. lcd_puts("ALM:");
  197. HEX_To_AscII(Alarm_Set_Value,Char_Array);  
  198. lcd_putchar(Char_Array[1]);  
  199. lcd_putchar(Char_Array[0]);
  200. lcd_putchar('C');


  201. while (1)
  202.       {
  203.       // Place your code here
  204.          //溫度讀取
  205.          Temp=ds18b20_temperature(0);
  206.          
  207.          //加熱處理
  208.         if((int)Temp>Temp_Set_Value)
  209.            OCR2B=0;
  210.          else
  211.            OCR2B=AD_Value;  
  212.            //OCR2B=255;  
  213.          
  214.          //報(bào)警處理
  215.          lcd_gotoxy(12, 0);
  216.          if(Temp>Alarm_Set_Value)
  217.            lcd_puts("ALM!");
  218.          else
  219.            lcd_puts("    ");
  220.          
  221.          
  222.          //溫度顯示   
  223.          Temprature=Temp*10;
  224.          //delay_ms(10);
  225.          lcd_gotoxy(5, 0);
  226.          if(Temprature<0)
  227.          {
  228.            Temprature=-Temprature;
  229.            lcd_putchar('-');
  230.          }
  231.          else  
  232.            lcd_putchar('+');
  233.            
  234.          HEX_To_AscII(Temprature,Char_Array);
  235.            
  236.          lcd_putchar(Char_Array[2]);
  237.          lcd_putchar(Char_Array[1]);
  238.          lcd_putchar('.');
  239.          lcd_putchar(Char_Array[0]);
  240.          lcd_putchar('C');
  241.          
  242.          //ad轉(zhuǎn)換處理
  243.          AD_Value=read_adc(0);
  244.          Temprature=(AD_Value*10)/51;
  245.          HEX_To_AscII(Temprature,Char_Array);
  246.          lcd_gotoxy(3,1);
  247.          //lcd_putchar(Char_Array[2]);
  248.          lcd_putchar(Char_Array[1]);  
  249.          lcd_putchar('.');
  250.          lcd_putchar(Char_Array[0]);
  251.          lcd_putchar('V');  
  252.          
  253.          //溫度設(shè)置按鍵處理
  254.          if(!Temp_Set_Key_Not_Pressed)
  255.          {
  256.            delay_ms(10);
  257.            if(!Temp_Set_Key_Not_Pressed)
  258.            {
  259.              Temp_Set_Value++;
  260.              if(Temp_Set_Value>20)
  261.                Temp_Set_Value=0;
  262.              lcd_gotoxy(5, 0);
  263.              HEX_To_AscII(Temp_Set_Value,Char_Array);  
  264.              lcd_putchar(Char_Array[1]);  
  265.              lcd_putchar(Char_Array[0]);
  266.              lcd_putchar('C');
  267.              lcd_puts("   ");
  268.              delay_ms(500);
  269.            }
  270.          }
  271.               
  272.          //溫度報(bào)警設(shè)置按鍵處理
  273.          if(!Alarm_Set_Key_Not_Pressed)
  274.          {
  275.            delay_ms(10);
  276.            if(!Alarm_Set_Key_Not_Pressed)
  277.            {
  278.              Alarm_Set_Value++;
  279.              if(Alarm_Set_Value>20)
  280.                Alarm_Set_Value=0;
  281.              lcd_gotoxy(12, 1);
  282.              HEX_To_AscII(Alarm_Set_Value,Char_Array);  
  283.              lcd_putchar(Char_Array[1]);  
  284.              lcd_putchar(Char_Array[0]);
  285.              lcd_putchar('C');
  286.              delay_ms(500);
  287.            }
  288.          }
  289.       }
  290. }
復(fù)制代碼
回復(fù)

使用道具 舉報(bào)

ID:165840 發(fā)表于 2017-2-21 21:52 | 顯示全部樓層
不錯(cuò)哦,能開源。值得學(xué)習(xí)。
回復(fù)

使用道具 舉報(bào)

ID:334441 發(fā)表于 2018-9-12 11:32 | 顯示全部樓層
怎么只有主程序的c文件
回復(fù)

使用道具 舉報(bào)

ID:334441 發(fā)表于 2018-9-12 11:34 | 顯示全部樓層
有沒(méi)有其他的c文件和h文件
回復(fù)

使用道具 舉報(bào)

ID:396939 發(fā)表于 2018-9-12 12:29 | 顯示全部樓層
只有一個(gè)主程序嗎
回復(fù)

使用道具 舉報(bào)

ID:334441 發(fā)表于 2018-9-13 16:41 | 顯示全部樓層
BaGas 發(fā)表于 2018-9-12 12:29
只有一個(gè)主程序嗎

是的
回復(fù)

使用道具 舉報(bào)

ID:358464 發(fā)表于 2018-9-21 12:31 | 顯示全部樓層
感謝分享
回復(fù)

使用道具 舉報(bào)

ID:358464 發(fā)表于 2018-9-21 12:32 | 顯示全部樓層
pcb和原理圖的文件沒(méi)有啊?
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

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

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

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 福利精品 | av黄色在线| 中文字幕高清 | 日本亚洲精品成人欧美一区 | 久久综合久色欧美综合狠狠 | 国产精品国产馆在线真实露脸 | 国产一区二区三区视频 | 一区二区高清 | 波多野结衣一区二区三区 | 欧美日韩美女 | 国产精品久久久久久久久图文区 | 成人免费一级 | 亚洲一一在线 | 久草99| 久久久久久久久久久久久9999 | 国产高清视频一区二区 | av手机在线 | www亚洲免费国内精品 | 亚洲三区视频 | 日韩精品视频在线 | 99精品免费 | 99视频精品 | 一级毛片免费完整视频 | 日本一区二区三区四区 | 亚洲视频一区二区三区 | 欧美日韩1区2区 | 久久天堂 | 人人鲁人人莫人人爱精品 | 欧区一欧区二欧区三免费 | 在线视频一区二区 | 狠狠色狠狠色综合系列 | 精品久久久久一区二区国产 | 亚洲成人免费 | 日韩在线欧美 | 久久久久国产精品一区二区 | 日韩在线一区二区三区 | 久久精品中文 | 在线一级片 | 色婷婷激情综合 | 国产美女精品视频免费观看 | 国产一区二区三区在线视频 |