Tuesday, March 13, 2012

More HVAC system pics

Some more pics:

Mounted control board and soldered in all the wires. Idealy I would have loved to make it terminal blocks instead but never even thought of ordering some direct mount ones when I did my order for the other stuff. I will try to find a piece of transparent plastic to use as the cover.


Can now control furnace with my playbook or any wifi device



I thought this was rather genius...




Conveniently this is a great location for an emergency light, or just a light to look inside the closet beside it.



Server room sensor (this "room" is basically my basement at this point)



Return duct sensor



Supply duct sensor



Top view of rack where the control board sits on a shelf and the DIN rail is mounted on top. The actual server is closer to the middle and not shown, it's a little 1U SuperMicro server.


And lastly, here's a pic of the front end. I will probably tweak it more over time and make it look nicer.



We're int he middle of a heat wave right now so wont get to use this to it's full extent for another couple days, but in a way it's a good thing as I need to do a simulation test for a few days anyway before letting it activate the relays. Though I'm 99% sure I sorted out the issue now.

I also need to hookup the outside sensor but I'll wait till summer for that.

I always say that I quit, but never do

When I made my last post I was about ready to quit this. The control board was acting stupid, I was unable to get any support for it, and I was getting pissed off considering it worked before and suddenly would not work after a server reboot. I have been pulling my hair out all week.

Well, I think I may have figured out a fix. I still don't understand WHY it does this and I still think it's some kind of bug, but by looking at different online examples of serial connectivity and copying code around, I changed my connect function to this:


bool SerialConnector::Open()
{
if(m_Path=="")
{
ScreenOutput("No path specified");
return false;
}



//init stuff

struct termios tio;
//struct termios stdio;
//int tty_fd;
//fd_set rdset;


//memset(&stdio,0,sizeof(stdio));
//stdio.c_iflag=0;
//stdio.c_oflag=0;
//stdio.c_cflag=0;
//stdio.c_lflag=0;
//stdio.c_cc[VMIN]=1;
//stdio.c_cc[VTIME]=0;
//tcsetattr(STDOUT_FILENO,TCSANOW,&stdio);
//tcsetattr(STDOUT_FILENO,TCSAFLUSH,&stdio);
//fcntl(STDIN_FILENO, F_SETFL, O_NONBLOCK); // make the reads non-blocking


memset(&tio,0,sizeof(tio));
tio.c_iflag=0;
tio.c_oflag=0;
tio.c_cflag=CS8|CREAD|CLOCAL; // 8n1, see termios.h for more information
tio.c_lflag=0;
tio.c_cc[VMIN]=1;
tio.c_cc[VTIME]=5;


//connect
m_fd=open(m_Path.c_str(), O_RDWR | O_NONBLOCK);



cfsetospeed(&tio,B115200); // 115200 baud
cfsetispeed(&tio,B115200); // 115200 baud

//this is required, it seems that it only needs to be called once per server reboot. It sets some kind of global thing that prevents the serial device (in my test: uk1104 from canakit) to go insane and spam junk
tcsetattr(m_fd,TCSANOW,&tio);

if (m_fd == -1 )
{
ScreenOutput("Unable to connect");
m_conactive=false;
return false;
}

m_conactive=true;

return true;
}


I want to thank the author of this page:

https://en.wikibooks.org/wiki/Serial_Programming/Serial_Linux

The example is straight to the point line by line and easy to follow. Most of the examples I found were terrible to figure out.

I don't really know what every single line of code does, but the key lines are these:






memset(&tio,0,sizeof(tio));
tio.c_iflag=0;
tio.c_oflag=0;
tio.c_cflag=CS8|CREAD|CLOCAL; // 8n1, see termios.h for more information
tio.c_lflag=0;
tio.c_cc[VMIN]=1;
tio.c_cc[VTIME]=5;




cfsetospeed(&tio,B115200); // 115200 baud
cfsetispeed(&tio,B115200); // 115200 baud




In that order. I'm guesssing setting the baud rate may possibly play a role, but the code above also does. The connect function is the same as before.

It seems to me some of these parameters stick even after the program is done executing. I discovered that when I ran an example stand alone, and ran my program, my program worked. If I rebooted, my program stopped working. Oddly, running picocom did not actually set whatever global flags were being set, at least not permanently.

