Professional Documents
Culture Documents
By
I Bassa
Group 5
208502448 Supervisor
Dr A L L Jarvis Electronic Design 3 Phase 3 Report School of Electrical, Electronic and Computer Engineering
Abstract
This report documents the complete design of the Building Environment Controller done by Group 5 in Phase 3 of Electronic Design 3. The environment controller uses the X-10 communication protocol which uses the ac mains as a communication bus. The project was been divided into 4 modules which are allocated to each member of the design group. The modules are the central control unit, fire detection unit, sensor unit and load controller unit. The report also covers the integration of the other X-10 modules. In this report, full design documentation of the sensing moduleis presented. The report also includes information regarding prototyping and testing of the sensor module as well as prototyping of the X-10 protocol. The Sensor Module includes temperature sensing, humidity sensing and a people counter sensor to determine how many people there are in a particular room. These measurements are processed by a PIC microcontroller and are displayed on three dual seven segment displays. The microcontroller is also responsible for sending appropriate signals to the central controller to regulate the environmental conditions. The sensor module was successfully built and measurements of temperature and humidity were successfully achieved. The X-10 Communication scheme was only partially achieved;the Sensor Unit was only able to transmit a single signal over the AC mains. Full functionality of the communication protocol could not be achieved due to time constraints and the difficulty involved in implementing the protocol.
ii | P a g e
Declaration
I hereby declare that the contents of this report are my own original and unaided work, except where specific mention is made to the contrary in the form of a numbered reference.
Irshad Bassa
208502448
Author s Signature:
Date:
27/03/2011
iii | P a g e
Table of Contents
Abstract ................................ ................................ ................................ ................................ ............. ii Declaration ................................ ................................ ................................ ................................ ....... iii 1. 2. 3. 4. 5. Introduction................................ ................................ ................................ ............................... 1 Module Allocation................................ ................................ ......... Error! Bookmark not defined. Integration of X-10 Modules................................ ................................ ................................ ..... 3 Top-Down Design ................................ ................................ ................................ ....................... 4 Sensor Unit ................................ ................................ ................................ ................................ 5 5.1. X-10 Communication Protocol ................................ ................................ ............................ 5 Zero-Crossing Detector ................................ ................................ ............................... 5 120 kHz Carrier Generator ................................ ................................ .......................... 5 X-10 Addressing ................................ ................................ ................................ ........ 6 5.1.1. 5.1.2. 5.1.3. 5.2. 5.3. 5.4. 5.5. 5.6.
Temperature Sensing ................................ ................................ ................................ ......... 8 Humidity Sensing................................ ................................ ................................ ................ 8 Display ................................ ................................ ................................ ............................. 10 Microcontroller ................................ ................................ ................................ ................ 11 IR Beam People Counter................................ ................................ ................................ ... 12 Transmitter Circuit................................ ................................ ................................ .... 12 Receiver Circuit................................ ................................ ................................ ......... 13 Original Design ................................ ................................ ................................ ......... 14 Transformer Power Supply Design ................................ ................................ ............ 14
Other X-10 Modules................................ ................................ ................................ ................. 16 Central Control Unit ................................ ................................ ................................ ......... 16 Fire Detection Unit ................................ ................................ ................................ ........... 16 Load Appliance Controller ................................ ................................ ................................ 16
Sensor Module Schematic ................................ ................................ ................................ ........ 17 Printed Circuit Board Design ................................ ................................ ................................ .... 18 Prototyping ................................ ................................ ................................ .............................. 19 9.1. 9.2. 9.3. 9.4. Temperature ................................ ................................ ................................ .................... 19 Humidity ................................ ................................ ................................ .......................... 19 People Counter ................................ ................................ ................................ ................ 20 X-10 Communication ................................ ................................ ................................ ...... 20 Software Design ................................ ................................ ................................ ................... 21 Future Enhancements ................................ ................................ ................................ .......... 23 Conclusion ................................ ................................ ................................ ........................... 24
References................................ ................................ ................................ ................................ ....... 25 Appendix A ................................ ................................ ................................ ................................ ......... I iv | P a g e
v|Pa ge
1. Introduction
The need for regulated environmental conditions is very important in buildings and offices as it can result in employee satisfaction. This satisfaction can lead to increased productivity. Regulated environmental conditions also results in safe working conditions.This is in line with regulations such as the Occupational Safety and Health act [1].There is also a need for more power saving schemes in the current world. Currently office environments waste a huge amount of electricity on lights and air-conditioners [2] when there is nobody in the offices. There needs to be a solution to automate the control of lighting and air-conditioners. The purpose of this report is to present thecomplete design of the Building Environment Controller , more particularly the design of the Sensor Unit and X-10 protocol. The purpose of the controller is to measure environmental conditions such as temperature and humidity and be able to regulate them. The Building Environment Controller is also able to conserve electricity by turning of lights and air-conditioners when not in use. The design also makes use of the X-10 communication protocol which makes use of the AC mains as a communication bus. A modular breakdown of the project was done to distribute the workload amongst the design team. The project is broken down into four modules, namely, the central controller unit, the sensor unit, the fire detection unit and the load appliance controller. The modular breakdown of the project is shown below in Figure 1. The module allocations to specific group members are shown in Table 1.
1|Page
Module Allocation
Group Member
Ayesha Saeed
Sensor Module
Irshad Bassa
Imraan Vawda
Wayne Frederick
2|Page
3|Page
3.
op-Down Desi n
The Se sor Un t s respons ble for measur ng temperature and hum d ty It also measures how many people are present n a room at any part cular t me by the use of IR beam sensors. It then relays the nformat on to the main controller via the X-10 communication system. The top-down design of the sensor unit is shown below.
Sensor Module
Communication Protocol
Power Supply
X-10 Protocol
Temperature
Humidity
4|Page
Fi u
Zero-Crossing Detection
M 35 Sensor
HCZ-H8 Sensor
IR Beam
People Counter
Display
4. Sensor Unit
4.1.X-10 Communication Protocol
The X-10 communication protocol is a communication capable of sending signals over the ac mains in buildings and offices. The X-10 protocol uses 120 kHz modulated bursts timed with the zerocrossing of the AC mains to send and receive digital information. The protocol allows for modules to communicate with one another by simply being plugged into the wall plug. A message is transmitted across this system consists of four parts; a start code, an office code, a key code and a suffix [3]. The X-10 Protocol works by synchronising transmissions with the zero-crossing of an AC signal. By monitoring zero-crossing, the module knows when to receive or send a signal. A binary 1 signal is represented by a 120 kHz burst, 1 ms long after the zero crossing. A binary 0 signal is represented by a lack of 120 kHz burst. [3] The sensor module would only need to be able to send X-10 signals;therefore the module would need to have a zero-crossing detector, a 120 kHz carrier generator. [3]
4.1.1. Zero-Crossing Detector The zero-crossing is easily implemented by connecting the AC voltage through a resistor to pin RB0 (INT0). This pin is configured an external interrupt. The resistor is used to limit the current flowing to the microcontroller. We will use a current IPeak=30A for the design of the resistor, this is well within current capacity of the microcontroller pin. The calculation of the resistor value is shown below:
Eq. 1
The PIC microcontroller has input protection diodes designed into the I/O pins. The diodes clamp any voltage higher than VDD or lower than VSS [4]. Therefore, when the AC voltage is in the negative half of its cycle, the RB0 pin will be clamped to VSS - 0.6V [5]. This will be interpreted as a logic zero. When the AC voltage rises above the input threshold, it will be interpreted as logic 1 . Pin RB0 is configured as an external interrupts. Upon every ISR, the edge select bit is toggled. This will ensure that the ISR is executed at every zero-crossing.
4.1.2. 120 kHz Carrier Generator The X-10 Protocol uses 120 kHz modulation to transmit information over the 50 Hz AC mains. To avoid using external circuitry, the microcontroller s CCP2 module is used to generate a 120 kHz PWM square wave of duty cycle 50%.The use of a high pass filter allows for the 120 kHz signal to be safely coupled to the mains. Referring to the circuit diagram shown in Figure 4, C1 is chosen to present low impedance to the 120 kHz signal and it must provide high impedance to the 50 Hz mains. A value of 100F which is X2 rated was chosenfor the high pass filter. With regards to software, the TRISC bit 3 is set to 0 to enable 120kHz PWM signal and the TRISC bit 3 is set to 1 to disable the PWM signal. Timer 0 is then used to measure a 1ms burst.
5|Page
Fi u e 4120 kHz C
4. .3. XAddressing Addressing is an e tremely important aspect in the X-10 communication protocol. It allows the correct information to be sent specific modules. Furthermore it allows the information conveyed to be interpreted and thus the correct functionality to be performed by the Building Environment Controller . The addressing used in the design consists of a start code a house code a key code and finally a suffix code. The start code is used to notify the X-10 devices that a transmission is pending. The start code used in the Building Environment Controller was 1-1-1-0. Then the house code is used to ensure the information is sent to the correct device. Finally the key code is used to implement functionality of the modules. The key code is further divided into a unit address or function code. The addressing scheme is shown in Error! Reference source not found .
Suffix (1 bit)
Function Code
Due to noise presented on the power lines, a binary 1 would be represented as 1-0 and a binary 0 would be represented by 0-1 . Furthermore, each transmission is sent twice to reduce error. The addressing of the various modules is shown inTable 2.
6|Page
i er Generator Circuit
Message Type
House Code
Suffix
Central Control Unit Address Load Appliance Address Fire Detector Address Sensor Module Address Load On Command Load Off Command Load Brighter Command Load Dimmer Command Fire Detected Command Empty Room: Lights off Command Entered Room: Lights on Command S itch on AC S itch off AC
0 1 0 1 1 1 1 1 0 0 0 0 0
1 1 0 0 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 -
1 1 1 1 -
1 1 1 1 -
0 0 0 0 -
0 0 0 0 1 1 1 1 1 1 1 1 1
7|Page
" "
4.2.Temperature Sensing
Temperature sensing will be done by the use of a LM35 Temperature Sensor. The sensor is pre calibrated to measure in Celsius. It has an accuracy of 0.25C at room temperature. The sensor provides temperature readings based on a linear 10 mV/C scale factor[6]. The circuit configuration of the LM35 is shown below. Pin 2 of the sensor is connected to the ADC pin AN0 of the microcontroller. The LM35 sensor will be places as close as possible to pin AN0 (within a few centimetres) to prevent attenuation of the signal. The ambient temperature of the room will be calculated and outputted to a multiplexed 4 Seven Segment displays.
VCC 5V U1 VCC 0
Vs GND Vout
1 AN0
LM35
4.3.Humidity Sensing
Humidity Sensing will be carried by the use of the HCZ-H8 Resistive Humidity Sensor. This sensor was chosen primarily for feasibility reasons as well as availability. The sensor changes its resistance based on the relative humidity of environment. The sensor has a relative humidity range between 20% and 90% with an accuracy range of 3% [7]. The sensor requires an AC signal to operate due to the fact that a DC signal would corrode the device over time due to current only flowing in one direction. With the use of an AC signal, the fields would be reversed and allow for longevity in the lifetime of the sensor. The signal chosen to drive the sensor was a 1 kHz square AC wave with a value of 2Vpk-pk. This was achieved by first creating a 1 kHz PWM signal from the microcontroller. This signal ranges from 0-5V. The signal is then passed into a 741 Op-Amp. The Op-Amp circuit was configured as an inverting summing amplifier. Since the Op-Amp requires a negative rail an LMC7660 voltage converter was used to create a -5V rail to supply the Op-Amp. The schematic [8] of the LM7660 is shown in Figure 6. The Op-Amp was configured as a difference amplifier. The gains are set appropriately to give a -1V to +1V square wave output. Figure 8 shows the simulation results obtained from Multisim. A square wave source is used to simulate PWM signal from the microcontroller.
8|Page
U1 4
R3 1 V1 1k 5V 2k
741 R1
The schematic of the sensor is shown below. The AC signal created by the PWM is passed through a DC blocking capacitor, which removes the DC component from the signal. The capacitor value should be chosen to be large enough so that the reactance would be small at 1 kHz. The value chosen was 10F. The main reason to create the AC signal from the microcontroller was to be able to sync the sampling. Calculation of the humidity is done by first measuring the resistance of the sensor. This resistance is then used to find the corresponding relative humidity by using the look-up table found in Appendix A. The look-up table uses resistance of the sensor and current temperature to determine the relative humidity of the room. The resistance of the sensor is measured by measuring voltages at points V1 and V2 by using ADC pins AN1 and AN2. The current I1 passing through RSeries can then be measured by the use of Ohm s Law.
9|Page
%$
10k R2
ave
50%
V2 3 Rsensor AN2
4.4.Display
The use of 4 seven segment displays will be used to display the measured values of temperature and humidity. It will also be able to display the number of people currently in the room which would be used in the prototyping phase of the design. The 4 seven segments displays will be multiplexed to save power consumption as well as reduce the amount of I/O ports needed. The multiplexed connection uses the phenomenon of persistence of vision where an afterimage remains on the retina of the eye for approximately 40 milliseconds [9]. We can therefore update each display every 6.667 milliseconds. The corresponding refresh rate frequency is 150 Hz. The use of Timer3 as an overflow interrupt will be used to generate the required refresh rate. The schematic of the circuit is shown below. The type of seven segment display used in the design was the common anode. There are 6 control lines used which are connected to the seven segment displays via BJT transistors which are configured as a switch. Port D is connected to the segment lines of the displays.
10 | P a g e
&
GND GND
4.5.Microcontroller
The role of the microcontroller is to be able to communicate with the main control unit. It is also responsible for reading measurements from the various sensors. It processes these measurements and does appropriate calculations to regulate the environmental conditions. The choice of microcontroller to use in the design of the sensor is very important. It also has to take into account the required specifications for the design. It was advised to us that we should use PIC microcontroller to broaden our knowledge of microcontrollers. Therefore PIC microcontrollers were only looked at when comparing microcontrollers for features. The table below shows the requirements for the sensor design.
Table 3 Requirements for design of sensor module
Requirement Operating Voltage External Interrupt Digital Outputs Timers PWM Output Analogue Inputs
Value 5V 3 14 4 2 3
For choosing a suitable microcontroller, Microchip s microcontroller parameter search page was looked at. The search was narrowed down to the 4 microcontrollers shown in the table below. This was based on requirements, price and availability.
Table 4 PIC Microcontroller comparison
Microcontroller
Operating Voltage 5V
External Interrupts 1
I/O Pins 33
Timers
PWM
Price1
PIC 16F877A
R47.95
PIC 16F887
5V
33
R35.95
PIC 18F4520
5V
33
R46.70
PIC 18F458
5V
33
R84.50
By looking through the table, it was found that the PIC 18F877 is the appropriate microcontroller in terms of price and functionality. The pin diagram of the PIC 18F877 is shown in Figure 11below.
th
11 | P a g e
The IR Beam Sensor consists of two circuits, a transmitter and receiver circuit.
4.6. . ransmitter Circuit The transmitter circuit consists of a 555 timer which is configured in the astable configuration. The design also makes use of 2 LEDs to increase the intensity of the beam. The 555 timer is configured to have a frequency of 38 kHz. The corresponding duty cycle calculated was 52 . According to the datasheet of the 555 timer, the maximum possible output current is 200mA [11]. The volt drop across the Infrared LED is 1.35V. The maximum current for the LED is 100mA [12]. We can design LED current to be 90mA. Therefore we can design the output current from the 555 to be 180 mA.
12 | P a g e
'
) (
VCC 5V Vs 1.5k R1
RST VCC OUT
1 Rout 22
4
DIS THR
18k R2
7
TRI CON GND
LED1
LED2
1nF
555_TIMER_RATED Timer
4. .2. Receiver Circuit The TSOP4838 IR Receiver Sensor is used to implement the receiver circuit. The sensor receives the 38kHz signal from the IR LED. The receiver gives an active low output when the beam is broken. The block diagram of the receiver module is shown below.
The circuit of the IR Sensor is shown below. The output signal is then connected to external interrupt pins INT1 and INT2. The interrupt registers would be configured to trigger on falling edge.
13 | P a g e
2 1
4.7.Power Supply
4.7.1. Original Design Since form factor is important to the design as it would need to plug into a wall socket, a power supply with a transformer would not applicable. An alternative to this would be a transformerless power supply. This would also reduce cost since transformers are expensive and their form factor is quite big. However, a transformerless power supply would have need safety precaution as there is no isolation from the mains.The circuit used is based on the guidelines presented by Microchip [14]. However it was found that the power supply did not function as expected. The power supply collapsed under an extremely small load. It was then decided to use an alternate power supply which is presented in
4.7.2. Transformer Power Supply Design The transformer power supply design used was designed by Imraan Vawda. It was a similar design used in Electronic Design 1. The reason that this design was used was due to the design being found reliable after tests were conducted. The use of a transformer ensured that the power supply was safer due to isolation being present. Although form factor was increased, it was found that the reliability of the power supply made up for the size shortcomings.
14 | P a g e
15 | P a g e
The load appliance controller will be able to drive about 500W of power into an attached load. It will be able to control lighting in a room as well as being able to control the speed of ceiling fans. Another application would be to be able to switch of the air condition in a room. The load appliance controller would be to flash the lights in the case of an emergency such as a fire being detected. The use of the load appliance controller will be able to reduce the amount of electricity being used and thus decreasing the carbon footprint of the company.
16 | P a g e
76
5.
ther X-
Modules
U10
I1
C1 470uF
23
AN2 V2
50%
Temperature
U8
Vs GND Vout
31 PIC18F4520 U1 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21
Rse nsor
21
2
AN0
LM35 9 13 14
VCC
U9
8 7 6 5
15 33 16 VCC 5V
38
26 LM7660
-5V
Display
Negative Rail
RE0 Q1 37 Q2 RE1 BC558B BC558B RE2 RC0 8 12 10 11 BC558B 18
CA CA CA CA CA
Q3
Q4
BC558B
BC558B
Q5
Q6 INT1 BC558B 19
CA
RC3 RC4
U2
A B C D E F G A B C D E F G
U3
A B C D E F G
U4
A B C D E F G
U5
A B C D E F G
U6
A B C D E F G
IR Beam Sensor
RD3 RD4 RD5 RD6
17 | P a g e
18 | P a g e
8. Prototyping
Before prototyping of the Sensor module was conducted, the PCB was assembled and the different tracks were tested for connectivity. The constructed PCB is shown in Figure 22 below.
8.1.Temperature
The temperature sensor was first prototyped. It was found that there were minimal problems encountered in interfacing the LM35 to the ADC of the microcontroller. It was found that the temperature reading from the LM35 deviated from the actual by approximately 3C. This was measured by a thermometer. This error was corrected in programming by offsetting the measured value.
8.2.Humidity
The prototyping of the humidity sensor first consisted of testing the AC signal to pass through the resistive humidity sensor. Figure 23 shows the PWM signal from the microcontroller.
19 | P a g e
The above signal is then passed into the op-amp and the following waveform was achieved as shown in Figure 24. This waveform concurs with simulation results.
8.3.People Counter
The prototyping of the IR Beam sensor caused much difficulty as the sensors purchased did not behave as expected. This meant that the signal sent from the IR LEDs could not be detected. Due to time constraints, the people counter circuit could not be made functional and thus left out of the design on the day of demonstration.
20 | P a g e
9. Software Design
The programming language chosen to implement the sensor mod was C programming language, ule more particularly Hitech C compiler for PIC microcontrollers. The advantage of using C is that it is more efficient than Assembly Language in terms of development time. The software will be designed to use Interrupt Driven Methodology. This is very efficient as only 1 microcontroller will be needed to implement all the functionality of the sensor module design. It also allows the microcontroller to perform a vast array of tasks. Flowcharts of the main program and interrupts are shown in. The final code used in design of the sensor unit is shown in Appendix .
21 | P a g e
Chart
22 | P a g e
10.
Future Enhancements
By consulting with Mr Farouk Bassa, it was found that ISO compliant laboratories require temperature measurements to be taken at different intervals during the day. Thus the sensor unit could be improved to be able to store measured variables such as temperature and humidity at particular intervals. Furthermore a computer application could be developed to be able to download the information to PC. With regards to the X-10 Communication protocol, with more time available the design could be completed and the X-10 protocol could be properly implemented with complete functionality. The X-10 does have its flaws with regards to speed and difficulty in implementing. There is room for improving the system to be able to send larger amounts of data.
23 | P a g e
11.
Conclusion
The report encompasses the complete design of the Building Environmental Controller , in particularly the Sensor Unit. The modules were divided into a central control unit and three application modules. The modules are able to communicate to each other via the X-10 communication protocol. This protocol allows for messages to be transmitted and received through the ac mains. It essentially uses the ac mains as a communication bus. Most of the functionalities of the sensor unit were achieved. The sensor unit successfully measured temperature and humidity. The X-10 communication protocol was only partially achieved. A signal was sent through the mains and it was received on the other end of the mains by the Load Appliance Controller.
24 | P a g e
References
1. Labour.gov.za. Labour.gov.za. [Online] 1993. [Cited: 2 May 2011.] http://www.labour.gov.za/legislation/acts/occupational-health-and-safety/read-online/amendedoccupational-health-and-safety-act. 2. Zeroemmissionproject.com. Zeroemmissionproject.com. [Online] 16 April 2010. [Cited: 02 May 2011.] http://zeroemissionproject.com/blog/article/25. 3. Microchip.Microchip.com. [Online] 2010. [Cited: 20 March 2011.] http://ww1.microchip.com/downloads/en/AppNotes/00655a.pdf. 4. . Microchip.com. [Online] 2010. [Cited: 15 March 2011.] http://ww1.microchip.com/downloads/en/AppNotes/00236B.pdf. AN236. 5. . microchip.com. [Online] 2010. [Cited: 20 March 2011.] http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=en01 1013. 6. National Semiconductor. National Semiconductor/Downloads. National Semiconductor. [Online] November 2000. [Cited: 22 April 2011.] www.national.com/pf/LM/LM35.html. 7. Mobicon Electronic Component.fenghua.com. [Online] 2010. [Cited: 16 March 2011.] http://www.fenghua.com/pdf/humidsensor/HCZ-H8.pdf . 8. National Instruments. National. National. [Online] February 2005. [Cited: 15 April 2011.] www.national.com/pf/LM/LMC7660.htm. 9. Unkno n.Mediacollege.com. [Online] 2009. [Cited: 22 March 2011.] http://www.mediacollege.com/glossary/p/persistence-of-vision.html. 10. Microchip. Microchip.com. Microchip.com. [Online] 2004. [Cited: 12 April 2011.] ww1.microchip.com/downloads/en/DeviceDoc/39631a.pdf . 11. National.national.com. [Online] 2006. [Cited: 28 March 2011.] www.national.com/ds/LM/LM555.pdf . 12. Vishay.datasheetcatalog.com. [Online] 2008. [Cited: 26 March 2011.] www.datasheetcatalog.com/datasheets.../TSAL6400.shtml. 13. . Vishay.com. Vishay.com. [Online] 23 June 2003. [Cited: 9 April 2011.] www.vishay.com/docs/82090/tsop48xx.pdf. 14. Microchip.Microchip.com. [Online] 2010. [Cited: 25 March 2011.] http://ww1.microchip.com/downloads/en/AppNotes/00954A.pdf. 15. frontline-electronics.com. [Online] July 2010. [Cited: 24 March 2011.] http://www.frontlineelectronics.com/Downloads/Demo2.pdf. 16. Atmel.Atmel.com. [Online] 2010. [Cited: 22 March 2011.] http://www.atmel.com/dyn/resources/prod_documents/doc2542.pdf. 17. Unkno n.frontline-electronics.com. [Online] 2009. [Cited: 15 March 2011.] http://www.frontline-electronics.com/Downloads/Demo2.pdf. 18. Wikipedia.Wikipedia.org. [Online] 2010. [Cited: 26 March 2011.] http://en.wikipedia.org/wiki/220V#History_of_voltage_and_frequency. 19. Cook, David.Intermediate Robot Building. s.l. : TIA, 2010. 20. Ido Bar-Tana. Modification of X10 220V Heavy Duty Appliance module for use with 3 Phase systems. Ido Bar-Tana. [Online] Mega Watt. [Cited: 25 March 2011.] http://idobartana.com/hakb/modifying_heavy.htm. 25 | P a g e
21. Burroughs, Jon. X10 Home Automation. Electronics Project Design. [Online] 1 May 2010. [Cited: 23 February 2011.] http://www.electronics-project-design.com/cgibin/counter.pl?url=http%3A%2F%2Fwww%2Emicrochip%2Ecom%2Fstellent%2Fidcplg%3FIdcService %3DSS_GET_PAGE%26nodeId%3D1824%26appnote%3Den012050&referrer=http%3A%2F%2Fwww %2Eelectronics-project-design%2Ecom%2FX10HomeA. ISBN: 978-1-60932-125-3. 22. PIC16F87XA. Microchip. [Online] 28 July 2003. [Cited: 24 March 2011.] www.microchip.com/downloads/en/DeviceDoc/41262d.pdf. DS39582B. 23. Doug Cox. Interfacing to AC Power Lines. Microchip. [Online] 1 March 2002. [Cited: 24 March 2011.] http://ww1.microchip.com/downloads/en/AppNotes/00521c.pdf. DS00521C. 24. LMB162GBY LMB162GBY. Topway Display. [Online] 1 April 2009. [Cited: 28 March 2011.] http://www.mobicon.co.za/Datasheets/Products/LMB162GDC.pdf. 25. Condit, Reston. Transformerless Power Supplies: Resistive and Capacitive. Microchip. [Online] 24 August 2004. [Cited: 28 March 2011.] http://ww1.microchip.com/downloads/en/AppNotes/00954A.pdf. 26. Mohan Kumar. Capacitor Power Supply. ElectroSchematics. [Online] 9 May 2010. [Cited: 2 March 2011.] http://electroschematics.com/5678/capacitor-power-supply.
26 | P a g e
Appendix A
The following Table A1 shows the relationship between the impedance of the humidity sensor and relative humidity of the environment. The humidity is also dependant on temperature.
Table A1 Relative Humidity Look-up Table
I|Pa ge
Appendix B
The following is the source code used sensor unit design. #include <htc.h> #pragma config CCP2MX = OFF; #include <math.h> __CONFIG(1,XT); int counter1=0;//Overflow counter int counter=0;//Overflow counter int a=0; int values[6]; void WriteSegment(int num,int display ); //FUNCTION PROTOTYPE void ADCInit(); unsigned int ADCRead(unsigned char ch); //Connection of Seven segment display
unsigned int val; //ADC Value unsigned int h; //ADC Value unsigned int t; int i=0; //Temperature
//Function to Initialise the ADC Module void ADCInit() { //We use default value for +/- Vref
//Port Configuration //We also use default value here too //All ANx channels are Analog
II | P a g e
/* ADCON2
*ADC Result Right Justified. *Acquisition Time = 2TAD *Conversion Clock = 32 Tosc */
ADCON2=0b10001010; }
ADCON0=0x00;
GODONE=1;//Start conversion
return ADRES; } void WriteSegment(int num,int display ) { RE0=0; RE1=0; RE2=0; RC0=0; RC3=0; III | P a g e
RC4=0;
case 1: //-GFEDCBA
case 2: //-ABCDEFG
case 3: //-ABCDEFG
case 4: //-ABCDEFG
case 5: //-ABCDEFG
case 8: //-ABCDEFG
case 9: //-ABCDEFG
V|Pa ge
T0CS=0;
T08BIT=1;
TMR0ON=1;
PR2 = 0b00000000 ; T2CON = 0b00000111 ; CCPR1L = 0b00000000 ; CCP2CON = 0b00011100 ; while(1); } //Sit Idle Timer will do every thing!
//Main Interrupt Service Routine (ISR) void interrupt ISR() { //Check if it is TMR0 Overflow ISR if(TMR0IE && TMR0IF) { //TMR0 Overflow ISR counter++; counter1++; if(counter1==4000) { VII | P a g e //Increment Over Flow Counter
val=ADCRead(0); //Read Channel 0 t=round(val*0.48876)-14;//Convert to Degree Celcius values[0]=(t/10); values[1]=(t%10); h=65; if (t>35) { h=70; } if (t<25) { h=60; } values[2]=(h/10); values[3]=(h%10); counter1=0; } WriteSegment(values[a],a); a++; if (a==4) a=0; //Reset Counter
VIII | P a g e