DESIGN ANALYSIS OF AN AUTOMATIC PHASE SELECTOR

Power instability in Nigeria caused by overbearing demand of power by consumers and lack of proper maintenance of the power system devices among others has brought about the need for alternative power sources such as generators, solar, typical inverters and other alternative supplies which requires one form of switching or the other to achieve phase selection during power failure. This paper gives a design analysis of an automatic phase selector linking available power supplies, that is; switching between a threephase public utility supply, as a result of total power outage in the public supply to an alternative secondary supply (in this case a Generator and an Inverter system) and back when power is restored. The design adopts the use of a microcontroller-based system interconnected with other hardware components for proper isolation, switching and visualization of switching conditions. The system design is divided into two major part: the hardware which consists of the power supply, sensing circuit, controller or control logic circuit, display and the power electronics switching unit and the software instruction code on the microcontroller unit. The design analysis was first carried out accompanied with computer simulation on a software tool (Proteus 8 Professional, version 8.4) to carry out performance evaluation of the sub-circuits, thereafter, a practical implementation of the design was carried out and tested with the utility power supply using five (5) switches, three of which represents the three-phase primary supply and the other two represents the secondary supply.


INTRODUCTION
Nigerians are confronted with issue of power instability needed for continuous services in key sectors of the economy such as research and development (R&D), banking, industrial and health sector hence leading to poor research output, loss, increased cost of production, damages on appliances and even death [1]. These sectors are made up of critical loads that needed to be powered at all times in order to carry out their various processes efficiently [2]. This in turn has made most of these sectors depend on alternative supply of power.
It is often noticed that power interruption in the distribution system could be deliberate as a result of curbing unscrupulous customers engaged in Electricity theft [3] or caused by single-phase failure which accounts for 70 % of failure on a three-phase system, which leaves the other two phases in normal condition, thus making a change-over switch is important in such a scenario. Alternatively, commercial or industrial outfits makes use of a distributed three-phase system to supply power to various sections or equipment within the industry and in extreme cases of power failures, an alternative (secondary) power supply need to be provided. Fig. 1. Manual change-over switch [3].
The introduction of a change-over switch within the three-phase mains and between the mains and the alternative sources shows some challenges in terms of switching smoothly in a timely manner, whenever there is power failure on the main utility [3,4] as shown in Figure 1. These challenges are addressed by the use of an Automatic Phase Selector (APS). The APS has a sensing circuit interfaced with a programmable integrated circuit (PIC) controller or microcontroller [5]. This allows seamless transition between the main and alternative power sources to the load [6,7].
The APS monitors the incoming mains supply voltage (approximately 240 Vrms) and detects when the voltage drops below a certain level or goes off, and cannot serve electrical or electronic appliances [1,8]. At this point of phase failure, a zero-voltage equivalent is delivered to a control circuit which rectifies the zero voltage Alternating Current (AC) to Direct Current (DC) whose output is fed through the sensing circuit to a microcontroller. Simultaneously an alternative voltage source is identified and sent to the microcontroller.
The APS's microcontroller unit compares the voltage between the individual mains component (that is Red, Yellow and Blue phase) and the alternative power sources (that is a solar inverter and generating set) using a comparator circuit to select an available source to power the load via a transistor driver-automatic relay circuit. This concept is similar to a multiplexer circuit design in selecting individual phases [9]. The mains and alternative supply circuit are designed to prevent feedback current into the system and ensure it is in proper synch in terms of voltage and frequency [10].
The auto-selection mode in this system is achieved by stacking a set of relays interconnected in such a way that if one of the relays feeding the load is initially energized; following a phase failure condition, the corresponding secondary winding of the step-down transformer delivers zero voltage which is duly rectified to DC and then fed to the sensing and micro-controller circuit which automatically switches ON the next relay that delivers power to the load. The microcontroller unit also provides a visualization interface with an LCD unit, on which the selected phase can be displayed.
Unlike conventional circuits where transformers are used to step down the power supply [11], this system utilizes a direct supply of five sources; three connected to the three-phase supply and the other two are supplies from solar inverters and generator. These were represented by five electrical switches from a single-phase power system which serves as sources of power to the system as shown in Figure 2. The direct supply implies the system is lethal having direct supply of 240 Vrms and as such the design should be handled carefully with correct cabling specifications. The design was simulated on Proteus 8 Professional V8.4 and hardware developed to be low cost and easily adaptable to houses, offices, hospitals etc. faced with constant power outages.
The system consists of four main parts namely; the voltage sensing circuit, controller (which is the brain of the system), transistor driver, and electrical switching devices (Relay). The circuit connection is divided into power lines and signal lines where the power lines is also subdivided into AC mains and DC power supply. A portion of the input power line is rectified and fed to the sensing unit, controller unit and switching unit, while the other CUT-OUT FUSE CIRCUIT BREAKER ANALOG METER portion is fed directly to the load via an electrical switch control as shown in Figure 3. The signal lines are used to link small voltage signals from the sensing unit to the microcontroller and between microcontroller and the display unit. Figure 3 illustrates how the various unit interconnect each other and are independent of load connected.

