SISY Y 2007 • 5th International Symposium on Intelligent Systems and Info f rmatics • 24-25 August,t 2007 Subotitca, Serb r ia i
Easy and Cheap AC Device for Softcomputing Realization Istvan Prosinger, Nandor Burany, Peter Odry Polytechnical Engineering College, Subotica, Serbia
[email protected],
[email protected],
[email protected] Abstract—Essential ideas are in this project: the microcontroller is not isolated from the mains and using simple numerical and programming solutions. The main idea of this project is to produce a cheap and easy device for controlling the current/voltage of a household appliance in a general sense (for example: motor rotation speed and heater control in the hairdryers, etc) with the help of the PWM outputs of a simple MSP430F20xx device.
I.
INTRODUCTION
The solution described here provides the possibility for kitchen and household appliances to contain better quality by use of more complex algorithms. Fuzzy or neural control could be used and could replace conventional technology [1]. Besides RPM and other control, including heating may also be solved to obtain complete regulation of an appliance. This project uses a small number of cheap parts, and it does not need much space. Fuzzy control, the PWM driver signal generating and measuring of current is done by a MOSFET and an microcontroller MSP430F2011. The microcontroller is not isolated from the mains. II.
HARDWARE
The main idea of this project is to produce a cheap and easy device for controlling the current/voltage of a household appliance in a general sense (for example: motor rotation speed and heater control in the hairdryers, etc) with the help of the PWM outputs of a simple MSP430F20xx device. In an example of a practical application of such an idea, we choose to show the methodology of controlling the motor rotation speed of a hairdryer, mixer or other similar device with an MSP430F2011 microcontroller. The main AC power is divided with RC elements and stabilized with a voltage reference (in this case an accurate Zenner diode, but it can be any other accurate dedicated voltage reference) to get the 3.3V supply voltage for the MSP. In this configuration, with 470nF capacitors the auxiliary supply can give a current up to 7mA, which is quite enough to drive the microcontroller, since there are no additional peripherals present. The gate of the logic level MOSFET, which drives the motor is directly connected to the MSP430 PWM output pins P1.2 and P1.6 which are synchronized and shorted together to give enough output current to the gate of the transistor (which is considered as a capacitive load) without damaging the port(s) of the microcontroller. Pins P1.2 and P1.6 are driven by the (&TACCR1)
1-4244-1443-1/07/$25.00 ©2007 IEEE
Figure 1. Microprocessor solution
capture/compare register of Timer A2, which runs the PWM modulation in 8-bit resolution (0-255). The actual speed from the motor is measured with a tachometer, which in this case gives 24 impulses per one rotation. This feedback signal is connected to the P1.0 pin of the microcontroller that is configured to generate an interrupt on the rising edge of the signal from the tachometer. The speed is calculated by measuring the period between the two pulses from the tachometer, with the help of Timer A2.
Figure 2. Schematic of energetic circuits
Since the timer runs at 8 MHz, which is too fast for measuring the motor speed, an interrupt is generated when it counts up to 256, and then a special period counter register (&PERIOD) is incremented. This way we manage to divide the timer clock by 256, and whenever the tachometer generates an interrupt, this register is being considered when calculating the speed of the motor. The desired speed (rotations per second –
49
I. Prosinger, N. Burany, P. Odry • Easy and Cheap AC Device for Softcomputing Realization
RPS) should be written into the R6 register, and it can be calculated as follows:
R 6 ( desiredspeed ) =
8.000.000 MHz 256 x 24 xdesired _ RPS
As mentioned above, the timer is sourced with an 8MHz clock, the resolution is of the PWM output is 8 bits, which means that the PWM modulator frequency is 8.000.000/256=31.250Hz, which should be high enough to drive most DC motors and avoid audible noise. The over current protection is designed with a help of a shunt resistor in a series with the DC motor. The voltage on the shunt resistor is monitored by Comparator A + on MSP430 port P1.5, and triggers an interrupt with the current sense (CS) algorithm that stops the PWM output. This interrupt will occur if the voltage on the shunt resistor exceeds 0.25xVcc. Since the shunt resistor is 0.22 Ohm, it means that the current limit is:
I LIMIT =
0.25 xVcc 0.25 x3.3V = = 3.75 A 0.22 0.22
The photograph of the prototype can be seen in Fig 3.
Figure 3. Realized test system without hardware optimization
III.
SOFTWARE
The microcontroller is sourced with a factory calibrated DCO clock at 16MHz without any additional clock source. The main routine is a simple endless loop that only resets the Watchdog timer which runs in NMI mode, to automatically generate a POR if for some reason the microcontroller stops responding. All the other routines are called from the interrupts. The program algorithm looks like this on Fig 4.
Figure 4. Algorithm of system
The heart of the control algorithm is an optimized Fuzzy controller with a centroid/gravity deffuzzyfication approximation. This is a simple one level Fuzzy controller, which increases or decreases the PWM output proportionally depending of the determined error feedback. The output of the controller is absolute, which means that it is written directly in the (&TACCR1) capture/compare register of the microcontroller. This means that the controller will almost never saturate its output, except if there is a maximum error feedback (0FFh) which will rarely happen, but for this application it gives supreme stability – way inside the Fuzzy controller boundaries, no noticeable overshoot on start,
50
and quite enough drive power for a DC motor with no significant load. An additive output controller would have a much more aggressive drive, but it would also be much more unstable and harder to adapt/implement. The way it is designed now, the controller can be easily adapted to any other application to make it respond appropriate to the given error feedback, by simply modifying its input or/and output membership functions if there is a need to give it a different fire power. The controller takes about 500 machine cycles to complete altogether with the computation. Since there is no hardware multiplier in the F20xx series, a fast multiply and accumulate (FMAC) and division (FDIV) algorithms had to be written which takes maximum about
SISY Y 2007 • 5th International Symposium on Intelligent Systems and Info f rmatics • 24-25 August,t 2007 Subotitca, Serb r ia i
150 machine cycles each. These algorithms are written with 8-bit logic in Macro style, to make them simpler for use, and because in this configuration the Fuzzy controller has no negative output, these algorithms are written for unsigned operation. For an example of using these macros, take a look at the defuzzyfication routine in the program listing (Appendix A). The listing of multiply and division macros is in Appendix B. IV. CONCLUSIONS This project has first been published in the pages of Texas Instruments in the competition of projects for the processor family MSP430Fxxxx. At the online rating of the projects, this project has continually been among the top 10 projects according to the marks it got. This project is very interesting in the sense that it offers a simple hardware and software solution with a cheap and powerful microcontroller. The hardware is realizes with a few, and in the domain of engineering applications, rather unusual solutions. These are: 1. The processor is charged from the network without galvanic separation 2. The processor charges the MOSFET transistor directly without any special driver. A fuzzy control algorithm was used for software. For the realization of a fuzzy real-time algorithm for the control rotation speed more and more powerful microprocessors or controllers are used. If a member of the MSP430 processor family [2] is also used, then it has
to be one with an implemented parallel multiplier, which are more expensive by 6 or 7 times from those which do not have such circuits. With the applied MSP430F2011 microcontroller there is no implemented parallel multiplier. Since the fuzzy procedure is rather demanding in the sense of multiplying instructions this strains the processor capacity. For this reason a microcontroller has been developed [3] and further some conveniences have been developed which are adapted to this type of microcontrollers. The complete program was published on the website of Texas Instruments during the time of the constructors' competition. The joint program of programming and hardware solutions offer the possibility of realization of intelligent small kitchen appliances and many extra applications which could not be realized with the classic solutions. Besides, the solution is simple and cheap, which is a primary requirement for mass production. REFERENCES [1]
[2]
[3]
Mathew George, Jr.: Implementation of Fuzzy Logic on Servo Motor Control, Selected Applications, SPRA028, Texas Instruments, January 1993 Dr. Odry Peter, Diveki Szabolcs, Csasznyi Andor, Burany Nandor (Texas Instruments editor of project: Andreas Dannenberg): 'Fuzzy Logic Motor Control with MSP430x14x’, Selected applications, slaa 235, Texas Instruments 2005. February Odry Péter, Divéki Szabolcs, Burány Nándor, Gyantár László “Fuzzy control of brush motor - problems of computing”, SISY 2004, Subotica, pp. 37-46
51