Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 03:53 25 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : 1-Wire

     Page 1 of 2    
Author Message
DuinoMiteMegaAn
Senior Member

Joined: 17/11/2011
Location: Australia
Posts: 231
Posted: 12:43pm 21 Dec 2011
Copy link to clipboard 
Print this post

Users beware 1-wire is s l o w - it takes about 700 millseconds for a 1-wire transfer. The CPU is really waiting for the read transfer to complete so be very careful when using 1-wire devices.

http://en.wikipedia.org/wiki/1-Wire


Cool link for 1-wire devices
http://www.hobby-boards.com/catalog/main_page.php

http://www.aag.com.mx/aagusa/index1.htmlEdited by DuinoMiteMegaAn 2011-12-22
 
DuinoMiteMegaAn
Senior Member

Joined: 17/11/2011
Location: Australia
Posts: 231
Posted: 12:33am 22 Dec 2011
Copy link to clipboard 
Print this post

Maybe the 1-wire creator for the DM could chime in on the
exact read / write times using his 1-wire MMBasic code?
 
ksdesigns

Senior Member

Joined: 25/06/2011
Location: United States
Posts: 143
Posted: 12:38am 22 Dec 2011
Copy link to clipboard 
Print this post

Well it depends on what you are using parts like the DS18B20 take 750ms to convert temp to a 12bit word ..
you can drop to 9bit resolution and conversion time would be about 94ms .
ken

 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 02:52am 22 Dec 2011
Copy link to clipboard 
Print this post

Hi

Gerard (Sec061)has been very kind and used his skills to add the Dallas 1-wire
protocol to MMBasic

I have attached the required hex file
2011-12-22_124124_Maximite-1w.zip

Gerard has also fixed the bugs that Geoff fixed in 2.7b

Quote from Gerard
"I have implemented my own fixes for the bugs he fixed in v2.7b - but I have no idea if I have fixed them the same way. But it works for me!
As a result of debugging the one wire code I have also fixed an insidious bug that would affect the state of Open Collector digital outputs - and believe me, that took some days too find!"

There are 4 commands and 2 functions:

Commands:

OWRESET pin [,presence]
OWWRITE pin, flag, length, data [, data…]
OWREAD pin, flag, length, data [, data…]
OWSEARCH pin, srchflag, ser [,ser…]

The OWRESET and OWSEARCH commands (and the OWREAD and OWWRITE commands if a reset is requested) set the MM.OW variable:
1 = OK (presence detected, search successful) else 0 = Fail (presence not detected, search unsuccessful).

Where:
pin - the MMBasic I/O pin to use

presence - an optional variable to receive the presence pulse (1 = device response, 0 = no device response)

flag - a combination of the following options:
1 - send reset before command
2 - send reset after command
4 - only send/recv a bit instead of a byte of data
8 - invoke a strong pullup after the command (the pin will be set high and open drain disabled)

length - length of data to send or receive

data - data to send or receive

srchflag - a combination of the following options:
1 - start a new search
2 - only return devices in alarm state
4 - search for devices in the requested family (first byte of ser)
8 - skip the current device family and return the next device
16 - verify that the device with the serial number in ser is available
If srchflag = 0 (or 2) then the search will return the next device found

ser - serial number (8 bytes) will be returned (srchflag 4 and 16 will also use the values in ser)

After the command is executed, the pin will be set to the NOT_CONFIGURED state unless flag option 8 is used.

The data and ser arguments can be a string, array or a list of variables.

Functions:

OWCRC8(len, cdata [, cdata…]) Processes the cdata and returns the 8 bit CRC
OWCRC16(len, cdata [, cdata…]) Processes the cdata and returns the 16 bit CRC

Where:
len - length of data to process

cdata - data to process

The cdata can be a string, array or a list of variables


Sample code below to display temperature using a DS18B20

