Jump to content

Temp controller


SpidersWeb

Recommended Posts

And on a side note, my point of doing this was for accuracy. But finding an accurate linear temp sensor that doesn't cost me my first born child is proving to be quite hard. LM335 is obvious choice and only a couple of bucks, but if you look at the stat sheets, it's not as accurate as they make out. Plus it'll look nasty all waterproofed on a budget.

Hopefully I find something low cost that's not too hard to get. Because I'd like to put my finished plans up for others to try and build.

Link to comment
Share on other sites

  • Replies 50
  • Created
  • Last Reply

Top Posters In This Topic

*gasp*

By thermostat I do you mean thermistor? I wanted something that could be calibrated and preferably linear. Hoping to find a sensor thats already waterproof with flying leads as well, would make it so much easier.

Not too cool for analoge though, the temp reading from whatever sensor I use is voltage based, I just measure the voltage and convert it. I get a number between 0-65535 where 0 is 0v and 65535 is 5V. The temp setting will likely be the same, probably just use a potentiometer, measure the voltage etc Maybe later on I'll make the temp setting digital, but the poor 08M only has 4 outs/ins.

My main goal this week is to make the LCD say stupid things, I'll get there ;) Hoping I can fit this project on the 08M, its got tiny memory (80 lines). It's a tiny 8x2 screen. It looked bigger on the interwebs :(

Link to comment
Share on other sites

Try an LM35. It's not too bad with 10mV/'C output. A simple rail-to-rail opamp can be used to add gain to boost the output to 50mV/'C (or more) so you can use the full range of the A/D. You'll also need to implement a PID controller in the PIC otherwise you'll likely end up with the temperature oscillating a bit due to the large mass you're trying to heat. Any delay between the heat source and measurement point will cause oscillations and overshoot in the temperature. The average temp will be ok though but you may bounce around the setpoint a bit. You may not need PID but be prepared for it as it's normally needed in most control systems. Don't use PIC's much so can't point you to a good reference site to get a free PID. Also, make sure any parts you use have low-drift and good temperature stability.

Link to comment
Share on other sites

Warren's right, your problem should not be heater response time or linearity of response or really anything about the heater (presuming you spent more than about $0.17 on your control circuit).

The problem is sensor feedback (control loops) and they are notoriously dependent on the environment. A large thermal mass like a tank of water can be a very good thing for control loops, it acts as a buffer.

eg1. Having a large still mass of water with a sensor on the far side of the tank gets you nice predictable heater response, but massive overshoot in tank temperature because it take a long time for the control loop to respond. But you don't get undershoot because heat loss is (mostly) uniform (wheras the heat source is a point).

eg2. Having the sensor too close to the heater means you get no under/overshoot, but the heater will be going beserk trying to keep up with the minor fluctuations caused by the changing conditions at the sensor.

The best situation is having the sensor far away from the heater, but having a very well mixed tank so the sensor sees changes quickly, but those changes are representative of the whole tank, not just a small patch of water or a particular current.

So have a well mixed tank, keep the sensor out of the filter current and not close to the heater

I think the control loop involving the environmental effects will massively overwhelm any hardware issues.

Link to comment
Share on other sites

Yeah sorry I forgot to respond to Warren's post with regards to the PID.

The reason I'm using a microcontroller is so I can develop this process :) I'm a software developer, so its far easier for me to write a program to do it than to use analog systems or complicated chip combinations.

I wanted to make it learn and store its results on an EEPROM, thereby auto adjusting itself for any sized aquarium, but I can't do that with this one (08M), as I'd need an 18X or better at least. So for the interim, perhaps just a single sensor and go with a less precise system of running the heater until x seconds is reach AND temp is 0.1C higher?

Will experiment when I get there :)

If I get an LM335 and calibrate it, I'll need 25C water, any ideas for very accurate temp measurements so I can be sure I've got 25C water?

Who else would sell temp sensors like that? So far only two models on Jaycar/DSE/Surplus, LM335 and DS1280.

Link to comment
Share on other sites

When Warren said L35 I thought it was a typo, didn't realise he meant L35! Ordered 3 LM35DXZ's (precision temp sensor) from South Island components. Hopefully they'll do the job (when I get there). Got reemed on shipping.

Tonight is shift register night! Yeee hah

Link to comment
Share on other sites

