Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : (MM) wild temp sensor readings
Page 1 of 2 | |||||
Author | Message | ||||
pcaffalldavis Senior Member Joined: 17/10/2011 Location: United StatesPosts: 187 |
(MM) Wild temp sensor readings LM335Z I’ve been having some difficulty with wildly extreme temperature readings from LM335Z temperature sensors. I’m doing the trial runs of the wood fired boiler and have noticed that two of the four temperature circuits fluctuate as much as 5 degrees C (10-12 degrees F) in as little as five minutes. Sometimes this fluctuation is in as little as two minutes and it is not uncommon for the first minute at MM boot to fluctuate as much as 8 degrees F or 4 degrees C. All temp sensor pins are set using SETPIN(x),1 The MM SM1 3.3 volt circuit reads at 3.26 volts so I use 3.26 in formula. For example: OUTDOORTEMPCENT=(PIN(2)/3.3 * 3.26-2.73)*100. I’ve swapped the outdoor temp sensor with the household hot water sensor and the fluctuation is extreme (beyond factual) regardless of which sensor I use. All four of my sensor circuits use only the + & - legs of the LM335Z. I have them soldered to 22 gauge 2 conductor red/black insulated wires with an outer layer of gray plastic. The hot water and outdoor temperature circuit wires are both about 8 meters long. The one for the indoor house temperature is similar, but only 3 meters long. This shorter one does not fluctuate nearly as much, probably reads more accurately is my guess. I have tested the sensors on different sensor circuits to make sure the problem was not on the circuit board. The results are that the sensors with the longer wires have the most fluctuation regardless of which sensor connection point they are plugged into. I wondered if I had too high of a current load on the MM SM1 power regulator, which I may have since it was warm when I was running the VGA to Composite converter off the 5 volt leg. But I disconnected the VGA converter and the temperature fluctuation problem is still there. I tested the setup using two different MM SM1’s too, so it is not machine dependent. Does anyone know what the heck is going on? I built an earlier MM project, a temperature sensor and data logger using a 10 meter wire to a LM335Z which is still running. I use it to view and log the current, high and low daily temperatures. It does not seem to fluctuate within a single minute much at all, maybe 1 or 2 degrees F (1 degree C). But these other circuits in my Wood Fired Boiler project sure do. Today I even tried replacing the Outdoor Temperature Sensor, one of the 8 meter 22 gauge stranded wires sensors, with a new 8 meter 20 gauge solid wire with a brand new LM335Z on the end. It has the same problem as the 22 gauge one it just replaced. So, I’m wondering, is it possible that these sensors might be picking up transient RF voltage on these longer wires? I can’t think what else it could be. The argument against that though is that my longer sensor on the other MM temperature logger does not manifest the wide range fluctuation problem. I would have taken the long 10 meter sensor off my daily temperature logger to test on the Wood Fired Boiler project, but that one is soldered in whereas all the others are connected using 2 conductor header pin connectors off the component circuit board. I don’t think those connectors could be the problem. I do run my outdoor sensors along a place on the back corner of the house where about a dozen CCTV camera signal and power wires are running into the house. But the other earlier project sensor wire that does not fluctuate much also runs along this corner of the house near these wires. Does anyone have any ideas on this? Has anyone else experienced wild fluctuations of temperature readings using LM335Z sensors? Should these longer runs of wire to sensors be shielded? Would this solve the problem? Pete in Hyder We're all here 'cause we're not all there. |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6098 |
Pete, I run 10-15 metre two wire leads to some of my LM335's without any problems. I feed mine from 5V and pick a resistor to give 1-2mA at 'normal' temperatures. A 1k resistor or slightly larger for R1 should do the trick. I have also put in a voltage divider to drop the output a bit and to keep the voltage to 3.3V if the signal lead goes open circuit. That happens when the wife goes mad with the pruning shears. I have lost a few soil temp sensors that way! I do usually put a small capacitor at the Maximite inputs and ferrite beads around the cables but I do play with radios as well so it's second nature for me. Jim My CGMMSTICK's arrived today so time to warm up the soldering iron... VK7JH MMedit  MMBasic Help |
||||
pcaffalldavis Senior Member Joined: 17/10/2011 Location: United StatesPosts: 187 |
Thanks Tassyjim, So how do you determine the voltage for the basic program? Do you just read across the downline side of the resistor and ground with the LM335 disconnected? And then use this voltage in the basic formula? Pete in Hyder We're all here 'cause we're not all there. |
||||
centrex Guru Joined: 13/11/2011 Location: AustraliaPosts: 320 |
Hi Pete Your formulae is correct but are you running the temp sensors from the 5Volt supply as TassyJim has shown, GeoffG suggested using a 1.8K resistor but also cautions that the max temperature that can be read is 57degC, if want to read a higher temp you have to use a voltage divider into the input pin and then scale the reading in software. Also a .001 cap on the input pin to gnd may get rid of some induced voltage. To TassyJim now that you have had at least 5min to play with the CGMMSTICK what do you think of it. regards Cliff Cliff |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6098 |
Pete This is my circuit I have put a 0.01uF capacitor from point A to ground on some of the long leads. To get the scaling factors, I measured the Maximite voltage at a known temperature and calculated it from there. With 4 sensors my program looks like: scaled(3)=av(3)*168.5-273 scaled(4)=av(4)*168-273 scaled(5)=av(5)*168.3-273 scaled(6)=av(6)*169.5-273 I take readings every 10 seconds and average them over 5 minutes. The variations between sensors is not worth worrying about in my situation. The location of the sensor causes the biggest errors and within one degree C is more than enough. Cliff, No chance to play with the CGMMSTICK yet, the wife cam out of hospital yesterday. I think I had more time when I was spending all the day driving to and from the hospital visiting. Just waiting for her to go back to sleep.... Jim VK7JH MMedit  MMBasic Help |
||||
pcaffalldavis Senior Member Joined: 17/10/2011 Location: United StatesPosts: 187 |
Tassyjim I like the way you got your circuits set up for each LM335. Is the av(3), av(4) the average of the pin(x), etc voltages you collect directly from the Maxmimite pins that the sensors are located on? This looks great. So you average the pin voltage readings for five minutes for each individual pin, putting the results into av(x), av(y), etc, and then at five minute intervals you use scaled(x), scaled(y), etc to convert the averaged voltages collected to display the results? I like that if I understand correctly. Could you share a couple lines of code showing how you collect and average the pin voltages on each program loop? I am new to circuit board building and have never learned about or understood capacitors before. I do have a box of capacitors, mostly disc types with a few cans. Wikipedia tells me the small disc types are rated in pF. So if I need to use a .01 uF isn’t that the same as 10 nF or 1000pF? I’m trying to see if I have what I need to jump these four sensors pins to ground. I’m not sure I understand how to read their markings. Guess I need to order up a collection of capacitors. Do you suggest cans, disc, or ceramic? Do I need all three for amateur work like this? Are the .01uF caps that I need most likely to be disc type? Pete in Hyder We're all here 'cause we're not all there. |
||||
Olimex Senior Member Joined: 02/10/2011 Location: BulgariaPosts: 226 |
for industrial environment with lot of noise and long cable I would modify TassyJim schematic to this: I've seen hundreds of volts induced picups on long cables going near motors and relays |
||||
Olimex Senior Member Joined: 02/10/2011 Location: BulgariaPosts: 226 |
Pete, I just post atricle on this in my blog and explained how to calculate your coefficients TEMPERATURE MEASUREMENT WITH LM335Z |
||||
jwettroth Regular Member Joined: 02/08/2011 Location: United StatesPosts: 71 |
A couple of things. If you don't need much speed- you can bypass your cable with a capacitor or an RC if the load has trouble driving capacitive loads. I am just starting to play with the Analog Inputs on an SM1 and am getting pretty poor results. The first reading that I get will be pretty good. If I run in a tight loop, the next reading will be down and the readings will settle out to about 70% of the initial reading. I'm using a 2.5v buffered reference as my voltage source and FW 3.0A. Do you all get repeatable readings at semi fast rates. I'd like to read about 10 readings per second- not really very fast... Thanks, John John Wettroth |
||||
Olimex Senior Member Joined: 02/10/2011 Location: BulgariaPosts: 226 |
I did single measurements then ran 1000 samplings and averaged them, the result was same, so I didn't want in this example to bloat the code as the precision stays same no matter if you sample 1 or 1000 times Jwettroth can you post your schematic how do you wire the sensor, you should do something wrong, or can you check with oscilloscope what is your voltage on the input pin and if it fluctoates by some way like modulated with 50Hz noise? investigate your PIC32 power supply for noise too, in DM special care was made when the power supply was layout and the Analog part must be properly de-coupled form the digital part |
||||
pcaffalldavis Senior Member Joined: 17/10/2011 Location: United StatesPosts: 187 |
Okay, I will add resistors R2 & R3 and recalculate based on the resistors true resistance as measured using a meter. I'm currently using 1.8K resistors for R1. Do I need to change them for 1.5K resistors or can I leave them as 1.8K? Will these 1.8K resistors affect the voltage divider formula? I don't see how they would, but I am not schooled in these matters. The formula I will use to calculate the Pin(1) multiplyer is: 100/(R3/(R2+R3)) If R2 is 18K and R3 is 27K the result should be about 166.7, but should be adjusted for the actual values of the resistors. If I understand correctly then the degree Celsius reading would be Pin(1)*166.7-273. Some of this was taken from Olimex's blog and repeated here for the benefit of those who didn't follow the link. Thank you Olimex So folks, do I need to swap the R1 1.8K resistors for 1.5K resistors? Pete in Hyder We're all here 'cause we're not all there. |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3800 |
The ratio of R2 & R3 will only move the readings a little if you measure the resistors carefully. Worth doing, but it's not going to fix the problem where the temp jumps. I can't see changing R1 by a little being a fix, either. You have noise spikes or something (by way of example, a heat source you've not realised is there). The filters & noise suppression shown in the above circuit and mentioned in various posts are to get rid of (suppress) the noise - if it's noise, and likely it is. John |
||||
Gizmo Admin Group Joined: 05/06/2004 Location: AustraliaPosts: 5078 |
I find its always good to use some software smoothing where possible. It depends on the application of course, and but instead of taking one reading, I would take several with a few milliseconds between them and then average them out. eg OUTDOORTEMPCENT=0 for i=1 to 10 OUTDOORTEMPCENT = OUTDOORTEMPCENT + (PIN(2)/3.3 * 3.26-2.73)*100. pause 5 next OUTDOORTEMPCENT=OUTDOORTEMPCENT/10 It takes longer to make a reading, 50mS in this case, but the accuracy and noise rejection are impoved. Glenn The best time to plant a tree was twenty years ago, the second best time is right now. JAQ |
||||
seco61 Senior Member Joined: 15/06/2011 Location: AustraliaPosts: 205 |
Hi All. For those that are interested the current implementation of the analog input in MMBasic performs the following process: 1) 10 consecutive readings are taken from the analog input and stored in ascending order. 2) The middle six readings are summed. 3) The value is divided by 6 and scaled from 0.0 to 3.3 4) The result is returned. Regards Gerard (vk3cg/vk3grs) |
||||
pcaffalldavis Senior Member Joined: 17/10/2011 Location: United StatesPosts: 187 |
I like that Gerard. Do you have a few lines of example code for collecting the 10 readings, selecting the six middle readings, and outputting the avg of the six? I'm sure I could write it, but if you already have it ... Thanks, Pete in Hyder We're all here 'cause we're not all there. |
||||
Olimex Senior Member Joined: 02/10/2011 Location: BulgariaPosts: 226 |
Pete, Gerard wrote that this is already implemented, this is how MM Basic reads analog pin I don't know maybe I'm lucky or just because I did the experiments in my office but averaging 1000 results gave me same temperature like measuring 1 time without averaging, i,e, no improvement the temperature variations were after the second digit after the decimal point |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3800 |
If, as seems likely, the OP's problem is noise or similar, IMO averaging is the wrong approach. Instead, the noise needs eliminating (rejecting) or if needs be the bad readings need to be detected and ignored. An example of the latter: if the temp jumps more than a tiny amount between readings which are close in time then either soemone's using a blowtorch or it's a bad reading. I'd go for the hardware approach. It's notoriously hard to fix this kind of thing in software that's in an interpreted language (or at all). John |
||||
pcaffalldavis Senior Member Joined: 17/10/2011 Location: United StatesPosts: 187 |
I am getting wild readings seconds apart (sometimes) so I think it is hardware too. But as I said earlier, I'm new to circuit board building. One poster mentioned putting a .01 uF capacitor across the MM pin connection point and ground. Wikipedia says small capacitors use a 3 digit code that is pF. So does that mean I'm looking through my collection for a 1000 pF? That would be four digits. I have a small capacitor that reads 100 and another that is labeled .001. Neither of these seem correct to my limited understanding though. Some of the can capacitors I have are rated in uF. But others don't have the scale rating (uF, nF or pF). What will a small disc capacitor that is .01 uF read like using the three digit pF scale? Could someone give me a clue about how to read capacitors for this project and which type I should be looking for? I guess I will order up a collection of capacitors. Should I get small disc capacitors first, or ceramic ones, or cans. Do I need a good collection of all three types to get started? Which do I need for this project? Pete in Hyder We're all here 'cause we're not all there. |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6098 |
Pete, The difference between 1.5k and 1.8k for R1 is insignificant. It will change the current through the 335Z slightly but not enough to change the voltage output. Also, small changes in the 5V supply wouldn't make much difference. The LM335Z output changes slowly by design so any sudden changes in voltage are caused by interference etc. Eliminate the fluctuations first then worry about getting the true value. Then: X=(T+273)/V where X is the multiplier we are looking for T is the actual temperature in deg C V is the voltage at the Maximite input. In your program: T = pin(1) * X - 273 In my situation I put a recording thermometer in the sensor location for 24 hours and adjusted for best fit. That's why my maths doesn't look quite right. Using your 0.001 capacitor would be OK as an RF filter. My choice usually depends on the first one I find in the box. Usually a ceramic. You can do all sorts of calculations to come up with a correct value if you know the frequency you are trying to eliminate but in this case its easier to use what you have. Jim VK7JH MMedit  MMBasic Help |
||||
pcaffalldavis Senior Member Joined: 17/10/2011 Location: United StatesPosts: 187 |
Thank you Tassyjim. So which collection of capacitors do you think I should buy first? Ceramics? Is it true that my little brown disc cap that reads .001 is in pF's so also equal to .000 001 nF & .000 000 001 uF? Are there any capacitors with ratings lower than .001 pF? Just trying to learn. Pete in Hyder We're all here 'cause we're not all there. |
||||
Page 1 of 2 |
Print this page |