1 Attachment(s)
Reading temperature using multi DS18B20
- chip use: pic16F876A running @ 20MHz, 2x20 alphanumeric LCD, DS18B20, MAX233
- software: when first power up the PIC scans for the DS18B20 and store ID ROM in the PIC's ram for later use. When the reads temperature and display the reading to the 2x20 LCD, also send out the temperature reading to RS232 for data logging.
-schematic included.
Please give credit to Mr. E, Jimbab, Bruce... as I copied some of their subroutines and modified.
Comments are welcome.
Thanks for reading.
In the zip file, you will find the pbp program and a pdf file for schematic.
I can't find your schematic - please
Your DS18B20 program is fantastic, and I would like to experiment with it.
You mention in your header, I should also see schematic 876DS18B20_ID_ROM_A.PBP.SCHDOC, but I can't find it anywhere. I can figure out most of the schematic from the code, but I will be using a serial LCD for my display, and need to know the type of LCD you used so that I might convert the codes.
Thanks again for a really well thought out piece of code
Thanks for the reply but..
Sorry, I just don't see the part number for the LCD used . Thanks
PIC16F877 based Temperature Controller
I wish to implement a PIC16F877 based temperature controller. A LM35DZ temperature sensing IC is connected to RA0 and 10bit A/D value is used to obtain voltage values at regular intervals. The value of the obtained temperature ( LM35DZ is calibrated to 10mV/0 C) is displayed on a HD44780 LCD module which is connected on PortB and using 4-bit data lines (RB4 to RB7). The deviation from the set-point temperature is used to compute a PID output and this output is used to generate PWM control signals. Both CCP modules of the PIC16F877 are used CCP1 being connected to the gate of the heater driving NMOSFET (IRL1004) and CCP2 also to the gate of the fan driving NMOSFET. The duty cycle has to be varied in proportionto the amount of deviation.
If you have any constructive advice do not hesitate to offer it or if anyone can hook me up with a similar design or relevant source code. I am familiar with both C and Basic programming languages. My regular email is [email protected] .Thanks in advance.
Re: Reading temperature using multi DS18B20
I am having some troubles understanding the read temperature portion of this code. Take the following exerpt from the code:
W1:
OWIN DQ,4,[busy] ' Check for still busy converting
IF busy = 0 THEN W1' Still busy?, then loop
owout dq,1,[$55,S[(L*8)+0],S[(L*8)+1],S[(L*8)+2],S[(L*8)+3],S[(L*8)+4],S[(L*8)+5],S[(L*8)+6],S[(L*8)+7],$BE]
OWIN dq, 2, [R_Temp.Lowbyte, R_Temp.Highbyte]' Read two bytes / end comms
HotOrCold:
IF Cold_Bit = Real_Cold THEN ' If Cold_Bit = 1, it's below "0" LcdDeg C
Sign = "-" ' Display - symbol for negative temp
Dummy = 625 * ~R_Temp+1' Multiply to load internal registers with 32-bit value
TempC = DIV32 10 ' Use Div32 value to calculate precise LcdDeg C
endif
if cold_bit = 0 then
Sign = "+"
Dummy = 625 * R_Temp ' Multiply to load internal registers with 32-bit value
TempC = DIV32 10 ' Use Div32 value to calculate precise LcdDeg C
TempC = (R_Temp & $0FF0) >> 4 ' Mask middle 8-bits, shift into lower byte
Float = ((R_Temp.Lowbyte & $0F) * 625) ' Lower 4-bits of result * 625
endif
1. Okay so, under HotOrCold:, about 10 lines down you are assigning TempC to DIV32 10. No problems there. Then you assign TempC to (R_Temp & $0FF0) >> 4. Does this not just overwrite the value of TempC that you just assigned?
2. Under HotOrCold: again. 3 lines down. What is the "~" for? Couldn't find any documentation on this from the picbasic help file. And what does the +1 do?
Re: Reading temperature using multi DS18B20
I think I can answer your last question...
~ is Bitwise NOT... meaning to invert each bit
For the other question I can not help... I have yet to understand exactly what the DIV32 function does.
Re: Reading temperature using multi DS18B20
Thanks! That clears that up. Do you know why the +1 on the end?
The DIV32 command allows you to divide the 32 bit number held in internal registers. But that's not really important here. More importantly, why do we assign TEMPC, then reassign it again on the next line of code without using it.
Re: Reading temperature using multi DS18B20
Thanks for posting your code. I was having difficulty with negative readings and converting to an integer. I saw what I was doing wrong, corrected my code and now I can read negative temperatures.
thanks,