10 dim ar(10)
20 p = 18
30 owreset p,presence:? "Presence: ";presence;
35 precision = 3 : gosub 500
40 owwrite p,1,2,&hcc,&h44
50 for i = 1 to 12000
60 owread p,4,1,b
70 if b = 1 then
80 if (i mod 8) = 0 then exit for
90 endif
100 next i
120 owwrite p,1,2,&hcc,&hbe
130 owread p,2,9,ar(0)
140 ? ", Data: (";ar(0);",";ar(1);",";ar(2);",";ar(3);",";ar(4);",";ar(5);" ,";ar(6);",";ar(7);",";ar(8);
150 owreset p,presence:? " ), Presence: ";presence
155 ? "CRC: ";owcrc8(9,ar(0))
160 tl = ar(0) : th = ar(1)
170 if (th and &h80) then
190 temp = ((tl and &h0f) * 0.0625) + ((tl and &hf0) / 16) + ((th and &h07) * 16) - 128
200 else
220 temp = ((tl and &h0f) * 0.0625) + ((tl and &hf0) / 16) + ((th and &h07) * 16)
230 endif
240 tempf = ((temp * 9) / 5) + 32
250 ? "Temp: ";temp;"C, ";tempf;"F"
260 owsearch p,1,ar(0)
262 if mm.ow = 0 then
264 ? "Search failed"
266 else
268 i = 0
270 do while mm.ow = 1
275 i = i + 1
280 ? "Serial number ";i;": (";ar(0);",";ar(1);",";ar(2);",";ar(3);",";ar(4);",";ar(5);" ,";ar(6);",";ar(7);" )"
290 owsearch p,0,ar(0)
300 loop
310 endif
320 owsearch p,16,ar(0)
330 if mm.ow = 1 then
340 ? "Verify serial number OK: (";ar(0);",";ar(1);",";ar(2);",";ar(3);",";ar(4);",";ar(5);" ,";ar(6);",";ar(7);" )"
350 else
360 ? "Verify failed"
370 endif
390 end
500 if precision = 4 then
510 owwrite p,1,5,&hcc,&h4e,&h00,&h00,&h7f
520 elseif precision = 3 then
530 owwrite p,1,5,&hcc,&h4e,&h00,&h00,&h5f
540 elseif precision = 2 then
550 owwrite p,1,5,&hcc,&h4e,&h00,&h00,&h3f
560 else
570 owwrite p,1,5,&hcc,&h4e,&h00,&h00,&h1f
580 endif
590 return


Output from above code

> run
Presence: 1, Data: ( 188, 1, 0, 0, 95, 255, 4, 16, 90 ), Presence: 1
CRC: 0
Temp: 27.75C, 81.95F
Serial number 1: ( 40, 180, 121, 247, 2, 0, 0, 227 )
Verify serial number OK: ( 40, 180, 121, 247, 2, 0, 0, 227 )

Many Thanks to Gerard for all his effort.

I have tested this and can confirm it functions as expected

Regards

John

 
Ray B
Senior Member

Joined: 16/02/2007
Location: Australia
Posts: 219
Posted: 03:30am 22 Dec 2011
Copy link to clipboard 
Print this post

WOW........ Thanks for the Xmas present ............ WOW
RayB from Perth WA
 
seco61
Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 205
Posted: 11:36am 22 Dec 2011
Copy link to clipboard 
Print this post

  DuinoMiteMegaAn said   Maybe the 1-wire creator for the DM could chime in on the
exact read / write times using his 1-wire MMBasic code?


The 1 wire support is based on the "standard" 1 wire speed (I do not support the "overdrive" speed).

This means a reset sequence takes nearly 1mS, and each bit transferred takes 70uS (including the inter-bit gap). So this means it can transmit/receive around 1780 bytes per second (not including the reset sequence).

As Ken mentioned, the delay in getting a response from a DS18B20 chip only occurs when you send it the "convert temperature" command - and then the time taken depends on the precision requested. You can always do other work instead of waiting for the device. The 1 wire protocol is not sensitive to delays between bits.

Regards

Gerard

Regards

Gerard (vk3cg/vk3grs)
 
Bryan1

Guru

Joined: 22/02/2006
Location: Australia
Posts: 1344
Posted: 08:28pm 22 Dec 2011
Copy link to clipboard 
Print this post

Hi Gerard,
First a big Thank you for the one wire inclusion for the Duinomite mate .

Now one thing has me thinking on line 20 p = 18, I do assume this is the (setpin) command and I have gone thru both datasheets looking for a reference to this with out any luck. Now if (p = ) is a new shortcut for the pin command I would like to add it to the help file but with no reference to it I'm out in the dark....

Regards Bryan
 
ksdesigns

Senior Member

Joined: 25/06/2011
Location: United States
Posts: 143
Posted: 08:29pm 22 Dec 2011
Copy link to clipboard 
Print this post

  Bryan1 said   Hi Gerard,
First a big Thank you for the one wire inclusion for the Duinomite mate .

Now one thing has me thinking on line 20 p = 18, I do assume this is the (setpin) command and I have gone thru both datasheets looking for a reference to this with out any luck. Now if (p = ) is a new shortcut for the pin command I would like to add it to the help file but with no reference to it I'm out in the dark....

Regards Bryan

Its just a variable for the pin number
so you don't have to enter the pin number for every command
ken

 
Keith @

Senior Member

Joined: 19/06/2011
Location: Australia
Posts: 167
Posted: 09:43am 23 Dec 2011
Copy link to clipboard 
Print this post

Gerard

Many thanks for your efforts with the 1-Wire code ... I have been waiting for this for a while now and it's really appreciated. I have loaded the DM2.7b which shows as 2.7a on the load message when my Maximite first boots.

Have run a couple of my programs and so far so good.

More testing and programming tomorrow

(this was also a test of the wrap around problem with Firefox)

regards
Keith

Looks ok in firefox even thou I didn't do a line return in the first paragraph hmmmmEdited by Keith @ 2011-12-24
The more we know, the more we know we don't know !
 
Keith @

Senior Member

Joined: 19/06/2011
Location: Australia
Posts: 167
Posted: 05:29am 24 Dec 2011
Copy link to clipboard 
Print this post

Hi Guys

The code is in it's early days ... I haven't changed anything except to add a blank remark at the end of line 590 because something chops off the last letter of return and the program spits the dummy.

Parasitic power doesn't work with the DS18B20 chips in my pre assembled Chinese probes so I had to apply 5.0v to VDD.

I didn't have a 4.7K resistor for the pullup so I used two 10k in parallel ... works ok.

Got the first probe working ok once I got the above issues sorted out.

Connected probe 2 and the software detects and reports the serial numbers of both probes but only reports the temperature of the probe with last serial number.

The code doesn't loop but that is easy enough to fix meanwhile I just have to keep typing the run command when I want a new temp read.

I'm happy .... next I'm going to drink the can of beer on which I was reading the cold temp ... then I 'll have a look at the code and maybe some more Xmas cheer.

Keith


The more we know, the more we know we don't know !
 
seco61
Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 205
Posted: 09:50pm 24 Dec 2011
Copy link to clipboard 
Print this post

Hi Keith.

The DS18B20 chips require special "treatment" if you wish to run them using parasitic power. The convert command requires either an external power source or a strong pullup on the data line during the conversion process. To supply a "strong" pullup you can set the appropriate value for the flag field for the send command that issues the temperature conversion request. Then instead of polling the data line to test when the conversion has completed, you have to wait until sufficient time has passed. This will depend on the precision you have requested - so the wait time will be between approximately 100mS (9 bit precision) to 750mS (12 bit precision). Then just issue the read command as usual.

In other words the lines 40 - 100 would change to:


40 owwrite p,9,2,&hcc,&h44
45 pause 750 ' or set a variable in the precision subroutine
50 'for i = 1 to 12000
60 ' owread p,4,1,b
70 ' if b = 1 then
80 ' if (i mod 8) = 0 then exit for
90 ' endif
100 'next i



The sample code I supplied uses a "skip rom" command - this means that all devices on the bus can respond to the following function command. This is great when there is only one device on the bus - if you need to address multiple devices then you must issue the "match rom" command with the appropriate serial number before issuing the device function commands.

Or you could place the 2 devices on different I/O pins.

Merry Christmas!

  Keith @ said   Hi Guys

The code is in it's early days ... I haven't changed anything except to add a blank remark at the end of line 590 because something chops off the last letter of return and the program spits the dummy.

Parasitic power doesn't work with the DS18B20 chips in my pre assembled Chinese probes so I had to apply 5.0v to VDD.

I didn't have a 4.7K resistor for the pullup so I used two 10k in parallel ... works ok.

Got the first probe working ok once I got the above issues sorted out.

Connected probe 2 and the software detects and reports the serial numbers of both probes but only reports the temperature of the probe with last serial number.

The code doesn't loop but that is easy enough to fix meanwhile I just have to keep typing the run command when I want a new temp read.

I'm happy .... next I'm going to drink the can of beer on which I was reading the cold temp ... then I 'll have a look at the code and maybe some more Xmas cheer.

Keith

Edited by seco61 2011-12-26

Regards

Gerard (vk3cg/vk3grs)
 
Keith @

Senior Member

Joined: 19/06/2011
Location: Australia
Posts: 167
Posted: 11:06pm 24 Dec 2011
Copy link to clipboard 
Print this post

Hi Gerard

Merry Xmas and thank you for your reply.

I must admit I jumped in and didn't really read your notes ... I just wanted to get at least one of the DS18B20 working ... which is exactly what I achieved.

I then went back over your notes. I dusted off my notes from when I was investigating doing some 1-Wire coding but I work best with changing code that works rather then starting from scratch ... at least that way I can only blame myself for any problems.

From the notes I also came across the idea of putting the two DS18B20 on separate pins and I decided that would be too easy ... I'm going to try for running them on the one wire without parasitic power at this point in time.

I figure the easiest way to get multiple devices running together is to use your code to provide the serial numbers and then to manually plug the individual serial numbers into some new/modified code to run with the number of devices I have on the one wire.

Keith


The more we know, the more we know we don't know !
 
seco61
Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 205
Posted: 11:55pm 25 Dec 2011
Copy link to clipboard 
Print this post

Hi Keith.

I have posted some sample code below that will (hopefully) report the temperature from multiple DS18B20 devices on the same one wire line.

The code will also work with parasitically powered DS18B20 devices (but remember to ground the Vdd pin if using parasitic power - It took me a while to realise that this was causing me some random results but is documented in the data sheet!)

I only have one DS18B20 at the moment so can not fully test the code.

Also, there was a minor bug in the earlier firmware that John posted - the OWSEARCH command was not correctly setting the IO pin status before sending data. I have asked John to update the firmware that he has linked to in an earlier post on this thread.

A work around for the bug is to issue an OWRESET command before any other one wire commands.


new
1000 ptime = 2000 ' Delay (in mS) between temperature readings
1010 parasitic = 1 ' 0 = external power, 1 = parasitic power
1020 precision = 3 ' 1 = 9 bit, 2 = 10 bit, 3 = 11 bit, 4 = 12 bit
1030 io_pin = 18 ' I/O pin to use
1040 max_dev = 5 ' Maximum number of one wire devices to find/use
1050 max_attempts = 2 ' Maximum number of attempts to read DS18B20 temperature if CRC error
1060 dev_found = 0 ' Number of one wire devices found
1070 device = 0 ' Index of the one wire device we are currently sending commands to
1080 DIM cmd(20), rsp(10), sn(max_dev,8)
1090 cmd(0) = &h55
1100 GOSUB 4000 ' Search for devices on the one wire bus
1110 ?
1120 IF dev_found = 0 THEN END
1130 GOSUB 3000 ' Verify devices found are present
1140 ?
1150 FOR device = 1 TO dev_found
1160 IF sn(device,0) = &h28 THEN GOSUB 2000 ' Set precision if device is a DS18B20
1170 NEXT device
1180 DO
1190 FOR device = 1 TO dev_found
1200 IF sn(device,0) = &h28 THEN ' Get temperature if device is a DS18B20
1210 FOR j = 0 TO 7
1220 cmd(j + 1) = sn(device,j)
1230 NEXT j
1240 cmd(9) = &h44
1250 crc_cnt = 0
1260 IF parasitic = 0 THEN
1270 OWWRITE io_pin,1,10,cmd(0)
1280 FOR i = 1 TO 12000
1290 OWREAD io_pin,4,1,bit
1300 IF bit = 1 THEN
1310 IF (i MOD 8) = 0 THEN EXIT FOR
1320 ENDIF
1330 NEXT i
1340 ELSE
1350 OWWRITE io_pin,9,10,cmd(0)
1360 PAUSE pwait
1370 ENDIF
1380 cmd(9) = &hbe
1390 OWWRITE io_pin,1,10,cmd(0)
1400 OWREAD io_pin,2,9,rsp(0)
1410 crc = OWCRC8(9,rsp(0))
1420 ? "Device ";device;" - Data: (";rsp(0);",";rsp(1);",";rsp(2);",";rsp(3);",";rsp(4);",";rs p(5);",";rsp(6);",";rsp(7);",";rsp(8);" ), CRC: ";crc
1430 IF crc <> 0 THEN ' If data is corrupt
1440 crc_cnt = crc_cnt + 1
1450 IF crc_cnt = max_attempts THEN
1460 GOTO 1610 ' Ignore this device if attempts greater than max_attempts
1470 ELSE
1480 GOTO 1260 ' else try again
1490 ENDIF
1500 ENDIF
1510 tl = rsp(0) : th = rsp(1)
1520 IF (th AND &h80) THEN
1530 temp = ((tl AND &h0f) * 0.0625) + ((tl AND &hf0) / 16) + ((th AND &h07) * 16) - 128
1540 ELSE
1550 temp = ((tl AND &h0f) * 0.0625) + ((tl AND &hf0) / 16) + ((th AND &h07) * 16)
1560 ENDIF
1570 tempf = ((temp * 9) / 5) + 32
1580 ' Logging of data goes here
1590 ? "Device ";device;" - Temp: ";temp;"C, ";tempf;"F"
1600 ENDIF
1610 NEXT device
1620 FOR i = 1 TO pdelay
1630 IF INKEY$ <> "" THEN END ' End if any key pressed
1640 PAUSE 1
1650 NEXT i
1660 LOOP
1670 END
2000 ' Set precision routine for a DS18B20 with index "device"
2010 FOR j = 0 TO 7
2020 cmd(j + 1) = sn(device,j)
2030 NEXT j
2040 cmd(9) = &h4e
2050 cmd(10) = &h00
2060 cmd(11) = &h00
2070 IF precision = 4 THEN
2080 pwait = 750
2090 cmd(12) = &h7f
2100 ELSEIF precision = 3 THEN
2110 pwait = 375
2120 cmd(12) = &h5f
2130 ELSEIF precision = 2 THEN
2140 pwait = 190
2150 cmd(12) = &h3f
2160 ELSE
2170 pwait = 95
2180 cmd(12) = &h1f
2190 ENDIF
2200 pdelay = ptime - pwait
2210 OWWRITE io_pin,1,13,cmd(0)
2220 RETURN
3000 ' Verify the presence of the devices in the array of serial numbers
3010 FOR i = 1 TO dev_found
3020 FOR j = 0 TO 7
3030 rsp(j) = sn(i,j)
3040 NEXT j
3050 OWSEARCH io_pin,16,rsp(0)
3060 IF MM.OW = 1 THEN
3070 ? "Verify OK for device ";i;": (";rsp(0);",";rsp(1);",";rsp(2);",";rsp(3);",";rsp(4);",";rs p(5);",";rsp(6);",";rsp(7);" )"
3080 ELSE
3090 ? "Verify failed for device ";i;": (";rsp(0);",";rsp(1);",";rsp(2);",";rsp(3);",";rsp(4);",";rs p(5);",";rsp(6);",";rsp(7);" )"
3100 ENDIF
3110 NEXT i
3120 RETURN
4000 ' Search for devices on the one wire bus
4010 OWSEARCH io_pin,1,rsp(0)
4020 IF MM.OW = 0 THEN
4030 ? "Search failed - no one wire devices found"
4040 ELSE
4050 DO WHILE MM.OW = 1
4060 dev_found = dev_found + 1
4070 FOR j = 0 TO 7
4080 sn(dev_found,j) = rsp(j)
4090 NEXT j
4100 ? "Serial number ";dev_found;": (";rsp(0);",";rsp(1);",";rsp(2);",";rsp(3);",";rsp(4);",";rs p(5);",";rsp(6);",";rsp(7);" )";
4110 IF rsp(0) = &h28 THEN
4120 ? " - DS18B20"
4130 ELSE
4140 ?" - Unknown device"
4150 ENDIF
4160 IF dev_found = max_dev THEN EXIT
4170 OWSEARCH io_pin,0,rsp(0)
4180 LOOP
4190 ENDIF
4200 RETURN