Voltage sensing unit
The voltage sensing circuit utilizes a sensor or electronic configuration to detect input supply of five sources into the system. The supplied voltage is preprocessed to allow control operation, which involves conversion from an Alternating Current (AC) to Direct Current (DC). A direct connection from the supply to the control circuit requires VOLTAGE SENSING UNIT CONTROLLER UNIT SWITCHING UNIT SIGNAL LINE AC DC careful selection of components to operate the system. An approximate input voltage of 240 Vrms at 50 Hz frequency of an electrical mains power supply is used as a baseline input supply for the system. This is appropriate because apart from the three single-phase mains supply, the generating set and power inverter system gives the same voltage and frequency output. Hence, for a direct connection as such, an appropriate choice of diode is required to ensure the current and power rating are not violated. Considering the rectifying circuit, Equation (1d)   = 2 × √2 × with a capacitor is introduced to the circuit in Figure 6, which filters out the ripples from the rectified signal, its capacitance is estimated based on the expressions in equation (2a-d), where 'r' is the ripple factor.
Considering a trapezoidal shape of the filtered full-wave rectified signal, which was formed as a result of the rectified peak voltage and capacitor discharge voltage expressed in equation (3a). The area of the trapezoidal shape is expressed in equation (3b).
Hence, equations (4a-c) are used in finding the average voltage covered within the interval of periods( 0 < < 0 + 1 ).
With first-order polynomial approximation equations (4b) is reduced to equation (5a) and equation (4c) can now be expressed by equation (5b).
where 1 is the time interval between two successive peaks.
From the above expressions assuming an average current of 25 mA was chosen and a ripple factor of 0.64 was selected, then the capacitance value obtained is approximately 100uF and the average filtered voltage (Vavgf) is 335 V.
An external 9 V supply voltage was also introduced to the circuit via the microcontroller terminal. This helps to nullify the use of an external voltage regulator capable of withstanding the high DC voltage from AC mains. Moreover, a voltage regulator present on the Arduino board makes it easier to convert the 9 V supply to 5 V.

Electronic configuration circuit
An electronic configuration shown in Figure 6 uses the concept of voltage division to supply signal voltage to the microcontroller circuit as expressed in equation (3). The DC voltage output is obtained with the help of fixed ® and variable (Rx) resistors of values 10 kΩ and 1 kΩ respectively connected in series to set a detectable voltage range on the microcontroller. The presence of a Zener diode ensures that the voltage does not exceed the Zener voltage.
With the configuration and resistor parameters chosen, the output voltage will be far lesser than the input DC voltage output. This voltage however will be constrained by the IN4732 Zener diode which has a power and voltage rating of 249.1 mW and 4.7 V respectively.

