Shop OBEX P1 Docs P2 Docs Learn Events
LM34 & MCP3204 wiring questions — Parallax Forums

LM34 & MCP3204 wiring questions

RussHRussH Posts: 35
edited 2011-12-05 04:47 in Accessories
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.
«1

Comments

  • kwinnkwinn Posts: 8,697
    edited 2011-08-04 20:38
    RussH wrote: »
    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.

    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).
    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.

    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.
    If anyone has any experience with these devices, or can shed some light on my questions I'd really appreciate it. Thanks.
  • RussHRussH Posts: 35
    edited 2011-08-05 11:28
    Thanks for the help, sorry if my question was missing some info.

    Here is the wiring diagram I am referring to:

    LM34 ckt.png


    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.
    372 x 412 - 12K
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2011-08-05 14:03
    P8 is not declared or used in any way that I can see in chapter 6 on the LM34 and is absent from the followup circuit on page 199.

    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.
  • kwinnkwinn Posts: 8,697
    edited 2011-08-05 16:08
    As Tracy says, that resistor and connection seems to be a leftover and nether the resistor or any connection to P8 is required. The output from each LM34 should go to a separate analog input on the MCP3204. A resistor in series is not required although I doubt that putting a 220 ohm resistor between the LM34 output and the MCP3204 analog input would have much effect on the calibration or operation of the circuit. The input impedance of the MCP3204 is pretty high.
  • RussHRussH Posts: 35
    edited 2011-08-08 10:31
    Thanks for the help guys, it's clear now.

    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?
  • kwinnkwinn Posts: 8,697
    edited 2011-08-08 21:40
    Having separate analog and digital grounds tied at one point only reduces noise caused by ground loops and noise from the digital circuitry. When digital circuits turn on or off there are relatively large and rapid changes in current that can cause noise spikes on the digital ground line.
  • RussHRussH Posts: 35
    edited 2011-08-09 09:53
    So if they're tied to a single point without some sort of filtering, doesn't that defeat the purpose? Judging by the MCP3202 performance, it won't be a problem, so I have tied them to a common ground
  • kwinnkwinn Posts: 8,697
    edited 2011-08-09 10:45
    RussH wrote: »
    So if they're tied to a single point without some sort of filtering, doesn't that defeat the purpose?

    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.
    Judging by the MCP3202 performance, it won't be a problem, so I have tied them to a common ground

    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.
  • RussHRussH Posts: 35
    edited 2011-08-09 14:26
    Thanks again for the help.

    When I get things a little better documented and fully tested, I'll post in the projects forum.
  • RussHRussH Posts: 35
    edited 2011-08-30 12:48
    One more question about the MCP3204, in the example code for the MCP3202, the SHIFTIN value is limited to 12 bits, that part makes sense. In the MCP3204 example code, the SHIFTIN value is limited to 13 bits. why is this? I had my conversions and temperature display working great with a 3202, now that I've switched to the 3204, I am getting strange results. I am going to do some more debugging tonight, I have just been looking at the differences in the code, and couldn't figure this one out. Thanks.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2011-08-30 19:07
    Russ, both converters shift out 12 bits of data, and in both the data is preceded by a 13th bit that is always zero (null). Difference in the programs may have to do with how the programmer decided to handle the null bit.

    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?
  • RussHRussH Posts: 35
    edited 2011-08-30 19:32
    Tracy, thanks, that's perfect. I had figured out the 5 bit on SHIFTIN, but didn't know about the null bit.

    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 .:smile:
  • RussHRussH Posts: 35
    edited 2011-09-01 09:57
    So, now that I have corrected the wiring to the ADC, the values that I am getting from it are very jumpy and erratic, and don't seem to make any sense. Here is how I've wired the ADC, and also how I've wired the LM7805 that is delivering the 5v to the ADC & temperature probes.

    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:

    13 - Testing.jpg


    17 - Complete.JPG


    And inside the control panel:

    2 - Panel innards.JPG


    Thanks.
    703 x 588 - 147K
    648 x 484 - 137K
    484 x 648 - 185K
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2011-09-01 12:06
    Russ, nothing jumps out at me in the wiring or in the program. It can't hurt to check the wiring again with a voltmeter to be sure all the wires are making contact as expected.

    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.
  • RussHRussH Posts: 35
    edited 2011-09-01 14:58
    Thanks for looking Tracy, I think I just figured out my problem. I am at work, but I'll confirm when I get home.

    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.
  • RussHRussH Posts: 35
    edited 2011-09-12 11:35
    Well, I've been busy working at this issue, and figured I'd give an update. I fixed the circuit board issues, and managed to get decent readings from 1 sensor, but the others were all over the place. The 3 temp sensors were connectorized by some 3 pin XLR connectors out of the control panel.

    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
  • kwinnkwinn Posts: 8,697
    edited 2011-09-12 21:03
    Russ, over the years I have seen many intermittent problems caused by connection problems of some sort. They may be cold solder joints, bad connectors, cracked pcb traces, bad feed thru's, cables with wires broken inside the insulation, or cables with intermittent shorts. I would suggest starting at the adc and checking everything from there to the sensors one step at a time. The first thing would be to replace the cables going from the adc board with a connector and resistors to simulate the LM34 output voltage. That will determine if the problem is on the adc board or somewhere else. If you post or pm the schematic and a picture of the board and sensor assemblies I may be able to make more specific suggestions.

    BTW, you should not leave any of the inputs to the adc floating. Short or place a resistor across unused inputs.
  • RussHRussH Posts: 35
    edited 2011-09-12 22:04
    kwinn wrote: »
    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.
  • RussHRussH Posts: 35
    edited 2011-09-13 10:51
    I've been doing my homework on this, and I just read the Microchip application note AN688 - Layout Tips for 12-Bit A/D Converter Application.

    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.
  • kwinnkwinn Posts: 8,697
    edited 2011-09-13 22:20
    You can short the unused ADC inputs to ground. Bypass capacitors are also necessary at the chip as well as the power supply. Since the inputs to the adc change slowly it would not hurt to put a small (0.01uF) capacitor between each input pin on the adc and ground.
    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?
  • RussHRussH Posts: 35
    edited 2011-09-14 09:54
    Thanks kwinn, I have managed to narrow the problem down to one of the sensors not working properly. I shorted the unused pin to ground, added bypass capacitors to the power supply of the ADC, and also the sensors. I have laid the panel out so that the power wires (and anything AC) are all separated from the DC signal wires. If you look in the control panel picture, you can see the three temp probe wires run down the side near the front. When I got home yesterday, I started probing around with a multimeter to check the grounds everywhere. I quickly realized that the BOE is mounted on aluminum standoffs, making the ground common to the backplate of the control panel. I imagine that this probably isn't the best situation. I removed it and isolated it from the plate, and this helped with the 'going wacky'.

    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.
  • RussHRussH Posts: 35
    edited 2011-09-22 13:10
    I've given up. This thing is whack. I have literally re-soldered every joint in the whole arrangement 3 or more times, replaced cables, replaced sensors, you name it, and cannot figure it out. I have 1 that works flawlessly, and the other two are hit and miss. You can have it working, power off, power on, and the readings are garbage all of a sudden. I am taking a scope home from work today to see if I can get into it a little more, but man it's frustrating.

    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.
  • kwinnkwinn Posts: 8,697
    edited 2011-09-22 22:22
    I am surprised that you are having so many problems with these chips. I have used the LM34 and LM35 series sensors with the ADC0838 and MCP3208 for measuring temperatures from -30C (-22F) to +110C (230F) with no problems. I am careful to make sure the connections to the sensor are soldered well and sealed from moisture with Humiseal or epoxy paint. At the ADC end I use the recommended pcb layout practices for the analog and digital portions of the chips. To date I have had very few failures and those have all been traced to other areas.

    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.
  • RussHRussH Posts: 35
    edited 2011-09-27 14:04
    I have done exactly as suggested. The problem does not seem to be the ADC, I can put the good sender on any channel, and the numbers I get are good. The senders giving bad results give the same results regardless of which channel they're on. I know that this makes it seem as simple as "oh, the sensors are bad" but, when I power them directly and measure the outputs with a multimeter, they give reasonable results. I have installed decoupling caps on the power supply, the ADC, and the sensors, and it makes no difference.

    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.


    :smile:
  • kwinnkwinn Posts: 8,697
    edited 2011-09-27 18:35
    You are more than welcome for what little help I provided. If you were within 2 or 3 hours drive of Edmonton I would be willing to come to your garage just to see if I could solve this issue. This is the kind of problem I find challenging and enjoy solving. Good luck with the new platform, and let us know how it turns out.
  • RussHRussH Posts: 35
    edited 2011-11-28 12:46
    So, I've been brewing beer without temperature control, and now that I have a stock pile of tasty goodness in the garage fridge, I've found myself with some more time (and patience/tolerance) to dig back into this problem a bit. I have started re-writing my program for the new controller, but since so many people use these sensors reliably, I would really like to sort this out before moving on. I have had the opportunity to borrow a fluke scope from work, and probe out the connections to get more of an idea of what is going on. Here are the results:

    IMG_1920.JPG


    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.
    484 x 648 - 135K
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2011-11-29 09:04
    Hi Russ,

    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)?
    Screen shot 2011-11-29 at 8.48.20 AM.png


    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.
  • RussHRussH Posts: 35
    edited 2011-11-29 10:26
    Tracy,

    Thank you so much. Especially for this part:
    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

    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.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2011-11-29 13:25
    1) It should be possible to put the resistor at the accessible end of the 10" tube, in series with the signal line. The amount of capacitance it takes to make the sensor oscillate is probably more than 10" worth, and no way would I want to try to disengage the sensors from the potting. I usually used 3kΩ instead of 2kΩ, recalling instances where 2k was not quite enough.
    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.
  • RussHRussH Posts: 35
    edited 2011-11-29 18:02
    Yaaaahhhhooooo! 2k resistors in line with the sensor output have sorted it out. Thank you so much. On a 600mV signal I had 115mV of ripple, and now have 0. If you're ever going to be in Victoria BC, PM me and I'll give you a brewery tour along with samples ;)
    I've spent countless hours stewing on this and can't believe it was so easy. :cool:
Sign In or Register to comment.