Over the next little while I will bring you through the processes of engineering my final project. From circuit design, prototyping, PCB layout, hardware manufacture, programming, and final packaging, I will give you a commentary on my choices, and what I might have done differently. Hopefully you can learn something in the process!
Before we get too far ahead in the project, let’s start at the beginning.
All projects start with an idea. It could stem from a need, a want, a proof of concept or a challenge. In my case, it was a conversation with one of my uncles. He told me about how, during his post-secondary studies, he had the idea to make a thermostat for his final project. However, in the interest of feasibility, he ended up doing something else. I decided I would engineer his original ideal, while incorporating today’s advancements in technology and adding wireless communication with a PC.
Although I could have begun with prototyping on a breadboard, I decided to begin by designing the schematic with Computer Aided Design software. This schematic serves as a starting point, something that I can build upon as I prototype and discover areas of improvement. Below is a portion of what has ended up being the final revision (for the purposes of the final project).
This is the peripherals sheet of the board. Because there are quite a few distinct sections in this design, I ended up splitting the entire schematic into 4 pages: LCD, Peripherals, Microcontroller, and Power Supply.
There are 5 elements on the peripherals page:
- XBee 2.4GHz Wireless Module
- DS1307 Real-Time Clock (for keeping track of time and date)
- Relay (for toggling the load)
- TMP36 Temperature Sensor
- Five push-buttons for user input
The XBee was chosen because of how simple it is to configure and because of how prevalent it is in hobbyist electronics. It is simply a UART transmitter/receiver: no libraries necessary to operate.
The DS1307 was chosen as a real-time clock for two reasons: firstly, it was available at one of my major part sources, http://adafruit.com, and secondly, because it is a very common chip that has plenty of library support, and uses very simple i2c communication.
The relay was chosen to support the loading of a heater. A breaker for a home electrical outlet is rated at 15 Amps, so I chose a 16 Amp relay to be sure. The only limiting factor is the circuit board, as traces cannot handle lots of current unless they are fat and thick.
The TMP36 temperature sensor was chosen because of how common it was and based on a suggestion from my professor. It takes input from 3-5.5V, and provides an output that indicates the temperature at 10mV/*C. Room temperature is approximately 0.75V.
The 5 push-buttons are more or less self-explanatory. In the interest of minimizing circuitry, the push-buttons make use of the microcontroller’s internal pull-up resistors.
The LCD sheet is simply composed of the LCD display, three resistors for the RGB LED backlight, and the 4050 buffer for level shifting from 5V to 3V logic. Here are additional details.
The LCD is from AdaFruit as well, and was chosen because it was graphical and was a negative LCD. This means that the background is black, and the pixels are whatever colour the backlight is. This is nice, because for a thermostat, if it is night time the backlight might be overpowering on a normal LCD, but this negative LCD means that only the information (temperature, time) is lit, making it easier to spot. It is based on the ST7565 controller.
The microcontroller chosen was the ATMega1284p. This is a very powerful IC. It has 16k RAM, 128k Flash, and operates at up to 20MHz. The LCD display stores all its data in a buffer on the IC. As a result, 1k of RAM is used up by the LCD alone. I chose to 1284p because I didn’t want to run into memory issues, and considering the price of this vs. a lower class ATMega, $6 for the best was a small price to pay.
Other circuitry includes a reset button, JTAG header, and a FOX H5C-2E 20MHz Clock Oscillator. I decided to make use of the highest possible frequency to improve refresh rates on the LCD. I chose this crystal because it has a small package (half the size of other clock oscillators I’ve found).
The power supply starts with input from 7.7-30V. The input passes through a 1n4001 diode, which protects the circuit from reversed polarity input. At this point, a 10uF capacitor filters noise from the input signal, and then the power goes to the input of a 7805 5V regulator. I chose this chip because it is, again, very common, and can provide up to 1A, more than I’ll need. The output is then filtered for higher frequency noise with a 1uF cap, and then output makes up the 5V rail.
An MC1700-33 LDO regulator is used to take 5V and provide 3.3V for the XBee and the LCD. It can provide a maximum of 200mA, and the output is filtered with a 1uF capacitor.
At the bottom of the page, you can see three smaller capacitors. The 0.1uF ceramic caps filter decouple the DS1307 and the 4050, while the 0.47uF is for the ATMega.
The above shots are taken from my final revision of the schematic, the revision which went into the PCB design. As I will describe in future posts, there are some changes I thought to make while prototyping, but, ahem, forgot to put into my design in my excitement to have the boards manufactured. The things I forgot are very minimal (set VRef for the analog to digital converter to 3V instead of 5V), but if I make a future revision I will make sure to correct them.
This first stage was a great way to get started, but the fun really begins when I start prototyping!