Pages: 1 2 [3]   Go Down
Author Topic: DS18B20 750ms delay bypass?  (Read 7997 times)
0 Members and 1 Guest are viewing this topic.
Gurnee, IL
Offline Offline
Jr. Member
**
Karma: 0
Posts: 65
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Okay, that works. So it looks like it would only re-check each unique sensor every 4 seconds or so, while checking each in series every 3/4 of a second, which is fine. So I need to implement this code into my sketch.

LOL it's been years since I did any sort of pseudo serious coding, it's like trying to run in foot deep mud. So please bear with me. Thanks.

I would like to know 3 things:

1. Can I omit the handling of negative data and fractional portions? My temp range will always be between 68*-74*F, or I have serious problems. Heh.
 
2 Where can I increase the 'quality' of the read? Is it this line?
Code:
for ( i = 0; i < 9; i++) {           // we need 9 bytes

3  I can write the C to F conversion, but what I need is to be able to pull the data for each sensor with out any of the folding, mutilating or spindling. Perhaps assigning each to a variable during the for loop with the ds.read?


EDIT: Oh yeah I'm pretty sure my Droid phone is way faster than my netbook, ROFL.
Logged

USA
Offline Offline
Jr. Member
**
Karma: 0
Posts: 90
I’m no expert, but I play one on the Internet…
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Glad to hear it worked!

Yes, the current code would take about 1 second to update each sensor reading.

Answers to your questions:
1. You could omit this, but why do it? If you don't have space for it on you LCD etc... then just don't display it.

2. No, we would need to add an additional step to write a change to the scratchpad on the sensor. By default the DS18B20 is configured for 12 bits. The 9 bytes are the complete response from the sensor, which includes ID#, checksums etc... If you only need .25C resolution I can probably write the code to flip the resolution bits in the scratchpad to 10bit, which would drop the convert time down to 200ms.
Quote
The resolution of the temperature sensor is user-configurable to 9, 10, 11, or 12 bits, corresponding to increments of 0.5°C, 0.25°C, 0.125°C, and 0.0625°C, respectively. The default resolution at power-up is 12-bit.

3. I have some existing code to convert C to F in one of my other projects if you get stuck on that. Also you could look in the DallasTemperature.cpp library file, since I think I saw it doing conversions in there as well. Unfortunately you will really need to do the folding, spindling and mutating to convert the data returned by the sensor to something you can read. I would setup 5 variables for your sensors then update them for each individual sensor read. On the main loop I would have an update LCD function that updated the LCD with the 5 variables each time.

You should upload a photo of the fish tank/display etc... when you get it running. Sounds like a cool project.

willnue
Logged

Gurnee, IL
Offline Offline
Jr. Member
**
Karma: 0
Posts: 65
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The values are defaults as none of the sensors are plugged in. There is also some data on the screen for diagnostics and code tweaking. But this is the basic layout of my main screen. The icons have 2-3 phases depending on what each is doing at a given time.



I'll take another crack at the code in a bit. Thanks again.
Logged

USA
Offline Offline
Jr. Member
**
Karma: 0
Posts: 90
I’m no expert, but I play one on the Internet…
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That rocks! I like your icons and the big/small fonts for the different temps.

Hmm... Maybe I should add a LCD display to my temp network. What type of display is it?

willnue
Logged

Gurnee, IL
Offline Offline
Jr. Member
**
Karma: 0
Posts: 65
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It's a 128x64 ks0108 series GLCD. It's been it's own fun, lol. Spent a couple weeks trying to trouble shoot an issue only to discover that I had fried a small part of it early on. This is my 2nd GLCD.

Been staring at the code a while now. Trying to figure out where/how to assign the 5 variables.

I've got that R is the device address, but what are P and CRC? and how do they correlate to R?

How does it decide to order the different sensors? I assume it's ordered based on unique address, is that true? Can I assume that they will always get pulled up in the same order regardless of what order the parasites are hooked up.

-OR-

Seems to me that I could run 5 "if" statements comparing the address of the current sensor to the 5 knowns and then assign the Tc_100 to that particular variable. Does the "addr" represent the 8 byte address across startTempConvert and readTemp?
Logged

Gurnee, IL
Offline Offline
Jr. Member
**
Karma: 0
Posts: 65
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well any further progress on my end is halted for 3-5 weeks. I some how fried my Arduino while hooking up my LEDs and now I'm waiting on a new one I ordered from China... smiley-sad
Logged

USA
Offline Offline
Jr. Member
**
Karma: 0
Posts: 90
I’m no expert, but I play one on the Internet…
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry to hear about your Arduino. Are you sure it's fried? They are usually pretty tough to break. I would check the Installation and Troubleshooting forum and see if maybe it's just resting...  smiley-sleep Why China? Do you know there are plenty of places in the US to purchase them from?

On your questions, my understanding is that the "P" array contains the data, which includes the temperature reading and the "CRC" is the checksum against the data to ensure it is correct. You don't really need to use either of them, just the results of the calculation on them (the temp). They are in the sample code to show what is being read from the sensors for troubleshooting etc... The "addr[]" array contains the address ("R") and yes it is a global variable that is the same in both startTempConvert and readTemp for any trip through the main loop.

I believe I read somewhere the order the sensors are returned from the search is related to which one answers first, second etc... and I think they will always be returned in the same order, not by the code, but by the nature of the 1-Wire bus. That being said I don't think you really want to count on them being returned in any order since if you add/remove sensors everything will be thrown out of whack. Your 5 "if" statements is heading in the right direction, but I would use an array of the addresses and check them in a FOR Loop.

willnue

 
Logged

Gurnee, IL
Offline Offline
Jr. Member
**
Karma: 0
Posts: 65
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Spent a couple hours searching and trying stuff yesterday and I have been unsuccessful in getting it to respond. All of the 'simple' things I've found so far haven't worked and I'm not motivated enough yet to try the more complex things. I'll keep trying to bring it up but as I've wanted to have a 2nd Arduino and with the 3-5 week delivery time it was better to order now and best case in 3 weeks time I'll have fixed mine and then have 2. Worst case is I can drop the new one directly in and get back to work. But if I were screw around with this for 2 weeks and it's still dead then order, I'd have to wait t hat much longer.

I've not found better prices than form China on ebay for some things. I'd love to order American, but with the price range of this Arduino ranging from $40-$100+ I'd be paying more for less. For $62 delivered I am getting the ATMega 1280, a 128x64GLCD, good sized solderless breadboard, big handful of jumper wires, and a number of other useful bits.

As for the code I'll try and tinker with it, but can't say I'll make much progress until I get the new board. I'm kind of surprised that they don't make an Arduino emulator to test code.
Logged

Gurnee, IL
Offline Offline
Jr. Member
**
Karma: 0
Posts: 65
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, new Arduino is here and every thing is hooked up. I started looking at the code again and remember why I didn't try to mess with it while waiting for the new board.

Trying a few things, will check in after testing. Any further advice would be appreciated....
Logged

USA
Offline Offline
Jr. Member
**
Karma: 0
Posts: 90
I’m no expert, but I play one on the Internet…
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I thought it was working on the old Arduino? Is it not working now?

willnue
Logged

Gurnee, IL
Offline Offline
Jr. Member
**
Karma: 0
Posts: 65
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I thought it was working on the old Arduino? Is it not working now?

willnue

Since we've been trying to implement the 'no delay' the best I've had was the primary sensor worked with little or no delay but none of the parasites worked. And currently none of the sensors are responding properly. It's been long enough that I don't know if it was a code or hardware issue is causing that. I'll start looking into that shortly.

Logged

Gurnee, IL
Offline Offline
Jr. Member
**
Karma: 0
Posts: 65
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Got the probes to read finally after having to run a "testing" sketch to initialize the probes? Regardless, now they work. BUT they only work once immediately after the sketch is pushed. Resets have no effect, it just displays the same numbers from the push. I remember that before the Arduino died I had it such that the primary probe worked as expected but the rest didn't. I have no idea what I did that would cause the new result.

So at this point I'm really not sure what to do. I know I made quite a mess in the code before the Arduino died. I think I'm going to have to rip the one wire/dallas code all out and start fresh.

I guess what's next is to write a "simple" sketch to handle the no delay temp reading. And be able to pull values from specific probes as requested.
Logged

Pages: 1 2 [3]   Go Up
Jump to: