Folks, you're probably tired of me asking questions about getting an analog TMP36 to offer a stable temperature, and I have done an adequate job refining both my circuit and my code. But it just turns out the it will be ridiculously easy for me to alter my project to use a digital TMP05 or TMP06 chip IF I can manage to do it with the same Analog input I was using for the TMP36.
Now the TMP05 and 06 are digital sensors, which output a PWM signal for the temperature. So of course it would be much easier if I'd use a digital pin in interrupt mode. But for a long list of reasons, I need to stick with using an analog input. Not sure whether I can turn an analog input pin into a digital one, but even if I did its a pain to use interrupts from anything but a chosen few.
So I want to know if the "brute force" method of measurement will work, if averaged over time. In its continual conversion mode and "nominal" speed setting, The TMP05 or 06 do not require blinding speed to measure their UP and DOWN PWM outputs. The T-LOW time and Full cycle time for 30 degrees C is 65.6 mS and 99.8 mS respectively. So with a simple circuit ( a pull up resistor, maybe a voltage divider depending on my Alog-Ref), I should be able to basically do this... (psudo code here...)
wait for low on analog pin, then wait for high // means new cycle is starting
Of course by "low and high", I mean something like > 800 and less than 400 for raw a/d readings. I realize the conversion time added to the conversion timing uncertainty will mean a significant error for one reading. But if I really only need temperature averaged over many seconds, I would think that just like the principal of "over-sampling", over time a linear average should be about as good as a more perfectly done interrupt driven measurement.
Delta_G:
You'd need some external circuitry to filter the PWM signal to a steady voltage to measure with analogRead. Otherwise you'll just measure 5V of the time and 0V others.
That's just silly. All the analog input pins are actually digital pins first. Their analog input status is extra for those pins. Just use the A0, A1, etc style pin names and call pinMode and digitalRead just like you normally would.
? ? ? ? What do you mean by this? Just that you don't yet know how to use them? Sounds like a great time to learn.
No, don't go through all that mess. Just use those pins as digital pins and read HIGH and LOW on them. No need to make it extra complicated.
Thanks! To answer in order,
I wouldn't want to filter the PWM signal, because if I'm measuring the HIGH time and LOW time, I WOULD want to measure 5V or 0 volts.
Thats great news! My knowledge of coding is way ahead of my knowledge of the MCU capabilities, but yeah... that makes it a ton easier.
I know that besides the easy interrupts (like the ones tied to a specific pin like D2) there is a way to interrupt on ANY pin, and then determine which pin with additional code. I was concerned because the project already was making use of one of those direct interrupts. But bottom line, YES!!! Great time to learn! Especially now that I know an analog pin can be just another digital pin.
So without having to worry about conversion speed, I'd think just reading the highs and lows and counting microseconds would offer pretty good timing even without an interrupt if I don't mind the wait time. But sure.. an interrupt would always be better!
DaveEvans:
Thought 1: why bother if you've "done an adequate job refining your circuit and code" for the TMP36
Thought 2: they're only available in surface mount - any breakouts available?
Thought 3: T-low = T2-T1
I don't have a good answer there. Even before retiring, I've had managers that respected my work having to tell me "stop... don't fix it if it ain't broke". But my success with the TMP36 involved a lot of averaging, and learning from many posts that the Arduino A/D conversion accuracy and stability leave a lot to be desired. Then this came up,
As it turns out, I had already had a small PCB made for the "long cable" situation of using a SMD (5 pin, SOT-23) version of the TMP36, complete with the manufacturer's recommended capacitor, output damping resistor, tying the shutdown pin to +V, and terminating in a convenient 3 pin header. So yeah, I have perfect breakout... I made it! Well guess what... I discovered that not only does the TMP05 (and 06) come in that same 5 pin SOT-23 package, but I can actually use my same board with no mods, other than flipping the 3 pin plug for the header the other way. It just worked out that way. I literally could not have planned it any better if I tried to plan it. Makes me think I should go play the lottery today!!
Wawa:
Can't you use the DS18B20.
A whole bunch of them can be read by one (any) pin.
Leo..
I only need one reading, and I was hoping to not need to cut into the pipe for one of those DS18B20 thingies. But considering how well the lowly TMP36 worked just glued to the outside of the pipe, I'm reconsidering. Maybe I can just tape one of those waterproof DS18B20 units to the pipe and see how well it does. Three questions I have for you. First, I'm already using I2C libraries, plus the various extensions for an LCD and a Real Time Clock. Is there any conflict using a one wire library along with the I2C?, and (2) how would I direct it to iuse the pin of my choice. and (3) my project is pretty "full". 88% pgm storage space and 58% dynamic mem already used. Granted, ditching all the processing code I used for the TMP36 will save a little space, but do you think adding the OneWire.h and the DallasTemperature.h, will break the bank?
PeterPan321:
But considering how well the lowly TMP36 worked just glued to the outside of the pipe, I'm reconsidering. Maybe I can just tape one of those waterproof DS18B20 units to the pipe and see how well it does.
If the TMP36 is OK, the DS187B20 will be OK too. I have made thermowells for DS18B20, but only installed one, as I can't tell any difference in performance. I was tempted to remove the cover to get better contact, but haven't. I just used a dab of heatsink compound and an insulated sleeve to hold it in place. Silicon goo would probably be just as good, but still with the sleeve.
Even if you only use one, reply#4 would be the best advice you ever get.
Nick_Pyner:
If the TMP36 is OK, the DS187B20 will be OK too. I have made thermowells for DS18B20, but only installed one, as I can't tell any difference in performance. I was tempted to remove the cover to get better contact, but haven't. I just used a dab of heatsink compound and an insulated sleeve to hold it in place. Silicon goo would probably be just as good, but still with the sleeve.
Even if you only use one, reply#4 would be the best advice you ever get.
Well I'm getting enticed, if only because they are already packaged and waterproofed, and so cheap! But I have the same questions as my reply to #4. Will there be any conflict in my project if I already use I2C for mt clock and LCD, will I be able to re-direct this particular one-wire usage to the pin of my choice without interfering with the pins already used for the I2C, and will the libraries take much space in an already very full project (89% code space and 1/2 my data space used)
DS18B20 has nothing to do with I2C and therefore RTC and LCD are not involved. There is nothing to suggest you are running short of pins, and the DS18B20 won't use any more anyway. As a Mega user, I can't really comment on code space - other that, in this line of work, you should be using a Mega as well.
If you use Sheepdog's method, I believe you save some memory by dispensing with a two libraries, hence the link. If you work in a fair range but still within the -25>125 deg range of the DS18B20, I fail to see why you would use anything else.
Nick_Pyner:
DS18B209 has nothing to do with I2C and therefore RTC and LCD are not involved. There is nothing to suggest you are running short of pins, and the DS18B20 won't use any more anyway. As a Mega user, I can't really comment on code space - other that, in this line of work, you should be using a Mega as well.
If you use Sheepdog's method, I believe you save some memory by dispensing with a two libraries, hence the link. If you work in a fair range but still within the -25>125 deg range of the DS18B20, I fail to see why you would use anything else.
Can't wait to try it. Ordered a couple of waterproofed DS18B209 on ebay. Cheaper from China on ali-express, but i don't want to wait a month.
As for the Mega suggestion, maybe... but for now I like my Nano clones. I may even move to the smaller ones without the USB luggage. I really enjoy coding small systems and getting the most out of limited resources. I've been coding since the days of ATARI 6502, so you surely understand the NANO feels almost like home, though without the video chip.
.
A Nano should be fine.......... for the moment. The way it is in the Arduino world, you are likely to venture further. Revisit reply #10 when you want to add an SD card. With datalogging, you are likely to run out of memory before you run out of pins.
Nick_Pyner:
If the TMP36 is OK, the DS187B20 will be OK too. I have made thermowells for DS18B20, but only installed one, as I can't tell any difference in performance. I was tempted to remove the cover to get better contact, but haven't. I just used a dab of heatsink compound and an insulated sleeve to hold it in place. Silicon goo would probably be just as good, but still with the sleeve.
Even if you only use one, reply#4 would be the best advice you ever get.
Reading the DS187B20 data sheet was a good thing for me to do, as I'd never used the MIXIM one wire protocol. After doing so, "sheepdogguides" article made sense. I'm a little skeptical it will work in my project, as I have existing interrupts going on that are somewhat critical, and I'm skeptical of the microsecond delays in the sheepdogguides methods being interfered with. I also see that the process of acquiring a temperature from the DS187B20 chip requires a significant amount of time. But it certainly will be worth learning to use.
As I mentioned in my post, my TMP36's technically are working well for me now, and I have taken the time to make those little PCBs boards for them. That said, I'm not so sure moving to the TMP06 I mentioned will be worth the effort, beyond it being educational. What is VERY enticing about the DS187B20 though has little to do with the fact that its digital at this point. What is really hard to ignore is that I can get them already housed in those neat pre-wired metal probes with 1M of cable, heat shrink protected, in some cases for less than $1 USD!!!
I'm considering possible commercial use of my finished project, so any and all work done for me is a big plus. The TMP36 or TMP06 for that matter, have to at least be soldered up on my little boards with a bypass capacitor and resistor, and THEN I have to build my planned aluminum rings for mounting, and THEN wire, mount, and protect the whole thing with epoxy. Then, the end result wouldn't look as good as one of those probes just taped to the pipe. If such a circuit were already done and packaged like those DS187B20 probes, I'd happily go that route too. So if I can get the DS probe to work in my project without ripping out too much hair, it will be worth it just for the work saved.
PeterPan321:
Reading the DS187B20 data sheet was a good thing for me to do, as I'd never used the MIXIM one wire protocol. After doing so, "sheepdogguides" article made sense. I'm a little skeptical it will work in my project, as I have existing interrupts going on that are somewhat critical, and I'm skeptical of the microsecond delays in the sheepdogguides methods being interfered with. I also see that the process of acquiring a temperature from the DS187B20 chip requires a significant amount of time. But it certainly will be worth learning to use.
I mentioned sheepdog because I believe it is more economical and makes sense if you have just one or two sensors on a Uno. The time taken is a matter of hardware and applies irrespective of the code you use. This time has no bearing on other time considerations, unless you want to work faster than the cycle allows, which I would have thought unlikely. The time taken varies with resolution, see the data sheet. I ignore it all and poll the temps in a one second loop.
What is really hard to ignore is that I can get them already housed in those neat pre-wired metal probes with 1M of cable, heat shrink protected, in some cases for less than $1 USD!!!
Be aware that you can't cheapskate with cable. They can come with 5m. I understand CAT5 is OK for extensions.
have to at least be soldered up on my little boards with a bypass capacitor and resistor, and THEN I have to build my planned aluminum rings for mounting, and THEN wire, mount, and protect the whole thing with epoxy. Then, the end result wouldn't look as good as one of those probes just taped to the pipe. If such a circuit were already done and packaged like those DS187B20 probes, I'd happily go that route too. So if I can get the DS probe to work in my project without ripping out too much hair, it will be worth it just for the work saved.
Nick_Pyner:
I mentioned sheepdog because I believe it is more economical and makes sense if you have just one or two sensors on a Uno. The time taken is a matter of hardware and applies irrespective of the code you use. This time has no bearing on other time considerations, unless you want to work faster than the cycle allows, which I would have thought unlikely. The timer taken varies with resolution, see the data sheet. I ignore it all and poll the temps in a one second loop.Be aware that you can't cheapskate with cable. They can come with 5m. I understand CAT5 is OK for extensions. All those THENs says it all......
I thought I'd mention that these little pre-wired DS18b20 modules worked out great. Its hard to believe they are so cheap. I did use sheepdogs code to test. I was happy to determine that the whole seemingly long process took no more than 5 to 6 ms for each temperature read, and further that it didn't really add much to my code or data space. I turned it all into a tidy class, along with the option to convert to Fahrenheit.
My main reason for getting back to you though was that last statement. These mostly come with 1M of cable, and I'd gladly pay a little more for 2 or 3M (plenty), since that would mean I could wire directly to my connectors with no splices. Can you recommend any suppliers who offer it with slightly longer wires?
I looked at the rising edges with 1M of cable and a 4.7K pull-up, and they looked good, so I'm hopeful a little more cable won't cause too much capacitance. Shielded wire would be better of course, but as it is a digital sensor I think the noise immunity should be decent, despite the resistive pullup.