Such a genius :(

Couldn't work out why my circuit wasn't making any sense.

I bought the wrong damn chip, I need an AND gate not a NAND gate! Can't beleive I forgot what the first N stgands for (for those who don't know, it means 'NOT AND'.

Thankfully the chip I actually need has the same pin layout, so just plug it in and it'll work. I redid the circuit from scratch on a new prototype board, MUCH better.

Didn't even get to touch the shift register yet, probably wont tomorrow either. Just want to get my pulses sorted.

Link to comment
Share on other sites

hehe yeah

Well DSE was out of the Quad AND gates I needed, so went for a hike to jaycar, couldn't find it! I've emailed them to ask where they're hiding but wont be any electronics tonight unless I can do what I want with the NAND gate, I worked out its possible, but it hurts my brain.*

Dentist is removing $1200 from my wallet tonight, so doubt I'll be doing too much more for a week or two. Unless someone wants an as new Xbox for $80.

* see if I can work this out while I'm typing

Feed Pin 1 the clock pulse

Feed Pin 2 +4.5V

Pin 3 will output an inverse clock signal (because when pulse is off or LOW, its not equal to HI, so output is HI)

Feed Pin 5 with the output from 3

Feed Pin 6 the output from the decade counter on outputs 0-7 (so constant 4.5V until the 8th pulse).

Pin 4 should output the half wave I need. Because NAND will be true when the pulse from pin 3 is off (real pulse is ON, but its inverted).

So in ten clocks I should get

FLASH FLASH FLASH FLASH FLASH FLASH FLASH FLASH OFF OFF then repeat, and it should be in time with the clock pulse which will just beat 10 times and repeat. I've got a 14 LED bargraph module wired up, so I can see wtf is going on.

Got an NPN transistor delivering extra current, the 4011 drops to 2V running a NAND gate + 1 LED :roll: so anyway, 4.8V now, LED probably not liking it but its only a flash.

Reason I'm doing this is so I can do async data transfer to the serial register, then output 9 (pulse 10) on the decade counter can tell the register to output. Result from this will be a serial to parallel circuit for running common LCD displays, using only two pins on the microcontroller.

Link to comment
Share on other sites

Ok so did some experimenting last night and had one of those 'OH YOU IDIOT' moments, actually a few.

1. I blew a channel on the NAND from having a 16 pin socket fitted with the 14pin chip, and I forgot, and had the pins in the wrong place (before I"d had this perfect, was just taking it out and putting it back to do soldering).

2. after getting my NAND circuit working, which required 3 NAND gates in the end, I realised I don't even need the stupid 4011 NAND chip.

Transistors will do this job perfectly, and I've tested it, and yes they do. Idea is to feed the clock signal in to all of their bases (which belong to us), then the outputs 0-7 from the decade counter to the first collector, output 8 for the second collector, and output 9 to the third collector.

The result is you have 3 emitters that pulse in time, one will go 8 times, then the next, then the next, then start over. Much more simplier than using logic gates, and is easier to work with.

So I should be able to get the serial register cranking, and get somewhere. EXCEPT I don't have any god damn money or fuel. I need more transistors or a desoldering tool. poopy.

Not sure if anyone is still actually following this, but depsite my booboo's I'm having a tonne of fun learning about this stuff via experimentation. I haven't built any kind of circuit since I was about 16 (over a decade ago :oops: )

Link to comment
Share on other sites

Well time for an update.

Next week I'll be ordering a lot more kit, including the gear to make my own PCBs.

What happened last week is my LCD blew, internal short, not sure how or IF I did that but need another one anyway. Because of my teeth being worked on, i r poor. Payday on Tuesday, so will kick some ass then.

Until then I've rigged the system up to LEDs.

So we've got:

08M Microcontroller Pin 1 -> Data In on Serial Register

08M Microcontroller Pin 2 -> Clock on Serial Register

Serial D1 to D6 -> what would be 4 data input pins for the LCD

Serial D0 -> what would be RS on the LCD (sets instruction or write mode)

Serial D7 -> crazy circuit using a 1N914 diode that lets me trigger E on the LCD (I'll explain if interested but too technical to describe for this post I think)

Then the 8 outputs each going to an LED, so I can see the binary code output. This lets me write some algorythms etc to familiarise myself with passing binary codes.

Now each pulse I need to send a clock and data signal (1 or 0) to the shift register. So I need to read the code bit by bit, and this little algorythm saved my life here:

- take the binary code, divide it by 128, (so say 0011101 / 01000000) and store the result somewhere else

- value of pin = result (always a 0 or 1 bit)

- multiply the binary code by two

- repeat process

So the result is I can make my LEDs flash parallel patterns by setting a byte in the program.

e.g. if I send 10101010 out, every 2nd LED would turn off, and the others on.

This setup lets me send 4 bit parallel data to the LCD. The downside to this is I have to use 4 bit mode on the LCD, which will double the time it takes to send instructions. By using more pins on the controller I could get past this BUT 08M $7 18X is something like $20. So unless its horrible to use, I wont be converting to a 3 or 4 wire interface design because I don't have the pin room!

I've only got two pins left, so not sure I'll be able to even do it with this chip. Since I need 1 input for setting the temp, and 1 input for the temp sensor, then 1 output for a relay...... ugh 18X it is. I'll add that to my buy list for Tuesday.

There is lots more I learned here too, but don't want to bore you with even more details.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...