LM34 & MCP3204 wiring questions
RussH
Posts: 35
Hello,
I am using a MCP3204, and 3 LM34 temperature sensors for monitoring temperatures in a home brewery.
Up to now I have wired the LM34's following the schematic in Chapter 6 of the process control book, but I am curious, why does the output of the LM34 need to connect to pin 8? The ADC is what reports the information back to the BS2, isn't it? Right now, I have a pin for each sensor, but I shouldn't need to I don't think. Is pin 8 just acting as a pull down? There is nothing in the program that indicates that anything is happening with it. I'd just like to free up some I/O's if possible.
My next questions are regarding the MCP3204. Previously I was using a MCP3202, and went to the 3204 for an extra couple channels. There are another couple connections that weren't on the 3202, and I'm unsure of what to do with them.
First is the Vref, can I just tie this to the 5V power supply powering the chip? or do I just leave it not connected?
Next, the 3204 has a digital ground, as well as an analog ground. Again, can I just tie these two together? should I use a filter capacitor between them or anything? I'm guessing since the 3202 used a common ground, and I didn't have any problems, this should work here too.
If anyone has any experience with these devices, or can shed some light on my questions I'd really appreciate it. Thanks.
I am using a MCP3204, and 3 LM34 temperature sensors for monitoring temperatures in a home brewery.
Up to now I have wired the LM34's following the schematic in Chapter 6 of the process control book, but I am curious, why does the output of the LM34 need to connect to pin 8? The ADC is what reports the information back to the BS2, isn't it? Right now, I have a pin for each sensor, but I shouldn't need to I don't think. Is pin 8 just acting as a pull down? There is nothing in the program that indicates that anything is happening with it. I'd just like to free up some I/O's if possible.
My next questions are regarding the MCP3204. Previously I was using a MCP3202, and went to the 3204 for an extra couple channels. There are another couple connections that weren't on the 3202, and I'm unsure of what to do with them.
First is the Vref, can I just tie this to the 5V power supply powering the chip? or do I just leave it not connected?
Next, the 3204 has a digital ground, as well as an analog ground. Again, can I just tie these two together? should I use a filter capacitor between them or anything? I'm guessing since the 3202 used a common ground, and I didn't have any problems, this should work here too.
If anyone has any experience with these devices, or can shed some light on my questions I'd really appreciate it. Thanks.
Comments
Not sure what you mean by this. Which chip's pin 8 does the output of the LM34 connect to, the MCP3204 or the BS2? Also, chapter 6 of what process control book (author, publisher, title ) ? Typically the LM34 +Vs goes to +5V, GND goes to the analog ground, and Vout goes to an input pin on the adc (pins 1-4 on the MCP3204).
Vref can be tied to +5V, which would give you a 0-5V range, which equates to a 0 - 500 degree Fahrenheit temperature range. This is what you have with the MCP3202. If you want better resolution you could use a lower reference voltage.
The analog and digital grounds should be tied together at one single point for best results.
Here is the wiring diagram I am referring to:
It is on Page 183 of the Process Control book published by Parallax, here:
http://www.parallax.com/StoreSearchResults/tabid/768/List/0/SortField/4/ProductID/395/Default.aspx?txtSearch=Process+control
If I am connecting the +Vout pin only to one of the inputs on the MCP3204, do I need a resistor in series or anything? I assume this is going to change the operation / calibration of the sensors from the programs point of view, correct? is the default state of the I/O's on the BS2 low? if so then I think that the pin8 connection could be replaced with a connection to ground, but then why would it be wired this way?
Thanks again for the help.
That resistor to p8 seems to be an artifact left over from the circuit and program on page 46, where they were using it with a potentiometer to find the input threshold of the Stamp. It should not be there with the LM34. However, it won't have any effect so long as p8 remains as an input. Just remove it and forget it.
Out of curiosity, why does the chip have separate analog and digital grounds if they're just tied to common anyway? Special applications I guess?
Yes it does. The analog ground is there as an option so you can have a separate analog power supply for applications where low noise is critical.
For a lot of applications this is more than adequate. No point in designing for 0.1% accuracy if the sensor is much less accurate or the application does not need it.
When I get things a little better documented and fully tested, I'll post in the projects forum.
The 3202 requires that the program send 4 configurations bits, and then deal with the null bit, and then clock in the 12 data bits, MSB first. Wheras the 3204 and 3208 require 5 configuration bits, then the null bit, then the 12 data bits. Does that help at all?
I am getting really jump values fro the ADC, and last time I had a trucation problem, so that's where I'll start.
I really am going to owe you some beer at the end of this project .
ADC Diagram.pdf
I have trimmed the program down to just the temperature measurement portion, and have attached that as well.
Temp_TestAug30.bs2
when I say jumpy, I mean the result variables read out something like this:
0,24, 158, 2, 243, 55, etc.
Any help with this would be appreciated. I am ready to brew beer, minus temp control. Here are a couple pic's of the whole setup:
And inside the control panel:
Thanks.
My next step would be to simplify the program further. One channel at a time. Leave out the math and display only the raw result.
It's kind of comical actually... When I first got into this, I built the circuits on a breadboard, and got everything working well. For the final installation, I switched the circuits over to a soldered protoboard, added another sensor, and switched to a 4 channel ADC. When I initially wired the ADC I left the grounds and power(s) disconnected because I was unsure about how to deal with them. At about the same time, a giant box of stainless fittings showed up, and the control end of the project got put on the back burner. Fast forward a few months, I hook everything up, expecting it to work as it did on the breadboard, and forgetting about the "loose wires".
Needless to say, I got nothing. The first thing I did was retrace the wiring, and realized that the ADC was wired all except for Power, Vref, and Digital and Analog grounds. After the help I got here, I wired these up this weekend, with one exception.... I tied the two grounds together, but failed to remember to tie them to ground. I guess I got caught up in the excitement of seeing the setup run.
I'll let you know how it goes after I fix this. Thanks again.
After a bunch of messing around, I found that the solder connections to the XLR's had broken. (the cable I used for the sensors is very small and flexible, so the strain at the pin was too much) I redid the connections with a 6" splice of some heavier wire to solder onto the XLR pins heat shrinked into a bundle so that it was protected through the XLR's strain relief.
This arrangement also gave me flaky numbers, and when the connectors were wiggled it worsened. I decided to bypass the connectors to eliminate that problem. Wiht the connectors out of the equation, when 3 sensors were plugged in, 2 were giving decent numbers one was not (ch0). When I move sensors around (from pin to pin on the ADC), sometimes the numbers stay normal, other times they turn to garbage. When this happens, it quite often upsets another good channel and they both start bouncing around. Reset does not fix it, unplugging for 10 seconds or so seems to fix it most of the time. Is this normal operation? Is it a must to have all 4 inputs of the ADC occupied in order to get reliable data? I plan on switching the connectors to something a little better quality, and hopefully that sorts that end of it out, but even with good connections, the sensor data seems hit and miss.
I am using these for process control, and if it becomes unstable / unreliable half way through a 6 hour brew day, it's going to be bad news. What can I do to make it so that at very least the channels act as though they're isolated, so if I lose one sensor, it doesn't take down another?
I was planning my inaugral brew for this sunday, but instead got to spend a delightful day trouble shooting this problem. I have the day off thursday, and I am making beer, with or without temperature control. (but VERY, VERY, hopefully - with)
Russ
BTW, you should not leave any of the inputs to the adc floating. Short or place a resistor across unused inputs.
Thanks for the comments. Right now the 4th input is floating, and I'd like to sort that out and see what happens. If that doesn't solve it, I'll give you the full "document package".
Do I put in a short / resistor to ground? What size resistor?
All three temps will read stable now, until the slightest thing changes, and it goes all wacky. Forget turning on a pump or 5500W element.
Edit: channels 0 & 2 go wacky. Channel 1 gives a flawless output all the time.
One of the major points is that the author recommends by-pass capacitors at the power supply and one for each active device. I am going to give this a try tonight, and I would also like to deal with the floating channel on the ADC.
Can someone confirm that I should be tying this pin to ground, and recommend a resistor size to use, or do I even need a resistor?
Thanks in advance.
Keep in mind that a pump motor and 5500W heating element draw a lot of current. Having a sensor cable near the pump or heating cable could induce a lot of noise in the signal cable. A signal cable should never be run parallel and close to a power cable.
As for "channels 0 & 2 go wacky. Channel 1 gives a flawless output all the time", what is different between channel 1 and channels 0 and 2 ?
Are the sensor cables close together?
Is the channel 1 cable routed differently from channel 0 and 2?
If you swap the channel 0 and 1 cables at the adc board is channel 0 flawless and channel 1 whacky?
Now, channels 1 and 2 read fine, 0 is out all the time, except when I remove the sensor, and give the ADC a known voltage, in which case it reads the voltage perfectly. I am going to build another probe tonight, and that should solve it. Since correcting these issues, I have not tried powering a pump or element, so I'm not sure that the problem is entirely solved, but I'm sure it's closer. Like I said before, I'm brewing tomorrow come hell or high water, so I've got one night left to get it sorted. I'll let you know how it goes.
Are there other sensors that could be more reliable? I got a couple DS 18B20's I am going to try, but I need to make some code and circuit changes, so I'd like to fully exhaust the LM34's first.
I am also VERY low on code space on the BS2, so I am going to upgrade. I would like to encorporate some averaging, and also have the ability to go to PID control in the future. Not sure yet if I'll go with another stamp module, or something entirely different. I was about to order a new module while they were on sale, but decided to hold off and do some more research first.
It is possible you have a bad adc chip or temp sensor, but in most cases problems are generally from other causes. It could be bad connections, noise pickup, ground loops, or a host of other things.
Troubleshoot by using the working sensor and adc channel.
Test the sensors by connecting them to the same location and adc channel as the working sensor. If they work there then the problem is somewhere else.
Move the working sensor to the location of non functional sensor 1 and see if it works in that position. Make sure you run the wiring in the same path as the bad sensor. If it works the problem is with the sensor 1 or the adc channel it is connected to. If not it may be noise pickup, a ground loop, or some leakage current at that location. Repeat for bad sensor 2.
Also, when I was brewing this weekend, the senders that had not been working started giving good results half way through. I have changed cables and resoldered them, changed connectors and resoldered them, still nothing makes them reliable. Literally every time you cycle power it's a different story (with the exception of the one that always works.
I don't know how much of an issue this is anymore, since I've run out of code space and have ordered a different development platform to try (it has dedicated analog in's to boot) and I'll see if anything changes. I also got a handful of DS18B20's to try and see if that helps.
Thanks for all the help, I think that without coming to my garage, you've done about all you can, and I appreciate it.
The 515 and 540 mV readings are about right, giving 51 and 54 degrees, it's the ~120mv of change that is screwing with my readouts.
When I put this together the first time, I had it all assembled on a breadboard using a 9V as a power supply and everything worked fine. In one step, I went to using an AC to DC power supply, soldered all the circuits onto a piece of protoboard, and put in in a big aluminum enclosure with several other 120 and 240 VAC circuits. On the breadboard I did not have any filter capacitors, except for on the 5V regulator. When going from bread to proto board, I looked at the individual components application notes, and used whatever capacitors were suggested. I have extra components, so I have decided to put the whole works back together on a breadboard just the way I had it, and see if that works inside the enclosure. I'll post more information/results as they develop, I just thought I'd give a quick update.
My novice thinking is that the waveform looks like there is some RC discharge superimposed on what would otherwise be an accurate reading, and this has me thinking that I have added some capacitors that I probably shouldn't have. I am going back to the last known good configuration and hopefully this will shed some more light on what has happened.
The period of that oscillation is a little less than 40 µs. Oscillation is almost certain to appear when the the bare LM34 is attached to cables of a certain length, due to the capacitance of the cable. Do you have a resistor or a damper on the outputs, per the LM34 data sheet (figure 3 attached)?
I have a probe construction diagram posted here. Without damping, the oscillation is usually not so strong, but it can be maddening as it comes and goes depending on the order that things are powered up, temperature, how you wave your hand at it and phase of the moon. Handheld DC multimeters tend to average over a long intervals, so the fluctuations are not so evident. Also check with the 'scope to see if there are any oscillations on the power supply to the sensors.
Thank you so much. Especially for this part:
The most frustrating part of this has been that powering off and back on, can sometimes solve the problem an one or more sensors. Also, in my boil kettle, as soon as the temp gets to about 170 degrees F, the reading completely stabilizes.
Last night I built a simple 5V reg on a breadboard powered by a 9V battery. I connected one channel of the scope to supply voltage, and one channel to the sensor output, and observed the same thing. I had one LM34 that was still in the bag from digikey, so I stuffed it in the breadboard and tested it. The output on that one was perfect. I was convinced that my potting procedure was buggering the sensors.
I have a couple questions about the diagram and your probe assembly instructions.
1. I have potted my LM34 (TO-92 package) in some 1/4" copper tube, that I insert into the kettles through a compression fitting, the copper tube is about 10" long, but the LM34's barely fit down there on their own. Would it work for me to have the resistor assembly just outside of this tube? They're also already potted, so getting them out is out of the question.
2. Figure 3 of your attachment shows a 2k resistor in line with the output, and the ground of the sensor tied to the cable shielding? (that's how I see it anyway) Currently, I have grounded the shielding to XLR connectors that I am using to separate them at the panel. Will grounding this 5VDC ground to the panel that also has AC grounds connected to it cause problems? I suspect not because the Parallax board is tied to the same ground plane, but figured I'd ask. I'd like to try this resistor configuration, since I have some 2k resistors in my arsenal.
I went at this last night determined to solve it, and was more frustrated than ever. I have a few DS18B20's and I was ready to scrap the LM34 probes and change sensors. Your advice came just in time. I'll give it one last shot, since I'd really like to be able to salvage what I have both hardware, and code wise. Thanks again. I really appreciate the help.
There is also the option of an RC snubber between the signal line and the Vss line, instead of the resistor in series. If you download app note AN460 and look at figure 18 on page 10, there is a circuit that positions the snubber at the far end of the cable away from sensor. The series resistor is easiest to try though.
2) That cable in my example is 3-conductor unshielded. If you have a shield for the LM34, in addition to 3 wires, I would leave it unconnected at the sensor end except possibly to the copper tube (insulated from the sensor). Connect it to the panel only at the XLR connector shield. It depends. Sometimes depending on the noise sources either ground connected or ground lifted works better. 60Hz pickup is not evident in your 'scope trace. However, inserting a 2k or 3k series resistor will increase susceptibility to 60Hz.
Keep at it! I agree with Kwinn that these are very nice and accurate sensors.
I've spent countless hours stewing on this and can't believe it was so easy. :cool: