ARID ZONE JOURNAL OF ENGINEERING, TECHNOLOGY & ENVIRONMENT AZOJETESeptember 2020. Vol. 16(3):621-636 Published by the Faculty of Engineering, University of Maiduguri, Maiduguri, Nigeria. Print ISSN: 1596-2490, Electronic ISSN: 2545-5818 www.azojete.com.ng Corresponding author’s e-mail address: aokandeji@unilag.edu.ng 621 ORIGINAL RESEARCH ARTICLE DESIGN ANALYSIS OF A MICROCONTROLLER BASED AUTOMATIC SWITCHING SYSTEM USING PASSIVE INFRARED SENSOR A. A Okandeji1*, Z.O. Jagun2, M. B Olajide3 and, M. T. Kabir4 1Department of Electrical and Electronic Engineering, University of Lagos, Akoka, Lagos state, Nigeria 2Department of Computer Engineering, Olabisi Onabanjo University, Ago-Iwoye, Ogun state, Nigeria 3Department of Electrical and Electronic Engineering, Olabisi Onabanjo University, Ago-Iwoye, Nigeria 4Department of Electronic and Telecommunication Engrng, Ahmadu Bello University, Kaduna, Nigeria. *Corresponding author’s email address: aokandeji@unilag.edu.ng 1.0 Introduction Electricity which has assumed a prime position as a form of energy for mankind play a vital role in the development of any nation. As human activities increase and inventions are made, the importance of electricity continues to be dominant (Grueneich, 2015). Based on increasing human activity, there has been an exponential rise in the demand for electricity. However, despite the importance attached to electricity, it remained one of the most wasted and abused resources especially in third world countries. It is not uncommon to see lightings left ON in unoccupied classrooms, offices, and homes for many hours. Nonchalant attitude is observed in the area of management and conservation of public power supply. Individuals often observe power on the lightings, cooling systems, and other appliances at homes, offices and commercial centers whenever it is not required. To address this problem, the method of writing statements such as “switch off all appliances when leaving the office” and placed at the back of the doors was adopted in many establishments. This however seem ineffective because in most cases due to epileptic power supply, some electrical appliances were not switched OFF. Specifically, the interrupted power is restored when occupants have left the office. This might result to increased power bills and may hinder a nation from diverting power to industrial areas, limiting the process of industrialization and increasing energy wastage. It has been estimated that approximately 45% of the electricity generated in many third world countries (including Nigeria) is wasted (Oyetola et al., 2019). This is due to poor energy conservation policy of the country and lack of public awareness of the need for efficient utilization of electricity. Energy ARTICLE INFORMATION ABSTRACT Poor management and conservation of public power supply has constantly resulted into wastage of electricity thereby limiting the industrialization process especially in third world countries. To reduce energy wastage in homes, institutions and public places, this paper presents the development of an automatic switch using passive infrared sensor (PIR). Automatic switch is a device that detects the human presence in a predefined area and can turn on the lights or any electrical appliances. Similarly, the device will automatically turn off the lights or any electrical appliance if nobody is present in the area. Using the PIR sensor (for human detection), Light Dependent Resistor (LDR) (to detect night and day), and a microcontroller programmed using Micro-C, a switching circuit that detects humans in a predefined area is investigated. In particular, an automatic switching system using passive infrared sensors to prevent unwarranted wastage of electricity, and also to prevent electricity related hazards which could result from the use of unmonitored electrical appliances is implemented. The research work guarantees less consumption of power, hence, lower utility bills. Also, it allows for more safety in homes, schools, and offices since heavy-duty and high-power equipment that could cause fire e.g. Air-conditioning systems, electric cookers, boilers, electric irons etc, if left unattended to, can be turned off automatically. © 2020 Faculty of Engineering, University of Maiduguri, Nigeria. All rights reserved. Submitted 13 March, 2019 Revised 19 June, 2019 Accepted 26 June, 2019. Power switch Energy conservation passive infrared sensor Relay Light Dependent Resistor. http://www.azojete.com.ng Okandeji et al.: Design Analysis of a Microcontroller Based Automatic Switching System using Passive Infrared Sensor. AZOJETE,16(3):621-636. ISSN 1596-2490; e-ISSN 2545-5818, www.azojete.com.ng Corresponding author’s e-mail address: aokandeji@unilag.edu.ng 622 conservation is thus an important element of energy policy. A well-thought-out energy conservation policy helps to reduce energy consumption and demand per capita. This in turn increases the energy supply needed to keep up with population growth (Moore, 2002). To address the problem of energy wastage in homes, offices etc, (Zhenfeng et al., 2020) considered the use of automatic switching controls to activate the lighting circuit when a human is sensed within a space. Furthermore, work done in (Xiao et al., 2020) considered the major types of automatic switching controls namely passive infrared, ultrasonic, and a dual technology device that uses both passive infrared and ultrasonic technology. In particular, passive infrared sensor (PIR) senses occupancy by detecting the difference between heat emitted from the human body in motion and the background space (Xiao et al., 2020). Passive infrared sensors use Fresnel lenses to create a defined pattern of coverage in both the horizontal and vertical planes. The latest technology ensures higher sensitivity to minor motion without the potential for false activation. PIR devices are available in a wall-switch model (in place of a standard snap-switch at a doorway) or a ceiling-mounted unit (Xiao et al., 2020). Ultrasonic sensor based detectors on the other hand transmit and receive low-intensity sound waves at a frequency of about 25 kHz to 40 kHz, which is inaudible to the human ear (Theraja, 2002). Any change in the signal return time is interpreted as motion, and the sensor responds by keeping the lighting on. Some products use patented signal processing circuitry to automatically adjust the signal detection threshold to compensate for changing levels of activity and airflow. This feature helps to eliminate false ON activation. Ultrasonic sensors are best suited for monitoring partitioned areas as well as areas with large objects, such as furniture, that are likely to block the field of view of PIR sensors. Alternatively, for spaces where neither a PIR nor an ultrasonic sensor is practical, a dual-technology device using both PIR and ultrasonic sensing can be installed. Both types must detect occupancy to turn lighting on, while continued detection by only one technology will keep lighting on (Xiao et al., 2020). These sensors are best suited for office areas with cubicles, general workplaces, warehouse and storage facilities, cafeterias, and public areas in commercial facilities. Another class of the less popular detectors is a photosensitive control unit which operates a lighting circuit that adjusts to ambient lighting levels (Sadeghi et al., 2016). In response to the photo control unit, a switching system will turn on lamps in a specific pattern, such as one or more contactors/branch circuits or a portion of a branch circuit, to provide typically one-third, half, or two-thirds of full light output in an area. Photo sensor units are available as two-component systems with externally mounted sensors connected to a remotely mounted electronic module via low-voltage wiring, making it convenient to adjust operational set points from inside the building. Other systems incorporate an infrared detection system which is configured to sense direction of motion so that it can increment or decrement its count based on the number of occupants. The system keeps the lighting circuit active until the programmed counter for the number of occupants within the control area drops to zero (Xiao et al., 2020). In contrast to existing results, this study considers the development of a microcontroller based automatic switch using passive infrared sensor. In particular, the design analysis of an automatic switching system using passive infrared sensors to prevent unwarranted wastage of electricity, and also to prevent electricity related hazards which could result from the use of unmonitored electrical appliances is implemented. Specifically, using the PIR sensor which consists of IR sensors to detect human body heat, the system detects the presence of a human, and automatically turn ON electrical appliances, and turns OFF appliances upon the observation of the absence of human. 2.0 Materials and Methods This section describes the development of the automatic switching system using passive infrared sensors to prevent unwarranted wastage of electricity, and also to prevent electricity related hazards which could result from the use of unmonitored electrical appliances. Functionally, power is cut off from the control area if the system senses human absence for a http://www.azojete.com.ng Arid Zone Journal of Engineering, Technology and Environment, September, 2020; Vol. 16(3) 621-636. ISSN 1596-2490; e-ISSN 2545- 5818; www.azojete.com.ng Corresponding author’s e-mail address: aokandeji@unilag.edu.ng 623 predetermined period of time using pyro electric means after it must have sensed motion. As long as there is human presence in the control area occasioned by body heat and motion, the system remains in an idle loop but it is called into action once no occupancy is detected after a pre-determined time. Figure 1 shows the combination of the sub-systems which determines the overall operation of the power controller circuit. To achieve the circuit objective, a sequence of pre-programmed processes are utilized which is combined to understand the overall functional flow of the study. Figure 1: Block diagram of an Automatic switching system using PIR This process flow is indicated using the flowchart as shown in Figure 2. file:///C:/Users/user/Downloads/azojete143/www.azojete.com.ng Okandeji et al.: Design Analysis of a Microcontroller Based Automatic Switching System using Passive Infrared Sensor. AZOJETE,16(3):621-636. ISSN 1596-2490; e-ISSN 2545-5818, www.azojete.com.ng Corresponding author’s e-mail address: aokandeji@unilag.edu.ng 624 Figure 2: Process Flow Chart for Automatic switching system using PIR sensor 2.1 Circuit Operation The circuit in Figure 3 is connected through the provided mains terminal to a suitable power supply outlet while the load or circuit to be controlled is connected to the circuit through the designated load terminal. Care must be taken to avoid polarity reversals. Once connection is complete and certified okay, power is supplied to the circuit. As the circuit senses power, the “POWER” light emitting diode (LED) comes on to indicate that the circuit is live. Instantaneously, the circuit goes into a pre-determined start-up delay of five seconds. Upon this delay time elapsing, the “STATUS” LED as well as the control relay both turn ON. Upon the energization of the relay, the load under control instantly receives power. At the expiration of the initial startup delay, the circuit automatically enters the countdown routine where it is http://www.azojete.com.ng Arid Zone Journal of Engineering, Technology and Environment, September, 2020; Vol. 16(3) 621-636. ISSN 1596-2490; e-ISSN 2545- 5818; www.azojete.com.ng Corresponding author’s e-mail address: aokandeji@unilag.edu.ng 625 programmed to count down for 10 minutes, and thereafter initiate the critical shutdown routine. If the circuit, through the sensor, picks up human presence anytime during the countdown routine, the countdown routine is automatically restarted. For as long as human presence is sensed within the control area, the countdown routine will be reset to restart. Accordingly, the circuit ensures that the relay is kept energized. However, if during the countdown sequence, no human is sensed, after a 10-minute period, the circuit goes into the critical shutdown routine. Accordingly, the LED is flashed rapidly while an audible alarm is annunciated once every 30 seconds to warn of imminent shutdown. This process is carried out for the next 3 minutes during which if a body is sensed, the circuit goes back to the start of the countdown routine. On the other hand, if no human is sensed during the critical shutdown routine, and the 3 minutes elapses, the “STATUS” LED and relays would both go off thereby turning off power to the load or the control area. After shutting down, if at any time instant the sensor senses human presence, the circuit again automatically turns ON. To summarize, immediately after turn ON, the circuit is designed to shutdown in approximately 13 minutes but the shutdown process will be interrupted, and the process restarted every time an interrupt occurs as a result of human presence. 2.2 Circuit Design The entire circuit in Figure 3 is divided into 2 sections namely: Power Supply Circuit Control Section file:///C:/Users/user/Downloads/azojete143/www.azojete.com.ng Okandeji et al.: Design Analysis of a Microcontroller Based Automatic Switching System using Passive Infrared Sensor. AZOJETE,16(3):621-636. ISSN 1596-2490; e-ISSN 2545-5818, www.azojete.com.ng Corresponding author’s e-mail address: aokandeji@unilag.edu.ng 626 Figure 3: The complete circuit of a switching system using a PIR 2.2.1 Power Supply Circuit The component parts of the control circuit to be powered are the digital microcontroller, sensors, relays, buzzer and LEDs. The controller requires +5V while the relays used are the 12V type which in reality can be powered by an unregulated voltage range of 7 – 19V. The PIR sensors can use a supply voltage between 4.5 – 20V. http://www.azojete.com.ng Arid Zone Journal of Engineering, Technology and Environment, September, 2020; Vol. 16(3) 621-636. ISSN 1596-2490; e-ISSN 2545- 5818; www.azojete.com.ng Corresponding author’s e-mail address: aokandeji@unilag.edu.ng 627 2.2.1.1 Transformer To determine the transformer size and rating, the voltage and current considerations of the circuit is considered. In view of this, the total current of the circuit which is the summation of current requirement of the individual circuit elements is considered. The major current consuming components in the circuit are the relays, LEDs, PIR, and the microcontroller. The transformer current rating is taken to be at least twice the total current required by the circuit elements. The characteristics of the relay (RLA) considered are given as: 12V (coil), 30A (contact), 250 (coil resistance). For the relay, as shown in (Theraja, 2002), the coil current is given as 12 250Ω = 48mA. (1) For the LEDs, assuming a maximum current of 50mA , to achieve good illumination, the total intake of about 150mA is considered. For other parts of the circuit (which are very low current consuming devices), we assume to draw not more than 50mA. Hence, total current required by the control circuit is given as: I = 48mA+ 150mA + 50mA = 248mA If input voltage V1 = 220V. Output voltage V2 =15V. N1 = number of primary turns = 550, N2 = number of secondary turns. N2 = N1 V2 V1 (2) = (15 x 550 )/220 = 38 turns. 2.2.1.2 Calculation for the Number of Turns From (Theraja, 2002), E1 = 4.44fAβN1 Volts, (3) where E1 = Supply voltage = 220V. f = frequency = 50 Hz. β = Flux density = 1.1 (for steel wire) A = Area = L x B m2 N1b = Number of turns in the primary winding. For A = Length x Breadth, L = 60cm = 0.06m. B = 2.8cm = 0.028m. Area = 0.00168m2 N1 = E1 4.44 x 50 x 1.1 x 0.00168 = 220 4.44 x 50 x 1.1 x 0.00168 = 220 0.4 = 550 turns For the secondary windings, from (Theraja, 2002), for E2 = 4.44fBAN2 Volts where E2 = Output voltage = 15V. A = Area = L X B = 0.00168m2 . β = Flux density = 1.1 (for steel wire) f = frequency = 50 Hz. N1 = E2 4.44 x F x B x A = 15 4.44 x 50 x 1.1 x 0.00168 = 15 0.4 = 37 turns file:///C:/Users/user/Downloads/azojete143/www.azojete.com.ng Okandeji et al.: Design Analysis of a Microcontroller Based Automatic Switching System using Passive Infrared Sensor. AZOJETE,16(3):621-636. ISSN 1596-2490; e-ISSN 2545-5818, www.azojete.com.ng Corresponding author’s e-mail address: aokandeji@unilag.edu.ng 628 2.2.1.3 Primary winding calculation. From (Theraja, 2002)., Ieq = Iin  duty cycle, (4) where duty cycle = 1 (Since the coil is wound round the core once) Also, Power = Voltage X Current. (5) The rating of the transformer is 250VA. Thus, Iin = V P , where Iin = Input current. Since V = 220V Iin = 250 220 = 1.13A Therefore, Ieq = Iin  duty cycle = 1.13  1 = 1.13A, where Ieq = equivalent current. Also, from (Theraja, 2002), cross sectional area of conductor = current current density , (6) but current density = 3A/m2 Therefore, conductor area = Iin current density = 1.13 3 = 0.379 m2 Therefore, from the standard wire gauge (SWG) table, the suitable gauge size is 28. For secondary winding, where V = 15volts Iin = P V = 250 15 = 16.67A. For duty cycle = 0.5 (for centre tapped i.e. it moves half of a cycle), Ieq = Iin x duty cycle = 16.67 x 0.5 = 8.33A. conductor area = current current density = 8.33 3 = 2.78 m2 The centre tapped transformer used is shown in Figure 4. Figure 4: Centre –Tapped Transformer For the proposed design, a transformer with secondary current rating of 500mA is appropriate. The schematic diagram of the power supply unit for the control circuit is shown in Figure 5. Figure 5: Power supply circuit http://www.azojete.com.ng Arid Zone Journal of Engineering, Technology and Environment, September, 2020; Vol. 16(3) 621-636. ISSN 1596-2490; e-ISSN 2545- 5818; www.azojete.com.ng Corresponding author’s e-mail address: aokandeji@unilag.edu.ng 629 2.2.1.4 Rectifiers Diodes A rectifying circuit is required to convert the stepped down alternating current (AC) from the mains socket to a form usable by electronic circuits. In general, the diode must be able to withstand the maximum voltage and current of the circuit to avoid a breakdown and reverse conduction. The mains supply voltage is an alternating current sinusoidal voltage, and for a single phase, it takes 220V at 50Hz. The requirement of this stage is to obtain a unipolar voltage i.e. a voltage which is made up of a sinusoidal half cycles but each of the same polarity either positive or negative. This is achieved using a PN junction diode and two methods namely: Half wave rectifier, and full wave rectifier. HALF WAVE RECTIFIER: This is the simplest circuit. The AC voltage is provided by the transformer powered from the AC power line. FULL WAVE RECTIFIER: This make use of four diodes, and it is chosen because it is economical in that a smaller transformer can be used to achieve the purpose of using a bigger transformer for other forms of rectification. The transformer secondary has a centre tap so that during each part of the sinusoidal AC voltage input, two diodes conducts simultaneously i.e. D1 and D3, while D2 and D4 conducts in the other half of the cycle. For the purpose of this research work, a compact rectifier is used where the four diodes are all connected into one. Thus, current flows through and drops a voltage across the load. The amount of ripple is also reduced compared with half wave rectifier (Theraja et al., 2002). The rectifier circuit with its output is shown in Figure 6. Figure 6: Circuit for Rectification and the Output Waveform To satisfy the above conditions, the diode specification is given as: chosen diode (D1, D2, D5 and D6): 1N4001; Continuous Forward Current = 1A, Peak Repetitive Reverse Voltage = 50V 2.2.1.5 Filter capacitors After rectification, the pulsating direct current (DC) produced is highly rich in ripples and harmonics. To remove these disturbances, filter capacitors are used. C1 is a high value electrolytic capacitor which acts as short circuit at low frequencies and bypasses these components to ground. C2 is a ceramic type used to bypass higher frequencies to ground because they act as short circuits at high frequencies. The voltage rating of the capacitors must be higher than 1.414 times the voltage rating of the transformer secondary. For this design, a maximum ripple voltage of 10% of the DC rectified voltage is considered. For this consideration, the equation below applies (Theraja et al., 2002): C = 5 x I load/Vdc x f, (7) where C is filter capacitance, I load = load current, Vdc = the rectified d.c voltage, f = the AC power supply frequency = 50Hz. file:///C:/Users/user/Downloads/azojete143/www.azojete.com.ng Okandeji et al.: Design Analysis of a Microcontroller Based Automatic Switching System using Passive Infrared Sensor. AZOJETE,16(3):621-636. ISSN 1596-2490; e-ISSN 2545-5818, www.azojete.com.ng Corresponding author’s e-mail address: aokandeji@unilag.edu.ng 630 Ripple voltage defined as the residual periodic and continuous voltage insider the supply of power whose derivation is from the a.c. source is given as (Theraja, and Theraja, 2002): Vripple peak = Vpeak − Vdc , (8) where the d.c voltage is Vo = Vin 2 . (9) Using the equation above, C is therefore given as 5 x 258mA 13.5V x 100Hz = 1191.11µF. For the proposed design, a capacitor of 1000µF was selected. The simplest way to smoothen the voltage output of a rectifier in order to minimize the ripples and give a better approximation to a DC is to use a capacitor in parallel with the resistive load. Here, two reservoir capacitors C1 and C2 are used to convert the pulsating half cycles which appear at the cathodes of the diodes into a near smooth DC voltage. This action depends on the fact that the capacitor stores energy during the conduction periods, and deliver this energy to the load during the non-conducting period. Thus, the time during which the current passes through the load is prolonged and the ripple is considerably reduced. The ripple voltage is the deviation of the load voltage from its DC voltage i.e. the values of capacitors C1 and C2 used with a 50Hz supply may range from 100µf – 30,000µf depending on the load current, and the degree of smoothening required. In selecting capacitors, the ripple voltage required is 5% of the peak value thus from (Theraja et al., 2002). C = CT x V d.c/ Rv x projectload, (10) where CT = Period capacitor = 0.0025 for full wave circuit. Higher values of 10000F are chosen as shown in Figure 7 because higher capacity efficiency can be achieved with higher capacity values (www.alldatasheet.com). Figure 7: Power Supply Unit 2.2.1.6 Voltage Regulator A stable +5V is required to power the microcontrollers, and since a maximum output current of 258mA is required in the circuit, an integrated voltage regulator capable of supplying 5V while still being able to supply more than 258mA is considered. The voltage regulator is a compact and versatile adjustable positive voltage regulator. The regulator features an internal thermal overload protection, short circuit current protection as shown in Figure 8. http://www.azojete.com.ng Arid Zone Journal of Engineering, Technology and Environment, September, 2020; Vol. 16(3) 621-636. ISSN 1596-2490; e-ISSN 2545- 5818; www.azojete.com.ng Corresponding author’s e-mail address: aokandeji@unilag.edu.ng 631 Figure 8: Voltage regulator circuit For the voltage regulator, the output voltage is approximately given by (Theraja et al., 2002). Vout = 1.25 1 R1 R2 (11) The values of resistors shown in Figure 8 are as recommended by the manufacturer’s datasheet. The electrical characteristics of the regulator are: Minimum regulated voltage range = 1.25V, Minimum input voltage = 3.5V, Maximum differential voltage (input to output) = 40V, Maximum regulator current = 1.5A. 2.2.1.7 LED Indicator To ensure adequate illumination, a current of about 50mA is considered. At a peak voltage of 19V(after filtering, capacitor increases rectified DC voltage 13.5V by a factor of 1.414), a limiting resistor is required. V = VLED + VRESISTOR (12) For an illuminated LED, the voltage drop is about 2V. Therefore, the resistor voltage is 19 – 2 = 17V. When passing 50mA, the value of the resistance required is 17V / 50mA = 340 Ohms . Therefore, R1 = 340 Ohms (330 is selected) . As recommended by the datasheet, R2 = 5kΩ and R3 = 220Ω. 2.3 Control Section The control section is made up of the following sub-circuits namely: 2.3.1 Body Heat Sensor For this design, a pyroelectric infrared sensor is selected. These sensors work by detecting changes in infrared energy levels caused by humans moving within the range of the sensor. PIR sensors are passive because they do not send out a signal or emit any type of energy; they just sense infrared energy (heat) that emanates from the human body. 2.3.2 Features of the PIR sensor Sensing occurs a minute after power initialization time. Sensor module uses a dual probe. file:///C:/Users/user/Downloads/azojete143/www.azojete.com.ng Okandeji et al.: Design Analysis of a Microcontroller Based Automatic Switching System using Passive Infrared Sensor. AZOJETE,16(3):621-636. ISSN 1596-2490; e-ISSN 2545-5818, www.azojete.com.ng Corresponding author’s e-mail address: aokandeji@unilag.edu.ng 632 When the body moves from left to right or right to left, the sensor responds but not when a body moves from top to bottom. This way, the sensor is able to interpret motion but attributes top-to-bottom sensing to external radiation like lighting or vibration. 2.3.3 Relay interface circuit The relay is used to switch ON or OFF the connected load depending on the state of the PIR, and the interpretation by the microcontroller. The relay used is a DC type with contacts capable of carrying the desired load current. The maximum load power considered for this design is 3000W at 220V. Therefore, maximum load current is given as 3000W / 220V = 13.64A. (13) Therefore, a relay with contacts capable of carrying 13.64A is selected. Due to the limitation of the source current of PIC microcontrollers to 25mA, and the requirement of a coil current far in excess of 25mA, a transistor amplifier is used in a common emitter mode to amplifier the base current provided by the PIC so that the relay acts as a collector load. Design consideration is shown in Figure 9. Figure 9: Relay interface circuit Relay parameters includes: Coil resistance = 150ohms, Coil voltage = 12V, contact rating = 30A. From where, coil current = 12V / 150Ω = 80mA . BC337 is selected with a collector current capability of 500mA to pass the relay coil current. Assuming a worst-case scenario current gain of 20 for the transistor, and a collector current of 80mA which is equal to the coil current, the base current is expressed as Ib = Ic / hfe = 80mA / 20 = 4mA. (14) The turn-on voltage of an NPN transistor = 0.6V (Theraja, 2002). Therefore, the voltage across the base resistor is VPIC(o/p) − Vbe = 5 – 0.6 = 4.4V. (15) Accordingly, R12 = 4.4V / 4mA = 1100ohms (1.1k), 1.2k is selected. 2.3.4 Audible Alert Circuit An audio alert circuit is considered to actively inform the user of the status of the entire system. The alert is such that after a period, predetermined by the microcontroller firmware, a tone is sounded at intervals to intimate the user of an impending shutdown. The alarm beeps once every 10 seconds for one minute, and if no human presence is sensed, the circuit shuts down after 120 seconds. The microcontroller activates the buzzer through a transistor as shown in the relay circuit in Figure 10. http://www.azojete.com.ng Arid Zone Journal of Engineering, Technology and Environment, September, 2020; Vol. 16(3) 621-636. ISSN 1596-2490; e-ISSN 2545- 5818; www.azojete.com.ng Corresponding author’s e-mail address: aokandeji@unilag.edu.ng 633 Figure 10: Buzzer interface circuit 2.3.5 Microcontroller Firmware At start-up, the status LED comes on and the circuit checks the sensor input for human presence. A shutdown sequence is initiated through an internal countdown timer in the microcontroller while the status LED remains steady. The timer counts down for a 10-minute period, and if any movement is detected, through the PIR, the countdown is cancelled and restarted. If on the other hand no movement is detected, after 10 minutes, the program enters a critical shutdown period and the status LED starts to flash once every second accompanied by an audible alarm once every 5 seconds. The critical shutdown period lasts for 3 minutes during which the countdown is again restarted if any movement is detected. If not, the system shuts down and turns on the relay after the critical shutdown routine. The relay then opens the connected load. After shutdown, any movement detected will re-initiate the system again. For this design, the microcontroller routine is written and compiled with GC Basic, a free and open source microcontroller basic compiler. Note that the environment and syntax is different from the more popular G Basic with the former targeted at embedded programming, and the latter targeted towards computer programming. 3.0 Testing and Performance Evaluation This section focuses on the testing of the various stages of the passive infrared automatic switching device. In general, the performance of a transformer can be determined on the basis of its equivalent circuits which contains four main parameters namely equivalent resistance, equivalent leakage resistance, the core-loss conductance, and the magnetising susceptance (Theraja et al., 2002). These constants or parameters can be easily determined by the open- circuit test and the short circuit test (Theraja et al., 2002). For this study, we consider only the short-circuit test, and for operational effectiveness, we investigate the preliminary test as well as the operational test of the proposed design 3.1 Preliminary Test This test was carried out to ensure that proper components were fixed at the right places and to ensure proper functionality of each components. The circuit was scrutinized to ensure that there was no short circuit or loose contact during the soldering which may cause failure of the circuit or damage to the component when the supply is fed in. The transformer of the proposed design was tested by checking both input and output voltage. The supply voltage was checked by using a voltmeter and it gave exactly 220V. The secondary voltage was also checked it was found out to be 15V-0-15V (for a centre tapped transformer). Additionally, the transformer was plugged to check for the heat dissipation. It was observed that there was no heat-up in the transformer. Also, there was no vibration in the transformer when the supply was fed in. file:///C:/Users/user/Downloads/azojete143/www.azojete.com.ng Okandeji et al.: Design Analysis of a Microcontroller Based Automatic Switching System using Passive Infrared Sensor. AZOJETE,16(3):621-636. ISSN 1596-2490; e-ISSN 2545-5818, www.azojete.com.ng Corresponding author’s e-mail address: aokandeji@unilag.edu.ng 634 3.2 Short- Circuit Test In this test, one winding, usually the low-voltage winding, is solidly short-circuited by a thick conductor (or through an ammeter which may serve the additional purpose of indicating rated load current). A low voltage (usually 5 - 10% of normal primary voltage) at the correct frequency is applied to the primary and it is cautiously increased till full-load currents are flowing both in the primary and secondary. It was observed that with the normal voltage applied to the primary, normal flux was set up in the core. Hence, normal iron losses was recorded. Additionally, as the primary no load current was small, the copper losses was negligibly small in the primary and nil in the secondary. 3.3 Operational Test. The operational test was performed by applying voltage to the components and a multi-meter was used to check the different stages of the passive infrared automatic switching device ensuring that they conform to the given requirement. The range of the passive infrared automatic switching device is then tested by placing the device at a fixed distance in an isolated environment where there is no infrared interference. The maximum distance as well as the angle at which it can detect human presence was determined. It was observed that the device covered an angle of 100° and a distance of 3.8m at the sides, and a distance of 5m in the middle. 3.4 The Casing Plastic was used as the case of the passive infrared automatic switching device because of its advantages over steel materials. Some of these advantages are: Openings for ventilation can easily be made. It can withstand corrosion. It is readily available in the market. It can withstand heat, either the heat generated by the system or in the surrounding. The casing of the device is shown in Figure 11: Figure 11: Front and Back view of the passive infrared automatic switching device 3.5 Causes of Equipment Failure The system could be affected adversely when it is not used permanently in a particular place (for example, Environmental stress; if it is conveyed from one point to the other continuously). http://www.azojete.com.ng Arid Zone Journal of Engineering, Technology and Environment, September, 2020; Vol. 16(3) 621-636. ISSN 1596-2490; e-ISSN 2545- 5818; www.azojete.com.ng Corresponding author’s e-mail address: aokandeji@unilag.edu.ng 635 3.6 Troubleshooting Table 1 gives the troubleshooting procedure for cases of non functionality of the switching device. Table 1 Troubleshooting Procedure SIGNS TEST POINT EXPECTED RESULTS POSSIBLE FAULT LOCATION/CAUSES REMEDIAL Power indicator LED not lit when system is powered Check Fuse Burnt Fuse Replace fuse with 13A fuse Power indicator on but no power output Check the supply voltage Voltage should be 220V – 240V Low Voltage Connect to proper voltage(220V – 240V) Unstable Output Check solder joints Solder joints should be strong Weak solder joints If a weak joint is discovered, it must be re- soldered System not coming up Check AC supply No AC supply from mains Connect to Powered Mains PIR doesn’t detect human presence Check if the PIR modules are properly connected. Bad PIR modules or damaged connector wire. Replace the PIR modules or replace the connector wires. 4.0 Conclusions This study considered the design and construction of the passive infrared automatic switching device capable of switching on and off electronic devices not in use. This research presents one of the simple and effective ways of saving energy automatically in a building or organization. The research work guarantees less consumption of power, hence, lower utility bills. Also, it allows for more safety in homes, schools, and offices since heavy-duty and high-power equipment that could cause fire e.g. Air-conditioning systems, electric cookers, boilers, electric irons etc, if left unattended to, can be turned off automatically. References Sadeghi, SA., Karava, P., Konstantzos, I., Tzempelikos, A. 2016. Occupant interactions with shading and lighting systems using different control interfaces: A pilot study. Building and Environment, 97: 177-195. Grueneich, DM. 2015. The next level of Energy efficiency: The five challenges ahead. The Electricity Journal, 28(7): 44-56. Zhenfeng, L., Jingtao, L., Xiaofan, L., Yijian, Y., and Bowen, X. 2020. Design of office intelligent lighting system based on Arduino. Procedia Computer Science, 166: 134-138. Moore, TD. 2002. User attitudes toward occupant controlled office lighting. Lighting Research Technology, 34(3): 207-219. Oyetola, OK., Okubanjo, AA.., Okandeji, AA.., Olaluwoye, OO., Alao, PO., and Ukagu, SN. 2019. Internet of things (IoT) cloud based model for low cost demand side management infrastructure. Arid Zone Journal of Engineering, Technology and Environment, 15(4): 1082- 1091. file:///C:/Users/user/Downloads/azojete143/www.azojete.com.ng Okandeji et al.: Design Analysis of a Microcontroller Based Automatic Switching System using Passive Infrared Sensor. AZOJETE,16(3):621-636. ISSN 1596-2490; e-ISSN 2545-5818, www.azojete.com.ng Corresponding author’s e-mail address: aokandeji@unilag.edu.ng 636 Theraja, BL., and Theraja, AK. 2002. Electrical Technology, 21st Edition. Ranjendra Ravida, New Delhi, India. Xiao, S., Yong, M., Fan, F., Huang, J., and Minghui, W. 2020. Tracking small targets in infrared image sequences under complex environmental conditions. Infrared physics and Technology, 104: 1-10. Electronic component datasheet, www.alldatasheet.com. HC-SR501 Body Sensor Module Data Sheet. accessed on 01 December, 2019. Electronic component datasheet, www.alldatasheet.com. PIC16F628A Data Sheet accessed on 01 December, 2019 https://www.sciencedirect.com/science/article/pii/S1350449519303214 https://www.sciencedirect.com/science/article/pii/S1350449519303214 http://www.azojete.com.ng