Video of the iPhone TV Lift controller working!
This was probably one of my most time consuming projects. Hopefully I can do some justice to the time and work spent through this post. I should probably begin by describing the whole system. First, the TV is lifted up & down by a"Lift Tech" lift. By the way, they get the prize for the most original company name ever. Their controller box has a port that allows home automation systems to control its operation. They did a really good job of making it extensible. You can control it in a variety of ways: short one pair for going up, another for going down; short a pair for down, open for up; etc. I had intended to use the first mode, but I think I fried a channel on my opto-isolator. I ended up using the second method because it only required one channel. Unfortunately that means I can only have the TV up, or down. I wasn't too disappointed, though, because I don't expect to want it any other way very often ;) .
TV Lift controller box
The board I designed to interface the TV Lift to the server was fun to design and build, even though it was prone to error. I had originally intended to use the Microchip ENC28J60 ethernet controller. I thought it'd be cool to have the iPhone app connect directly to the board's ethernet controller and microcontroller. Unfortunately, I screwed up the interface from the ethernet controller (specifically the physical layer circuitry) and the magnetics. This interface is harder than it looks, trust me. I thankfully included a serial port on the board (which I had other plans for) and used that instead. This choice made the microcontroller software extremely simple. All it really has to do is wait for a 'd' character over the serial port and lower the TV, a 'u'character lifts the TV, and a 's' character queries the controller for the current state. I've included an image of the schematic for the board, in case you are curious about my lofty intentions.
If you're interested, the board I used on my reflow soldering toaster oven page is the TV Lift board. Incase you don't want to go over there, here is a picture of it mostly finished up:
Controller board installed
Using the RTS line for reset
There is one more thing that I had to change. For some reason the controller board that I made crashes after a while. I have to use a ladder to reboot it(power-cycle). Hauling the ladder around is annoying, and I don't like doing it. To allow myself to reboot it remotely, I added a diode from the MCLR line(reboot) of the microcontroller to the RTS line of the serial port. The RTS line is used for modems from back in the day. Now I can use it to force MCLR low, to reboot the controller, if it's "low" (-5 volts). It's a hack, but what are you going to do?
The software for this project is deceptively simple. The iPhone software basically connects to the server using a socket, and if the "up" button is pressed it sends a 'u' over the socket, and a 'd' if the down button is pressed. That's it! Server software is almost identical, however it listens to the return of the serial port and expects my controller board to return a 'U'or a 'D' from the 'u' and 'd' command. If these are not received, the board is reset and the command is tried again.
Well, that's all there is. I hope you've enjoyed it, I know I have. Please, feel free to ask any questions in the comments section!