Either way, after several server reboots and several resets of the USB device it seems to work. Though, I may be calling it too early. I will let it run overnight before I take the app out of simulation mode, (basically this mode just ignores relay calls).

After tomorrow I will be off for 2 days, so I will run it live and see how it works out.

I really hope this works out on a long term basis, as I'm looking forward to actually putting this to good use and no longer need to keep messing with the thermostat programming day to day to accommodate my different shifts. This app is set and forget, which is awesome. It's why I did it. Given most people work standard shifts, consumer thermostats are designed for that, so I needed something to accommodate shift work.


Once this is proven, I will probably make up a full blown article explaining everything I did. Man, I'm so glad I got this working though, this spam thing was really starting to burn me.

Well this was a waste of time

The control board decided to crap out and now it refuses to work. IT did this before but resetting it would fix the problem. Now it wont work period. As soon as I try to write anything to it, it just starts spitting out bullshit.



::



::



::



::R

ERROR : R



:::

ERROR : :



:::

ERROR : :



::



::



::



::::

ERROR : ::



::



:::

ERROR : :



::E

ERROR : E



::



::



::



::



::



::



::



::



::



::ER

ERROR : ER



::



::::

ERROR




Canakit has not replied to any of my emails on this issue, so it looks like I'm on my own. I need to find another board that can interface with the Dallas thermal sensors.

What's screwed up is if I use picocom, it works fine, but the minute I try to use echo/cat or my own code, it does this crap. I even copied the code from picocom into my own code, and it STILL does it. I'm at a loss. This project was just too good to be true. I was SO close too. :( I had to go reboot that server... but guess it's better now, than down the line when a relay is turned on and I'm not home...

Saturday, March 10, 2012

So I just did the final hookup of my hvac system

I just officially started the furnace using my playbook. So far the system is working. I've been testing it for a long time using a light bulb and sensor in a bucket so it's been fairly proven. Today I now did the hookups to the furnace. I wired it so my old thermostat can serve as a backup, it's in parallel.

I just have one more sensor to hookup, some cleaning up to do and a few minor final steps, and the system will be officially completed.

Tuesday, March 6, 2012

More progress on HVAC control system

Started pulling wire today. Also decided to change up a bit the way I run wire around the house. Instead of just hanging in screw eyes and tie wraping any new cabling on the existing cabling that's passed through the screw eye (normally only one can fit) I decided that I will run a metal wire in the screw eye, pass the first wire into the screw eye, but use velcro straps to hold additional wires. The metal wire also acts as something to strap wire to between joists to prevent hang. So I did that today as well.

Wired the first sensor into the thermostat, so it's more or less hidden. I decided to make the sensor part itself stick out on the outside, for a more accurate temp reading. The thermostat will remain as a backup and be wired in parallel for the heat only.



After I took that pic I realized I wired it wrong, The orange and brown/white wires are mixed up. Mostly mentioning this in case I come back and look at this in the future.... lol. I just made my own "standard" that I will follow for each sensor. Will make future troubleshooting easier. The sensors have 3 wires, so I just assigned each one to a color.


And here's some runs (some of those are existing Ethernet runs).




Crawlspace data run, the one going to the far end is actually existing Ethernet, the one going behind the light is for the sensor.



A run to the outside sensor. I will leave it coiled up at the end till summer. I don't really want to work outside in this weather, and I doubt any glue/cement I use would cure properly anyway. My plan is to have a small pipe go outside and have a down elbow with a cap and a couple holes in it. The sensor will reside at the tip of the pipe and the rest will be filled with insulation and caulked in. Will provide weather proofing for the sensor. I specifically chose a north wall which should provide an accurate reading. Most of these sensors are just for extra informational readings, more than anything. Though they will be used in some logic as I improve the control application.



Din rail with the terminal blocks. They are all labeled to make it easy to identify each conductor.



Hoping to more or less finish this up tomorrow, if not, next week. I'm off tomorrow but then start work again the next day. I still have one more wire run to do for the upstairs sensor. I bought a LED wallmount light which I'll be using to mask the sensor into, and the light itself may come in handy in the event of a power outage or what not.