| Swordfish Tutorial - DS18B20 Temperature Sensor |
|
|
| Saturday, 04 April 2009 09:00 | |
|
There are 3 Dallas digital temperature sensors, so be sure to get the correct one. There is the 1820, 18S20 and 18B20. The 18S20 is the successor to the 1820, and does not drift over time. The 18B20 is further enhanced, and offers faster conversions. Be aware that the 1820 and 18S20 will not function correctly with this 18B20 example.
Be sure to attach the 4.7K pull-up resistor to the databus, this is a requirement of the Dallas 1-Wire system. Most of the popular One Wire devices have their own libraries within Swordfish, I'm using the DS18B20 library to make this as simple as possible. Note that Swordfish also has an extensive One Wire library should you want to create your own custom interfacing module.
Device = 18F452 Clock = 20 // import modules... Include "DS18B20.bas" Include "convert.bas" Include "usart.bas" // working variables... Dim TempA As ShortInt, TempB As Word // Start Of Program... SetBaudrate(br19200) SetPin(PORTC.0) // Find() will search the bus for a single DS1820 device // and load its ROM ID into the DS1820 public variable RomID - you // could do this manually. For example, RomID = MyRomID... If DS18B20.Find Then While true Convert GetTemp(TempA, TempB) USART.Write(DecToStr(TempA),".",DecToStr(TempB,4), " C", 13, 10) DelayMS(1000) Wend Else USART.Write("No device found", 13, 10) EndIf
Comments (5)
Joomla components by Compojoom
|
|
| Last Updated ( Saturday, 18 April 2009 07:17 ) |
Whos Online
- ta1dr
- andyo
- Jon Chandler
Forum Activity
the LCD demo hello world - jon chandler Tuesday, 09 March 2010 23:48 - [28 replies]
USB problem - jon chandler Tuesday, 09 March 2010 11:31 - [3 replies]
Servo Module - andyo Tuesday, 09 March 2010 03:39 - [3 replies]
pic to ps2 communication - roshan Friday, 05 March 2010 01:30 - [7 replies]
Way Off Topic: Worldwide Ignite Week - jon chandler Wednesday, 03 March 2010 20:33 - [4 replies]
PIC USB with C and Visual C++ Project - hop Tuesday, 02 March 2010 21:49 - [0 replies]
Function generator help - magic Tuesday, 02 March 2010 16:37 - [10 replies]
Recent Comments
- 2010-03-09 13:27:12 air j...
link:http://www.b2c2u.com/ [air jordan] [url=http://www.handba...
- 2010-03-05 13:24:23 mrpse...
I was thinking of battery with powered routers or powered for every...
- 2010-03-05 12:17:40 andyo
50 rooms - wow. The XBee modules are very easy to use but I'm not ...
- 2010-03-05 11:46:37 mrpse...
Thanks AndyO. What I have to do is design a device to monitor temp...
- 2010-03-05 03:08:58 andyo
The circuit used for the remote sensor can be found here: [url]http...
- 2010-03-04 07:19:06 renno
plz i need help do u know from where i could download it or how cou...
- 2010-03-04 07:16:05 renno
hello everyone i'm trying to finish my final project and i want to ...
- 2010-03-04 02:49:38 Saira...
Thanks that was helpful





Can any digital pin be used for 1-wire receive?