![]() |
Forum Index : Microcontroller and PC projects : Temp LM335 voltage fluctuations
![]() ![]() |
|||||
Author | Message | ||||
WhiteWizzard Guru ![]() Joined: 05/04/2013 Location: United KingdomPosts: 2944 |
IF you are wanting a reading every half second (assuming this based on PAUSE 500) then the way your code is at the moment will actually take 700mS due the the 200mS 'delay' incurred by the conversion/reading. So change your PAUSE 500 to PAUSE 300 IF you are trying to read every half second ![]() Other than that, all is good. You could also make your two PRINT statements into one: PRINT tempcent, odtemp This may then allow more readings on the screen before you need to CLS - i.e. your IF statement becomes IF x=>34 . . . Hope this all makes sense ! WW |
||||
pcaffalldavis![]() Senior Member ![]() Joined: 17/10/2011 Location: United StatesPosts: 187 |
Yes that does make sense. I'll put the two prints on one line and double it to 34. I was only using 500 ms just for a test. I've had the program hang twice in the last couple minutes. It reports the DS18B20 did not respond. Hum.. I'll change the pause to 1000 ms and see if that stops the odd program hang. We're all here 'cause we're not all there. |
||||
pcaffalldavis![]() Senior Member ![]() Joined: 17/10/2011 Location: United StatesPosts: 187 |
The error: DS18B20 is not responding is now a pretty frequent error. Once a minute or so. I re-pinned it to the board but there do not seem to be any loose connections. I also noticed that as soon as I tried using the DS18B20 sensor my autorun program which gets the date$ and time$ from the auxiliary clock fails on boot. This line now causes an error on every boot: I2CEN 100,100 ' Enable I2C When that line tries to execute the MM says: Error, Unknown Command. I wonder what is changing? We're all here 'cause we're not all there. |
||||
pcaffalldavis![]() Senior Member ![]() Joined: 17/10/2011 Location: United StatesPosts: 187 |
Okay, I see the I2C has changed a bit. I'll go fix that, but I still don't know why the DS18B20 fails to respond so often now. I'd sure appreciate some help rewriting the I2C portions of this Autorun prog where it gets the date and time from the battery clock. I changed the I2Csen, i2cdis and the others that were mentioned in the 4.5 Manual, but now I get syntax errors. So I put them back like they were before I tried to update to the newer 4.5 MMBasic version. 100 ' Autorun.bas for Eboil03.bas On MM PRE VERSION 4.5 firmware 105 ' Last Modified May 4, 2014 by PCD 110 ' This program will get the date and time from the RTC 120 ' It will load the Date$ & Time$ from an optional Maximite's RTC 125 ' And Then run EBOIL03.bas.bas 130 ' I2C RTC based On PCF8563 Secs,Mins,Hours,Day,Date,Month,Year 140 ' 9150 DIM RTCbuff(255) 9160 i2caddr = &h51 ' PCF8563 I2C address 9170 I2CEN 100,100 ' Enable I2C 9180 I2CRCV i2caddr, 0, 7, RTCbuff(0), 1, 2 9190 I2CDIS 9200 BCDTEMP = RTCBuff(0) AND &H7F ' Mask unwanted bits 9210 GOSUB 9450 9220 sec$ = STR$(decimal) 9230 BCDTEMP = RTCBuff(1) AND &H7F ' Mask unwanted bits 9240 GOSUB 9450 9250 min$ = STR$(decimal) 9260 BCDTEMP = RTCBuff(2) AND &H3f ' Mask unwanted bits 9270 GOSUB 9450 9280 hours$ = STR$(decimal) 9290 BCDTEMP = RTCBuff(3) AND &H3f ' Mask unwanted bits 9300 GOSUB 9450 9310 day$ = STR$(decimal) 9320 BCDTEMP = RTCBuff(5) AND &h1F ' Mask unwanted bits 9330 GOSUB 9450 9340 month$ = STR$(decimal) 9350 bcdtemp = rtcbuff(6) 9360 GOSUB 9450 9370 year$ = STR$(decimal + 2000 ) 9380 t$ = hours$+":"+min$+":"+sec$ 9390 D$ = day$+"/"+month$+"/"+year$ 9400 TIME$ = T$ 9410 DATE$ = D$ 9420 ? "Time has been set to ";T$ 9430 ?"Date has been set to ";D$ 9440 RUN "EBOIL03.bas" ' or end END 9450 ' Convert to Decimal 9460 Decimal = FIX(BCDTemp / 16) * 10 9470 Decimal = Decimal + (BCDTEMP AND &hF) 9480 RETURN We're all here 'cause we're not all there. |
||||
pcaffalldavis![]() Senior Member ![]() Joined: 17/10/2011 Location: United StatesPosts: 187 |
This is how I thought the key lines needed to be changed, but now I get syntax errors. 9150 DIM RTCbuff(255) 9160 i2caddr = &h51 ' PCF8563 I2C address 9170 I2C OPEN 100,100 ' Enable I2C 9180 I2C READ i2caddr, 0, 7, RTCbuff(0), 1, 2 9190 I2C CLOSE With regards to the DS18B20 that wasn't responding, I put one on the breadboard and it works non-stop. I must have an intermittent open circuit in the wire somewhere on the outdoor one. What luck I'm having. We're all here 'cause we're not all there. |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
Page 14 of the MMBasic V4.5 manual: Most of the hard work is done for you now. Jim VK7JH MMedit |
||||
pcaffalldavis![]() Senior Member ![]() Joined: 17/10/2011 Location: United StatesPosts: 187 |
Thank you again Mr. Jim. I guess that means on every daylight savings time change from now on I'll use the RTC SETTIME command instead of the old Clockset.bas program. At least in all my MM's that are upgraded to Firmware version 4.5. That will be nice. I'll rewrite the boiler instruction cards for my wife. It occurs to me there may be a possible downside to using DS18B20 sensors in safety critical program applications. Today I managed to have an intermittent open circuit on a sensor which caused the program to hang, or stop. If my program had been in charge of controlling a wood-fired boiler, with an active burn in progress, such a program hang could leave the air intake open, possibly for hours longer than it should be, causing the water temp to get much too high, and even boiling off much of the water. I have some fail-safe shutdown routines (two) that monitor alternate boiler data and when they get beyond the expected safety ranges they force a shut down of the boiler. If the program had stopped due to a open circuit to a one-wire temp sensor those safety routines would not have been triggered or executed. Is there a way to prevent a lack of communication with a DS18B20 from stopping the program? I've never had my original boiler program loop stop in the past six years. My boiler fire box is huge, it holds 27 cubic feet of firewood, and can easily go 24 hours on a single load. That is because it opens and closes the air intake and controls the fire-box blower automatically. Loading it that full is only safe if one is sure it will never become a run-away boiler. A comm error with a temp sensor can't be allowed to stop the program. Especially when the air-intake and blower is open and running. Any ideas how to prevent this from happening going forward if I migrate to firmware version 4.5 and DS18B20 sensors all around? We're all here 'cause we're not all there. |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
Bugger. That was fixed with later versions of MMBasic but not for the Maximite. I am sure there was away around it but it might take me a while to find it. I will do some digging around in the murky grey matter. Reading your posts, it appears that you might have the LM335s working now. Jim VK7JH MMedit |
||||
pcaffalldavis![]() Senior Member ![]() Joined: 17/10/2011 Location: United StatesPosts: 187 |
I do have the LM335 sensors working with very little fluctuation in genuine Maximite SM1 modules. The problem for me is I'm on my last one of these. My wood-fired boiler is running on one, and has been for six years. And I have one on the bench for testing and program development. That's all! ![]() If there was a way to get two more I'd keep developing projects that use temp sensors on the SM1 units. But I don't think there are any more SM1 units available. If anyone knows differently please clue me in. Maybe Geoff has a private stash and might part with some? Maybe you'll be able to figure out this winter why the CGMMStick1 I'm sending has wildly fluctuating voltages on all three sensors when the only thing it is running is three LM335 sensors. If so, after that, my CG Sticks may work for me with LM335 sensors. BTW, the one I'm sending is Firmware version 3.0. I didn't see a reason to flash it with Version 4.5 to test it with LM335's. I figured you would want it exactly as it was while I was having the wild temperature fluctuation problem. Thank you all and good morning from here, 5:30 AM Sunday March 18, 2018. Peter in Hyder. We're all here 'cause we're not all there. |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 5091 |
pcaffalldavis, I am not sure what a maximite sm1 is, but if you can be helped by receiving an original monochrome maximite then just email me your address, and I'll ship one over. It has MMbasic 4.5. It is laying around here and gathering dust (I am using micromites recently), it might just as well serve a purpose. volhout PicomiteVGA PETSCII ROBOTS |
||||
Phil23 Guru ![]() Joined: 27/03/2016 Location: AustraliaPosts: 1667 |
Exactly 85°C, I see precisely that reading occasionally on one of my "Still on Breadboard" projects. The solution is usually to wiggle all the wires, the 4.7k resistor & the plug in 5/3.3V breadboard power supply I use. Have never ascertained which is at fault; 5V rail, pull-up or data line, but it always comes good indicating something is wrong; bits dropped maybe... 85 is the error reading it does 90% of the time, but there are occasions when it's -16.5. The real board is WIP... In my head... Someone curious might translate this error in a binary way, for a better explanation of what's happening. Phil. |
||||
pcaffalldavis![]() Senior Member ![]() Joined: 17/10/2011 Location: United StatesPosts: 187 |
Good idea Phil. I did exactly that, and over two days the Error, not responding finally got so bad that sensor would not work at all. Plugged other(s) directly into the board as suggested, the others worked perfectly. Today I made up three more DS18B20 sensors with lead wires. One 10 meter using the same wire that had the bad one yesterday, a 2 meter one for reading house temp at my work bench, and one with only a 5" lead. All work perfectly on the breadboard, at least right now. I'll hook the third one up to the wire that goes into the boiler water temp tube tomorrow. Then all three DS18B20 sensor will be getting real world testing for a few weeks to see if they hold up over time. I suppose it is necessary and normal to calibrate the DS18B20 sensors using a glass of ice-water as suggested here in this thread, a latex glove and some formula adjustments in MMBasic. That should be fun. After that it will be nice to have a real accurate temp reading of boiler water temp. I've never had that before. It had not occurred to me to use ice-water to calibrate with the LM335 sensors I've been using on the MMSM1 units up until now. Now I'll keep my fingers crossed that these will keep working without any comm or not responding errors. Cheerio! Its a beautiful day, 7 degrees C! Peter in Hyder We're all here 'cause we're not all there. |
||||
Phil23 Guru ![]() Joined: 27/03/2016 Location: AustraliaPosts: 1667 |
Good to hear they are working. If you want to get brave you can add multiple DS18B20's onto a single cable. I've mentioned it in some other threads. One of my projects has 5 & the other 7. All daisy chained together. Makes life a whole lot easier not having to run 7 cables up into the roof & to each room. Just have a flat telephone cable with droppers. Total run length is about 30m. Phil. |
||||
pcaffalldavis![]() Senior Member ![]() Joined: 17/10/2011 Location: United StatesPosts: 187 |
Interesting. I'd kind of like to understand what you mean by daisy chained, and how a single MM pin can deal with multiple sensors. Even if I am not understanding it correctly I do like what you've done and would like to know more. I must say, it sure gets hot on your roof! We're all here 'cause we're not all there. |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
I did find out a bit more. You can use the onewire search command to look for the sensors before doing a read. That will let you know if the rats have chewed the cable and allow you to raise an alarm and put everything into safe mode. Version 4.5 of MMBasic also has a watchdog function. While your program is running, you keep resetting the watchdog. If your program stops for any reason, the watchdog times out and re-boots the Maximite. Started of at 7 degrees here this morning but now up to 11. Jim VK7JH MMedit |
||||
Phil23 Guru ![]() Joined: 27/03/2016 Location: AustraliaPosts: 1667 |
Here's a couple of the older threads. https://www.thebackshed.com/forum/forum_posts.asp?TID=8656&KW=1%2Dwire https://www.thebackshed.com/forum/forum_posts.asp?TID=8764&KW=1%2Dwire Getting on towards 2 years back now... Probably explains why I need to wriggle things occasionally on that old breadboard. Phil. |
||||
pcaffalldavis![]() Senior Member ![]() Joined: 17/10/2011 Location: United StatesPosts: 187 |
Thanks Jim, Watchdog will be just the ticket for safety. And I do some trial runs using OWSEARCH to see if it returns Not 1 for no sensor found so the program can skip asking if the sensor is open circuit. That could be a really good temporary fix for an intermittent failing sensor circuit. And I suppose a counter of skipped readings would be good to display on screen in reverse text to alert that this was taking place so one could go find the failing sensor or circuit wiring. Nice. And Phil, your multi sensors on one loop of phone wire is genius. I have a box of that old wire and dozens of those connectors and splitters. I was just today looking for a good way to make individual DS18B20 sensors click on and off the end of a wire run for easy interchangeability. I think you got it! I was even lamenting that I couldn't find connectors in the Jameco catalogue that would be small enough to go through a 3/8" hole in the wall or ceiling and be click connected to the sensor on the other side. Wahoo! Aren't forums wonderful! I'll read more on your multiple sensors on a single wire run later. I read the first thread you referenced above, but I need to read the other one and maybe do some testing. I think it is wonderful there is finally a use for all that old modular phone wire and connectors! Peter in Hyder We're all here 'cause we're not all there. |
||||
![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |