Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

I'd like to hear your thoughts on a Thermostat kit design

Status
Not open for further replies.

blueroomelectronics

Well-Known Member
I've not announced a new kit since the Junebug (I do have a new kit ready called Wasp but the documentation is incomplete)

I've always had a desire to build my own thermostat as I think it would be a practical and useful device for both experimenting and actual use as an HVAC controller.

Although I've called the design Cricket from the start this is a much more modern design and here's what I have followed hopefully by feedback and suggestions by you.

Eight character 14 segment LCD display with decimal points
PIC18F6390 LCD controller or 18F8490 (I may need the extra pins)
I2C temperature IC LM75A or equ.
I2C RTCC with battery backup or trickle charger eg: DS1340
5V Simple Switcher supply eg: LM2675
RS485 communications
ICD debug support

Questions... (feel free to comment on anything in the post)

How many relays? 3 seems enough for 1 Heat & 1 Cool
Switching relays (very low power consumption) vs standard?
How many buttons would be the minimum to run a thermostat?
iButton support?
User expansion? Analog / I2C / digital?
Wall mounting options? Case?
Would you like to build your own thermostat?

**broken link removed**
The expensive ~$300 Aprilaire RS422 thermostat with 6 relays and info display on top. No battery backup whatsoever.
 
I've always had a desire to build my own thermostat as I think it would be a practical and useful device for both experimenting and actual use as an HVAC controller.
The last thing I designed/build before 10y break from electronics was thermostat :D (bit more complex then the this one as it was to be used in industry but ..). I'm not clear on how far have you gone with it, but, from my exp the software is much harder to implement then the hardware (and I am the software guy)... It is much more complex then it initially looks like (if you want to have some proper control and not to kill the heaters / use too much power ..)

Although I've called the design Cricket from the start this is a much more modern design and here's what I have followed hopefully by feedback and suggestions by you.

/me likes the Cricket name :D ... IIRC cricket's change the duty cycle (or freq) of the skreeeks related to temperature or humidity... so "proper" name :)

Eight character 14 segment LCD display with decimal points
PIC18F6390 LCD controller or 18F8490 (I may need the extra pins)

IMHO you do not need to go LCD... It is true that LCD will
- use less power
- emit less heat
But, if you are going to control some heating elements - darn, you are going to sit on the power :D, no need to worry about few milliamps... Standard 16x1 (or 16x2) char panels emit next to no heat if back light is off, and you do not want to have back light on all the time... (auto turn off 30sec after keypress)... Much easier to program, many many many many many wires less :D and much more functionality. Not to mention the ability to choose among many more uC's to get the "right one for the job" as here you are pretty much limited to few pic's with LCD controller.

I2C temperature IC LM75A or equ.

I used mostly 1wire temp sensors as it allows much longer distances then i2c. What I would suggest if you really want to make "fancy" and "usable" device is to:
- use one onboard temp sensor
- use one "attached to device via wire" temp sensor (1wire digital protocol - you can attach more then one device on this bus)
- add a receiver that can receive data from remote wireless sensor (2+ canals)

Let me elaborate on the last point. If the room is big enough, one point for measurement is not enough and sometimes, due to technical difficulties, architectural stupidity or any other reason the actual device has to be mounted on place that is "wrong" to measure temperature for the room it is controlling.

You can then have a menu that
- can turn on/off any detected temperature sensor
- add "weight" to every active sensor
so the "real" temperature you are monitoring is temperature that is calculated using data from all sensors using the weight algorithm.

Now, with regards to "receiver" for the device, you can go IR (death easy / cheap) but that put's some limits to the device or RF which is bit more expensive and not that cheap but then you can have also the "outside temperature" sensor that do not have to affect the indoor temperature monitoring / thermostat operation, but can be displayed on the device :) (very useful option IMHO)

I2C RTCC with battery backup or trickle charger eg: DS1340
RTCC - always :D .. DS1340 or some other .. does not matter much

5V Simple Switcher supply eg: LM2675
RS485 communications
ICD debug support

I'd add IR receiver for remote control .. maybe even 2way IR (so you can build remote control that will have full control over device, menu's etc..)

