Академический Документы
Профессиональный Документы
Культура Документы
by
Certifico, Ma. Dia Lauren S.
Eugenio, Francis Erik V.
Onda, Aldrin James M.
Electrical Engineering
APPROVAL SHEET
This is to certify that we have supervised the preparation of and read the thesis prepared by
Ma. Dia Lauren S. Certifico, Francis Erik Eugenio and Aldrin James M. Onda, entitled
Intelligent LED Lamp with varying light intensity according to ambient light and
height with integrated motion sensor and that the said thesis has been submitted for final
examination by the Oral Examination Committee.
ii
ACKNOWLEDGEMENT
Our deepest thanks to the LORD for all the gifts He has given us and for directing
our path to the following persons who have been instrumental in the completion of this study.
Our adviser, Engr. Joseph Bryan Ibarra, for his guidance and patience in providing us
with an excellent atmosphere for doing research.
The Institution and its faculty members, without whom this project would have been a
distant reality.
Our family, whose prayers have provided us with the strength to hold on during the
times that we wanted to give up.
All our friends, who in one way or another have given us support and encouragement.
iii
TABLE OF CONTENTS
TITLE PAGE i
APPROVAL PAGE .. ii
ACKNOWLEDGEMENT iii
TABLE OF CONTENTS..iv
LIST OF TABLES vi
LIST OF FIGURES..vii
ABSTRACT..ix
Chapter 1: INTRODUCTION. 1
Chapter 2: REVIEW OF LITERATURE 4
2.1 LED Lamp ...4
2.2 Passive Infrared (PIR) Sensors.5
2.3 Light Dependent Resistor (LDR Sensor)... 12
2.4 Pulse Width Modulation 17
2.5 Recommended Light Levels.. 19
Chapter 3: INTELLIGENT LED LAMP WITH VARYING LIGHT INTENSITY
ACCORDING TO AMBIENT LIGHT AND POLE HEIGHT WITH INTEGRATED
MOTION SENSOR 25
Introduction 25
Methodology Process in Designing the Prototype ..28
Microcontroller Coding...29
Conceptual Diagram. 30
Objective 1: To construct a LED lamp control circuit with analog
input control... 32
Objective 2: Calibration of LDR using lux meter34
Objective 3: To program a microcontroller that will maintain the desired
APPENDIX B
APPENDIX C
LIST OF TABLES
TABLE 3.1: Lux intensity of the LED Lamp in varying its duty cycle ...................................
33
35
36
TABLE 3.4: Output Voltage and Current of the LED lamp at 50 Lux, 5 ft high ....................
41
TABLE 3.5: Output Voltage and Current of the LED lamp at 75 Lux, 5 ft high ....................
42
TABLE 3.6: Output Voltage and Current of the LED lamp at 100 Lux, 5 ft high ..................
42
TABLE 3.7: Varying ambient light with Maintaining lux intensity of 50 lux at 5 feet high ...
43
TABLE 3.8: Varying ambient light with Maintaining lux intensity of 75 lux at 5 feet high ...
44
TABLE 3.9: Varying ambient light with Maintaining lux intensity of 100 lux at 5 feet high .
44
TABLE 3.10: Output Current of the LED lamp at 50 Lux, 6 ft high .......................................
48
TABLE 3.11: Output Voltage and Current of the LED lamp at 50 Lux, 7 ft high ..................
48
TABLE 3.12: Output Current of the LED lamp at 75 Lux, 6 ft high .......................................
49
TABLE 3.13: Output Current of the LED lamp at 75 Lux, 7 ft high .......................................
49
TABLE 3.14: Output Current of the LED lamp at 100 Lux, 6 ft high .....................................
50
TABLE 3.15: Output Current of the LED lamp at 100 Lux, 7 ft high .....................................
50
TABLE 3.16: Varying ambient light with Maintaining lux intensity of 50 lux at 6 feet high .
51
TABLE 3.17: Varying ambient light with Maintaining lux intensity of 50 lux at 7 feet high .
52
56
56
56
57
57
57
TABLE 3.24: 7 o'clock in the evening at a height of 5ft and maintaining at 50 lux................
59
TABLE 3.25: 7 o'clock in the evening at a height of 6ft and maintaining at 50 lux................
59
TABLE 3.26: 7 o'clock in the evening at a height of 7ft and maintaining at 50 lux................
60
vi
LIST OF FIGURES
FIGURE 2.1: Block diagram of the Zilog ZMOTION detection module. ...............................
11
FIGURE 2.5: Detection zone and sensor output (Courtesy of Panasonic). .............................
11
13
14
15
16
18
FIGURE 2.11 The block diagram of a simple switch-mode servo amplifier ..........................
19
FIGURE 2.12: Illuminance Categories and Values for Generic Indoor Activities ...............
20
21
FIGURE 2.14 Illumination Levels and Limiting Glare Indices for Various Functions ...........
22
FIGURE 2.15: Different Location with Desired Illuminance level and Limiting Glare
Index .........................................................................................................................................
24
28
29
30
32
FIGURE 3.5: Adjusting the power of the led lamp using the program ...................................
32
FIGURE 3.6: Block diagram in calibration of LDR using Lux meter .....................................
34
FIGURE 3.7 Adjusting the power supplied to the led lamp using the program ......................
34
34
35
37
37
vii
37
FIGURE 3.13 Program Process in change ambient light and height of positioning of the led
lamp ..........................................................................................................................................
37
39
40
FIGURE 3.15 Lux meter positioning at 5 ft. LED Lamp High ...............................................
40
41
42
FIGURE 3.18 Current and Voltage vs Ambient Light at 5 ft 100 lux .....................................
42
FIGURE 3.19 Direct and Indirect lux meter reading vs Ambient Light at 5 ft 50 lux ............
43
FIGURE 3.20 Direct and Indirect lux meter reading vs Ambient Light at 5 ft 75 lux ............
44
FIGURE 3.21 Direct and Indirect lux meter reading vs Ambient Light at 5 ft 100 Lux .........
44
46
46
46
FIGURE 3.25 Output Current and Ambient light for 50 Lux at a height of 5, 6, 7 feet ..........
48
FIGURE 3.26 Output Current and Ambient light for 75 Lux at a height of 5, 6, 7 feet ..........
49
FIGURE 3.27 Output Current and Ambient light for 100 Lux at a height of 5, 6, 7 feet ........
50
FIGURE 3.28 Direct and Indirect lux meter reading vs Ambient Light at 6 ft 50 lux ............
51
FIGURE 3.29 Direct and Indirect lux meter reading vs Ambient Light at 7 ft 50 ..................
52
54
55
55
56
56
57
57
viii
ABSTRACT
Intelligent led lamp is designed to which its light intensity varies according to
ambient light and height of positioning and at the same time maintains the selected desired
lux in the area. PIR sensor which will serve as the motion sensor is just an add-on feature that
aims to add security feature on the system by maximizing the luminance level output of the
led lamp as movement is detected for a certain delay and then back to normal luminance
level once there is no more activity. With the utilization of PIC18F4520 as the
microcontroller, the lux meter reading is obtained when the light source is varied to verify if
the desired lux intensity is maintained and the LED Lamp will turn off once the there is
enough ambient light in the surrounding. The study was conducted in a dark area. After the
necessary data and parameters are gathered, the researchers were able to prove that when the
ambient light increases the output current obtained is decreasing, thus it can be concluded
that it conserve energy. The researchers also proved that the luminance in the area is
maintained though ambient light varies. When the height of the led lamp increases the
current will also increase as well to maintain the selected desired light intensity in the area.
Keywords: LED Lamp, lux meter, LDR, lux, PIR sensor
ix
Chapter 1
INTRODUCTION
One of the biggest expenditures nowadays is the use of lighting. According to a study
in 2009, 19% of the worlds electric consumption comes from lighting. In fact, about 52
billion kWh were consumed for lighting alone in manufacturing facilities, which was equal to
about 1.3% of total U.S. electricity consumption based to the study of Energy Information
Administration (EIA) in 2010. The light levels and visibility required within an area depends
on a number of factors, including the task performed, the age of the workers, and whether the
space is open or blocked. The more active the area the higher the light levels needed and the
lesser the activity the lower the light levels needed.
The use of LED technology in general lighting is a good option because of its
continuous improvements and advantages, including long lifetime, low power cost, the
physiological impact to the user, low light pollution and low carbon footprints. According to
the study, a LED circuit will approach 80% efficiency, which means 80% of the electrical
energy is converted to light energy. The remaining 20% is lost as heat energy. Compare that
with incandescent bulbs which operate at about 20% efficiency (80% of the electrical energy
is lost as heat). LEDs can emit a larger amount of light intensity than any other lamps.
Gradually, other lamps experience a gradual reduction in their light output. The more it is
used the more it fails to maintain its light output. LEDs do not fall to under this category of
lamps thus, it will still give a good measure of light intensity.
Nowadays, maintaining the desired amount of luminance needed for a certain area
and at the same time conserve electricity is very important. Sometimes for short visited areas
1
the light levels needed must be lower compared to the task performed areas. Also some
lighting fixtures does not give enough amount of illumination due to the wrong estimation of
the optimum height of mounting pole according to its luminosity. There is an on-going trend
of creating intelligent systems for every device at home and even at work area. Developing
an intelligent light controller in maintaining constant illumination levels based on ambient
light and pole height is the focus of this research. Integrating motion sensor in this research is
an add-on feature for security purposes.
The study aims to build an intelligent LED lamp with varying light intensity based on
ambient light and height of positioning with integrated motion sensor. In order to attain the
main objective, the following specific objectives are to be achieved: (1) To construct a LED
lamp control circuit with analog input control; (2) To build and calibrate an LDR sensor
using lux meter; (3) To program a microcontroller that will maintain the desired light
intensity with varying parameters: ambient light and height of positioning; (4) To integrate a
motion sensor that controls light intensity from normal to maximum as movement is detected
and lastly; (5) To test the overall functionality of the prototype.
By having an intelligent LED lamp it can adjust its output based on available ambient
light and its mounting position to provide a constant illumination level needed. And using
this technology, the user can choose the desired luminance level in the area and at the same
time helps not to waste consumption of electricity. It has also the ability to have an automatic
light dimmer in all areas as well as maintaining its light intensity at the same time.
This study is limited to be built a single system as a prototype and the maximum
rating of the LED lamp used is 30W that the lamp gives a light intensity of 50-100 lux. The
system can provide recommended light levels for short visited areas only. The height
2
adjustment of the intelligent LED lamp is limited only to 7ft and it can be plugged in 100240 VAC outlet only.
Chapter 2
REVIEW OF RELATED LITERATURE
2.1 LED Lamp
According to the paper by WU Yue, SHI Changhong, ZHANG Xianghong and
YANG Wei entitled Design of New Intelligent Street Light Control System, street lamps
control at most of the urban is only by manual control, a control switch set in each of the
street lamps, it is the so-called first generation of the original street light control, which is
inefficient and a waste of manpower, and cumbersome to operate street light opening and
closing time. Or using optical-control method, set up optical control circuit, change the
resistance by using of light-sensitive device to control street lamps light up automatically in
the evening after dark, turn off automatically after dawn in the morning, but the low
reliability of the method, vulnerable to interference, night street lighting is too bright and are
a waste of energy and other issues [1]. The other is time-control method (that is, from time to
time opening and closing control) [2], and time-optical-control [3] (that is, from time to time
with light intensity control). This three street light control method can be attributed to the
second generation of street light control. The second generation street light control method
achieved automatic control of street light, thereby reducing the labor intensity and lowering
labor costs and improving the efficiency of street lighting control. With the use of in-depth,
but it also exposed a problem that it cannot meet the needs of the growing street lamp
information and intelligent management. The time of lighting is not only lack of precision,
many street lights are controlled by using the mid-night lights strategy, energy-saving effect
is poor. In short, the current street lighting strategy is simple and crude, lack of humane care
of the car and human, cannot achieve the sleep and wake-up call of the lamps in time, but
some research for the city's festive lighting and landscaping is also rare. An urgent need to
4
voltages generated, which are measured by an on-board amplifier. When motion is detected
the PIR sensor outputs a high signal on its output pin, which can either be read by an MCU or
drive a transistor to switch a higher current load.
What is actually detected is the broken field for a normal temperature. The field
does not have to be broken by an object with a different temperature in order to register
change, as highly sensitive sensors will activate from the movement alone. Designed for use
at ambient temperatures of 15C to 20C, at higher temperatures the field of view narrows,
and if below 15C, the field of view widens and small or distant objects can activate the
sensor. For this reason, it is not recommended that the sensors be used in drafty
environments, near HVAC equipment, or facing windows where outside temperatures, or
even motion, can cause false readings.
Commonly used in security lighting and alarm systems in an indoor environment, PIR
sensors have a range of approximately 6 meters, depending on conditions. The sensor adjusts
to slowly changing conditions that occur normally within the environment, but shows a highoutput response when a sudden change takes place.
Generally speaking, PIR sensors are small, inexpensive, low power, rugged, have a
wide lens range, are easy to interface with, and are easy to use. Their best feature is that they
dont wear out. While they may be easy to use, they are also fairly complex, since many
variables that can change the sensors input and output must be considered.
The PIR sensor typically has two slots on it, each made of material sensitive to
infrared radiation. When idle, both slots detect the same amount of IR. When a person/animal
comes into their environment, one half will intercept the IR, causing a positive change
between the two halves. Once the entity passes through, there is a negative differential
change. It is these change pulses that are detected by the PIR sensor.
6
PIR sensors are most frequently found in motion detector devices aptly called passive
infrared detectors (PIDs). The PIR sensor in this case sits on a PCB that interprets signals
from the pyroelectric sensor chip. Focusing the infrared energy onto the surface of the sensor
is accomplished in two primary ways: (1) the window or cover of the PID has Fresnel lenses
molded into it that are used to gather light from a very wide field of view and focus it onto
the PIR sensor directly, or (2) the PID has segmented parabolic mirrors that focus the
infrared energy inside of it.
For example, the Zilog ZMOTION Detection module solution (Figures 2.1 and 2.2)
used for lighting control and other occupancy and proximity detection applications combines
the Z8FS040 motion detection microcontroller with a pyroelectric sensor and a low-profile
Fresnel lens.
Zilog
also
offers
detection
module
development
kit
designated
ZEPIR000102ZCOG.
An example of a PIR sensor used in alarm systems is the Parallax PIR sensor, a
pyroelectric device that detects motion by measuring changes in the infrared levels emitted
by surrounding objects (Figure 2.3). This motion can be detected by checking for a high
signal on a single I/O pin.
When the infrared energy focused on the sensor changes within a given time frame,
the relay is switched.
The internal mirrored segments, or Fresnel lenses, focus on the infrared energy
emitted by whatever intrudes on the field, and the intrusion causes a hot spot to move along
with the intrusion within the field. The hot spot de-energizes the relay and activates the
detection mechanism on the alarm panel. Again, care is typically taken to avoid drafty
HVAC vents or windows, or placement near windows where external elements can cause a
false alarm.
9
One solution, instead of having two detection zones, offers four. The Panasonic
NaPiOn pyroelectric sensor module is ideal for small movement detection based on a quadtype (Figure 2.4) pyroelectric element with four receptors. Since the detection zone within
the detection range is so precise, even small movements are detected. The lenses on this
device are miniaturized because the pyroelectric element is small, enabling the use of a short
focal point. This device detects small temperature differences between the detection target
and its surroundings, and the lowest required temperature difference in the background is
4C.
10
11
Light dependent resistors are a crucial part in any electric circuit which is to be turned
a off and on automatically in accordance to the level of ambient light for instance in night
security lighting or solar powered garden lights.
Light dependent resistors are usually used in circuits where it is necessary to detect
the presence or the level of light. They are commonly used in photographic light meters and
they are sensitive to light. This device is made from semiconductor materials like cadmium
sulfide. Light dependent resistors are used to re-charge a light during different changes in the
light or they are made to turn a light on during certain changes in lights. One of the most
common uses for light dependent resistors is in traffic lights.
12
To increase the dark resistance and therefore reduce the dark current, the resistive
path forms a zigzag pattern across the ceramic substrate. The CdS photocell is a very low
cost device often used in auto dimming, darkness or twilight detection for turning the street
lights ON and OFF, and for photographic exposure meter type applications.
One simple use of a Light Dependent Resistor, is as a light sensitive switch as shown
below.
circuit shown above has a fairly low sensitivity and its switching point may not be consistent
due to variations in either temperature or the supply voltage. A more sensitive precision light
activated circuit can be easily made by incorporating the LDR into a Wheatstone Bridge
arrangement and replacing the transistor with an Operational Amplifier as shown.
As with the previous circuit the output of the operational amplifier is used to control a
relay, which is protected by a free wheel diode, D1. When the light level sensed by the LDR
and its output voltage falls below the reference voltage set at V2 the output from the op-amp
changes state activating the relay and switching the connected load.
As likewise as the light level increases the output will switch back turning OFF the
relay. The hysteresis of the two switching points is set by the feedback resistor Rf can be
chosen to give any suitable voltage gain of the amplifier.
The operation of this type of light sensor circuit can also be reversed to switch the
relay ON when the light level exceeds the reference voltage level and vice versa by
reversing the positions of the light sensor LDR and the potentiometer VR1. The
potentiometer can be used to pre-set the switching point of the differential amplifier to any
particular light level making it ideal as a simple light sensor project circuit. [6]
A PWM circuit works by making a pulsating DC square wave with a variable on-tooff ratio. The average on time may be varied from 0 to 100 percent. In this way, a variable
16
amount of power is transferred to the load. The main advantage of a PWM circuit over a
resistive power controller is the efficiency. At a 50 percent level, the PWM will use about 50
percent of full power, almost all of which is transferred to the load. A resistive controller at
50 percent load power would consume about 71 percent of full power; 50 percent of the
power goes to the load, and the other 21 percent is wasted heating the dropping resistor. The
PWM circuit will typically waste well under 1 percent of the power, depending on the load
current. It takes a constant trickle of power to operate, so the efficiency improves with higher
power loads. [7]
According to the study of Djuro G. Zrilic entitled Alternative Approach to Use of
Pulse Width Modulation, a sampled converter amplifier, controlled by PWM, is shown in
Figure 2.10. The operation of this system is identical to the operation of the system in Figure
2.11. For small robot applications transistor is supplied with on-board batteries. The output of
the transistor has variable pulse width (Ton), which is rectified and then filtered to get nearly
DC voltage
proportional to the average value of the pulse-width wave. Should some variation in the load
cause the output to try to increase, the PWM will sense this and reduce the pulse width to the
switching transistor and thus, lower the output voltage to the load. Conversely, an increase in
voltage at the PWM input will cause the PWM to increase a pulse width out of the switch
transistor. This causes the voltage to rise to the load. Should some impulse noise appear at
the output of the comparator circuit, it will be eliminated by the sampled quantizer. In
addition, one of the benefits of a negative feedback is in the suppression of undesired noise
components. [8]
18
Figure 2.12: Illuminance Categories and Values for Generic Indoor Activities
Legends:
A-C for illuminances over a large area
D-F for localized tasks
G-I for extremely difficult visual tasks
19
20
Figure 2.14 Illumination Levels and Limiting Glare Indices for Various Functions
The table following lists illumination levels suitable for a range of situations: the
quality of these levels could be influenced by glare and an acceptable limiting index is also
shown. The glare index is calculated by considering the light source location, the luminances
of the source, the effect of surroundings and the size of the source. Glare indices for artificial
light range from about 10 for a shaded light fitting having low output to about 30 for an
unshaded lamp.
As seen from this illustration, various basic decisions have to be made concerning
lighting objectives and whether the system involves daylight, electric light or a combined
system. With electric or combined systems, further decisions must be taken concerning the
way light is distributed by particular fittings, and upon their positions relative to each other as
well as in relation to the surface to be illuminated. As with day lighting, light - colored and
21
highly reflective room surfaces help to provide more illumination from the same amount of
energy source it preserves the luminance effect of the light source. [10]
Figure 2.15: Different Location with Desired Illuminance level and Limiting Glare Index
22
Chapter 3
INTELLIGENT LED LAMP WITH VARYING LIGHT INTENSITY ACCORDING
TO AMBIENT LIGHT AND POLE HEIGHT WITH INTEGRATED MOTION
SENSOR
INTRODUCTION
One of the biggest expenditures nowadays is the use of lighting. According to a study
in 2009, 19% of the worlds electric consumption comes from lighting. In fact, about 52
billion kWh were consumed for lighting alone in manufacturing facilities, which was equal to
about 1.3% of total U.S. electricity consumption based to the study of Energy Information
Administration (EIA) in 2010. The light levels and visibility required within an area depends
on a number of factors, including the task performed, the age of the workers, and whether the
space is open or blocked. The more active the area the higher the light levels needed and the
lesser the activity the lower the light levels needed.
The use of LED technology in general lighting is a good option because of its
continuous improvements and advantages, including long lifetime, low power cost, the
physiological impact to the user, low light pollution and low carbon footprints. According to
the study, a LED circuit will approach 80% efficiency, which means 80% of the electrical
energy is converted to light energy. The remaining 20% is lost as heat energy. Compare that
with incandescent bulbs which operate at about 20% efficiency (80% of the electrical energy
is lost as heat). LEDs can emit a larger amount of light intensity than any other lamps.
Gradually, other lamps experience a gradual reduction in their light output. The more it is
used the more it fails to maintain its light output. LEDs do not fall to under this category of
lamps thus, it will still give a good measure of light intensity.
23
Nowadays, maintaining the desired amount of luminance needed for a certain area
and at the same time conserve electricity is very important. Sometimes for short visited areas
the light levels needed must be lower compared to the task performed areas. Also some
lighting fixtures does not give enough amount of illumination due to the wrong estimation of
the optimum height of mounting pole according to its luminosity. There is an on-going trend
of creating intelligent systems for every device at home and even at work area. Developing
an intelligent light controller in maintaining constant illumination levels based on ambient
light and pole height is the focus of this research. Integrating motion sensor in this research is
an add-on feature for security purposes.
The study aims to build an intelligent LED lamp with varying light intensity based on
ambient light and height of positioning with integrated motion sensor. In order to attain the
main objective, the following specific objectives are to be achieved: (1) To construct a LED
lamp control circuit with analog input control; (2) To build and calibrate an LDR sensor
using lux meter; (3) To program a microcontroller that will maintain the desired light
intensity with varying parameters: ambient light and height of positioning; (4) To integrate a
motion sensor that controls light intensity from normal to maximum as movement is detected
and lastly; (5) To test the overall functionality of the prototype.
By having an intelligent LED lamp it can adjust its output based on available ambient
light and its mounting position to provide a constant illumination level needed. And using
this technology, the user can choose the desired luminance level in the area and at the same
time helps not to waste consumption of electricity. It has also the ability to have an automatic
light dimmer in all areas as well as maintaining its light intensity at the same time.
This study is limited to be built a single system as a prototype and the maximum
rating of the LED lamp used is 30W that the lamp gives a light intensity of 50-100 lux. The
24
system can provide recommended light levels for short visited areas only. The height
adjustment of the intelligent LED lamp is limited only to 7ft and it can be plugged in 100240 VAC outlet only.
25
Start
Research about
Ambient Light Sensors
Experiments and Data
Gathering
Research about LED
Lamps
Microcontroller coding
Stop
Figure 3.1 Methodology Process of designing an intelligent LED Lamp with varying light
intensity according to ambient light and pole height with integrated motion sensor
As shown in Figure 3.1, the study will start on researching about ambient light
sensors, its operation, its components and designs. After that the group will research about
LED lamps, its types, understanding its ratings and technical specifications. Programming of
the microcontroller follows, motion detection system will be integrated to the input of the
microcontroller and driver to the LED lamp will be connected to the output. The study will
conduct experiments and data gathering that will determine the current supplied to the LED
lamp and its luminance level in lux. And lastly overall system test and comparison will be
performed to check the performance of the system.
26
Microcontroller Coding
27
Conceptual Diagram
Set
target
lux
Set Pole
Height
Ambient Light
Monitoring
Motion detection
Controls
LED Lamp
Driver
Circuit to
control Light
Intensity
28
Figure 3.3 shows the conceptual diagram of an intelligent LED lamp with varying
light intensity according to ambient light and its mounting height with integrated motion
sensor. Based from the conceptual diagram, the system will monitor the amount of ambient
light and as an add-on feature, the system also uses the signal of the motion sensor for
security purposes. The task of the microcontroller is to control the amount of current for the
LED driver circuit to control its light intensity. The height of the pole and the desired
luminance level will be chosen. An increase on ambient light detected means a decrease in
current output correspondingly to maintain luminance level. An increase in height of the
mounting pole of the LED lamp means an increase in current output correspondingly to
maintain luminance in an area. The integrated motion sensor aims to add security feature on
the system by maximizing the luminance level output of the led lamp as movement is
detected for a certain delay and then back to normal luminance level once there is no more
activity.
29
Objective 1: To construct a LED lamp control circuit with analog input control
Figure 3.5 Adjusting the power of the led lamp using the program
Figure 3.5 shows that the researchers program the microcontroller to control the
power supplied through the 30 watts LED Lamp. PWM ranges from 0-255, where 0 indicates
fully off, and 255 indicates fully on pulses. With the use of PWM the researchers can
30
generate an analog average voltage using the digital pulses. Duty cycle is expressed in
percent, a low duty cycle corresponds to a low power and 100% is being fully on. The
researchers will use a lux meter to measure the light intensity coming from the LED Lamp,
which located 2 feet above the ground.
PWM
Duty Cycle,
%
0
13
26
38
51
64
77
89
102
115
128
140
153
166
179
191
204
217
230
242
255
0
5
10
15
20
25
30
35
40
45
50
55
60
65
70
75
80
85
90
95
100
Lux Meter
Reading
Direct, Lux
0
41
94
139
183
196
276
297
314
327
337
344
351
357
359
359
359
359
359
359
359
Table 3.1 Lux intensity of the LED Lamp in varying its duty cycle.
Table 3.1 shows that when the power delivered to the led lamp is increased from 075%, the light intensity of the led lamp increases as well. But when it reaches 75-100% there
are minimal changes in the light intensity of the LED lamp. The researchers were able to
adjust the PWM value from 0-179 only. Making the researchers focus more on a much lesser
light intensity.
31
PC
Microcontro
ller
Output of
LED lamp
LDR
equivalent
ADC
reading
LCD display
Calibration is done by adjusting the power supplied to the LED lamp to vary its light
intensity using microcontroller PIC18F4520 as shown in Figure 3.7. The LDR and digital lux
meter Model1010B are both place equidistant (2ft above the ground) from the light source.
The power that is supplied to the led lamp is varied from 0-100 percent. For each setting, the
adc reading of the microcontroller is recorded.
32
The resistance of the Light Dependent Resistor (LDR) varies according to the amount
of light that falls on it. The relationship between the resistance LDR and light
intensity Lux for a typical LDR is
List of Materials
Pickit2
Pic18F4520
microcontroller
LX1010B
Typical LDR sensor
Functions
Program debugger
Controller
Digital Lux Meter
Ambient light
sensor
33
PWM
Duty Cycle
Light
intensity,
Lux
0
13
26
38
51
64
77
89
102
115
128
140
153
166
179
191
204
217
230
242
255
0
5
10
15
20
25
30
35
40
45
50
55
60
65
70
75
80
85
90
95
100
0
41
94
139
183
196
276
297
314
327
337
344
351
357
359
359
359
359
359
359
359
LDR, Vout
0
0.38
0.79
1.09
1.34
1.41
1.78
1.86
1.93
1.98
2.01
2.04
2.06
2.08
2.09
2.09
2.09
2.09
2.09
2.09
2.09
LDR
Resistance,
Kohm
12.20
5.32
3.60
2.73
2.55
1.81
1.68
1.59
1.53
1.48
1.45
1.42
1.40
1.39
1.39
1.39
1.39
1.39
1.39
1.39
34
ADC
Reading
0
78
162
223
275
289
364
382
395
405
413
418
423
427
428
428
428
428
428
428
428
35
In Table 3.3 show the response of the ldr as the light changes. In Figure 3.10, the
researchers observe that as the ambient light increases the ldr resistance decreases. The light
intensity sensed by the LDR and its resistance is inversely proportional. The output voltage
of the LDR was calculated by using the voltage divider formula. The researchers noticed that
whenever the LDR detects a strong light intensity it produces more voltage. Figure 3.11
shows that output voltage of the LDR is directly proportional to the light intensity detected
by the LDR. The LDR adc reading which is reflected to the microcontroller increases as well
as the light intensity detected also increases.
36
Objective 3: To program a microcontroller that will maintain the desired light intensity with
varying parameters: ambient light and height of positioning.
Flowchart
Start
No
Yes
Stop
Figure 3.13 Program process in change ambient light and height of positioning of the led
lamp
In creating the program of the system, the researchers used two LDRs, with same
specifications, LDR2 is located below the LED lamp (2 ft above the ground), and LDR 1 is
located on the top of the LED lamp, LDR2 will serve as the guide to the researchers if the
desired lux will be met.
37
Procedure
The prototype will be places in a dark area which the lux meter reading of the area
itself is 0 lux. The researchers will use a dimmer switch to control the 150 watts halogen
lamp which will serve as a varying ambient light located 2 ft above the LDR sensor and
digital lux meter (Figure 3.14). The researchers decided the height of 5 ft. to be the basis on
the varying light source case then the researchers will choose the maintaining lux of the area
from 50, 75, or 100. The researchers will vary the light intensity of the ambient light. The
ADC reading of the program along with the percentage duty cycle of the lamp will be
displayed in the LCD. The light intensity of the LED lamp will also be measured at a height
2ft above the ground in two different points, one that is directly below the lamp and the other
38
at a distance to the first point that the ambient light and LED lamp light intensity will add up.
The researchers tested that the second point is 12 inches away from the first point in the
height of 5 ft. (Figure 3.15). After obtaining the lux reading, the digital multimeter will
measure the output current and output voltage from the LED lamp.
Varying Light
Source
(Ambient
Light), Lux
0
16
32
48
64
80
96
112
128
144
160
176
192
208
224
240
256
272
288
304
320
Output
Voltage, V
Output current
of the LED
Lamp, A
4.6
4.41
3.17
3.09
2.6
2.47
2.44
2.4
2.15
1.93
1.91
1.84
1.84
1.87
1.85
1.76
1.76
1.05
0.98
0.3
0
0.51
0.45
0.37
0.35
0.3
0.27
0.25
0.21
0.21
0.18
0.14
0.12
0.11
0.11
0.11
0.04
0.04
0.03
0.02
0.01
0
39
Varying Light
Source
(Ambient
Light), Lux
0
24
48
72
96
120
144
168
192
216
240
264
288
312
336
360
384
408
432
456
480
Output
Voltage, V
Output current
of the LED
Lamp, A
5.36
5.25
5.08
4.63
3.8
3.33
3.33
3.3
2.97
2.47
2.42
1.95
1.91
1.85
1.85
1.79
1.79
1.76
1.06
0.81
0
0.7
0.63
0.53
0.5
0.44
0.35
0.35
0.31
0.27
0.22
0.18
0.17
0.17
0.12
0.12
0.08
0.08
0.04
0.02
0.01
0
Output Voltage,
V
Output current
of the LED
Lamp, A
0
34
68
102
136
170
204
238
272
306
340
374
408
442
476
510
544
578
612
646
680
6.9
5.28
5.32
5.16
4.55
3.3
3.78
3.18
2.89
2.8
2.47
2.04
1.94
1.59
1.64
1.03
0.98
0.68
0.35
0.35
0
0.92
0.78
0.66
0.57
0.49
0.44
0.4
0.32
0.27
0.22
0.22
0.17
0.17
0.13
0.13
0.07
0.07
0.03
0.01
0.01
0
The data in Table 3.4 show that when the ambient light source is set to 0 lux the
output current obtained was 0.51 A, increasing the ambient light source into 16 lux the output
current obtained was 0.45 A, increasing it again into 32 lux the output current gives 0.37 A.
Table 3.4, Table 3.5 and Table 3.6 show that there was a decrease in output current obtained
when the light source was increased. Noticed that the maximum current in every table is
different, the maximum current recorded is in Table 3.6 which has a maintaining lux of 100
is 0.92 A and the minimum current recorded is in Table 3.4 which has the maintaining lux of
only 50 is 0.51 A. It is because the higher the light intensity needed the more current the
system must produces to give the desired light intensity in the area. Figure 3.16, Figure 3.17
and Figure 3.18 shows the graph of voltage and current at different maintaining lux at 5 ft
high.
Varying Light
Source
(Ambient
Light), Lux
0
16
32
48
64
80
96
112
128
144
160
176
192
208
224
240
256
272
288
304
320
Lux meter
reading with
ambient light Indirect, Lux
62
53
45
43
33
32
30
23
23
21
16
14
12
12
11
5
4
4
3
2
1
51
50
50
50
52
52
51
52
50
52
50
50
50
51
51
51
52
52
53
53
53
41
Varying Light
Source
(Ambient
Light), Lux
0
24
48
72
96
120
144
168
192
216
240
264
288
312
336
360
384
408
432
456
480
LED Lamp
Lux meter
reading -Direct,
Lux
93
84
70
57
55
45
44
38
33
28
21
20
19
15
15
12
11
8
5
5
4
Lux meter
reading with
ambient light Indirect, Lux
75
75
75
75
75
75
76
76
76
76
75
75
75
75
75
74
74
74
74
75
75
Lux meter
reading with
ambient light Indirect, Lux
0
34
68
102
136
170
204
238
272
306
340
374
408
442
476
510
544
578
612
646
680
123
103
88
76
62
56
48
41
34
28
28
20
20
17
17
11
11
8
6
6
0
100
99
98
98
98
98
98
98
97
98
98
99
99
99
99
99
99
99
100
100
100
In Table 3.7, Table 3.8 and Table 3.9 show that the power which is supplied to the led
lamp which is reflected as (direct) light intensity of the LED lamp decreases when the
ambient light increases. The lux meter reading (direct) is the measure of the light intensity of
the LED lamp only in lux. Noticed that as the ambient light increases the program will
automatically lessen the percentage duty cycle of the led lamp to reduce its light intensity as
shown in Figure 3.19, Figure 3.20 and Figure 3.21. Indirect lux meter reading is the measure
of light intensity of both the led lamp and ambient light. Figure 3.19, Figure 3.20 and figure
3.21 also shows the graph of the indirect lux reading which the lux meter both reads the
ambient light and the light intensity of the led lamp. The data show that luminance in the area
is maintained though ambient light varies. Also noticed that in Table 3.9, the maximum
direct light intensity is higher which has 123 lux compare to Table 3.7 and Table 3.8 with
maximum direct light intensity of 62 and 93 lux respectively. It is because of the desired lux
selected, if the user selected a higher desired lux of the area, LED lamp must produce more
light intensity compare to the lower desired light intensity.
43
44
Procedure
The prototype will be placed in a dark area which the lux meter reading of the area
itself is 0 lux. The researchers will use a dimmer switch to control the 150 watts halogen
lamp which will serve as a varying ambient located 2 ft above the LDR sensor and digital lux
meter. The researchers will set and adjust the pole height ranging from 5ft 7ft with an
interval of 1 ft. (Figure 3.24). The researchers will vary the pole height at different lux meter
reading of the halogen light source. The adc reading will be displayed in the LCD. The light
intensity of the LED lamp will also be measured at a height 2ft above the ground in two
different points, one that is directly below the lamp and the other at a distance to the first
point that the ambient light and LED lamp light intensity will add up. The researchers tested
that the second point is 12 inches away from the first point in the height of 5 feet (Figure
3.15), 15inches in the height of 6 feet (Figure 3.22), and 18 inches in the height of 7 feet
(Figure 3.23). After obtaining the lux reading, the digital multimeter will measure the output
current and output voltage from the LED lamp.
45
Varying Light
Source
(Ambient
Light), Lux
0
16
32
48
64
80
96
112
128
144
160
176
192
208
224
240
256
272
288
304
320
Varying Light
Source
(Ambient
Light), Lux
0
14
28
42
56
70
84
98
112
126
140
154
168
182
196
210
224
238
252
280
320
Output current
of the LED
Lamp, A
0.81
0.74
0.62
0.59
0.5
0.46
0.43
0.36
0.32
0.3
0.25
0.25
0.18
0.14
0.14
0.11
0.11
0.07
0.03
0.02
0
Output current
of the LED
Lamp, A
1.23
1.04
0.91
0.8
0.68
0.63
0.56
0.5
0.44
0.44
0.31
0.31
0.31
0.23
0.22
0.15
0.11
0.11
0.11
0.04
0
46
Figure 3.25 show that the current obtained in 7 feet is higher than in the current
obtained in 6 feet and in 5 feet. It is because when the mounting height of the led lamp goes
higher, to be able the led lamp to maintain the desired 50 lux, the system must produce more
current to be able to meet the selected desired lux in the area.
Varying Light
Source
(Ambient
Light), Lux
0
20
40
60
80
100
120
140
160
180
200
220
240
260
280
300
320
340
360
400
480
Varying Light
Source
(Ambient
Light), Lux
0
23
46
69
92
115
138
161
184
207
230
253
276
299
322
345
368
391
414
450
480
Output current
of the LED
Lamp, A
1.2
1.01
0.88
0.77
0.66
0.61
0.54
0.49
0.44
0.37
0.3
0.3
0.23
0.23
0.17
0.17
0.11
0.11
0.03
0.02
0
Output current
of the LED
Lamp, A
2.09
1.79
1.39
1.12
1.02
0.87
0.73
0.64
0.55
0.55
0.46
0.37
0.37
0.27
0.27
0.17
0.17
0.17
0.15
0.07
0
Figure 3.26 show that the current obtained in 7 ft is higher than in 6 feet and 5 feet.
The maximum current obtained when the led lamp is at 7 feet high is 2.09 A (Table 3.13), at
6 feet high is 1.2 A (Table 3.12) and at 5 ft high is 0.7 A (Table 3.5). When the height of the
led lamp increases the current must be increases as well to maintain the desired light intensity
of 75 lux.
Varying Light
Source
(Ambient
Light), Lux
0
28
56
84
112
140
168
196
224
252
280
308
336
364
392
420
448
476
504
550
680
Varying Light
Source
(Ambient
Light), Lux
0
29
58
87
116
145
174
203
232
261
290
319
348
377
406
435
464
493
522
580
680
Output current
of the LED
Lamp, A
1.84
1.4
1.07
0.97
0.82
0.66
0.59
0.59
0.43
0.43
0.32
0.32
0.25
0.25
0.14
0.14
0.07
0.07
0.07
0.07
0
Output current
of the LED
Lamp, A
2.1
2.1
2.11
1.48
1.31
1.18
1.02
0.73
0.73
0.72
0.59
0.59
0.45
0.45
0.3
0.3
0.3
0.13
0.13
0.07
0
Figure 3.27 show that the current obtained in 7 ft is higher than in 6 feet and 5 feet.
The maximum current obtained when the led lamp is at 7 feet high is 2.10 A (Table 3.15), at
6 feet high is 1.84 A (Table 3.14) and at 5 ft high is 0.92 A (Table 3.6). When the height of
the led lamp increases the current must be increases as well to maintain the desired light
intensity of 100 lux.
Varying Light
Source
(Ambient
Light), Lux
0
13
26
39
52
65
78
91
104
117
130
143
156
169
182
195
208
221
234
250
320
Lux meter
reading with
ambient light Indirect, Lux
63
58
49
47
37
33
32
27
24
20
19
19
13
10
10
8
8
6
3
2
1
51
50
50
50
50
50
50
50
50
49
49
50
50
51
51
51
51
51
51
52
52
49
Varying Light
Source
(Ambient
Light), Lux
LED Lamp
Lux meter
reading Direct, Lux
0
14
28
42
56
70
84
98
112
126
140
154
168
182
196
210
224
238
252
280
320
61
54
50
41
35
32
29
25
22
22
15
15
15
12
12
9
6
6
6
3
1
Lux meter
reading with
ambient light Indirect, Lux
51
51
50
50
50
49
49
48
48
49
49
50
50
50
50
50
51
51
51
51
51
50
Conclusion
The systems were able to adjust the current that passes through the led lamp as the
pole height increases. Therefore the system can be able to maintain the selected desired lux in
the area. Also the led lamp turns off when there is much ambient light.
51
Objective 4: To integrate a motion sensor that controls light intensity from normal to
maximum as movement is detected.
Flowchart
Figure 3.30 shows that as movement is detected maximum duty cycle of the led lamp
will be produced and after a 10 seconds delay if there is no movement detected the system
will go back to its original state (normal condition).
52
Procedure
The prototype will be placed in a dark area which the lux meter reading of the area
itself is 0 lux. The researchers will monitor the parameters after the motion sensor is
triggered. The digital multimeter will measure the output current and output voltage of the
LED lamp. The light intensity of the LED lamp will be measured at a height 2ft above the
ground which is located the same position when measuring the (indirect) lux meter reading.
53
Motion
Sensor
Detection
Lux
meter
reading
Indirect,
Lux
51
Output Output
Voltage, current,
V
A
4.6
Motion
Sensor
Detection
Lux meter
reading
Indirect,
Lux
Output
Voltage,
V
Output
current,
A
51
6.6
0.81
99
7.47
1.84
0.51
100
6.9
0.92
1
Table 3.18 Motion Detection at desired
50
lux at 5 ft high.
Motion
Sensor
Detection
Lux meter
reading
Indirect,
Lux
Output
Voltage,
V
Output
current,
A
51
7.33
1.23
100
9.91
2.1
1
Table 3.20 Motion Detection at desired 50 lux at 7 ft high.
54
Motion
Sensor
Detection
Lux
meter
reading
Indirect,
Lux
75
5.36
0.7
100
6.9
0.92
Output Output
Voltage, current,
V
A
Motion
Sensor
Detection
Lux
meter
reading
Indirect,
Lux
0
1
75
99
Motion
Sensor
Detection
Output Output
Voltage, current,
V
A
7.28
7.47
1.2
1.84
Lux meter
reading
Indirect,
Lux
Output
Voltage,
V
Output
current,
A
76
7.51
2.09
0
100
9.91
2.1
1
Table 3.23 Motion Detection at desired 75 lux at 7 ft high.
Note:
0 without detection
1- with detection
Conclusion
The researchers were able to integrate a motion sensor that controls light intensity
from normal to maximum as movement is detected. The system were able to maximize the
luminance level output of the led lamp as movement is detected for a certain delay (10 sec)
and then back to normal luminance level once there is no more activity.
56
Trials
10
Motion
Sensor
Detected
Lux meter
reading
(Indirect)
Output
current
without person
49
0.50
with person
97
0.90
without person
48
0.50
with person
98
0.90
without person
49
0.50
with person
97
0.90
without person
49
0.50
with person
97
0.90
without person
49
0.50
with person
97
0.90
without person
49
0.50
with person
97
0.90
without person
48
0.50
with person
97
0.90
without person
48
0.50
with person
97
0.90
without person
48
0.50
with person
97
0.91
without person
48
0.50
with person
97
Trials
10
0.91
Motion Sensor
Detected
Output
current
without person
52
0.80
with person
100
1.78
without person
52
0.80
with person
100
1.78
without person
51
0.80
with person
100
1.79
without person
52
0.80
with person
100
1.79
without person
52
0.80
with person
101
1.79
without person
51
0.80
with person
101
1.79
without person
52
0.80
with person
101
1.80
without person
52
0.80
with person
101
1.80
without person
51
0.80
with person
101
1.80
without person
51
0.80
with person
101
1.80
57
Trials
1
2
3
4
5
6
7
8
9
10
Output current
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
51
103
50
102
50
103
50
103
50
103
50
103
50
103
50
103
50
103
50
102
1.25
2.07
1.25
2.07
1.25
2.07
1.25
2.07
1.25
2.07
1.25
2.07
1.25
2.07
1.25
2.07
1.25
2.07
1.25
2.07
Table 3.26: 7 o'clock in the evening at a height of 7ft and maintaining at 50 lux
The data from Table 3.24, shows that when there is no detection or without person the
lux meter reading obtained was 49 lux in trial 1at 5 ft with a maintaining desired lux at 50
while the output current obtained was 0.50, noticed that the lux meter reading and output
current retain until 10 trials. Meanwhile, when there is detection or with person the lux meter
reading obtained was 97 lux at its maximum condition of 100 lux and the output current was
0.90, it also noticed that the lux meter reading and output current retain until 10 trials. When
the pole height varies and repeating the same procedure with the same desired lux, it can be
observed that the output current increase as shown in Table 3.25 and Table 3.26, because
when the pole height vary the output current increase to maintain the desired lux level. The
motion sensor is add one feature for security purposes when there is a detection or with
person.
58
Chapter 4
CONCLUSION
The researchers were able to create an intelligent LED Lamp with varying light
intensity according to ambient light and pole height with integrated motion sensor by
creating a LED Lamp control circuit with analog input control, calibrating LDR sensor using
lux meter, constructing a program using PIC18F4520 as the microcontroller that will
maintain the desired lux selected, integrating a PIR as a motion sensor that controls light
intensity from normal to maximum when movement is detected and lastly, testing the overall
functionality of the prototype. After the prototype had been completed and the necessary data
and parameters are gathered, the researchers had proven that it is possible to maintain the
desired lux intensity of the area as the ambient light and the pole height varies. When the
ambient light increases the output current obtained is decreasing thus, it can be concluded
that it conserve energy. The system has an add-on feature that also uses the signal of the
motion sensor for security purposes.
59
Chapter 5
RECOMMENDATION
The researchers recommend that it can be used in an area which are more recently
visited and needs a higher amount of intensity. It is furthermore recommended to consider
the use of a double/multiple LED lamp instead of single LED lamp and a higher wattage of
the LED lamp must be used, but it must consider the effect of varying ambient light to
maintain the desired light of the area. The system must use a protection for its electric
wirings and microcontroller because these components are sensitive. The area of installation
must be free from wet and moist. It is recommended to extend its pole height to be more
flexible in many place and integrate a height sensor in the system that will automatically
detects its mounting height. Also the researchers recommend to use a numeric keypad in
selecting the desired lux. If the height of the pole has reach its limit a warning indicator must
be integrate to the system. It is also required that the system must be free from abrupt
increase in temperature. This can cause the LED lamp to blow up. A suitable shielding must
be installed in the LED lamp in able to prevent accidents.
60
REFERENCES
[1] LIU Lianhao, A new street lamp controller design (J). Computing Technology and
Automation, 1997, (4):61-63
[2] ZHANG Liqun, Single-chip single board controller from time to time in the street lamp
factory control (J). Application of Energy Technologies, 1998, (4):33-34
[3] YU Xiao-xiang, HUANG Pei-wei. Intelligent Road Lamp Control System Based on
Lonworks(J).Computer Technology and Development, 2007,(2):99-102
[4] Digi-Key Corporation Site by Carolyn Mathas. Last updated 28th June 2014, 2012
[5] Jacob Millman Christos C. Halkias.: Electronic Devices And Circuits, Tata McGrawHill Publishing Company Ltd. Sep, 2003.
[6] Basic Electronics Tutorials Site by Wayne Storr. Last updated 5th March 2014,1999
2014.
[7] G. Forrest Cook: Pulse Width Modulator for 12 and 24 Volt Applications, Carnegie Dr.
Boulder, 2000
[8] Djuro G. Zrilic: Alternative Approach To Use Of Pulse Width Modulation, World
Automation Congress (WAC) 2006, July 24-26
[9] LED Lighting Management Company Catalog. 2014.
[10] Lighting Levels Site by the University of Wolverhampton. 2014.
61
APPENDICES
62
APPENDIX A
Specification of PIR Sensor
GH-718C Specifications
Input Voltage: DC 4.5-20V
Static current: 50uA
Output signal: 0 - 3V (Output high when motion
detected)
Sentry Angle: 110 degree
Sentry Distance: max 7 m
Shunt for setting override trigger: L - No (Default)
Terminals:
(+) : +4.5- 20VDC Power in
OUT : TTL Compatible Digital Output
(-) : GND
63
APPENDIX B
Program of the PIC Microcontroller
Declare
LCD_RSPIN PORTD.0
'PORTD.0
'D5
Declare
LCD_ENPIN PORTD.1
'PORTD.1
'D6
Declare LCD_LINES
2
Declare LCD_INTERFACE 4
Device 18F4520
Declare XTAL 20
Declare WATCHDOG = OFF
Declare FSR_CONTEXT_SAVE = On
Declare ADIN_RES
10
Declare ADIN_TAD
32_FOSC
Declare ADIN_STIME
50
'All_Digital=TRUE
REMARKS On
Symbol PBtn1=PORTB.1
Symbol PBtn2=PORTB.2
Symbol PBtn3=PORTB.3
Symbol PBtn4=PORTD.3
Symbol PBtn5=PORTB.5
Symbol PBtn6=PORTD.2
On_Interrupt myTimerInterrupt
Symbol T0IF = INTCON.2 ' TMR0
Overflow Interrupt Flag
Symbol T0IE = INTCON.5 ' TMR0
Overflow Interrupt Enable
Symbol GIE = INTCON.7 ' Global
Interrupt Enable
'Hserial_Baud = 9600
'Hserial_RCSTA = %10010000
'Hserial_TXSTA = %00100100
'Hserial_Clear = On
'ANALOG Setting
ADCON1=%00001101
ADCON2.7=1
Dim TempAvg As Word
Dim ictr As Byte
Dim LdrAdc As Word
Dim LdrAdc2 As Word
Dim IRAdc As Word
Declare
LCD_DTPIN
'PORTC.0
'D4
PORTD.4
66
TRISA=$FF
TRISB=$2F
TRISC=$80
TRISD=$0C
TRISE=$03
If T0IF=1 Then
'sdelay=sdelay + 1
PORTA=$FF
PORTB=$2F
PORTC=$80
PORTD=$0C
TRISE=$03
smin=0
ssec=0
shr=0
myCtr=0
IrFlg=0
IRAdc=0
LdrAdc=0
LdrAdc2=0
TempAvg=0
dflg=0
ictr=0
RefID=0
MaxAdc=0
LuxVal=0
sdelay=0
RefID=0
T0IE=0
GIE=0
ssec=ssec + 1
smin=0
shr=shr + 1
While 1=1
EndIf
'Select Feet Reference
If PBtn5=0 Then 'switch 1
DelayMS 200
While PBtn5=0
Wend
DelayMS 300
RefID=7
Break
ElseIf PBtn4=0 Then 'switch 2
DelayMS 200
While PBtn4=0
Wend
DelayMS 300
RefID=6
Break
ElseIf PBtn6=0 Then 'switch 3
DelayMS 200
While PBtn6=0
Wend
DelayMS 300
RefID=5
Break
EndIf
EndIf
'Print At 2,1,Dec2 shr,":",Dec2
smin,":",Dec2 ssec
Else
myCtr=myCtr + 1
'Print At 2,1,Dec2 shr,":",Dec2
smin,":",Dec2 ssec
EndIf
T0IF=0
EndIf
Context Restore
End If
';----------- END OF INTERRUPT
SERVICE ROUTINE----------
Main_Prog:
Cls
'PRINT AT 1,1,"STATE"
'WHILE 1=1
' Print At 2,1,Dec2 PBtn4
' PRINT AT 3,1,DEC2 PBtn5
' Print At 4,1,Dec2 PBtn6
' DELAYMS 500
'WEND
Wend
Sub_LuxRef:
LuxVal=0
DelayMS 1500
RefID=0
Print At 1,1,"Select Reference"
Print At 2,1,"Switch #1:7Ft"
Print At 3,1,"Switch #2:6Ft"
Print At 4,1,"Switch #3:5Ft"
Cls
Select Case RefID 'at 7 feet
Case 7
Print At 1,1,"Select Lux at 7 Feet"
68
LuxID=2
End If
If PBtn6=0 Then
DelayMS 200
While PBtn6=0
Wend
DelayMS 200
MaxAdc=136
LuxVal=100
LuxID=3
End If
EndSelect
While 1=1
'switch 3
'at 7 feet
'switch 2
69
If PBtn4=0 Then
DelayMS 200
While PBtn4=0
Wend
DelayMS 200
MaxAdc=107
LuxVal=75
LuxID=2
End If
'switch 2
If PBtn6=0 Then
DelayMS 200
While PBtn6=0
Wend
DelayMS 200
MaxAdc=128
LuxVal=100
LuxID=3
End If
'switch 3
Case 5
End If
'switch 2
If PBtn6=0 Then
DelayMS 200
While PBtn6=0
Wend
DelayMS 200
MaxAdc=142
LuxVal=100
LuxID=3
End If
'switch 3
Wend
GetADC:
If LuxVal < 5 Then
GoTo Main_Prog
End If
Cls
TempAvg=0
LdrAdc=0
LdrAdc2=0
IRAdc=0
IrFlg=0
dflg=0
T0IE=1
GIE=1
While 1=1
'Get IRADC
'IRAdc=ADIn 2
'If IRAdc >=675 Then
If PORTA.2=1 Then
If dflg=0 Then
dflg=1
ElseIf dflg=1 Then
IrFlg=1
smin=0
ssec=0
shr=0
myCtr=0
End If
End Select
If MaxAdc > 0 Then
Cls
Print At 1,1,"MaxAdc:",DEC4
MaxAdc
Print At 2,1,"Ref #:",DEC2 RefID, "
ft."
Print At 3,1,"at Lux:",DEC3 LuxVal
Print At 4,1,"loading wait..."
DelayMS 2000
GoTo GetADC
End If
'Get LDRADC
While GIE > 0
T0IE=0
GIE=0
70
Wend
EndSelect
For ictr=1 To 200
LdrAdc=ADIn 5
TempAvg=TempAvg + LdrAdc
Next ictr
GoSub RefSevenFt
GoSub SetPWM
GoSub DisplayData
LdrAdc=TempAvg / 200
Case 6
Case 1
'at lux 50
Case 7
Select Case LuxID
Case 1
'at lux 50
GoSub RefSixFt
GoSub SetPWM
GoSub DisplayData
71
Case 5
SetPWM:
'MOTION DETECTION
If IrFlg=1 Then
'at lux 50
Select Case RefID
Case 7 'at 7 feet
If LuxID=1 Then 'at 50 lux
DutyCycle=160
Percentage=100
ElseIf LuxID=2 Then 'at 75 lux
DutyCycle=160
Percentage=100
ElseIf LuxID=3 Then 'at 100 lux
DutyCycle=160
Percentage=100
End If
Case 6 'at 6 feet
If LuxID=1 Then 'at 50 lux
DutyCycle=91
Percentage=100
ElseIf LuxID=2 Then 'at 75 lux
DutyCycle=91
Percentage=100
ElseIf LuxID=3 Then 'at 100 lux
DutyCycle=91
Percentage=100
End If
EndSelect
GoSub RefFiveFt
GoSub SetPWM
GoSub DisplayData
EndSelect
EndSelect
End If
'Hardware Pwm
HPWM 1 ,DutyCycle,myFrequency
Wend
72
Percentage=0
Case 1 To 3
DutyCycle=3
Percentage=5
Case 4 To 11
DutyCycle=7
Percentage=10
Case 8 To 15
DutyCycle=10
Percentage=15
Case 16 To 21
DutyCycle=13
Percentage=20
Case 22 To 29
DutyCycle=17
Percentage=25
Case 30 To 33
DutyCycle=20
Percentage=30
Case 34 To 39
DutyCycle=23
Percentage=35
Case 40 To 44
DutyCycle=27
Percentage=40
Case 45 To 50
DutyCycle=30
Percentage=45
Case 51 To 54
DutyCycle=34
Percentage=50
Case 55 To 58
DutyCycle=37
Percentage=55
Case 59 To 62
DutyCycle=40
Percentage=60
Case 63 To 64
DutyCycle=44
Percentage=65
Case 65 To 68
DutyCycle=47
Percentage=70
Case 69 To 70
DutyCycle=50
Percentage=75
Return
'Display Data LCD
DisplayData:
If sdelay >=50 Then
Print At 1,1,"Ldr1:",DEC4 LdrAdc, "
PP:",DEC3 Percentage,"%"
'Print At 2,1,"Pwm:",Dec3 DutyCycle, "
Lux:",Dec3 LuxM
Print At 2,1,"Pwm:",DEC3 DutyCycle,
" Ldr2:",DEC3 LdrAdc2," "
Print At 3,1,"Ft:",DEC2 RefID , "
Lux:",DEC3 LuxVal,"
"
Print At 4,1,"Motion:",DEC2 IrFlg,
"Sec:",DEC2 ssec
sdelay=0
Else
sdelay=sdelay + 1
Print At 4,1,"Motion:",DEC2 IrFlg,
"Sec:",DEC2 ssec
End If
LdrAdc=0
LdrAdc2=0
TempAvg=0
While GIE =0
GIE=1
T0IE=1
Wend
Return
'-------------SEVEN FEET --------------RefSevenFt:
If LuxID=1 Then 'at lux 50
Select Case LdrAdc2
Case 0
DutyCycle=0
73
Case 71 To 74
DutyCycle=54
Percentage=80
Case 75 To 78
DutyCycle=57
Percentage=85
Case 79 To 80
DutyCycle=60
Percentage=90
Case 81 To 82
DutyCycle=64
Percentage=95
Case 83 To 85
DutyCycle=67
Percentage=100
EndSelect
Percentage=40
Case 63 To 66
DutyCycle=45
Percentage=45
Case 67 To 72
DutyCycle=51
Percentage=50
Case 73 To 76
DutyCycle=56
Percentage=55
Case 77 To 82
DutyCycle=61
Percentage=60
Case 83 To 87
DutyCycle=66
Percentage=65
Case 88 To 91
DutyCycle=72
Percentage=70
Case 92 To 93
DutyCycle=76
Percentage=75
Case 94 To 99
DutyCycle=81
Percentage=80
Case 100 To 101
DutyCycle=86
Percentage=85
Case 102 To 103
DutyCycle=91
Percentage=90
Case 104 To 109
DutyCycle=96
Percentage=95
Case 110 To 115
DutyCycle=101
Percentage=100
EndSelect
DutyCycle=8
Percentage=5
Case 12 To 25
DutyCycle=16
Percentage=10
Case 26 To 37
DutyCycle=24
Percentage=15
Case 38 To 50
DutyCycle=32
Percentage=20
Case 51 To 62
DutyCycle=40
Percentage=25
Case 63 To 68
DutyCycle=48
Percentage=30
Case 69 To 76
DutyCycle=56
Percentage=35
Case 77 To 82
DutyCycle=64
Percentage=40
Case 83 To 89
DutyCycle=72
Percentage=45
Case 90 To 97
DutyCycle=80
Percentage=50
Case 98 To 101
DutyCycle=88
Percentage=55
Case 102 To 107
DutyCycle=96
Percentage=60
Case 108 To 113
DutyCycle=104
Percentage=65
Case 114 To 119
DutyCycle=112
Percentage=70
Case 120 To 123
DutyCycle=120
Percentage=75
Case 124 To 125
DutyCycle=128
Percentage=80
Case 126 To 130
DutyCycle=136
Percentage=85
Case 131 To 132
DutyCycle=144
Percentage=90
Case 133 To 134
DutyCycle=152
Percentage=95
Case 135 To 136
DutyCycle=160
Percentage=100
EndSelect
End If
Return
'-------------END OF SEVEN FEET -------------'-------------SIX FEET --------------RefSixFt:
If LuxID=1 Then 'at lux 50
Select Case LdrAdc2
Case 0
DutyCycle=0
Percentage=0
Case 1 To 3
DutyCycle=2
Percentage=5
Case 4 To 7
DutyCycle=5
Percentage=10
Case 8 To 13
DutyCycle=7
Percentage=15
Case 14 To 19
DutyCycle=9
Percentage=20
Case 20 To 23
DutyCycle=11
Percentage=25
75
Case 24 To 31
DutyCycle=14
Percentage=30
Case 32 To 35
DutyCycle=16
Percentage=35
Case 36 To 41
DutyCycle=18
Percentage=40
Case 42 To 44
DutyCycle=20
Percentage=45
Case 45 To 50
DutyCycle=23
Percentage=50
Case 51 To 52
DutyCycle=25
Percentage=55
Case 53 To 56
DutyCycle=27
Percentage=60
Case 57 To 60
DutyCycle=29
Percentage=65
Case 61 To 66
DutyCycle=32
Percentage=70
Case 67 To 68
DutyCycle=34
Percentage=75
Case 69 To 72
DutyCycle=36
Percentage=80
Case 73 To 74
DutyCycle=38
Percentage=85
Case 75 To 78
DutyCycle=41
Percentage=90
Case 79 To 80
DutyCycle=43
Percentage=95
Case 81 To 82
DutyCycle=45
Percentage=100
EndSelect
Case 81 To 85
DutyCycle=46
Percentage=70
Case 86 To 89
DutyCycle=49
Percentage=75
Case 90 To 93
DutyCycle=52
Percentage=80
Case 94 To 97
DutyCycle=55
Percentage=85
Case 98 To 101
DutyCycle=59
Percentage=90
Case 102 To 105
DutyCycle=62
Percentage=95
Case 106 To 107
DutyCycle=65
Percentage=100
EndSelect
Percentage=30
Case 57 To 66
DutyCycle=32
Percentage=35
Case 67 To 72
DutyCycle=36
Percentage=40
Case 73 To 78
DutyCycle=41
Percentage=45
Case 79 To 85
DutyCycle=46
Percentage=50
Case 86 To 89
DutyCycle=50
Percentage=55
Case 90 To 97
DutyCycle=55
Percentage=60
Case 98 To 101
DutyCycle=59
Percentage=65
Case 102 To 105
DutyCycle=64
Percentage=70
Case 106 To 109
DutyCycle=68
Percentage=75
Case 110 To 113
DutyCycle=73
Percentage=80
Case 114 To 117
DutyCycle=77
Percentage=85
Case 118 To 123
DutyCycle=82
Percentage=90
Case 124 To 125
DutyCycle=86
Percentage=95
Case 126 To 128
DutyCycle=91
Percentage=100
EndSelect
End If
77
DutyCycle=16
Percentage=60
Case 59 To 64
DutyCycle=18
Percentage=65
Case 65 To 70
DutyCycle=19
Percentage=70
Case 71 To 76
DutyCycle=20
Percentage=75
Case 77 To 78
DutyCycle=22
Percentage=80
Case 79 To 80
DutyCycle=23
Percentage=85
Case 81 To 85
DutyCycle=24
Percentage=90
Case 86 To 89
DutyCycle=26
Percentage=95
Case 90 To 91
DutyCycle=27
Percentage=100
EndSelect
Return
'-------------END SIX FEET --------------'-------------FIVE FEET --------------RefFiveFt:
If LuxID=1 Then 'at lux 50
Select Case LdrAdc2
Case 0
DutyCycle=0
Percentage=0
Case 1 To 3
DutyCycle=1
Percentage=5
Case 4 To 5
DutyCycle=3
Percentage=10
Case 6 To 9
DutyCycle=4
Percentage=15
Case 10 To 13
DutyCycle=5
Percentage=20
Case 14 To 23
DutyCycle=7
Percentage=25
Case 24 To 27
DutyCycle=8
Percentage=30
Case 28 To 29
DutyCycle=9
Percentage=35
Case 30 To 37
DutyCycle=11
Percentage=40
Case 38 To 44
DutyCycle=12
Percentage=45
Case 45 To 52
DutyCycle=14
Percentage=50
Case 52 To 54
DutyCycle=15
Percentage=55
Case 55 To 58
Case 28 To 35
DutyCycle=10
Percentage=25
Case 36 To 37
DutyCycle=11
Percentage=30
Case 38 To 48
DutyCycle=13
Percentage=35
Case 49 To 54
DutyCycle=15
Percentage=40
Case 55 To 60
DutyCycle=17
Percentage=45
Case 61 To 70
DutyCycle=19
Percentage=50
Case 71 To 76
DutyCycle=21
Percentage=55
Case 77 To 80
DutyCycle=23
Percentage=60
Case 81 To 82
DutyCycle=25
Percentage=65
Case 83 To 91
DutyCycle=27
Percentage=70
Case 92 To 97
DutyCycle=29
Percentage=75
Case 98 To 101
DutyCycle=30
Percentage=80
Case 102 To 105
DutyCycle=32
Percentage=85
Case 106 To 109
DutyCycle=34
Percentage=90
Case 110 To 113
DutyCycle=36
Percentage=95
Case 114 To 119
DutyCycle=38
Percentage=100
EndSelect
ElseIf LuxID=3 Then At 'at lux 100
Select Case LdrAdc2
Case 0
DutyCycle=0
Percentage=0
Case 1 To 5
DutyCycle=3
Percentage=5
Case 6 To 13
DutyCycle=5
Percentage=10
Case 14 To 27
DutyCycle=8
Percentage=15
Case 28 To 35
DutyCycle=10
Percentage=20
Case 36 To 48
DutyCycle=13
Percentage=25
Case 49 To 54
DutyCycle=15
Percentage=30
Case 55 To 64
DutyCycle=18
Percentage=35
Case 65 To 76
DutyCycle=20
Percentage=40
Case 77 To 80
DutyCycle=23
Percentage=45
Case 81 To 89
DutyCycle=26
Percentage=50
Case 90 To 93
DutyCycle=28
Percentage=55
Case 94 To 101
DutyCycle=31
Percentage=60
79
Next ictr
LdrAdc2=TempAvg / 200
DelayMS 500
Print At 1,1,"ADC1:",DEC4 LdrAdc2
TempAvg=0
LdrAdc2=0
Wend
Test_Timer:
Cls
myCtr=0
T0IE=1
GIE=1
While 1=1
'Print At 1,1,"Secs:",Dec2 ssec
'DelayMS 1500
Wend
End If
End
Return
'-------------END FIVE FEET --------------Test_LuxPwm:
DutyCycle=8 '0
HPWM 1 ,DutyCycle,myFrequency
Cls
LdrAdc2=0
TempAvg=0
While 1=1
For ictr=1 To 200
LdrAdc2=ADIn 5
TempAvg=TempAvg + LdrAdc2
80
APPENDIX C
Gathered Data from the Prototype
Motion Sensor
Detected
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
Output
current, A
0.50
0.90
0.50
0.90
0.50
0.90
0.50
0.90
0.50
0.90
0.50
0.90
0.50
0.90
0.50
0.90
0.50
0.91
0.50
0.91
Trials
1
2
3
4
5
Motion Sensor
Detected
without person
with person
without person
with person
without person
with person
without person
with person
without person
Lux meter
reading
(Indirect), Lux
74
98
73
98
74
98
74
98
74
81
Output
current, A
0.69
0.90
0.69
0.91
0.69
0.91
0.69
0.91
0.69
6
7
8
9
10
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
98
74
98
73
98
73
98
73
98
74
98
0.91
0.69
0.91
0.69
0.91
0.69
0.91
0.69
0.91
0.69
0.91
Scenario 3: 7 o'clock in the evening at a height of 5ft and maintaining at 100 lux
Trials
1
2
3
4
5
6
7
8
9
10
Motion Sensor
Detected
Lux meter
reading
(Indirect), Lux
Output
current, A
98
98
98
98
98
98
98
99
98
98
98
98
98
99
98
98
98
98
98
99
0.91
0.91
0.91
0.91
0.91
0.91
0.91
0.91
0.91
0.91
0.91
0.91
0.91
0.91
0.91
0.91
0.92
0.92
0.92
0.92
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
82
Trials
1
2
3
4
5
6
7
8
9
10
Motion Sensor
Detected
Lux meter
reading
(Indirect), Lux
Output
current, A
52
100
52
100
51
100
52
100
52
101
51
101
52
101
52
101
51
101
51
101
0.80
1.78
0.80
1.78
0.80
1.79
0.80
1.79
0.80
1.79
0.80
1.79
0.80
1.80
0.80
1.80
0.80
1.80
0.80
1.80
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
Trials
1
2
3
4
5
Motion Sensor
Detected
Lux meter
reading
(Indirect), Lux
Output
current, A
75
101
75
101
75
101
75
101
75
1.19
1.80
1.19
1.80
1.19
1.80
1.19
1.81
1.19
without person
with person
without person
with person
without person
with person
without person
with person
without person
83
6
7
8
9
10
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
101
75
101
75
101
74
101
74
101
74
101
1.81
1.19
1.81
1.19
1.81
1.19
1.81
1.19
1.81
1.2
1.81
Scenario 6: 7 o'clock in the evening at a height of 6ft and maintaining at 100 lux
Trials
1
2
3
4
5
6
7
8
9
10
Motion Sensor
Detected
Lux meter
reading
(Indirect), Lux
Output
current, A
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
1.82
1.82
1.82
1.82
1.82
1.82
1.82
1.83
1.83
1.83
1.83
1.83
1.83
1.83
1.83
1.83
1.84
1.84
1.84
1.84
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
84
Trials
1
2
3
4
5
6
7
8
9
10
Motion Sensor
Detected
Lux meter
reading
(Indirect), Lux
Output
current, A
51
103
50
102
50
103
50
103
50
103
50
103
50
103
50
103
50
103
50
102
1.25
2.07
1.25
2.07
1.25
2.07
1.25
2.07
1.25
2.07
1.25
2.07
1.25
2.07
1.25
2.07
1.25
2.07
1.25
2.07
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
Trials
1
2
3
4
5
6
7
Motion Sensor
Detected
Lux meter
reading
(Indirect), Lux
Output
current, A
75
103
75
103
75
102
75
102
74
102
75
102
75
2.09
2.07
2.09
2.07
2.08
2.06
2.08
2.06
2.08
2.06
2.08
2.06
2.08
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
85
8
9
10
with person
without person
with person
without person
with person
without person
with person
102
74
102
74
102
74
102
2.06
2.08
2.06
2.08
2.06
2.08
2.06
Scenario 9: 7 o'clock in the evening at a height of 7ft and maintaining at 100 lux
Trials
1
2
3
4
5
6
7
8
9
10
Motion Sensor
Detected
Lux meter
reading
(Indirect), Lux
Output
current, A
102
102
102
102
102
102
102
103
102
102
102
102
102
102
103
102
102
102
102
102
2.06
2.06
2.06
2.06
2.06
2.06
2.06
2.06
2.06
2.06
2.06
2.06
2.06
2.06
2.06
2.06
2.07
2.07
2.07
2.07
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
without person
with person
86