Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Multi DS1820 OWD's in temperature alarm

Status
Not open for further replies.
Hi,
A simple fan failure caused a near disaster to an old computer system I am working on.

As the system has no way of detecting overheating I thought that it would be good idea to put one in.

My thoughts are to use up to 8 DS1820 1 wire devices into a PIC which has pre-set temperature limits above which an alarm sounds. The device zone and it's temperature are shown on an LCD.

Having looked at the Oshon help I can see how one device can be read from, but how to do it with 7 others ?

I know that each DS1820 is manufactured with a unique code, but how to read that and tie it in with the sensor position I do not know.

Help would be very much appreciated.

Stewart
 
Stewart,

The following code will allow you to find the address of each DS1820 you want to use. You can then use a single i/o pin and run them all in parallel. Hope this is of some help.



'Set all proc pins to I/O

AllDigital

'Setup port B for LCD use
Define LCD_BITS = 4
Define LCD_DREG = PORTB
Define LCD_DBIT = 4
Define LCD_RSREG = PORTB
Define LCD_RSBIT = 0
Define LCD_RWREG = PORTB
Define LCD_RWBIT = 1
Define LCD_EREG = PORTB
Define LCD_EBIT = 2


'Setup port A pin 2 for temp sensor

Define 1WIRE_REG = PORTA
Define 1WIRE_BIT = 0

'Declare variables to be used
Dim numb As Byte
Dim hexh As Byte
Dim hexl As Byte
Dim loop1 As Byte
Dim romcode(8) As Byte


Lcdinit

start:

1wireInit
'Command to read ROM contents
1wireSendByte 0x33
For loop1 = 0 To 7
1wireGetByte romcode(loop1)
Next loop1

'Now display device family code
Lcdout "FC= "
numb = romcode(0)
Call convert_to_hex(numb)
Lcdout "h CRC= "
numb = romcode(7)
Call convert_to_hex(numb)
Lcdout "h"
'Now display serial number on LCD line 2
Lcdcmdout LcdLine2Home
Lcdout "#="
For loop1 = 6 To 1 Step -1
numb = romcode(loop1)
Call convert_to_hex(numb)
Next loop1
Lcdout "h"
WaitMs 500
Lcdcmdout LcdClear
Goto start
End
'Convert HEX byte to 2 nibbles

Proc convert_to_hex(num1 As Byte)
hexh = num1 And 0xf0
hexh = ShiftRight(hexh, 4)
Call display_hex(hexh)
hexl = num1 And 0x0f
Call display_hex(hexl)
End Proc
'Convert HEX nibble to ASCII and display

Proc display_hex(numb As Byte)
If numb <= 9 Then
numb = numb + 30h
Else
numb = numb + 37h
Endif
Lcdout numb
End Proc
 
Thanks Mellbreak.

I will have a look at your code, as although I have finished the project using the MUX technique I am interested for the future.

Best wishes
Stewart
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top