Small Solar Room Temperature Regulator
1945 Views, 3 Favorites, 0 Comments
Small Solar Room Temperature Regulator
This is a final project for our CPE 133 class at Cal Poly that was designed to be a small scale version of an automatic shutter and insulator. The system has two temperature probes to measure external and internal temperature, an FPGA Basys 3 Board, a stepper motor, several male to female pins, ambient light sensor, and a small scale model of a house along with mechanical window. This system is supposed to be used to help conserve Heater Air Conditioner energy by automatically opening and closing windows to let in energy from the outside or to insulate the current temperature on the inside depending on the two temperatures and the setting that the user inputs. The system is light activated so the shutter requires sunlight or other bright light source to be enabled. This small scale model assumes the shutters are able to insulate against heat and light.
Materials List
The project requires the following:
1 x Basys 3 Artix 7 FPGA Board
1 x 28BYJ-48 Stepper Motor
1 x ULN2003 Driver (Motor module comes with Stepper Motor in Amazon link)
2 x MAX6675 Modules (Temperature Control Module)
2 x K Type Thermocouple Sensors (Temperature probes that connect to the MAX6675 and comes with MAX6675)
1 x Cardboard box or Shoebox for house representation (Use the amazon boxes you get from links above!)
1 x Mechanical shutter that can be attached to the Stepper Motor's axle (Make it yourself)
1 x Yurobot Light Sensor
1 x Desktop computer with mini-USB cord, and is loaded with the program Vivado 2014 (preferred)
Many jumper cables (Male/Female cables preferred, but may require assorted types)
Assembly
The first step is to figure out the mappings of the Basys board and how the parts will be assembled on it. A full reference manual of the board can be found on the Digilent Basys 3 website that lists all the ports of the board.
https://www.digilentinc.com/Data/Products/BASYS3/B...
We used all four PMOD connectors located on the left and right sides of the board. On the reference manual, the PMOD pins can be found on page 17 "PMOD Controllers."
Motor
The stepper motor ULN2003 module's ground and power should be connected to the matching ground and 3Volt VCC on the connectors with jumper cables. Align the N1-N4 connectors on the ULN2003 motor module to fit into the four ports adjacent to the power and ground on the same row on the board with jumper cables. Remember which PMOD ports are used.
Temperature Modules
Next connect the MAX6675 ground and voltage pins to another PMOD connector's ground and 3Volt VCC. Then connect the three remaining pins of the MAX6675 to the three pins of the PMOD connectors on the same row as the ground and VCC of the PMOD ports. Connect the thermo coupler prongs to the corresponding positive and negative screws on the MAX6675. Do this for both of the MAX6675s and note which PMOD ports are used.
Connection to "House"
At this stage, the motor and mechanical shutter/curtain should be attached to each other and to the cardboard house window somehow. Our mechanical shutter is simply a straw bound to the motor with a paper flap that can cover the window opening. The opening is a hole cut on the side of the cardboard box, roughly to the size of the shutter. The idea is that the motor will rotate inward and outward to move this shutter.
Mark one of the thermo coupler probes to be the inside temperature and one to be the outside temperature. The top right (JB PMOD ports) are the inside temperature probe and the bottom right (JC PMOD ports) are the outside probe. These labels will help with organization later on.
Coding
Coding is perhaps the most difficult part. The algorithm contains the following:
1 x Overall main circuit to instantiate and drive all modules
2 x Comparators
1 x Decoder for the Basys 3 display
1 x Light controller module provided by Xilinx
1 x Motor controller module
1 x Motor counter module to drive the motor for a certain period of time
1 x Reader module for the temperature probes
1 x Overall clock to drive the code
3 x Clock dividers within the code to slow down the clock signal
1 x Counter module to drive the displayed user setting temperature up or down
1 x Basys 3 Master File Configuration
It is suggested that you use Vivado 2014 to code this project, because it is the same program we used. The Digilent website has great tutorials on getting started with Vivado.
Instructions for Coding:
Reference Files: Before doing anything, you must first create a new project in Vivado. Then you will be able to add our files as sources to use as references. Without creating the project in Vivado, the files will not open up.
1. Build each modules at the lower level separately. If possible test the individual modules as you work.
2. The comparator modules are the easiest to build and test at this point. They are less-than-or-equal-to comparators that compare the following: The temperature inside and the temperature outside, and the temperature the user sets (with the incrementing/decrementing counter module) and the temperature inside.
3. Add the files for the seven segment decoder and clock dividers. Put this as needed in the separate modules first for testing (Coding Links).
4. Create the controller modules for the temperature probes and test (Coding Links). The probe reads temperature in Celsius!
5. Create the controller modules for the motor and test. This includes both the motor controller and motor counter (Coding Links).
6. Create the counter module and test it with the display to see if it properly increments or decrements.
7. Create the light controller from the Xilinx code and test it to see if the LEDs move properly (Coding Links).
8. Map the systems together in a main circuit file.
9. Put in the inputs and outputs to the Basys 3 Master Configuration File.
Also uploaded are the actual VHDL files used for your reference. All of the files have been commented to help understand the function of each module and their components. Look at the uploaded image for the hierarchical structure of the files within Vivado.
Note: The project files provided may come up with an error during implementation for the light sensor file. The circuit will still work, there is just a small error.
Coding Links
Outside code, and information to help code our project will be provided here.
Temperature Probe:
The temperature probe's data sheets (so you know which ports do what) can be found here: http://www.adafruit.com/datasheets/MAX6675.pdf
Motor:
The motor code was translated from Arduino code to work in VHDL, and our code already reflects that. For a basic starter on the code you can go here: https://learn.adafruit.com/adafruit-arduino-lesson...
Clock Divider and Seven Segment Decoder VHDL:
Obtained under Creative Commons License from Brian Mealy and Fabrizio Tappero.
Clock Divider Code from page 151 and SSEG Decoder from page 163 of the book Free Range VHDL by Brian Mealy and Fabrizio Tappero: http://freerangefactory.org/pdf/free_range_vhdl.pd..
Light Sensor:
Code from light sensor, courtesy of Xilinx:
https://reference.digilentinc.com/basys3:xadcdemo
Basys 3 Master File Configuration:
Map out the appropriate signal outputs of the code to the Basys 3 Master File, which can be found here:
https://www.digilentinc.com/Data/Products/BASYS3/b...
A reference file has also been included. This master file is where knowing which ports are which is important to the project.
Testing
Once the code has been inputted and the Basys 3 master file has been mapped, it is time to test. The probes should be able to sense body heat, and a switch inside the code allows the user to check the inside temperature. The algorithm for how the main circuit deciphers the temperature probes is shown above.
The video demonstration can be downloaded below the instructions. In the demonstration, both temperature probes are experiencing the same temperature, so we use the temperature set increment and decrement to open or close the shutter. The system is able to automatically adjust based on the parameters of the chart.
Instructions for Operation:
1. Make sure the system is in the on position. The right-most switch should be flipped up to turn the system on.
2. Make sure inside temperature switch (second switch from the right) is off/ switched down. That setting is only used to temporarily check what temperature the room is at.
3. Using the buttons or the seven leftmost switches, increment the displayed temperature to the desired temperature. The switches represent preset numbers from 5 to 35 in increments of 5. The top down buttons should increment or increment the display by 1 when held. The right left buttons should increment or decrement the display by 5 when held. *IMPORTANT NOTE*: Once the motor starts moving, let it continue moving until it completely stops before you try moving it again. It will move in accordance to the preset temperature. We haven't found a solution for this problem, but it is possible to fix. We could not fix the problem given our time constraints but you're welcome to challenge yourself in fixing the problem.
4. If the system is on, the motor will then begin to function, lifting or lowering the curtains based on the temperature inside, the outside, and the preset.
5. From then on, the user can change the desired temperature and the motor will then self adjust. You can use some heat source available to raise the temperature of either of the temperature probes that are connected to the system, or cold source to lower the temperatures. Play around with the different occasions that the shutters open or close.
6. There is also a light sensor that will enable or disable the whole circuit. If you cover your hands over it, the LEDs on the board will sequentially shut off and the system will be disabled. Otherwise, if if the LED’s are all on, then the system will continue to work. The light sensor determines when it is night or day with the amount of sunlight outside.
Notes and Extra
List of Sources
-Code derived from Xilinx for the light sensor module.
-Code from Brian Mealy (CPE Professor at Cal Poly) for the clock divider and seven segment display.
-Motor code translated and modified from Arduino code library. Original code created by Simon Monk from Adafruit website.