DS18B20 used on a RIMS with Arduino PID Library

Homebrew Talk - Beer, Wine, Mead, & Cider Brewing Discussion Forum

Help Support Homebrew Talk - Beer, Wine, Mead, & Cider Brewing Discussion Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

t_met

Well-Known Member
Joined
Apr 15, 2009
Messages
96
Reaction score
12
I'm thinking about using a DS18B20 for a RIMS system that is driven by an Arduino. How frequent should the Arduino's PID sample the DS18B20? As fast as it can? or if there was some downside with back to back temperature reading cycles?

Just seeing what other people use. If I should be looking for an analog temperature probe for this setup. If so, what kind.
 
IIRC - The DS18B20 sends out the temperature every second or so. I would think that would be plenty fast enough because a RIMS tube isnt a super fast changing process.

I had three DS18B20's sitting right next to each other in ambient air and they read within a few hundredths of a degree of each other, so I'd assume from that they are very accurate.

I'm not sure how fast you can read the analog inputs on an Arduino.

Search for RIMS Arduino Library - a lot of what you want to do has already been done and shared.

https://code.google.com/p/rims-arduino-library/
 
The response time of the DS18B20 depends on the resolution you require. If you want 12-bit resolution, the time from a "Convert T" command (0x44) to a valid reading in the scratchpad can be as high as 750ms. The same sequence with 9-bit resolution is less than 100ms.

In my TeensyNet Project, I fire off a "Convert T" command, set a timer, and go off and do other things. I check back periodically, and if the timer value equals or exceeds the required elapsed time, I read the scratchpad.

I do everything with 9-bit precision, as I don't see the need for extreme accuracy, and the resultant time lag. I'm also monitoring a large number (36) of devices.

YMMV
 
Thanks for the reassurance. You answered my main concern, which is what sort of resolution the Arduino's PID software needs for a RIMS.
 
so I'd assume from that they are very accurate.

just keep in mind the difference between accuracy and precision

three probes reading similar readings should lead you to believe that they are *precise*
...but, you dont have enough info to make a determination about accuracy.
:mug:


Thanks for the reassurance. You answered my main concern, which is what sort of resolution the Arduino's PID software needs for a RIMS.

the specs of the arduino are less important than the temp probe itself, since the DS18B20 use a standard digital I2C interface, as opposed to the Arduino reading an analog value in its ADC (where bit precision comes into play). so long as the Arduino can in some way handle or store the 9- or 12-bit digital value being sent to it over I2C (which it can, easily), then the Arduino isn't going to be your bottleneck.
 
I don't seen any reason to sample any faster than about every second. The biggest problem is going to be the integral. The more often you sample the faster the integral will rise and possibly hit the maximum I term or overflow if there's no overflow protection. I don't know arduinos PID code since I'm coding in standard c.
 
I do pretty much the same as jimmy, I send out the 1-wire request, go off and spin round the main control loop, every time checking if 750ms is up and if it is I read the temp sensors and immediately re-issue the 1-wire get temps request. I have DS18B20 sensors. I use the PID SW to control my boil kettle and I am getting around the LOOP around every 60ms. Every 1000ms I visit the PID routine and update it. I run a 5sec window on the element. You'll need to tune the PID for your own environment, I don't use the Auto tune routines at all.
 
The OpenTroller (BrewTroller) project uses the DS18B20's and the Arduino PID library for all of it's control functions. It works very nicely with my RIMs.
 
I do pretty much the same as jimmy, I send out the 1-wire request, go off and spin round the main control loop, every time checking if 750ms is up and if it is I read the temp sensors and immediately re-issue the 1-wire get temps request. I have DS18B20 sensors. I use the PID SW to control my boil kettle and I am getting around the LOOP around every 60ms. Every 1000ms I visit the PID routine and update it. I run a 5sec window on the element. You'll need to tune the PID for your own environment, I don't use the Auto tune routines at all.

Another way I have seen is the DS18B20 will "reply" with either 1/0 depending if the conversion has been completed when a read command is sent. But I don't know if you would gain (or possibly loss) anything in the relatively simple RIMS application - i.e. it is possibly less time consuming (to the overall process) to just check every cycle if a second is up then read the scratchpad rather checking if it is ready every cycle and then reading it as soon as it is ready. Would really need to do some testing to see which one is faster to the overall process - and I don't know how the dallas temp & onewire libraries play with each other - i.e. if you start the read via onewire does it get screwy to then get the temp via dallas temp?
 
Given that standard Arduino I/O is fairly slow (lots of clock cycles) repeatedly checking for a return value will use up time you can probably use elsewhere. Now if your using a something with a faster CPU such as a PI, BBB or Arduino Due then it probably doesn't matter. But does getting taking maybe 0.1-0.2 second longer to get a temp really going to have a material effect?
 
I implemented a PID routine in python on my Pi that updates the PID output every second (heating is a slow process, no need for it to be faster)... I have another thread that constantly updates the ds18b20 temp sensors as fast as it can, not sure how fast but I'm reading five temp sensors. Currently I am not using a sliding window of average temperature over a period of seconds, but I have seen some people do that to smooth out the PID response


Sent from my iPhone using Home Brew
 
The biggest problem is going to be the integral. The more often you sample the faster the integral will rise...
This seems to be a common misconception when it comes to PID sampling time. If it is truly integrating correctly, it will take into account the time delta. In theory, the faster you sample the more accurate the integration will be.

Riemann_Integration_and_Darboux_Lower_Sums.gif
 

Latest posts

Back
Top