Edited by seco61 2011-12-27

Regards

Gerard (vk3cg/vk3grs)
 
Keith @

Senior Member

Joined: 19/06/2011
Location: Australia
Posts: 167
Posted: 01:24am 26 Dec 2011
Copy link to clipboard 
Print this post

Hi Gerard

It stopped with line 4030 ... Search failed - no one wire devices found

I have tried using external and parasitic power (and changed line 1010 accordingly)

If I may have a guess could there be a problem in the OWSEARCH code?

Keith
The more we know, the more we know we don't know !
 
Keith @

Senior Member

Joined: 19/06/2011
Location: Australia
Posts: 167
Posted: 02:07am 26 Dec 2011
Copy link to clipboard 
Print this post

Gerard

I got the code to run by using OWRESET and forcing MM.OW to 1

here's the hack/changes I made

4005 OWRESET io_pin
4010 'OWSEARCH io_pin,1,rsp(0)
4020 'IF MM.OW = 1 THEN
4030 ' ? "Search failed - no one wire devices found"
4040 'ELSE
4045 MM.OW = 1

hope this helps

Keith

The more we know, the more we know we don't know !
 
seco61
Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 205
Posted: 03:38am 26 Dec 2011
Copy link to clipboard 
Print this post

Hi Keith.

As I mentioned in the previous post, there is a minor bug in the OWSEARCH command. It does not correctly set the state of the IO pin before using the pin. I have corrected the error, but the new firmware is not on the Duinomite site yet.

The temporary fix is very simple - just issue an OWRESET command before any other commands. Add the following line:


1095 OWRESET io_pin ' Temporary fix for OWSEARCH bug




  Keith @ said   Hi Gerard

It stopped with line 4030 ... Search failed - no one wire devices found

I have tried using external and parasitic power (and changed line 1010 accordingly)

If I may have a guess could there be a problem in the OWSEARCH code?

Keith


Regards

Gerard (vk3cg/vk3grs)
 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 06:05am 26 Dec 2011
Copy link to clipboard 
Print this post

Hi
Gerard has updated the 1-wire firmware (MM)
This fix's addressed are
1) Fix for I2C using strings

2) The OWSEARCH command was not correctly setting the pin status before sending commands. So if the OWSEARCH command is issued before any other one wire command the search will not work. In the sample code I previously sent you there was an OWRESET command before the OWSEARCH command and the sequence worked.

This version will display version v2.7O


Once again a HUGE thank you to Gerard

2011-12-26_160304_Maximite-1w-v2.zip

If you are using 1-Wire please update your firmware with this version

Regards

JohnEdited by jman 2011-12-27
 
Keith @

Senior Member

Joined: 19/06/2011
Location: Australia
Posts: 167
Posted: 07:58am 26 Dec 2011
Copy link to clipboard 
Print this post

Hi Gerard & John

Both codes are working together just fine ... no mods and running on parasitic power

But my beer is only 7.5C and the air temp is 32.0C ... I think someone's been in the fridge whilst I was out ... looks like I'll have to drink it any way.

Cheers guys!

That's a sterling effort ... much appreciated.

Now where's that code for the SD data logging and the LCD ... and then with the relay and the remote 240V AC control I've put together I'll have my home brew back in action by putting the fermenter in the old fridge to keep the temp constant at about 20.0C .... shuffle shuffle ... glug glug ... oh darn that one's finished ... off to the fridge for another ...

regards
Keith
The more we know, the more we know we don't know !
 
seco61
Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 205
Posted: 09:55am 26 Dec 2011
Copy link to clipboard 
Print this post

Hi All.

I just noticed a coding error in the sample code I posted.

To fix it the following lines should be changed:


1240 crc_cnt = 0
1250 cmd(9) = &h44

1480 GOTO 1250 ' else try again



Regards

Gerard (vk3cg/vk3grs)
 
Ray B
Senior Member

Joined: 16/02/2007
Location: Australia
Posts: 219
Posted: 02:23pm 28 Dec 2011
Copy link to clipboard 
Print this post

I've always wanted to confirm the accuracy / repeatability of readings of DS18B20.

Following is a test result using the code above and 4 x DS18B20 side by side in a section of protoboard in free airspace.

FYI the DS18B20's are some 3 for A$5.20 total inc postage from China alongside an original $10 purchase from Aussie supplier some time back.

> run
Serial number 1: ( 40, 94, 252, 151, 0, 0, 0, 195 ) - DS18B20
Serial number 2: ( 40, 77, 70, 63, 3, 0, 0, 98 ) - DS18B20
Serial number 3: ( 40, 3, 46, 100, 3, 0, 0, 103 ) - DS18B20
Serial number 4: ( 40, 103, 62, 63, 3, 0, 0, 72 ) - DS18B20

Verify OK for device 1: ( 40, 94, 252, 151, 0, 0, 0, 195 )
Verify OK for device 2: ( 40, 77, 70, 63, 3, 0, 0, 98 )
Verify OK for device 3: ( 40, 3, 46, 100, 3, 0, 0, 103 )
Verify OK for device 4: ( 40, 103, 62, 63, 3, 0, 0, 72 )

