| 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
- Graham
- andyo
- Jon Chandler
Forum Activity
Marching LEDs - mrdeb Saturday, 13 March 2010 22:54 - [7 replies]
Credit Where Credit's Due - jon chandler Saturday, 13 March 2010 18:51 - [4 replies]
USB 8 Channel Servo Controller - andyo Saturday, 13 March 2010 01:19 - [2 replies]
Dedicated Servo Controller - graham Friday, 12 March 2010 17:58 - [0 replies]
Must have....delta temperature glowies! - graham Friday, 12 March 2010 17:31 - [3 replies]
A 'throw-away" PIC board - jon chandler Friday, 12 March 2010 13:41 - [31 replies]
iHID - graham Friday, 12 March 2010 02:04 - [5 replies]
Recent Comments
- 2010-03-13 16:36:21 andyo
Very nice - 900,000 packets and 0 errors - can't ask for better tha...
- 2010-03-13 11:59:14 Anony...
proton
- 2010-03-12 19:44:17 Jon C...
Here is a spreadsheet of compatible parts: [url]http://digital-diy...
- 2010-03-12 14:26:02 Anony...
What program do you use to capture the simulation to a videofile?
- 2010-03-12 13:15:58 Jon C...
Here's a tip for tying out SD cards. An SD card will fit the flopp...
- 2010-03-11 21:03:32 Jon C...
If this wasn't a class project that had to be done on a PIC16F690 u...
- 2010-03-11 15:30:06 uuu
I am going to send two data from ADC to USART(async mode) to serial...
- 2010-03-05 13:24:23 mrpse...
I was thinking of battery with powered routers or powered for every...





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