How many relays? 3 seems enough for 1 Heat & 1 Cool
I'd go with more then 3 in total ...
3 different ones for heating elements (as you might be able to measure temp in different points of the room, you need to be able to control different heating elements)

1 relay for cooler + Pulse for cooler (just a pulse for on/off)

1 relay for fan (if too big temperature difference between different parts of the room - you turn on fan)

Switching relays (very low power consumption) vs standard?
IMHO - you are sitting on the mains ?! why waste money

How many buttons would be the minimum to run a thermostat?
I'd go with
1x rotary encoder (to change value up/down, move trough menu left/right)
1x menu/select button
1x reset button (hidden behind the device)

iButton support?
for what ?! to "authorize" before you make changes?

User expansion? Analog / I2C / digital?
what is expansion ... I already noted I'd like to have one wire interface for additional sensors and RF/IR interface for additional wireless sensors ... 1wire is kinda standard so I'd not go with i2c/spi/rs* ...

Wall mounting options? Case?
you need
- power (2-3 wires)
- relay contacts going to "big relay's"
so, you probably need to have "mounting box" inside the wall and your device "on top of it" ...

Would you like to build your own thermostat?
bin there done that :)

Regarding power, I'd add a 12V DC source inside (you have to assume you will get 110/220V AC so you need PSU) ... you will need 3V or 5V to power the uC and rest of the board, I suggest you add a 12V DC source inside the box so one can feed that 12V directly trough onboard relays to power the "big relays".

Few "extra" option I'd put there:
- data logger (some i2c eeprom storing data once every 15 or 30 minutes)
- IR A/C control :D (you would need to record some IR commands from A/C remote controller and then you can send them from device controlling the A/C via IR) :D
- more relay's + more sensors + more complex software - controlling temperature in all rooms in whole house


Yes, I assumed SW will enable things like "18C 06:00 - 08:00; 26C 08:00-09:00; 24C 08:00-03:00; 12C 03:00-06:00" as I do not believe tha i2c RTC is just to display time on display :D
 
Last edited:
Wow thanks arhi, great stuff.
The LCD makes the kits more attractive and I hope kitbuilder will learn how to use a probably unfamiliar technology.
They are extremely low power and inexpensive $4 digikey 153-1113-ND dumb glass displays (the LCD PIC does all the driving automatically) I've used them on the 16F917 and once you set them up they're dead easy to control.

More EEPROM yes, that's easy since it's I2C so I'll make sure it's in the design.
IR easy, I put it on most of my kits now. And 1 wire (great stuff) is a simple I/O pin. I'll try to keep RA0,RA1 available for user expansion.

As for more relays yes but I'm running out of I/O (the 128segment LCD uses more than 40pins! including bias) and I'd like to avoid anything larger than a 64pin TQFP as they can be a bear to solder for the unfamiliar...
But since the design has always been communicating (RS485) you can keep adding zones (thermostats) or could repurpose them to register or curtain controllers.

Power will be external and standard 24VAC HVAC compatible. The NatSemi simple switchers run cool and from a wide range of voltages.

Aside from the relays (PWM will help) I'm keeping the design as Nanowatt as possible, I have found that the small amount of heat given off by the PIC, supply, relays will affect the themal sensor all though I'll try to locate it a far away from everything else and put it on the bottom of the PCB. I've seen drilling holes in the PCB around the sensor as a way to keep heat transfer to a minimum.

Rotary encoders sound like fun, I've got one but never wrote firmware to use it. Some PICs can actually do quaderature encoding in hardware.

There are no "big" relays, just common HVAC type relays with transient supressors on the contacts. 2A @ 30VAC seem to be typical in thermostats.

I agree the software is the tricky part, that's why I make educational kits. The 18F6390 Has 8K words Flash & 768bytes RAM.
 
Last edited:
Wow thanks arhi, great stuff.
Glad to be of help :) this is one of the projects I actually did (long time ago but then again, it still works :D in very ugly conditions)