Device 1 - Data: ( 178, 1, 0, 0, 95, 255, 14, 16, 4 ), CRC: 0
Device 1 - Temp: 27.125C, 80.825F
Device 2 - Data: ( 174, 1, 0, 0, 95, 255, 2, 16, 34 ), CRC: 0
Device 2 - Temp: 26.875C, 80.375F
Device 3 - Data: ( 178, 1, 0, 0, 95, 255, 14, 16, 4 ), CRC: 0
Device 3 - Temp: 27.125C, 80.825F
Device 4 - Data: ( 174, 1, 0, 0, 95, 255, 2, 16, 34 ), CRC: 0
Device 4 - Temp: 26.875C, 80.375F
Device 1 - Data: ( 178, 1, 0, 0, 95, 255, 14, 16, 4 ), CRC: 0
Device 1 - Temp: 27.125C, 80.825F
Device 2 - Data: ( 172, 1, 0, 0, 95, 255, 4, 16, 14 ), CRC: 0
Device 2 - Temp: 26.75C, 80.15F
Device 3 - Data: ( 178, 1, 0, 0, 95, 255, 14, 16, 4 ), CRC: 0
Device 3 - Temp: 27.125C, 80.825F
Device 4 - Data: ( 174, 1, 0, 0, 95, 255, 2, 16, 34 ), CRC: 0
Device 4 - Temp: 26.875C, 80.375F
Device 1 - Data: ( 178, 1, 0, 0, 95, 255, 14, 16, 4 ), CRC: 0
Device 1 - Temp: 27.125C, 80.825F
Device 2 - Data: ( 172, 1, 0, 0, 95, 255, 4, 16, 14 ), CRC: 0
Device 2 - Temp: 26.75C, 80.15F
Device 3 - Data: ( 176, 1, 0, 0, 95, 255, 16, 16, 178 ), CRC: 0
Device 3 - Temp: 27C, 80.6F
Device 4 - Data: ( 174, 1, 0, 0, 95, 255, 2, 16, 34 ), CRC: 0
Device 4 - Temp: 26.875C, 80.375F
Device 1 - Data: ( 178, 1, 0, 0, 95, 255, 14, 16, 4 ), CRC: 0
Device 1 - Temp: 27.125C, 80.825F
Device 2 - Data: ( 172, 1, 0, 0, 95, 255, 4, 16, 14 ), CRC: 0
Device 2 - Temp: 26.75C, 80.15F
Device 3 - Data: ( 178, 1, 0, 0, 95, 255, 14, 16, 4 ), CRC: 0
Device 3 - Temp: 27.125C, 80.825F
Device 4 - Data: ( 174, 1, 0, 0, 95, 255, 2, 16, 34 ), CRC: 0
Device 4 - Temp: 26.875C, 80.375F
Device 1 - Data: ( 178, 1, 0, 0, 95, 255, 14, 16, 4 ), CRC: 0
Device 1 - Temp: 27.125C, 80.825F
Device 2 - Data: ( 172, 1, 0, 0, 95, 255, 4, 16, 14 ), CRC: 0
Device 2 - Temp: 26.75C, 80.15F
Device 3 - Data: ( 176, 1, 0, 0, 95, 255, 16, 16, 178 ), CRC: 0
Device 3 - Temp: 27C, 80.6F
Device 4 - Data: ( 174, 1, 0, 0, 95, 255, 2, 16, 34 ), CRC: 0
Device 4 - Temp: 26.875C, 80.375F
Device 1 - Data: ( 178, 1, 0, 0, 95, 255, 14, 16, 4 ), CRC: 0
Device 1 - Temp: 27.125C, 80.825F
Device 2 - Data: ( 172, 1, 0, 0, 95, 255, 4, 16, 14 ), CRC: 0
Device 2 - Temp: 26.75C, 80.15F
Device 3 - Data: ( 176, 1, 0, 0, 95, 255, 16, 16, 178 ), CRC: 0
Device 3 - Temp: 27C, 80.6F
Device 4 - Data: ( 174, 1, 0, 0, 95, 255, 2, 16, 34 ), CRC: 0
Device 4 - Temp: 26.875C, 80.375F
Device 1 - Data: ( 178, 1, 0, 0, 95, 255, 14, 16, 4 ), CRC: 0
Device 1 - Temp: 27.125C, 80.825F
Device 2 - Data: ( 172, 1, 0, 0, 95, 255, 4, 16, 14 ), CRC: 0
Device 2 - Temp: 26.75C, 80.15F
Device 3 - Data: ( 176, 1, 0, 0, 95, 255, 16, 16, 178 ), CRC: 0
Device 3 - Temp: 27C, 80.6F
Device 4 - Data: ( 174, 1, 0, 0, 95, 255, 2, 16, 34 ), CRC: 0
Device 4 - Temp: 26.875C, 80.375F
Device 1 - Data: ( 178, 1, 0, 0, 95, 255, 14, 16, 4 ), CRC: 0
Device 1 - Temp: 27.125C, 80.825F
Device 2 - Data: ( 172, 1, 0, 0, 95, 255, 4, 16, 14 ), CRC: 0
Device 2 - Temp: 26.75C, 80.15F
Device 3 - Data: ( 176, 1, 0, 0, 95, 255, 16, 16, 178 ), CRC: 0
Device 3 - Temp: 27C, 80.6F
Device 4 - Data: ( 174, 1, 0, 0, 95, 255, 2, 16, 34 ), CRC: 0
Device 4 - Temp: 26.875C, 80.375F
Device 1 - Data: ( 178, 1, 0, 0, 95, 255, 14, 16, 4 ), CRC: 0
Device 1 - Temp: 27.125C, 80.825F
Device 2 - Data: ( 172, 1, 0, 0, 95, 255, 4, 16, 14 ), CRC: 0


RayB from Perth WA
 
     Page 1 of 2    
Print this page
© JAQ Software 2024