Sensor
A typical sensor (optocoupler) as shown in Figures 7 and 8, on the other hand, was deployed for real-life circuit development. The optocoupler is an electronic component capable of transferring electrical signal between two isolated circuits such as a high voltage and low voltage circuit.  The component with augmented circuit configuration operates based on infra-red transmission at the primary side and detection at the base of the secondary side of the optocoupler. The secondary side connected to a low voltage (5 V +Vcc) gives out an output proportional to the secondary side voltage source as expressed in equation (7), once it detects an infra-red transmission. The resistance (R) of 10 kΩ was chosen to limit the control voltage supplied at a current of 0.43 mA to the analog terminal of a microcontroller.

Controller unit
In both sensing cases, possible fluctuation may occur warranting the use of analog to digital converter (ADC) circuit or analog input pins (A0-A4) on the Arduino microcontroller circuit [5,9] as shown in Figures 3 and 9. Equation (8) expresses the digitization of the input signals (Vin) at the analog input terminals which are scaled up to a reference voltage (Vref) of +5 V at default resolution of 8-bit. The Arduino processing unit is powered by 5 V supply, consist of a 16 MHz crystal oscillator or resonator which determines its sampling frequency and an ATMEGA 328 microprocessor on which the firmware is stored. This supports clocking and reset functions, memory and I/O registers on the microcontroller [1].
The controller unit operates based on instruction codes (in software) which senses the input from the analog input pins to actuate signals sent to the base terminal of the transistor driver circuit. The electronic configuration sensing circuit was used during simulation while the sensor circuit was deployed in real-life implementation. In simulation, the Arduino board source its power supply internally, uses Arduino IDE as a platform for writing the instruction codes which is interfaced with Proteus 8 professional software, output signals to the 16x2 Alphanumeric LCD unit and driver circuit via digital I/O pins D2-D7 and B1-B5 respectively. Fig. 9. Automatic phase selector simulation circuit.

Switching unit
The switching circuit operates with a voltage supply of 5 VDC biasing the collector terminal of the five BC547 NPN transistor driver circuit and the primary side of the relay module supported by equations (9a-b). Depending on the sensed signal, the microcontroller triggers required driver circuit with approximately 5 V, 25 mA, at the base via a base resistor of resistance 10 kΩ, and output via the collector terminal which feeds the relay module of specification 30 A, 250 VAC. The secondary side of the relay directly connects the input AC power supply (240 Vrms) and at the contacting terminal, they are all interlocked. This stage requires care as two or more different sources intersecting each other could cause an explosion. In other words, the effectiveness of the microcontroller, transistor and the proper operation of the relay module must be ascertained. The interlocked terminal is connected to a test load that selects only one supply based on availability and priority settings, while others are switched OFF or made inactive.
The transistor circuit is turned ON only when its base voltage is greater than the base-emitter voltage (approx. 0.7 V), hence the base resistance value of the driver circuit can be estimated.
With the minimum hFE of 110 for BC547 transistor, the maximum current flowing through the collector terminal can be estimated.
Diodes (IN4007) are externally incorporated in the primary side of the relay module to prevent inductive spikes or flyback current from destroying the transistors in relay driving circuits. Figure 10 shows an example of a three single-phase switching configuration assuming the mains supply are grouped as one while the other two are for generating set and solar inverter unit.

RESULTS AND DISCUSSION
The sample automatic three single-phase selector configuration was tested in simulation mode with three single phases power supply and later expanded and deployed for hardware implementation design. A rectified power supply input from a single-phase source is shown in Figure 11 which describes a full-wave signal of amplitude value 337.5 V in line with Figure 4. This can be estimated with the oscilloscope calibration at 50 V/div formed by the combination of the main and smoothing knob on Proteus simulator, the signal from the mean position can be estimated as 50 V/div multiplied by 6.8 div to give an approximate peak voltage of 340 V. Figure 12 shows the average voltage of the filtered waveform of a full-wave rectified signal (Vavgf) as 335 V in line with equation (5b) and Figure 5. Fig. 11. Full-wave rectification.
The two different configurations ensure that minimum voltage of approximately 5 V is sent to the control unit by attaching a Zener diode parallel to the potentiometer output terminal for the electronic divider circuit and an external supply of 5 V at the secondary side of the optocoupler. An external power supply was tapped from the priority input supply to charge up a battery source as shown in Figure 9 for the simulation design which serves as input source to the LCD circuit, Arduino Uno microcontroller circuit and the primary side of the relay circuit. Fig. 12. Filtered full-wave rectified signal.

Software implementation
The software section encodes the system algorithm from Figure 13 and Table 1 into a C programming language in an Arduino interface development environment (IDE). The preference menu from File drop-down menu of the Arduino 1.8.5 IDE gave the option to select the compilation and upload mode which helped in extracting the '.hex' file that was exported into Arduino image on proteus 8 professional simulator.
The switching process thereafter perfectly mimics the control flow chart in Figure 13 in line with the instruction codes exported to proteus. It demonstrates priority placed on the mains power supply 'PHCN' now BEDC as against the alternative supplies. The generator automatically switches ON whenever the mains supply goes OFF with a switching delay of 5 secs. Also, if the generator is not available it automatically switches to the solar inverter power supply observing the 5 secs delay. A return flow is always observed when power is restored to the mains supply or generator as the power supplied by the solar inverter is retained until when triggered OFF, then it switches to the mains if available or generator. The following tests results were summarized in Table 1. The circuit automatically switches to the mains supply based on priority, hence triggering the relay attached to the mains to switch ON the load. In a situation when the mains power supply is OFF the generator automatically switches ON via its relay triggering and supply the output load Switching OFF all the supply inputs. The output load goes OFF and the monitoring unit displays no supply Switching ON all the supply inputs The control circuit automatically selects the mains supply based on priority hereby triggering the relay attached to the mains while others are disregarded by the control circuit to avoid short of any form by the input supplies Timing of the delay circuit from the microcontroller The circuit allowed a timed delay of within ±5 secs tolerance Reset switch This is an external button used to free the memory of the control unit is all processes hereby creating enough space in the memory.
The implemented APS simply extends the workings of the flow chart by splitting the mains supply into three independent sources whereas the algorithm remains the same by selecting the red phase as priority in the switching order. This device can as well be implemented by adopting the finite state machine technique where base on an input trigger the system switches state to a next priority state. The switching section is corroborated with visualization on an LCD unit.

Hardware implementation
The simulation circuit deployed for the hardware implementation uses the sensor-based (optocoupler) circuit and an Arduino Nano microcontroller. An external battery source (9 V Hi-Watt) was provided as shown in Figure 14 for the hardware simulation design to power the LCD unit, Arduino nano board and the primary side of the relay circuit. The tested instruction codes are then uploaded to the Arduino nano hardware device via a USB 2.0 serial connector cable.  The sensing stage shown in Figure 14 was grouped into a subsystem termed voltage sensing unit shown in Figure  15 with individual terminals attached to switches from the five different sources. Also, a power terminal was routed from the input supply to the relay unit which depending on the control switching mechanism as shown in Figure 16 in which an available source is supplied to the load. The internal circuit of the subsystem contains the rectification unit and sensor-based circuit configuration which outputs to the analog pins of an Arduino nano microcontroller.

CONCLUSION
This paper had illustrated how to analyze, design and construct a microcontroller-based automatic single-phase selector from three single-phase sources in the simulation stage and additional two alternative sources (generator and solar inverter) in anticipation of the implementation stage design. This design adopts the use of low-cost materials which made it easily affordable to residential building, industries and particularly hospitals and ensures the right components and cable size were chosen. The design analysis was first carried out to test the performance of the sub-circuits, thereafter, practical implementation of the design was carried out with the utility power supply to switch a 60 W bulb.