Instruction FACTA UNIVERSITATIS Series: Electronics and Energetics Vol. 33, N o 1, March 2020, pp. 83-104 https://doi.org/10.2298/FUEE2001083V © 2020 by University of Niš, Serbia | Creative Commons License: CC BY-NC-ND UNIVERSAL MICROPROCESSOR CONTROLLED POWER REGULATOR WITH AND WITHOUT ADDITIONAL POWER SUPPLY  Vladan Vučković 1 , Simon Le Blond 2 1 Faculty of Electronic Engineering, University of Niš, Serbia 2 University of Bath, Department of Electronic & Electrical Engineering, United Kingdom Abstract. Inexpensive microcontrollers allow complex control methodologies for improving well-established technologies such as resistive lighting. In this paper, we present two constructions of a microprocessor controlled power regulator for resistive load of up to 2.5 kW and exemplify its use for the lamps in Tesla’s Fountain reconstruction project. These are universal power controllers and could be applied to a wide verity of non-inductive loads, but our primary intention was to construct a miniature light regulator with touch sensor for Tesla’s Fountain. The devices operate using the phase control of the power grid’s alternating current and controlled fade-in to increase lamp longevity. Extensive testing shows the device to operate successfully for 2400 hours of continuous error-free operation, to robustly handle high cycling stresses and increase bulb lifetimes by approximately a factor of 7-8. The microcontroller software can easily be adapted for controlling many non-inductive apparatus, like light bulbs or halogen lamps, as well as resistive heating. We also used advanced technologies from other multi-disciplinary areas to complete project. Key words: AC voltage controllers, Microcontrollers, Power regulation, Phase control, Signal processing. 1. INTRODUCTION In this paper we present a working prototype of a novel universal power regulator with touch control as part of a complete realization of Tesla’s Fountain patent. Major problem with Tesla’s basic construction was mechanical control mechanism for lights that is too much complex and expensive, with potentially huge risk of mechanical failures. Due to those problems, we decided to develop solution with no mechanical parts without changing any other details of the original patent. The presented power regulator operates using phase control of the power grid alternating current, and could potentially Received April 19, 2019; received in revised form November 10, 2019 Corresponding author: Vladan Vuĉković Faculty of Electronic Engineering, University of Niš, Aleksandra Medvedeva 14, 18000 Niš, Serbia (E-mail: vladanvuckovic24@gmail.com)  84 V. VUĈKOVIĆ, S. LE BLOND be used for control of a wide range of resistive loads. The prototype device was tested up to powers of 2.5 kW and shown to operate safely. The construction does not require electromagnetic relays or other mechanical moving-parts, so it is very reliable even after intensive use. The embedded microcontroller enables the construction of very complex control programs that could not be accomplished by some other digital circuits, for example counters and timers. The power regulator is universal, so the same hardware could be used in different applications; with only changes required in software. In addition we present a more advanced second iteration of the regulator. Here we removed the power supply transformer as well as the opto-triac component replacing it with a power ignition system based on a dual capacitor electronic circuit, and a smaller and cheaper microcontroller. The light control is solved in the same construction: this device can be coupled with a simple metal touch plate instead of classical switch or push button. The result is a miniature device, with not a single moving mechanical part, that could be embedded directly in the core construction of Tesla’s Fountain. In general, the field of power electronics is the processing of electrical power using a variety of electronic devices. The basic circuit is the switching converter that processes power from the input port and delivers it to an output port achieving regulation via a control port. Usually the raw input power passes through several phases until it reaches the final desired stage, regulated sequentially by the control lines. Several basic functions in power processing can be achieved in this way. This paper is concerned with AC–AC cycloconversion, specifically converting an AC input to a required AC output with the same output frequency, supplying the desired power through controlling the switch-on time at every AC cycle [1]. The present state-of-the-art is mostly focused on Pulse-Width Modulated (PWM) rectifiers, both single-phase and three-phase, as the preferred way of controlling modern semiconductor power devices. Constant-frequency PWM is achieved by comparing a saw-tooth or triangle carrier against a sinusoid to generate pulses of varying width [2]. One of the standard, well-known PWM controlled constructions is the CCM Boost Converter that can produce any conversion ratio between one and infinity. Another is a PWM switched inverter that combines voltage control and frequency control. This inverter uses a fixed voltage DC source where each of the phase legs of the inverter are switched at high frequency and basically operate as choppers. This circuit is widely used in motor controls. Here the switching patterns are complex and use sophisticated control electronics, often involving low-cost microprocessors, which is a central idea adopted in this paper. Another fundamental concept we exploit is modulation of output waveforms by controlling the switched pulse width for the phase leg. With the PWM technique the primary objective is to determine when to switch on the converter at each cycle to supply the desired output power. For example, an earlier solution uses a spatial PWM controller or an EPROM chip to store values that are latterly accessed in real time to determine the optimized switching angles [3]. There have been many multilevel PWM techniques developed in past decades, especially for three-phase three-level (3L) inverters [4]. In our approach we used simplified single-phase input, single-phase output (SISO), and AC/AC type cycloconverter for converting one AC power source into another AC power application. AC/DC/AC or AC/AC direct converters are newly developed power switching circuits widely applied in industrial applications, in comparison with other power switching circuits. Universal Microprocessor Controlled Power Regulator with and without Additional Power Supply 85 Although choppers were dominant in power supplies in the more distant past, power AC/DC/AC converters have been common in industrial applications since the late 1980s [5]. As a consequence of developments in semiconductors, new devices such as the thyristor (SCR), gate turnoff thyristor (GTO), triac, bipolar transistors (BT), insulated gate bipolar transistors (IGBT) and power metal oxide field effected transistors (MOSFET) have become available. Since the 1980s, control circuits have gradually migrated from analog control to digital control [5]. Digital power controllers have become an interesting choice in switching voltage regulators for high performance low-cost applications, like microcontroller voltage regulation modules (VRM’s) and other types of portable electronics. For example digital dither is introduced as a means of increasing the effective resolution of digital PWM (DPWM) modules. By using microprocessors, a universal dither generation scheme may be realized, producing patterns of any shape [6]. Mathematical modeling for these type of converters has also been given much attention, for example the first order-hold (FOH) is a widely accepted method to simulate the AC/AC and AC/DC/AC converters [5]. Additionally some practical matrix based iterative techniques have emerged for generating the PWM waveform that are guaranteed to converge. A wide range of calculations can be performed with a low cost microcontroller [7]. In some applications with asymmetric double-edge PWMA, complete experimental system comprising a front-end board, an FPGA board functioning as an ADPWM modulator and an eighth-order analog active low-pass filter board is developed [8]. Also, an interesting application for PWM is image processing circuit that performs a directional pixel-state propagation algorithm based on a pixel-parallel architecture, using low-cost devices [9]. In our presented method we choose the ubiquitous Microchip PIC microcontrollers as the basic processing device [10]. The possibility of precise power control for loads without need for modifications enables many different possibilities in home and industrial applications. The basic principle of the electronic power regulator is well known and is applied in different devices: light control systems, halogen lamp power control, and electric heater control, and many others. In industrial literature for this class of power regulators there exist synonyms like AC voltage controllers or dimmers. The functionality of these regulators is based on output thyristor and triac component characteristics. Specifically, these semiconductor components are able to conduct currents up to 40 A with low losses controlled by the proportionally extremely low gate current. When the triac is in the conductive state, it is deactivated only when voltage between the anode and cathode is zero. Therefore, if the triac is operated with an AC 220 V circuit, each sinusoid zero crossing turns off the triac. In this context its activation can be controlled over a wide range by turning on at any point in either the positive or negative half-period. The described functionality is the operating principle behind the device presented in this paper. By using microcontrollers to achieve this, compared to other solutions based on digital and analogue circuits, dramatic hardware simplifications, miniaturization, and cost savings can be achieved because calculation for control is computed in software - the microcontroller machine program. This philosophy has driven the design of the novel power regulator presented here. However, it is important to note that the complexity of the design is largely dependent on the practical application. Our basic intention was to construct exact replica of the Tesla Fountain, based on his original drawings in patent pending provided by the Museum of Nikola Tesla. Instead of the original mechanical control device for lights, we developed two much simpler versions of the electronic control unit that can be programmed to execute exact control functions like original mechanical device granted in Tesla’s patent. 86 V. VUĈKOVIĆ, S. LE BLOND The paper is organized as follows: Firstly, in section 1 we describe theoretical principles behind the basic power regulator, then described in the following sections 2-4. In Section 5 we describe detailed construction of innovative touch sensor power regulator device that works without an external power supply. In section 6 we exemplify use of the power regulator in Tesla’s 3D Fountain project. This device is in patent pending procedure (Serbia’s patent office). Finally the overall system and contributions are summarised in the conclusion. 2. THEORY OF OPERATION 2.1. AC Voltage Phase Control We begin by considering the power grid voltage (U) waveform presented in Fig. 1. For the simplicity, let us suppose that the load has is non-inductive or capacitive, so there is no phase shift between current and voltage phasors. It is well known fact that capacitive and inductive impedances in electric circuits cause the current to lead or lag the voltage respectively. However this does not apply to a purely resistive loads like the type of lighting solution powered by this device. a) b) Fig. 1 (a) Power grid sinusoid power transfer in the shaded region (b) Half-period of sinusoid The basic assumptions thus are that the current and voltage sinusoids are in phase. In addition the activation of the device is synchronized by a constant delay after the zero values of current sinusoid. Dark arrays in Fig. 1 (a) show active areas when the device receives energy from the power grid, in this case by virtue of changing the triac to a conducting state in these periods. It is obvious that total power consumption in that situation is less than full (nominal) power consumption. Also, it is well known that the energy conveyed to the load is proportional to the active dark region array on the current and voltage time series. Thus, the principle of power control is formulated in following way: The power regulation is based on control of the turn-on delays after the zero- crossing in every period of the sinusoidal power grid alternating current. The solution of power control then becomes a time delay control problem that is much easier to solve. To determine quantitative parameters that represent power control we will use a simple model presented in Fig. 1 (b). The half-period in Fig. 1 (b) is analogue to the half- period of power grid sinusoidal voltage. The phase is marked with variable k. The Universal Microprocessor Controlled Power Regulator with and without Additional Power Supply 87 portion of energy, which is conveyed to the device, can be determined by calculating the FP factor that represents the proportion between dark array and total array under the sinusoid. The Fp factor could be calculated by the proportion of the sine function integral in interval [k,] (dark array) and [0,] (full half-period): 2 1)cos( )0cos()cos( )cos()cos( )sin( )sin( 0        kk dww dww Fp k     (1) After the integration and rearranging for k we obtain equation (1b): )12arccos(  pFk (1b) This formula enables determination of the time delay, if the desired FP factor is known. Using the nominal power grid frequency of 50 Hz, and thus a half period relating to 10 ms, we can postulate the required time delay is:  k t *10  (1c) where t is the delay in miliseconds. After the combination of (1b) and (1c) we can postulate a practical formula to determine the time delay in miliseconds if we know targeted FP factor:  )12arccos(10   Fp t (ms) (2) By changing the input values in formula (2) we can precisely generate the time delay in one half-period to achieve targeted FP factor. If we change Fp from 0 to 1 with constant step value (for instance 0.1 or 10%), and successively apply the formula (2), the following table values are generated (Table 1). Table 1 Time delays according to target FP factor. Fp (%) t (ms) 0 10.000 10 7.952 20 7.048 30 6.310 40 5.641 50 5.000 60 4.359 70 3.690 80 2.952 90 2.048 100 0.000 88 V. VUĈKOVIĆ, S. LE BLOND It is clear that the non-linear function for time delay requests that formula (2) must be applied for each value to determine the output value precisely. But in real time applications it is not suitable to use the formula (2) in its original form because the inverse cosine function is computationally expensive. Thus for speed, every equidistant value in Table 1. is pre-memorized in microcontroller hash memory in a look-up hash table. This approach has an excellent trade-off between access time and functionality and thus frees up the micro- controller processor for sophisticated control tasks. It is possible to increase the precision by decreasing the step size between values, but this would then increase the numbers of elements required in the hash table. In addition linear interpolation between values could be used to achieve better granularity of the target Fp (%) factor. However the granularity in table 1 produces sufficiently smooth evolution of the light output. From Table 1., it is obvious that the difference between neighboring values is the most exposed near the beginning and the end where the sinusoid has the steepest gradient (Fig. 1). 2.2. Controlled fade-in for bulb longevity Immediately after turn-on, the temperature of the metal in light devices is low, so the resistance is low, causing a high transient current impulse. The impulse current is up to ten times greater than nominal steady state current. For instance, one 100 W incandescent lamp has an initial electrical resistance of 39. If it is connected to the 220 V power grid, the ignition current will be over 5.6 A. This high current impulse places great stress on the light bulb filament, and as such, devices usually malfunction during this initial turn-on period. To overcome this, the microcontroller can be used to power up the lamp gradually, starting not with 220 V but with a factor of ten lower voltage, approximately 20-25 V. By calling a special function on turn on, the microprocessor generates an initial output wave shape that first gently heats the metal filament in the bulb to red incandescence. This is achieved by gradually decreasing the time delay of the triac gate excitation in every period, up to the delay corresponding to desired Fp factor. When red incandescence occurs, the resistance is 70-80% of the maximal resistance, so after the turn- on, the current jump is only 20-30%. So rather than an initial starting current of 5.6 A the starting current is reduced to around 0.45 A. The whole process takes around 1 second so does not inconvenience the user, merely produces a pleasant but rapid fade-in effect. Following this, the microprocessor turns on to full power. This gradual fade-in process prolongs expected lifetime of the light bulbs by factors of 5-10. 3. MICROPROCESSOR CONTROLLED CONTINUAL POWER REGULATOR Based on theoretical discussion in the previous section, we now describe the technical solution that will enable power regulator construction. 3.1. Subsystems The description of the functionality for the sub-systems with component characteristics is also presented (Fig. 2). Universal Microprocessor Controlled Power Regulator with and without Additional Power Supply 89 Fig. 2 The block scheme of the power regulator Fig. 2b The Gretz bridge rectifier, capacitor and stabilizer (standard circuit)  Output Subsystem – Power component triac BT 139-600 is used. This triac can carry alternating currents up to 16 A RMS maximum steady state current. Thus the maximal power that can be controlled by the device is about 3.5 kW (for the nominal voltage 220 V) but is limited to 2.5 kW to give a wide safety margin. When high current values are present, the triac must be equipped with a metal heat sink to dissipate the ohmic heat.  Microcontroller – The whole device is organized around the microcontroller PIC16F8 which is the central functional part executing the control algorithm. The algorithm can be described in following steps: 1) Using the zero crossing detector, determine the start point of the half-period for alternating power grid current and reset the timer. The triac is inactive in this moment due to the input voltage zero values. 2) Determine the delay constant in milliseconds using the value of the target FP factor. Use the hash look-up table in Table 1. for fast approximation of the function (2). 3) After selected delay, turn-on output switch unit (triac). 4) Wait for triac activation time; a few hundred of microseconds depending on component type. 5) Turn-off (gate) triac. At that point the input voltage is still non-zero, so the triac will continue to conduct. 6) Goto 1) 90 V. VUĈKOVIĆ, S. LE BLOND The central component Microchip PIC16F84 was chosen for the device [11],[12]. This microcontroller is perfectly suitable due to its functionality, adaptability and low cost. The processor is clocked with a 4 MHz crystal oscillator that enables stable and accurate time cycles.  Electronic Coupling Unit – is accomplished by using the opto-triac component MOC 3020. Its breach voltage is about 7.5 kV. The optoelectronic component is controlled by the processor from the input side and it generates gate excitation current for triac as the output. This unit enables galvanic decoupling from the 220 V power grid giving high levels of protection for the sensitive low voltage electronic components.  The Electronic Circuit for Zero-Crossing Detection – uses the alternating signal from the secondary of the 220 V/6 V transformer that energizes the microcontroller (via 7805L stabilizer to limit the input voltage to 5 V). This simple solution is used as simple, safe and sustainable solution. When the signal rises above 2.0 V the microcontroller reads this as a logical 1, and when it falls below 0.8 V a zero. Compared with power grid current, the signal has opposite phase but the same frequency so it can be used for realization of the 1) step in the main algorithm.  Rectifier – standard Gretz bridge rectifier which also uses electrolytic capacitor 470 F and stabilisator 7805 enabling +5V DC for microcontroller, shown in fig. 2b. To ensure protection of the sensitive electronic components, the device is galvanically isolated from the mains between A and B line (Fig. 2). Line A decouples the microcontroller from power power grid by power transformer and line B decouples it from the output power circuit by optoelectronic component. 3.2. Device operation The block scheme of the device is presented in Fig. 2. The construction of the device is compact so it can be embedded on a 3x5 cm wafer. It possesses many useful technical characteristics and is proven to be very reliable in challenging use scenarios. To begin with, the microcontroller part of the device is galvanically decoupled from one side with transformer (A), and from the other side with opto-triac (B). Also, it is grounded separately, enabling very high level of resistance to power grid overvoltages and currents. By virtue of the online zero crossing detection, the regulator can accommodate small power grid frequency changes, ensuring that the delay in triac activation is always from the actual measured zero crossing rather than the ideal 10 ms delay. It is well known that in practice power grid frequencies vary somewhat around the nominal 50 Hz (or 60 Hz in other regions). For example, at times of high load and excessive consumption, the power grid frequency has a tendency to decrease as there is less kinetic energy stored in the prime movers of generators. The embedded microcontroller solves this problem because it constantly, period by period, measures successive zero-crossing points, so that all corrections to changes of frequency are achieved in real time and the device remains synchronized to the power grid. For programming of the microcontroller, the assembly language development environment was used. The light controller has an original construction that surpasses similar devices in its class. It possesses all characteristics that are well known for this type of device and also has a set of new advanced functions. Universal Microprocessor Controlled Power Regulator with and without Additional Power Supply 91 Some of the key characteristics of the device are specified:  Microcontrollers and integrated technology are used for the construction of the device. This implementation attains high functionality and reliability with low power consumption and low costs. The basic circuit is a PIC 16F84 microcontroller which is widely produced at low cost. The construction does not employ components with mechanical moving parts like relays, so the probability of malfunction decreases.  Integrated technology enables the development of the device onto compact 3x5 cm one-side wafer which can be energized with normal line transformers.  The light power regulator generates an alternating signal that could power a small guide light source enabling much easier location of the switch fitting in darkness.  Maximal output power is over 25 kW (16 A). With a heat sink the device was tested successfully up to powers of 1800 W (equal to 30 parallel connected 60 W light bulbs). The main circuit must contain only resistive based lighting: i.e. light bulbs or halogen lamps.  If the push button is pressed in the active phase, the turn power turn-off is delayed until the inactive phase. 3.3. Device testing After a construction of the industrial prototype that possesses all characteristics and components of the final version of the device, we have performed comprehensive testing of the device to check all defined functions in normal and extreme working conditions. Test sets are equivalent to both design versions of our device.  Continual testing – The device continually worked in long periods of time. After a few months of permanent testing the device retained all nominal and projected parameters, so this test was successfully passed.  Test of output power – Large thermal loading was connected to the output – heaters up to 2 kW, emulating a large number of lighting bulbs in parallel connection. The device managed this loading without problems, although these tests indicated that the metal heat sink is required at very high loads. As the maximal nominal output power for the embedded type of triac is 16 A, the output fuse must be scaled accordingly to only rupture before the triac is damaged by short circuit current, but not rupture under normal high load conditions.  Shock test – Using another microcontroller connected to a relay, a series of voltage shocks were emulated across a broad range of possible instantaneous voltage values (from the 220 V waveform) and frequencies of switching. The tests proved that the prototype device is resistant to high instantaneous peak power grid voltage and high cycling stresses, preserving stable performance in the presence of both. 4. MICROPROCESSOR CONTROLLED CONTINUAL REGULATOR WITHOUT ADDITIONAL POWER SUPPLY In this section we will present the advanced version of power regulator developed after extensive testing of the previous initial prototype. The power transformer supply as well as opto-triac component are removed from the construction, reducing the cost and size. Here we use an 8-pin PIC12F675 microcontroller instead of standard 18-pin PIC 92 V. VUĈKOVIĆ, S. LE BLOND 16F84 in the previous iteration. The touch control sensor circuit is achieved within the same device. We discuss the principle of the operation of microprocessor controlled switch without additional source of the power supply, shown in Fig. 3. Fig. 3 Operational principle in electrical circuit and functions The microprocessor controled continual regulator and the switch without additional power supply contains microcontroller (MC1), switch component (TR1), restricted current capacitor (C1), restricted impulse power supply resistor (R1), diodes for current routing (D1) and (D2), stabilization and filtration voltage power supply components (ZD1) and (C2), resistor for synchronisation with the power grid voltage (R3), extrusion capacitor for synchronized interferances (C4), capacitor (C3) and resistor (R2) for excitation voltage restriction of the switch component (TR1), capacitor (C7) and resistor (R6) for the power grid interferances and input circuit components (CP), (C6), (R5), (R4), and (C5), emphasized by the fact that the device is using power supply current running through the load (S) in such a way that the whole device obtains voltage and is syncronized by parallel wiring with its switch component. The contact plate (CP), through which the user activates the device, can be of any design and made of any conducting material, though it is desirable that the conductor is as warm as possible. This contact plate should have sufficient mechanical strength to ensure the switch can be fastened on the wall. On the back side of the contact plate it is desirable to fasten the metal heat sink of the triac (TR1), so that the device can dissipate heat accumulated when handling heavy loads. The contact plate must be electrically insulated from the wall by plastic or some other strong insulating material, so that the wall does not conduct signals to or away from it causing interference in the device’s operation. 4.1. Powering the microprocessor The functional heart of the device is the microcontroller (MC1). In this case Michrochip`s microprocessor PIC12F675 was used, because of its size and overall performance. From a hardware perspective, the main problem is securing enough electrical power for the microcontroller in order that its program would perform without interruption. In the boxes in the wall that are usually used for installing the switches there are two different potentials: live wire and the potential of the bulb (point A potential). It is therefore Universal Microprocessor Controlled Power Regulator with and without Additional Power Supply 93 necessary to supply the device with a small amount of the current that runs through the load S (the bulb). When the switch (triac TR1) is turned off, the potential at point A is 0 V. In this case it is not difficult to provide the power supply for the microcontroller, first by the restriction of current with the resistor R1 or capacitor C1, and then by the stabilization of the voltage. Problems can occur when the triac is in the on state, because then both potentials in the switch box are at the live wire potential, in such a way that all voltage transfers from the switch to the bulb. The problem of the voltage loss of the microcontroller (MC1) is solved by use of the triac (TR1) and by choosing the correct moment to turn on by MC1’s program. So as not to leave the microcontroller without the power supply under certain conditions, it is necessary to ensure that the triac (TR1) never turns on at the beginning of the semi-period, but only in the moments when the average current of the device supply, of that period, exceeds the average power consumption required by the microcontroller. This problem is addressed by the microcontroller (MC1) itself. Stabilization and filtration of the voltage of the power supply is performed by parallel connection of the zener diode (ZD1) and the capacitor (C2). Capacitor (C2) is filled over the diode (D2) in the time intervals when the rate of change of voltage is dUFA / dt < 0. Diode (D1) is used to pass through the current through the capacitor (C1) in intervals when the rate of change of the voltage dUFA / dt < 0, in order that it would be possible to recharge capacitor (C2) when the rate of change of voltage dUFA / dt again becomes bigger than 0. In the circuit of Fig. 3 the restriction of the current by regular connection of both capacitors and resistors is chosen, because of the incomparably smaller dimensions and losses possible in comparison to (restriction) through resistors alone. The capacitor C2 must be sized to ensure the average required current of the mircocontroller of 1.5 mA is continually supplied by only turning on the triac after the first sixth of every semi period. By the end of the first sixth of every semi-period, on power grid effective voltage of 230V (amplitude 310V) based on formula, a sufficiently sized capactior will be: U tI C K    (3) where VVUU M 1555.0*310 6 sin   , and the semi-period ms T t 10 2  . 1.5mA 10ms 100nF 155V C    (4) The dimensions of the capacitor from 100 nF/400 V are relatively small, and since active power on them gravitates towards zero, no warming occurs. During the process the difference in the light level is only slight (negligible) when the triac is turned on in the end of the first sixth of the semi-period, compared to turning on of the triac at the beginning of the semi-period. 94 V. VUĈKOVIĆ, S. LE BLOND 4.2. Touch detection switch One of the main advantages of this switch is the detection of touch instead of pressure, in such way that it is possible to make it very firm and very sensisitive at the same time. To excitate this device it is necessary for the user to make physical contact with the contact plate. Touching of the contact plate is detected by the microcontroller into pin GP1, producing a sequence of logic zeros and ones with the frequency of the input power grid. Based on the time duration of the user touching the contact plate, the moments of the turning on of the triac is updated in the microcontroller's program. Maximal electricity which can be conductuted by the control plate is determined by capacitor values C6 and the resistor (R5), so that it can be calculated by the following formula: fC R U I EF EF 2 1   (5) The capacitor value C6 is not bigger than 220 pF, and the resistor value R5 is not less than 1 M  . The penetration voltage of the capacitor C6 must be tested and guaranteed by the manufacturer and must not be less than 630 V, although it is desirable to be multiple stronger for the user`s safety.With these limit values and the voltage of UEF = 220 V, the maximal effective current will be IEF max = 14 A which that cannot be felt, or have any kind of the negative consequences for the user. Even in the event of capacitor short circuit failure the maximum current would be limited by the resistor alone to 0.63 mA. The prototype regulator was tested and certified for safety and found to be completely safe. 4.3. Triac exitation Current of over 20 mA is necessary for the safe excitation of the triac (depenant on the triac type) which is achieved through R2 and C3. For a smaller size of resistor for the current limitation, a smaller capactior value must be adopted. A reasonable size capacitor could be 100 nF/400 V (as in the previous example). However, maximal available current is 1.5 mA with such a capactior. That is why the excitation of the triac is achieved through capactior C3 as follows: a) In the semi-period, when the live wire potential is negative, the microcontroller output (G4), at the moment of traic activation, transits from the logic zero state to logic one, thus sending short-term positive current toward the triac gate. The value of the current is determined by resistor R2, and must large enough to allow successful triac excitation. b) In the semi-period, when the live wire potential is positive, the micro ontroller output (G4), at the moment of traic activation, transits from the logic zero state to logic one, thus sending short-term negative current toward the triac gate. The value of the current is determined by resistor R2, and must large enough to allow successful triac excitation. By this way of triac excitation, the average current of the gate is greatly reduced, to around 100 A. One of the conditions for the precise determination of the moment of turning on of the triac is the use of one microcontroller's input (GP2) for continual zero crossing detection and thus the power grid voltage synchronisation. The signal is delivered through resistor R3, while capactitor C4 eliminates interferances which would eventually appear on that input. The triac must have a galvanically isolated heatsink comprising of pins connected to the contact plate. The triac used in this device is BTA16/600, and its heatsink within the triac is guaranteed by the manufacturer. It must have a penetration voltage of over 2.5 kV. Universal Microprocessor Controlled Power Regulator with and without Additional Power Supply 95 5. FINAL DEVICE PROTOTYPE This section presents further details of a new microprocessor controlled continual regulator practical realization (Fig. 4). This device is a result of several year`s development and testing. As we have presented in previous sections, there are many original and new aspects to its hardware, making it unique device in many aspects. Nevertheless, the construction remains simple and very easy to manufacture. Fig. 4 Device prototype The purpose of this section is to briefly highlight some important features of the device:  The device has potential to completely replace today’s classic wall switches and dimmer switches for incandescent and halogen light bulbs.  The device is built around extra efficient and small eight pin chip microcontroller. The Microchip PIC12F629/675 is used. The embedded control program is relatively complex (see appendix B for assembly code), but only about 40% of the total program memory is used, allowing a lot of space for future software expansion. Therefore, it has high level software flexibility.  The embedded program uses advanced control algorithms. Among other functions, the device has program control of the sinusoidal fade-in (Fig. 5) and fade-out output voltage, power saving control mechanism and automatic shutdown after predefined time period. The list of the functions could be easily expanded if the manufacturer has additional requirements. 0 0.2 0.4 0.6 0.8 1 1.2 1 9 17 25 33 41 49 57 65 73 81 89 97 O u tp u t p o w e r p .u . Time, 1x10-2 s Fade… Fig. 5 Fade-in output effective power diagram 96 V. VUĈKOVIĆ, S. LE BLOND  The device does not use transformation units for power supply. It has original power ignition system based on dual capacitor electronic circuit. The device is connected directly to the 220 V electric power grid only via two pins. The connection scheme is presented in the following picture (Fig. 12): Fig. 6 Simple connection scheme It should be noted that the connection scheme is extremely simple; in fact it is the same as the classic installation. Therefore, existing installation for ignition of the lights can be used; the change of the wall switch is the only requirement.  It has no mechanical moving parts like relays, levers, or rotating pots that could easily break. It is completely made of electronic components on single-side printed wafer. Instead of the classic switch it uses only thin metal (iron, copper, aluminum or other conductor) layer, connected with special touch detecting hardware. The microprocessor has a special subroutine when controlling this touch sensor. All commands of the user are detected only by a light touch of this layer.  The device has two basic versions of input. It is possible to use classic push button. Nevertheless, the main version of the prototype uses touch sensor. The CPU program handles both variants. After one touch, the device goes into the fade-in program. The output voltage slowly rises from 20-30 V to approximately 95% of the nominal voltage (around 210V). At any point of this process, device could be paused, maintaining the current power level, again only by one touch. This level is memorized into the internal non-volatile EEPROM memory, so if the current power grid power supply is lost, the level will be recalled on the next energization. Also, when the user wants to turn-off the lights, one touch is enough – the device will go into the slow fade-out. These functions are in complete harmony with modern power-saving regulations.  In contrast to classic switch, that has only two power levels (on and off), the new device has many possible levels, between 0% and 95%. For instance, if someone has 100 W incandescent bulb, using this switch, that person could adapt all standard powers 25 W, 40 W, 60 W, 75 W, but also nonstandard 10 W, 33 W, 67 W, 80 W etc. Also, precise fade in and out procedures visually look attractive. The maximal power is about 95%, so the device constantly saves power even at maximal output.  The gradual fade in control program significantly extends the lifetime of standard incandescent lamps by a factor of at least 7-8 according to our observations.  The output power component which is used has maximal 16 A current. In our system when a sensor metal layer is used at the same time as a heat sink, being a standard configuration, the output power above 1 kW is easily reached. We have tested the device under 700 W output power for a few months and its performance Universal Microprocessor Controlled Power Regulator with and without Additional Power Supply 97 was excellent. If 1 kW is loaded (for instance two 500 W halogen lamps in parallel circuit), after around 20 minutes the temperature of the touch sensor is slightly increased, but all functions still remain the same.  The device has very useful characteristic of universality. By changing only the microcontroller’s program it is able to serve as:  Standard wall switch for room lamps,  Alternating switches,  Cross switch,  Time relay,  Classic push button.  If it is necessary to turn on one or more parallel connected incandescent light bulbs from the different switch location (for instance N places), the current system needs 2 alternating and (N  2) cross switches to comply. By using this device there will be need only for one switch unit and N  1 metal sensor layers (coupled with one capacitor and resistor), parallel connected. This solution is therefore much simpler and cheaper.  The device signals the normalization of the power on 220 V power grids by shortly turning on and off output lamps using minimal power. If the device is at certain power level, after the power grid power incidentally goes on and off, the device resets in the turn-off mode.  The latest versions of the industrial prototypes of the device have been intensively tested in areal working environment for a few months continually, maintaining perfect operational functionality. The master device prototype has had around 2400 hours of continuous error-free operation.  Device dimensions are 33x24 mm, the height is 24 mm. The other important device characteristics are systematized in the following table 2: Table 2 Key device characteristics Temperature range -20 do +70 o C Maximal output power > 1000 W Power loss (output power is off) < 100 mW Power factor (output power is off) 0.028 Supply current (output power is off) 14 mA Maximal enabled power grid voltage > 440 V Permeable voltage (toward user) 2500 V Maximal sensor current (toward user) 10∙10 -6 A Device temperature (P=700W, Tamb=20 o C) 60 o C Type of pertinex plate One-sided Dimension of the pertinex plate 33 mm x 24 mm 98 V. VUĈKOVIĆ, S. LE BLOND 6. TESLA’S FOUNTAIN The project ―Computer Simulation and 3-D Modelling of the Original Patents of Nikola Tesla‖ in cooperation with ―Nikola Tesla Museum‖ of Belgrade, which represents an institution of national importance, was started in 2009. The main purpose of the project is to digitalize, visualize and reconstruct (with real models) the original legacy of the Museum [13], [14], [15]. This research was conducted in the project entitled ―Computer Simulation and Modelling of the Original Patents of Nikola Tesla‖ and approved by the Ministry of Education, Science and Technological Development of the Republic of Serbia [15]. The first of Tesla's patent that was studies was Tesla’s Fountain patented as Tesla’s Fountain, no. 1,113,716, US patent office, granted Oct, 13, 1914 (Fig. 7). The first achievement on this project was a 300.000 particle 3D model of Tesla’s Fountain (Fig. 9). The applications used are 3ds Max, Adobe Photoshop, RealFlow, V-Ray, Microsoft Visual Studio C++. Then, we used different tools to generate digital model of Tesla's fountain in various configurations and environments. This work was conducted with a team of professors and students from the Electronic faculty, who have been are assembled together with professional experts from the Museum. We used original construction schema from Museum (Fig. 8) to generate first 3D model of Tesla’s Fountain. Fig. 8 Tesla-Tiffani original Fountain construction (Museum of Nikola Tesla Heritage) Fig. 7 Original Tesla’s Fountain patent Universal Microprocessor Controlled Power Regulator with and without Additional Power Supply 99 The original construction indicates the solid materials for basic structure is comprised of metal. The main idea in the patent is to use just one induction motor to generate water flow against gravity and to run the complex light control mechanism using the mechanical gearing (Fig. 8). Our first innovation was to alter the basic material to glass [16] (Fig. 9). Fig. 9 Tesla's 3D Fountain model in glass The Tesla Fountain in glass has advantages for research and development of the inner structure as well as aesthetic benefits. After the initial structure modelling, we concentrated on a problem of light control. In his original patent (Fig. 7) Tesla used multi-colour filters to generate interesting colour effects in Fountain water flow. We implemented this original idea in our model (Fig. 10): Fig. 10 Tesla fountain in glass with colour filters (detail) 100 V. VUĈKOVIĆ, S. LE BLOND To run this colour filter system on the top on the Fountain, Tesla proposed a complex mechanical system with differentials, similar to a clock mechanism. This unit reduces the high rotational speed of the main induction motor which also runs the water pump on the same axis (Fig. 7). Our model follows this part of the original construction also (Fig. 11). Fig. 11 Tesla fountain with mechanical redactor system This mechanism is embedded in the central part of the Fountain, out of water flow and above the main water level in the reservoir. It is integrated with a colour filter (Fig 12). Fig. 12 Tesla's Fountain with mechanical system (detail) After the animation of the model, the main invention is presented visually, using one induction motor work to pump water and at the same time connected via mechanical differentials to run the colour filter, whose speed is proportional to the water flow. After the modelling and simulation, the next step is to build the real construction of the model [16], [17]. Using current technology, it is easy to manufacture the basic structure using 3D printers. However the main difficulty is to produce the mechanical parts which far Universal Microprocessor Controlled Power Regulator with and without Additional Power Supply 101 outstrips cost of producing the rest of the basic construction. For this reason it was decided to substitute the whole mechanical part with a static colour lamp controlled by a microprocessor device that is in the main innovation presented in this paper. 7. CONCLUSION This paper presents theoretical and practical realization of the two versions of universal power regulator for Tesla’s Fountain. The power regulation device comprises hardware and software part designed using the Microchip PIC 16F84/12F675 development system and other applications, going through the different design phases discussed. The main intention of this paper is to develop complete substitution for the mechanical light control part of the Tesla Fountain. The further research efforts proved that general use of our solution was possible for a variety of loads.. The processor does not require supporting memory and peripheral integrated circuits which enable realization of the device with very low component and small physical footprint. Using the power regulator with non-inductive light sources like light bulbs and halogen lamps, it is possible to regulate the light intensity. However the power regulator may have other uses, such as in the case of electric heaters it is possible to regulate the temperature by controlling the heater current loading. The authors’ intentions are to develop further applications and modifications starting from the basic concept described in this paper. Acknowledgement: This paper is supported with III44006-10 project of the Ministry of Education and Science Republic of Serbia and Museum of Nikola Tesla in Belgrade, Serbia. Authors also want to thanks to eng. Dragan Tošić, who is co-owner of the patent pending for the construction of the advanced Michochip 12F675 microprocessor device. APPENDIX A Detailed computer model and simulation of the device is also developed in Auto- CAD application. That model is used to generate following pictures: Fig. 13 Blueprint of the device Dimensions are in millimeters Fig. 14 3D models of the device 102 V. VUĈKOVIĆ, S. LE BLOND Fig. 15 3D models of the device (different views) Fig. 16 Method of sensor layer, device and plastic case assembly into the wall switch box (front view) Fig. 17 Method of sensor layer, device and plastic case assembly into the wall switch box (side view) Fig. 18 First version of the device prototype. Tested for over 2400 hours Fig. 19 Last version of the device (industrial prototype) Universal Microprocessor Controlled Power Regulator with and without Additional Power Supply 103 Fig. 20 Illustration of the device’s miniature size Fig. 21 Side view of the device Fig. 22 Compact solution for wall switch APPENDIX B Assembly code for microcontroller: 0078 0018 ;--------------------------------- 0079 0018 procedure(periode) 0079 0018 0080 0018 0081 0018 01 96 clearq(kx) ;key buffer 0082 0019 20 15 call wait_low ;synhro 0083 001A 0084 001A 08 22 load(wx) ;wait constant in millisecond 0085 001B 20 0D call wait 0086 001C 0087 001C 16 06 set(portb,triac) ;turn on triac gate 0088 001D 30 0A load.(5*2) ;delay 0089 001E 20 0D call wait 0090 001F 12 06 reset(portb,triac) ;turn off triac gate 0091 0020 0092 0020 30 BE load.(95*2) ;delay and wait for second power half-pe 0093 0021 20 0D call wait 0094 0022 0095 0022 16 06 set(portb,triac) ;turn on triac gate 0096 0023 30 0A load.(5*2) ;delay 0097 0024 20 0D call wait 0098 0025 12 06 reset(portb,triac) ;turn off triac gate 0099 0026 104 V. VUĈKOVIĆ, S. LE BLOND 0100 0026 00 08 return 0101 0027 ;--------------------------------- To control “fade-in” procedure repeat call periode function changing delay time (in memory register WX) from its maximal value (minimal output power) to the minimal value (maximal/full output power). This is done through memory register EX loop: 0160 0048 light: 0161 0048 0162 0048 30 A0 mem(wx,maximum) ;warming, 1sec 0162 0049 00 A2 0163 004A 30 32 for(ex,warm,m1) 0163 004B 00 90 0163 004C 0164 004C 20 18 call periode 0165 004D 0B 90 loop(ex,m1) 0165 004E 28 4C 0166 004F REFERENCES [1] R. W. Erickson and D. Maksimovic., Fundamentals of Power Electronics, Kluver Academic Publishers, second edition, Dordrecht, 2001. [2] J. Sun, Pulse-Width Modulation, Dynamics and Control of Switched Electronic Systems Advanced Perspective for Modeling, Simulation and Control of Power Converters, Monograph, Chapter 2, Springer, 2012. [3] D.G. Holmes, T.A. Lipo, Pulse Width Modulation for Power Converters—Principles and Practice, 1st edn. Wiley–IEEE Press, Piscataway, 2003. [4] G. Grandi and J. Loncarski, "Simplified implementation of optimized carrier-based PWM in three-level inverters", Electronic Letters, vol. 50, no. 8, pp. 631-633, 2014. [5] F. L. Luo, H. Ye, M. Rashid., Digital Power Electronics and Applications, Elsevier Academic Press, San Diego, California, U.S.A., 2005. [6] A.V. Peterchev., Digital control of PWM converters: Analysis and application to voltage regulation modules, M.S. thesis, University of California, Berkeley, U.S.A., 2002. [7] J. Huang, K. Padmanabhan, and O. M. Collins, "The sampling theorem with constant amplitude variable width pulses", IEEE Transactions on Circuits and Systems, vol. 58, no. 6, pp. 1178-1190, 2011. [8] Z. Yu, Y. Fan, L. Shi, G. Lv, A Pseudo-Natural Sampling Algorithm for Low-Cost Low-Distortion Asymmetric Double-Edge PWM Modulators, Springer Circuits, Systems, and Signal Processing, 2014. [9] Y. Kim, T. Morie, A PWM-Mode Pixel-Parallel Image-Processing Circuit Performing Directional State- Propagation and Its Application to Subjective Contour Generation, Springer Circuits, Systems, and Signal Processing, vol. 34, pp. 605-623, 2014. [10] J. B. Peatmann, Design with PIC Microcontrollers, Prentice-Hall, 1998. [11] PIC16C84:8-bit CMOS EEPROM Microcontroler, Microchip Technology Inc., U.S.A., 1997. [12] PIC16C84:EEPROM Memory Programming Specification, Microchip Technology Inc., U.S.A., 1997. [13] V. Vuckovic, A. Stanisic, N. Simic, "Computer simulation and VR model of the Tesla's Wardenclyffe laboratory," Digital Applications in Archaeology and Cultural Heritage, vol. 7, pp. 42-50, 2017. [14] V. Vuckovic, S. Spasi, " 3-D stereoscopic modeling of the Tesla’s Long Island", Facta Universitatis, Series: Electronics and Energetics, vol. 29, pp. 113-126, 2016. [15] V. Vuckovic, A. Stanisic, S. Le Blond, "Virtual reality modelling and simulation of the Tesla's radio controlled boat", pp. 61-64, 2017. [16] V. Vuckovic, V. Mitic, Lj. Kocic, B. Arizanovic, V. Paunovic, R. Nikolic, "Tesla’s Fountain, Modeling and Simulation in Ceramics Technology", Journal of the European Ceramic Society, vol 38, no. 8, pp. 3049-3056, 2018. [17] V. Vuckovic, V. Mitic, Lj. Kocic, V. Nikolic, "The fractal nature approach in ceramics materials and discrete field simulation", Science of Sintering, vol. 50, no. 3, pp. 371-385, 2018.