I have bought 2 DS18S20-PAR digital temperature sensors, to implement into my aquarium controller. Ad first I had an analogue sensor KTY26-1 witch you have to make a lookup table to determine what the temperature is. Now I understand How I need to do this, Thanks a lot for your help people I really appreciate it.
So far so good,
Now I want to go a step further. because I had some trouble with the accuracy of my analogue sensor I wanted something more reliable (and easier) to work with. So I decided to purchase two DS18S20-PAR temp. sensors. I new that these type of sensor where already calibrated by default so I dont have to worry about that. And also I have read that these type of sensors are communicating with what is called a ONE-WIRE bus. I was really excited because I never heard from it before and really want to learn how it works. I also noticed that flowcode has macros for the one wire bus and specifically 3 macros for the DS1820. NICE
After reading the datasheet 3 times and looking into the One-Wire help file I have made this program to read the raw temperature data from the sensor. White my weather station left of my, I can use his temperature as my base point to confirm my DS18S20 is working correct. Because if my room temperature is rounded 25"C then my DS18S20 should probably give 400. After a calculation |Temperature = (400*10)/16| Temperature is = 250.
But to start understanding I only want to read the raw temperature value.
So as I have seed before, I have made A program that can detect how many device there are connected on the bus so that greet
# DS1820_Start_Conversion
<<<<1000ms delay
# DS1820_Read_Scratchpad <<<<< Stored in variable: (one_wire_scratchpad)
# DS1820_Get_Temp <<<<< Stored in variable: (ds18s20_temp)
So uploaded the program to my EB006 programmer board
CHIP = PIC16F887a
CLOCK = 19.6608 MHz
LCD = PORTB
One-Wire = PORTA.0
DS18S20 is in parrasite mode and I used a 4.7K pullup from DQ and PORTA.0 to 5V+
After I have loaded the program, YES the program doesn't work. Here is where the learning part begins. My program detects if there is a device connected if not the program keeps checking. If a device is found It will continue and preform a convert macro every 1000ms.
The result is 170. no matter what I do, I can stair at it pull it out and back in reset the uC. It keeps showing me 170.
Can you help me why this is and help me understand and learn from it. So I can say; Ah haa now I get it, now I know how it works.
Thanks Guys
Regards Jordy Kleian
