DS18x20 Temperature-Sensors readout with AVR

发布: 2009-9-14 15:02 |  作者: 玲珑 |   查看: 68次

DS18X20 with AVR

Demo application to read DS1820, DS18S20 andDS18B20temperature-sensors with an Atmel AVR controller. 1Wire-Bus with several devices on the wire supported, parasite power-supply supported without external FET ("strong-pullup" sourced from AVR-Portpin). The source-code is for avr-gcc/avr-libc. The 1-Wire- and DS18x20- routines may be used as "library" for own developments. 1-Wire-Bus I/O-Pin can be changed during runtime.

Credits: Peter Dannegger (some DS18x20- and most of the 1wire-code), Peter Fleury (uart-library), Colin O'Flynn (CRC-code)

P. Fleury's uart-library and P. Danneggers 1-Wire code have been slightly extended. There is not too much left from P. Dannegger's DS18x20-code but it has been the base for the presented "project". Used C. O'Flynns CRC8-Code only.

Changelog

  • 20. Sept. 2004 - Version 0.5
  • 30. Sept. 2004 - Version 0.6.1
  • 03. Oct. 2004 - Version 0.6.3, Run-time-config of 1-wire-bus, improved timeing
  • 24. Nov. 2004 - Version 0.6.4, Extended measurements for DS18(S)20 contributed by Carsten Foss (CFO)
  • 02. Feb. 2005 - Version 0.6.5, added function to read single sensor on OW-Bus (no rom-search needed), added demo using this function
  • 10. Mar. 2005 - Version 0.7, added functions to access the internal DS18x20 EEPROM

Hardware

  • Atmel AVR-Controller (ATmega16 and ATmega32 @ 1MHz, 2MHz, 4MHz, 8MHz internal R/C and 1,8432 MHz, 3.6864MHz ext. XTAL used for testing)
  • DS18X20 temperature-sensors (3 DS18B20 used during development)
  • 4,7 kOhm pull-up resistor for 1-Wire data-line
  • UART-connection to PC

Demo-Output

Version 0.6.x with two DS18B20

DS18X20 1-Wire-Reader Demo
--------------------------
Scanning Bus for DS18X20
2 DS18X20 Sensors available:
# in Bus :1 : FC:28 (18B)SN: 67 C6 6B 00 00 00 CRC:E2 CRC O.K.
# in Bus :2 : FC:28 (18B)SN: 44 D7 6B 00 00 00 CRC:BC CRC O.K.
Sensor# 1 is a DS18B20 which is parasite powered
Sensor# 2 is a DS18B20 which is externally powered

Convert_T and Read for every Sensor (reverse order)
Sensor# 2 = +20.9375°C [+20.9°C]
Sensor# 1 = +20.8750°C [+20.9°C]

Convert_T for all Sensors and Read for single Sensor
Sensor# 1 = +20.8750°C [+20.9°C]
Sensor# 2 = +20.9375°C [+20.9°C]

Verbose output
FC:28 (18B)SN: 67 C6 6B 00 00 00 CRC:E2 CRC O.K.
SP:4E 01 4B 46 7F FF 02 10 CRC:D9 CRC O.K.
T_raw=014E B20/12 +20.8750°C
FC:28 (18B)SN: 44 D7 6B 00 00 00 CRC:BC CRC O.K.
SP:4F 01 4B 46 7F FF 01 10 CRC:CF CRC O.K.
T_raw=014F B20/12 +20.9375°C

Version 0.7 with one DS18B20

DS18X20 1-Wire-Reader Demo by Martin Thomas
-------------------------------------------
Scanning Bus for DS18X20
1 DS18X20 Sensor(s) available:
# in Bus :1 : FC:28 (18B)SN: 44 D7 6B 00 00 00 CRC:BC CRC O.K.
Sensor# 1 is a DS18B20 which is externally powered

DS18x20 EEPROM support test for first sensor
TH/TL from EEPROM sensor 1 : 140 / 141
TH+1 and TL+1 written to scratchpad
scratchpad copied to DS18x20 EEPROM
DS18x20 EEPROM copied back to scratchpad
TH and TL verified
TH/TL from EEPROM sensor 1 now : 141 / 142

There is only one sensor -> Demo of "read_meas_single":
+21.8125°C [+21.8°C]

Convert_T and Read Sensor by Sensor (reverse order)
Sensor# 1 = +21.8125°C [+21.8°C]

Convert_T for all Sensors and Read Sensor by Sensor
Sensor# 1 = +21.8125°C [+21.8°C]

Verbose output
FC:28 (18B)SN: 44 D7 6B 00 00 00 CRC:BC CRC O.K.
SP:5D 01 8D 8E 7F FF 03 10 CRC:BD CRC O.K.
T_raw=015D B20/12 +21.8125°C

Software/Source-Code

(Hex-file for ATmega16@3,6864MHz included, 1-Wire data-pin PD6, remind the 1-wire pull-up between PD6 and VCC.)

TAG: AVR avr readout
打印 | 收藏此页 |  推荐给好友 | 举报
上一篇 下一篇
 

评分:0

发表评论
查看全部回复【已有0位网友发表了看法】

开发板推荐导购

 电子园服务子站:  电子园主站   电子园论坛    电子园社区    电子园商城    电子园百科    开发工具网    项目交易网    在线学习网
 电子园技术子站:   51单片机学习网   USB开发学习网   AVR单片机学习网   CAN总线学习网   PIC学习网   FPGA学习网   ARM学习网   DIY学习网   STM32学习网
  DSP学习网   EDA软件学习网   GPS开发学习网   GUI技术学习网   电源技术网   RF射频技术网   汽车电子技术网   医疗电子技术网   消费电子技术网
 助学开发板资源:  51单片机开发学习板   USB开发学习板   AVR M64单片机开发学习板   AVR M16单片机开发学习板   CAN总线开发学习板