By: Alexander Samietz, Joeny Zhen, Spencer Esparza, Wenmin He
Step 1: Introduction
In this tutorial, we are going to build a portable heating and cooling detection system that will turn on its corresponding fan or heater. It will utilize an ultrasonic sensor that will detect the user from a relatively reasonable distance that will allow fan or heater to turn on based on the surrounding temperature. The system uses the Basys 3 board and it is connected to three external components: a fan, a heater, and an ultrasonic sensor. This system is based on the temperature of the environment. If the temperature of surrounding is too high, the fan will be turned on. If the temperature is too low, the heater will be turned on. If the environmental temperature is in between the two set temperature, neither the fan nor the heater will be turned on. However, none of these functions will operate if the ultrasonic sensor does not detect a person in the given range. It will save energy if the user is not in the given range of the ultrasonic sensor and the fan and heater will not operate if the environmental temperature is reasonable to the user.
Step 2: Materials and Code
Listed in order of appearance:
Standard Two Pin Cooling Fan
LM35 Temperature Sensor
Two N-Type MOSFETS
HC-SR04 Ultrasonic Sensor
Here is a link to download all our code and schematics: here
Step 3: Understanding the Design
The Black Box diagram and the Schematic for the system is posted above. In the black box diagram, the P6 and Pn6 are the pin inputs that sends the voltage signal from the Basys 3 board to the XADC component, and then the outputs of the XADC are connected to the seven segments display, anodes, and decimal place to display to temperature detected from the temperature sensor. The XADC also generate the 8 bits binary outputs that compares the temperature with the default temperature range. Ultrasonic sensor on the other hand is the 1 bit signal that output ‘1’ when people are in the range. Hot comparator and cold comparator will take in the signals from both XADC temp output and Ultrasonic sensor output signal and sending the signals to turn on/off the fan/heating pad.
Step 4: Components
The XADC takes an analog signal (in our case the temperature sensor voltage outputted by the LM35) and converts it into a 16-bit binary number. The comparator then takes in those binary number as the input for comparison. To get the We need to instantiate the Basys 3 XADC demo, which is an verilog component to make it be a VHDL component. Port map the Demo inputs, and then convert the output of the XADC to 8 bits as the input of the comparators.
Comparator (Schematics listed above)
Cold: Hot and Cold Comparator The hot comparator is connected to the fan that takes in the temperature value as an input to compare with the default hot temperature value and signal from Ultrasonic sensor to turn on the fan. If the temperature input is greater than the default internal hot temperature value and the person in on near by, then the hot temperature comparator will send the signal to turn on the fan. If the temperature input is less or equals to the internal hot temperature value regardless of whether people is nearby or not, the fan will not be turned on. If the Ultrasonic sensor is sending the out of range signal, but the environmental temperature is higher than the set range, the fan will not be turned on.
The cold comparator which is almost the same as the hot comparator. It is connected to the heating pad that receives the on or off signal based on the temperature input and the Ultrasonic sensor signal. If the environmental temperature gathered from temperature sensor is greater than the default cold tempetemperature input from the XADC and the person is on the range, then the heating pad will be turned on to warm up the environment. If the temperature is greater than the default cold temperature and the people is on range, then the comparator will send off signal to heating pad to conserve energy. If the temperature input is greater than the default cold temperature and people are in the range, the hot comparator are going to send an off signal to turn off the heating pad. The temperature sensor will not be operating if the temperature input is greater than the default cold temperature value and people are not in the range.
Arduino - Ultrasonic Sensor
The Arduino is utilized to program the ultrasonic sensor. The setup is when the ultrasonic sensor does not detect a person within a set range, then a LED will light up. In the other case, if the person is within the range of the ultrasonic sensor, then the LED will turn off. The Arduino will also output a high(1) if it detects someone or a low(0) if it does not. The Basys 3 board will operate its fan and heating pad when it receives a ‘1’ signal from the arduino.
LM35 Temperature Sensor
The LM35 temperature sensor outputs a voltage based on the environmental temperature. This output analog voltage is read by the XADC and then converted into a digital voltage between zero and one. To obtain the temperature in celsius, multiply the result by 100. In the XADC vhdl code, we just moved the decimal point to the second anode.
Power MOSFETS and Power Supplies
Power mosfets were used to function as a switch to the fan and heating pad. N-Type MOSFETs act as a switch on the grounded end of a component. With a connection to the negative end of the component it wants to be a switch for, a gate voltage source, and a ground pin to complete the circuit. The gate voltage source is where voltage is controlled based on a situation. In our case, the gate voltage is turned on whenever the person is within range and it suits the respective temperature range for the comparator. When these requirements are met, the code activates the variable power outputs from the component’s respective pins. Since power mosfets we used were too resistive, they require a fair amount of voltage to operate and close the gate. Looking at the mosfet schematics, it showed that there needed to be about a 4V difference between the gate voltage and the ground. Since our variable pins could only output 3.3V, we added an additional voltage of at least 1 from the voltage sources in order to control how the gate works. The constant 1 to the gate pin is definitely not enough to turn on or off the switch, but when the 3.3 volts is added together with the 1 through vhdl code, it is enough for the power mosfet to function properly. If we had access to weaker MOSFETS, the constant voltage sources would not have been necessary because the 3.3V from the board would have been sufficient power to close the gates.
Step 5: Assembly
1. To start out we will look at inputs to the Basys 3 board. Looking at our black box diagram we can see that we have three inputs to it. The middle pin of the temperature sensor is the output voltage and that is connected to the first JXADC pin on the board. We must also connect a ground pin directly below the LM35 pin.
2. Next we must wire up the Arduino with the ultrasonic sensor. In the code we provided for the arduino we used pins 10-14. Wire the pins the the corresponding pins seen in the code, but instead of pin 11 going to an LED wire it directly as an input to the Basys 3 board. This is the ultrasonic input seen in the black box diagram.
3. We now have all the inputs, but we need to wire up the fan and heating pad with the MOSFETs. First required plugging in the positive terminals of the fan and heating pad into the constant voltage sources. Then, the ground pins of the fan and pad plug into the MOSFETs, while another pin of the MOSFET goes back to the ground of the Basys 3 Board. The coded power output pins, along with a boost from external voltage sources connected in series, plug into the MOSFET gate pins in order to close the circuit when appropriate.
Step 6: Finishing Up
Our temperature range is set up to turn on the fan once the environmental temperature reaches 30 degrees C (About 86 F), but you could change the high temp and low temp in the comparators to adjust to your liking. All of our code and images are in the zip file attached. The hot and cold comparators and the XADC are named as such. The overall file with all the components attached is called Compator_PORTINFO_Reader.