Chaotic Logistic Map Implementation in the PIC12F629 Microcontroller Unit Leonardo Acho Zuppa CoDAlab, Departament de Matemàtica Aplicada III, Escola Universitària d'Enginyeria Tècnica Industrial de Barcelona (EUETIB), Universitat Politècnica de Catalunya (UPC), Comte d'Urgell, 187, 08036 Barcelona, Spain. {
[email protected]} Abstract: This paper is about chaotic logistic system realization using the PIC12F629 microcontroller manufactured by Microchip Technology Inc.. Implemetation done by using just assembler language machine. An appropriate scale change transformation and a re-definition of the system parameter are carried out to the logistic map to fit its microcontroller actualization. Resistive-Capacitive circuits are employed to transform binary chaotic signals into continuous ones. The obtained strange chaotic attractor is displayed on an analog oscilloscope. Keywords: chaos, logistic map, microcontroller. 1. INTRODUCTION The logistic map is one of the simplest ways to produce chaos (Sastry, S. (1999)). Basically, it consists on a rule for getting a number from a number. The logistic map is a firstorder difference equation that can exhibit random fluctuations (May, R.M. (1976)), now, identified as chaos (Sastry, S. (1999)). This map is given by (Thomsen, J.J. (2003)): x(k+1)=hx(k)(1-x(k)), k=0,1,2….
installation design. We used this optional internal clock resource in our project. By the other hand, another advantage of the PIC technology, is its instruction set which is highly orthogonal and is compromised of three basic categories (Microchip Technology Inc. (2003)): Byte-oriented operations Bit-oriented operations Literal and control operations
(1)
The parameter h has to be adjusted to produce chaos. Chaos is observed when this parameter is varied and the system behaviour (1) transits from regular state to chaotic state behaviour, referred as the ‘route to chaos’ procedure (Thomsen, J.J. (2003)). For instance, chaos is observed when h=4 and with initial condition x(0)=0.1 (Thomsen, J.J. (2003)). The simplicity of the system (1) causes it to be attractive for an electronic realization using discrete electronics, like microcontroller units. Today, microcontrollers are found in a huge number of applications in automotive, consumer, communications and industrial manufacturing (Predko, M. (2002)). The microcontrollers are also important because they make electronic circuits cheaper and easier to build (Bates, M. (2004)). The objective of this paper is to use the simplicity of the system (1) and the low cost of PICmicrocontroller units to produce chaos by using just low-level language machine programming: Assembler. This simplest software was employed in (Chen, C.S. (1982)) for dynamic digital controllers implementation in the Intel 2920 microprocessor. Recall that each microcontroller, or microprocessor, has its own Assembler language. We select the cheapest microcontroller manufactured by Microchip: The PIC12F629 (relative cost (Bates, M. (2004)): 1.02 US dollars). Other reasons are the properties of the PIC12F629 architecture. For instance, this architecture has an optional internal clock oscillator that provides a fixed 4 MHz (nominal) system clock. This saves crystal oscillator
Each PIC instruction is 14-bit word divided into an opcode, which specifies the instruction type, and one or more operands, which further specify the operation of the instruction. Moreover, the PIC microcontrollers are supported with a full range of hardware and software development tools: assemblers/compilers, simulators, emulators, in-circuit debugger, device programmers, etc. For instance, the MPASM Assembler is a full-featured, universal macro assembler for all PIC microcontrollers (Microchip Technology Inc. (2003)). For software realization of our chaotic algorithm, we employed theVELLEMAN K8076 PIC Programmer Board. This PIC Programmer can program several PIC micro controllers in the DIP type packages. It includes an easy to use programming software, and onboard configurable 40 pin ZIF socket selection. This board connects to a computer using the serial port (RS232). Over the past decades there has been increasing interest and motivation in studying chaotic oscillators (see, for instance, Sprott, J.C. (2000), Nakagawa, S., and Saito, T. (1996), Elwakil, A. S., Ozuguz, S., and Kennedy, M. P. (2002), including references there in). Chaotic oscillators are useful devices, not only for investigation of nonlinear phenomena, bifurcation and chaos, but also for a variety of applications such as synchronization (Wang, F., and Liu, C. (2007), Park, J. H. (2005), Yu, Y., and Zhang, S. (2004), among many others), control (Cuomo, K.M., Oppenheim, A.V., and Strogatz, S.H. (1993), Jiang, G. P., and Zheng, W. X.
(2004)), liquid mixing (Lu, J., Chen, G., and Cheng, D. (2004)), and chaos-based communications systems (see, for instance, Acho, L. (2006) and Corron, N. J., and Hahs, D. W. (1997)), whitin many other applications (see, for instance, Lu, J., Chen, G., and Cheng, D. (2004), and ferences there in). In resume, chaos has a very interesting complex nonlinear behaviour that has been intensively studied on the last decades.
microcontroller has just 35 instructions to learn, and all of them are executed in a single cycle instruction except branches (Microchip Technology Inc. (2003)). We do not use all of them. Numerical values in hexadecimal format are represented with the letter H at the end of it. For instance, the initial condition for system (4), is set as y(0)=100H, and β=0BH. The assembler code is as follows:
The objective to apply chaotic signals in secure communication systems design is due to theirs ‘random’ like behaviour available to mix with information signals (Cuomo, K.M., Oppenheim, A.V., and Strogatz, S.H. (1993), Acho, L. (2006), Corron, N. J., and Hahs, D. W. (1997), etc.). The secure communication system performance can be improved if more chaotic systems are available, specially, if they are not published (unknown for intruders). Here, the proposed chaotic oscillator can be considered as a new digital chaotic oscillator that can be employed, for instance, in digital secure communication system design via digital chaotic signals, a completely new field. The organization of the paper is as follows. Section two is about software realization of the system (1) using Assembler language. The system parameter to produce chaos was obtained by experiments following the ‘route to chaos’ procedure; that is, the logistic map parameter was varied until chaos is experimentally observed. Its strange attractor displayed on an analog oscilloscope is shown too. It is important to realize that analog oscilloscopes cannot store digital information; in other words, it shows steady state signals and they cannot be confused with ‘stored’ historical transition behaviour. The experimental circuit electronic realization is described too. Finally, Section three states the conclusions.
2. PROGRAMMING THE LOGISTIC MAP To begin with the programming, system (1) is manipulated by employing scale change transformation; that is, using the scale change y(k)=ax(k), where a is a positive constant, system (1) is transformed to: y(k+1)=y(k)(h-h/a y(k)).
(2)
Selecting h=4, we arrive to: y(k+1)=y(k)(4-by(k)), k=0,1,2,…. ,
(3)
where b=4⁄a. We set this value as b=0.03125. We program the alternative representation of the logistic map: y(k+1)=y(k)(β-0.03125y(k)), k=0,1,2,…. .
(4)
The above difference equation (4) will be translated into Assembler PIC language. β is now our system parameter. The step-by-step program development is written below. The punctuation mark ‘;’ is a symbol employed to comment the statement and it is ignored by the processor. According with the microcontroller unit PIC12F629 manufacturer, this
In the previous Assembler program, the output is digital information (binary data) available at the pins microcontroller output port. These binary information can be converted to analog information through RC (Resistive-Capacitive) circuits at the output pins. For instance, taking the GP0 and GP1 pins as output binary chaotic signals, the realization is shown in Fig. 1. The system was compilated and programmed to work with the internal oscillator (about 4MHz ), and the Watchdog timer interrupt disable (in fact, all interrupts were disabled). Fig. 2 shows the chaotic strange attractor (V1 (t) versus V2 (t)), and Fig. 3 displays the chaotic signal at V1 (t). The oscilloscope was set with 1Volts/Div and 5msecs(mili-seconds)/Div in AC configuration. Fig. 4 shows a picture of the circuit realization. On this picture, a 5VDC regulator is appreciated. The input to this regulator is a battery of 9VDC. The components surrounding the
PIC12F629 are those shown in Fig. 1. It is important to realize that the system in PIC assembler format has truncation in its numerical operations, and, to avoid a negative number, the value 1H is added (it is clearly indicated in the assembler program).
5VDC regulator
+5V
2.2kΩ GPO
2.2kΩ
GP1
PIC12F629
GND
PIC12F629
V1 0.1μF
2.2kΩ
V2 0.1μF
Fig. 4 Circuit realization.
MCLR 0.1μF
Fig. 1 Electronic circuit. 3. CONCLUSIONS
Fig. 2 Experimental strange attractor.
An embedded chaotic system programming was realized using the PIC12F629 microcontroller. Then, a digital source of chaotic signals is proposed. A scale change transformation was employed for discrete system realization. According with (Cuomo et al. (1993)), a chaotic system is insensitive to scale change transformation. Although there have been a lot of chaotic circuits realization (see, for instance, (Sprott, J.C. (2000)), in digital format, there are a few ones. Moreover, the proposed chaotic oscillator is digital. This digital chaotic oscillator can be used for secure communication systems design via digital chaotic signals. It is important to realize that digital signals are different from those of discrete signals. Our chaotic oscillator can be used directly in digital domain utilizing the same PIC microcontroller. This can be an interesting future work. Also, this device can be cheaply implemented as an experimental device for laboratory experiments of chaos. From the technology point of view, our digital implementation of the logistic map is more cheaper than that reported in (Narendra, S., and Sinha, A. (2010)), where analog electronics is employed using two analog multipliers, which, usually, are too expensive.
Acknowledgements This work is supported by the National Ministry of Science and Innovation of Spain (DPI2008-06463-C02-01 and CIT020000-2008-40), the School of Industrial Engineering of Barcelona, Spain (EUETIB), and the Polytechnic University of Catalonia, Spain. Fig. 3 Experimental chaotic signal.
REFERENCES Acho, L. (2006). Expanded Lorenz Systems and Chaotic Secure Communications Systems Design, Journal of Circuits, Systems and Computers 14 (4), 607-614. Bates, M. (2004). PIC Microcontrollers, Second Edition, Newnes, Netherlands. Chen, C.S. (1982). Application of One-Chip Signal Processor in Digital Controller Implementation, Control System Magazine, 16-22. Corron, N. J., and Hahs, D. W. (1997). A New Approach to Communications Using Chaotic Signals, IEEE Tran. on Circuits and Systems I: Fundamental and Applications, 44(5), 373-381. Cuomo, K.M., Oppenheim, A.V., and Strogatz, S.H. (1993). Synchronization of Lorenz-Based Chaotic Circuits with Applications to Communications, IEEE Tran. on Circuits and Systems II, 40(10), 626-633. Elwakil, A. S., Ozuguz, S., and Kennedy, M. P. (2002). Creation of a Complex Butterfly Attractor Using a Novel Lorenz-Type System, IEEE Tran. on Circuits and Systems I: Fundamental Theory and Applications, 49(4),527-533. Jiang, G. P., and Zheng, W. X. (2004). Chaos Control for a Class of Chaotic Systems Using PI-Type State Observer Approach, Chaos, Solitons and Fractals, 21, 93-99. Lu, J., Chen, G., and Cheng, D. (2004). A New Chaotic System and Beyond: The Generalized Lorenz-Like System, Int. J. of Bifurcation and Chaos, 14(5), 15071537. May, R.M. (1976). Simple Mathematical Models with Very Complicated Dynamics, Nature 261, 459-467. Microchip Technology Inc. (2003). PIC12F629/675 Data Sheet. Nakagawa, S., and Saito, T. (1996). An RC OTA Hysteresis Chaos Generator, IEEE Tran. on Circuits and System I: Fundamental and Applications, 43(12), 1019-1021. Narendra, S., and Sinha, A. (2010). Chaos-Based Secure Communication System Using Logistic Map, Optics and Lasers in Engineering, 48, 398–404. Park, J. H. (2005). Chaos Synchronization of a Chaotic System via Nonlinear Control, Chaos, Solitons and Fractals, 25, 579-584. Predko, M. (2002). Programming and Customizing PICmicro Microcontrollers, Second Edition, McGraw Hill, USA. Sastry, S. (1999). Nonlinear Systems: Analysis, Stability, and Control, Springer-Verlag, New York. Sprott, J.C. (2000). Simple Chaotic Systems and Circuits, Am. J. Phys. 68(8), 758-763. Thomsen, J.J. (2003). Vibrations and Stability, Second Edition, Springer-Verlag, Berlin, 2003. Wang, F., and Liu, C. (2007). Synchronization of Unified Chaotic System Based on Passive Control, Physica D, 225, 55-60. Yu, Y., and Zhang, S. (2004). Adaptive Backstepping Synchronization of Uncertain Chaotic System, Chaos, Solitons and Fractals, 21, 643-649.