The LCD makes the kits more attractive and I hope kitbuilder will learn how to use a probably unfamiliar technology.
They are extremely low power and inexpensive $4 digikey 153-1113-ND dumb
that is true, they are cheap and "new" to most. Problem is they are fairly "fixed" (not that easy to display txt) althoe you mentioned 14seg "digits" .. that's actually able to display txt :D ... 8char's is not that much dough. pay attention when getting them to find ones that have same number of backplanes as your PIC is able to multiplex. I got some static 5 digit 7seg display's I can drive only with dsp430, did not find a single pic with that many lcd pins :(... (btw - I tried out the lcd when you posted that link with your thermometer :D, I ordered few 16f917 and bunch of lcd's from local store :D and yes - they are dead easy to control when you figure out how the darn multiplexing work - then you can purchase the "right lcd for the pic")

Donno what to tell ya... with 8 chars, you will have to be bit inventive in writing the menu but it is more then doable :D

More EEPROM yes, that's easy since it's I2C so I'll make sure it's in the design.
IR easy, I put it on most of my kits now. And 1 wire (great stuff) is a simple I/O pin. I'll try to keep RA0,RA1 available for user expansion.
nice .. I made logger (for my dad, he have some big headache problems) that logs pressure, inside temp and outside temp every 30min .. (only 5leds to show current pressure level, but you connect to usb and download data) .. uses spi pressure sensor (it has temperature sensor built in) and external 1wire sensor for outside temp.... I put largest eeprom I could find in the drawer :D it can hold data 6 month worth :D ... the data looks very interesting

As for more relays yes but I'm running out of I/O (the 128segment LCD uses more than 40pins! including bias) and I'd like to avoid anything larger than a 64pin TQFP as they can be a bear to solder for the unfamiliar...
no need for larger packages .. and that is sure way to push hobbyist from the kit as there's not a normal person (yes I know most of us are not normal) who find soldering TQFT relaxing.

Use MCP23017 (High Speed I2C 16-Bit I/O Expander) :) 28pin, pdip, 16 ports, I2C :)
- do not use any pins (as you will have i2c bus anyhow)
- very fast (and you do not need speed for the relay's, not that you are going to PWM the heater :D )
- very important thing for hobbyist to learn about (port expander)

Rotary encoders sound like fun, I've got one but never wrote firmware to use it. Some PICs can actually do quaderature encoding in hardware.
donno about that hw encoding, but decoding rotary encoder should be fairly easy. Find some that you find interesting and post a link to datasheet, I'll help you with C18 decoding routine ... (I noticed that you did not make use of IR encoders on the mongoose project of yours :) ). Thing with rotary encoder is that it not only removes the need for 2 buttons but drastically improve user experience (and it is FUN, not to mention learning moment :)).

I agree the software is the tricky part, that's why I make educational kits. The 18F6390 Has 8K words Flash & 768bytes RAM.

It is going to be FUN :D
 
I've got to run but quick note, if I recall right the PIC18F2331/2431/4331/4431 have quadrature encoder HW.

And the next larger PIC is a 80pin TQFP, hmm. Schmartboard can make PCBs with guides so 10yr olds can solder TQFP (they raise the soldermask between the pins, IC falls in to place). nice.
**broken link removed**
 
Last edited:
the LCD PIC does all the driving automatically

Lucky. Last time I had to do a Pelt and Ashko multiplex, it was with a bunch resistors and software loops.

Now I can't even find a reference to "Pelt and Ashko" on Google.
 
@duffy, works like a charm... the biggest problem I found is that "general use lcd's" are too general use to be of real use :( so in many cases for hobby - you end up using glcd... I spoke with some ppl that are in this for "bread 'n' butter" and they told me that it is fairly easy and quite cheap to make a custom LCD design with as much backplanes as you need. The only problem is, you cannot order 10pcs :(

On the other hand, if one is to make a "kit" that will be sold in 1000pcs, maybe that would be possible ... interesting idea :)
 
That IS a recurring problem! There's a guy at work right now needs a custom LCD - can't prototype it, can't just buy a dozen. Problem comes up over and over again.
 
I looked at custom LCD glass. I settled on the 14x8 alpha as it's a perfect fit for the PIC. I like the idea of a rotary encoder I wonder if they make them with a pushbutton too?
 
Yes, you can buy rotary encoders with a pushbutton, they have them on Digikey. I also have a nifty little illuminated trackball with pushbutton - it's the size of a sugar cube.

I'm a big fan of rotary encoders. Just takes a few lines of code and a couple of registers, and beats the pants off tapping a button anyday.
 
Last edited:
Here's the rotary encoder firmware I wrote for a piece of bench equipment. As you can see, it's wheel fun!

Code:
#define _ENCA		PORTA, 5, acc	;encoder line A
#define _ENCB		PORTA, 4, acc	;encoder line B

#define _ENC1		wheel, 5, acc
#define _ENC2		wheel, 4, acc

#define _OLDENC1		old_wheel, 4, acc
#define _OLDENC2		old_wheel, 5, acc

#define _FIRSTWH		wheel_stat, 0, acc


;trackwheel
wheelfun
		btfsc	_FIRSTWH
		goto	firsty
		movf	PORTA, w, acc
		movwf	wheel, acc
		andlw	b'00110000'
		xorwf	old_wheel, f, acc
		bz	wheelout
		btfsc	_OLDENC2
		goto	ao_b
		btfsc	_ENC1
		goto	bo_a
		goto	bo_b
ao_b		btfsc	_OLDENC1
		goto	wheelout		;noise filter
		btfsc	_ENC1
		goto	bo_b
bo_a		btfsc	_ENC2
		goto	cw
		goto	ccw
bo_b		btfsc	_ENC2
		goto	ccw
cw		decf	wheel_dat, f, acc
		goto	wheelout2
ccw		incf	wheel_dat, f, acc
		goto	wheelout2

firsty		bcf	_FIRSTWH
		movf 	PORTA, w, acc
		andlw	b'00110000'
		movwf	wheel, acc
wheelout
		movf 	wheel, w, acc
		andlw	b'00110000'
		movwf	old_wheel, acc
		retlw	b'00000000'

wheelout2				;indicates changed data
		movf 	wheel, w, acc
		andlw	b'00110000'
		movwf	old_wheel, acc
		retlw	b'00000001'

As you can see, I'm doing this horrible thing where I both define the port pins and read them as bits AND read the 8-bit port and mask the same pins.

"wheel_dat" stores the output data. It returns with a WREG = 1 if the data changed since the last read. It is in a subroutine that was called on a timer interrupt.

Importantly, wheel_dat can be LOADED with values before you call the routine, to increment and decrement them, and then save them back.

_FIRSTWH is "set" when the proc comes out of reset. This test was necessary to stop a 1-bit jitter that was annoying when it first called the routine.
 
I think that thing on an iPod would be even COOLER, but I'm not sure if it's a quadrature encoder. Seems like it's some kind of circular resistive membrane thing.
 
Well touch panels are cool but the simplicity and low pincount of the rotary encoder are exciting on this single MCU design. I'm also looking at auto TxRx RS485 ICs simply to save an IO

Also looking at different i2c rtcc chips. Some have binary vs 24hr, some trickle chargers, some NV RAM, some reset or 1hz to 32khz outputs.
Same goes for temperature ICs some have thermostat outputs.
The design will stick to 5v VPP
May add 1 latching (heat/cool) and 2 non latching relays (HC, fan)
 
You could do the clock internally. Some pics have that 32khz clock on the timer that can wake on interrupt. Pretty sure this is what that's for - loss of power, switch to battery mode, all ports off, sleep, wake, update the registers, back to sleep.
 
Kind of like the idea of a thermostat type chip like the DS1721 or? Saves a pin, maybe a little software because of the onboard hystersis saved to TH and TL in eeprom.

On a tangent note, was surprised to see the price on the Microchip rf modules, way cheaper than the XBEE's. Can't keep up with all the changes out there.
 
Look like your mom just logged in.

Anyway, section 11.6 in the spec sheet - "Using Timer1 as a Real-Time Clock". They even give cut n' paste op code for it to convert seconds, minutes, etc.

If you want to save port pins, there are those 1-wire Dallas interface thermal sensors like the DS18B20.
 
Status
Not open for further replies.

Latest threads

Back
Top