10 th International Symosium of Hungarian Researchers on Comutational Intelligence and Informatics Modeling and Simulation of an Incremental Encoder Used in Electrical Drives János Jób Incze, Csaba Szabó, Mária Imecs Technical University of Cluj-Naoca, 400020 Cluj-Naoca, 15 C. Daicoviciu Str. PO 1, ox 159, RO-400750 Cluj-Naoca, Romania ioan.incze@edr.utcluj.ro, imecs@edr.utcluj.ro, csaba.szabo@edr.utcluj.ro bstract: Electrical drives use frequently incremental encoders as osition sensor. The aer deals with modeling and simulation of an incremental encoder and Matlab- Simulink simulation structure is realized and tested. In order to rocess the information rovided by the encoder it was built a structure to determine the direction of the rotation in an angular interval equal to a quarter of the angular ste of encoder graduation. The encoder signal based osition comutation was also simulated. Exerimental measurement were erformed. Keywords: osition sensor, angle transducer, incremental encoder, simulation, electrical drive 1 Introduction One of the most frequently used osition transducers is the incremental encoder. It is a device which rovides electrical ulses if its shaft is rotating [3], [6]. The number of generated ulses is roortional to the angular osition of the shaft. The market offers a variety of incremental encoders realized in different technologies, like electromechanical, magnetic etc, however the otical encoders are very oular. Together with the shaft of otical encoder there is rotating a transarent (usually glass) rotor disc with a circular graduation-track realized as a eriodic sequence of transarent and non-transarent radial zones which modulates the light beam emitted by a light source laced on the fix art (stator) of the encoder on one side of the disc. On the oosite side the modulated light beam is sensed by a grou of otical sensors and rocessed by electronic circuits. The outut of encoder will generate one ulse when the shaft rotates an angle equal to the angular ste of graduation, i.e. the angle according to one successive transarent and nontransarent zone. The number of the generated ulses is roortional to the 97
J. J. Incze et al. Modeling and Simulation of an Incremental Encoder Used in Electrical Drives rotation-angle of the shaft, i.e. to its angular osition [5]. The counting of the ulses is realized by external electronic counters [3]. Due to the fact that the sequence of generated ulses does not offer any information about the direction of rotation, the encoder is rovided with a second grou of otical sensors, shifted with a quarter angular ste of graduation in comarison to the first grou of sensors. second channel of the electronic circuits rocesses the signals generated by the second grou of sensors. During rotation of the shaft the second channel will generate on its outut ulses identical to those generated by first outut but these are shifted with a quarter angular ste of graduation. y the reversal of the rotation the hase-shift between the two oututs will be also reversed. In this manner the mutual hase-shift of the oututs contains information regarding the direction of rotation. This information may be extracted by relatively simle logic circuits. In order to have a reference osition the encoder is rovided on its disc with a second track having a single graduation, and on the stator the corresonding light source, grou of otical sensors and electronic rocessing circuits. This arrangement roduces on the outut of this third channel in the course of a comlete (360 ) rotation a single ulse of width equal to a quarter angular ste of graduation. The shaft osition corresonding to this ulse may be considered as reference osition. Usually the two shifted oututs are named resectively, the reference marker outut is named Z. Mostly, in order to facilitate the differential signal transmission and further rocessing of the osition information in the user s equiment, the encoder rovides also the oosite logic value of above signals. LED LED d ω = dt LED Z 4 4 Z Photosensors Fixed reference axis Figure 1 Construction rincile of the incremental encoder: the gray surfaces are otically transarent 98
10 th International Symosium of Hungarian Researchers on Comutational Intelligence and Informatics The rincile of incremental encoder with the used notations is resented on Figure 1. Usually the whole construction is closed in an enclosure (not shown on figure), rovided with mounting ossibilities. The shaft rotates on bearings located in enclosure. Figure 2 resents the diagram of the generated outut signals. Z 2π - /4 /4 2 0 Figure 2 Diagram of the outut signals generated by the incremental encoder The control of the modern adjustable-seed electrical drives needs the knowledge of osition and/or seed of the rotor [1], [4]. This information in some alications is comuted or estimated without the use of mechanical transducers (in case of sensorless drives) or more frequently the osition/seed information is rovided by osition or seed transducers (is the case of sensored drives). Incremental encoders are frequently used as osition transducers. The modern drive systems are controlled digitally. Usually in these systems the rocessing is accomlished at a fixed samling rate. However, the osition information furnished by incremental encoder is inherently digital, with a rotationseed-deendent samling rate. This statement is true also for seed information, comuted using the encoder signals. ccordingly, the whole drive system may be considered as a comlex system comosed of some arts working with fixed samling rate, other arts with variable one. Frequently, the samled character of the osition or seed information is neglected, they are treated as continuous quantities. In order to take into account the real character of the information rovided by the encoder already in extensive simulation works during research and early develoment stages of the drive systems, it is necessary to create the mathematical model and the corresonding simulation structure of the encoder. 99
J. J. Incze et al. Modeling and Simulation of an Incremental Encoder Used in Electrical Drives 2 Modeling of the Incremental Encoder The inut signal of the incremental encoder is the angular osition of its shaft with resect to a fixed reference axis. The outut signals are the two ulses shifted by a quarter angular ste () and (), resectively the marker signal Z(). If is the angular ste of the encoder, the oututs may be described by the following equations: ( ) 1 = 0 if if 0 < modulo ( ) < / 2 / 2 < modulo ( ) < (1) ( ) 1 = 0 if if 0 < modulo ( / 4) < / 2 / 2 < modulo ( / 4) < ( ) ( ) 1 if modulo 2π = 0 Z ( ) = (3) 0 if modulo 2π 0 It is imortant to note, that during a rotation angle of the shaft equal to the angular ste of graduation there are four switching events in the outut ulses, and therefore the minimal rotation-angle-increment detectable by the encoder is /4. It is obvious that the number of ulses generated by the encoder in the course of a rotation will be N r 2π = (4) which is equal with the number of angular stes of the-graduation on the circular track on the rotor. The number of ulses er rotation together with the angular seed of the shaft will determine the frequency of encoder s outut signals. ω f = f = Nr (5) 2π From oint of view of simulation the above equation is imortant because offers a starting oint in choosing of the simulation ste. For usual values of N r and ω one concludes that the encoder signal is far the highest frequency quantity in a usual drive system. numerical examle underlines this fact: the N r =1000 ulses/rotation value is very common for low-cost incremental encoders, angular seed ω=314 rad/s is tyical for the wide-sread 1 ole-air/50 Hz motors; this combination yields an encoder signal frequency of 50 khz (accordingly, the eriod is 2*10-5 s) it is about an order of magnitude higher than the highest frequency in the drive system, suosing a 5 khz PWM frequency. The environment used for simulation is the Matlab/Simulink, because it is the most used software in simulation of electrical drives. The simulation structure is (2) 100
10 th International Symosium of Hungarian Researchers on Comutational Intelligence and Informatics shown in Figure 3. It is created mainly based on equations (1) (3) with some modification in order to easy the building of the structure. The outut Sense of the Sens Detect block indicates if the inut angle is increasing or decreasing. The outut of the modulo /2 function is comared to uer-limit U and lower limit L. ased on the four ossible oututs of the block Relational Oerators and the Sense signal, the Logic block generates the t or t switching moment signals. The outut signals of the encoder are obtained using two T-tye fli-flos, one T-FF for oututs, N, triggered by t and the other T-FF for, N triggered by t. The fli-flos hold their actual state until a new switching moment occurs due to the rotation of the shaft. The hollow-shaft encoders are secial constructions which avoid the couling arts between encoder and controlled machine shaft. Their shaft is very short, has a tubular form and is ulled u on the controlled machine shaft. Modulo 2π IEnc Sense Detect Modulo /2 Zero Detect Sense Relational Oerators U L Uer/Lower Limits U< U> L< L> Logic t t T-FF T-FF Q Q Q Q Z Logic N N Z Z N Figure 3 Simulation structure of the incremental encoder y every comlete, (i.e. 2π rad.) shaft rotations identified by modulo 2π function the Zero Detect block roduces an outut signal which in block Z Logic is synchronized with and/or signals roducing the marker outut Z. 3 Identification of Direction of Rotation The direction of rotation will be identified comaring the relative osition of the oututs to. This may be accomlished on different ways. trivial solution of de roblem may be a samling with a D tye fli-flo at every rising front of the outut ulses the outut logic value. For counterclockwise (CCW) direction of rotation the outut of fli-flo will be at 1 logic value, for the 101
J. J. Incze et al. Modeling and Simulation of an Incremental Encoder Used in Electrical Drives clockwise (CW) direction at 0 value. The drawback of the method is that the direction changing is detected only after a time interval according to a rotation of 3 /4 5 /4; it is deending on the moment of direction changing relative to signals and. more recise aroach takes into account the all four ossible combinations of and signals for the both situations: when the actual direction is CCW and is changing to CW, and the CW is changing to CCW. Table 1 summarizes all combination of signals which detect the reversal of rotation sense. This strategy ermits detection of direction changing in all cases during a rotation of /4, namely in minimal detectable rotation-angle-increment. Table 1 From CCW to CW Q=1 to Q=0 From CW to CCW Q=1 to Q=0 Occurs if Triggered by Occurs if Triggered by R S 0 0 N & 0 0 N & 0 1 & 0 1 N & 1 0 N & 1 0 & 1 1 & 1 1 & Note: The subscrit symbol N denotes negated logical variable; The and denote the raising- resectively the falling-edge of associated logic variable. The realized direction-detector-block is based on above idea. The block scheme of the simulation structure is resented in Figure 4. Logic CCW Logic CW J K JK- FF Q Q S S N DiD Figure 4 The scheme of the simulation structure of the direction-detector block Corresonding to the two ossible direction changes the logic blocks detects all combinations of inut signals shown in Table 1, the actual combination triggers a 102
10 th International Symosium of Hungarian Researchers on Comutational Intelligence and Informatics fli-flo of which Q outut retain the direction of rotation until another changing occurs. The logic circuits of the direction-detector may be easy imlemented in FPG or other rogrammable logic. 4 Encoder-based Position Comutation In incremental encoder based system the angular osition referenced to a fixed reference axis (corresonding to =0 rad.) is obtained by counting the number of generated encoder ulses and multilying it with the angular ste of the encoder. The counting of the ulses is made by electronic counters, which usual is not contained in the structure of the encoder. The simulation structure is resented on Figure 5. The encoder-outut signal is the common inut signal for the two counter blocks: Counter CCW and Counter CW. The counters are resettable by the marker ulse, if the shaft is ositioned in the reference osition. oth counters receive on their En inut distinct enable to count signals generated from the DiD direction detector block according to the detected direction of the rotation. y counterclockwise rotation of the shaft the Counter CCW will be enabled by signal S and will count the encoder ulses. If the shaft rotates clockwise, the Counter CW will be enabled by signal S N and will count the ulses. The content of the Counter CW is subtracted from that of the Counter CCW. The difference N will indicate the number of ulses according to osition of the shaft. In order to obtain the angular osition the difference N has to be multilied by the angular ste. Z DiD 1 st Pulse S S N Poz En In Rst En In Rst Counter CCW Counter CW O O + - N Figure 5 The simulation structure of the osition comuting block 103
J. J. Incze et al. Modeling and Simulation of an Incremental Encoder Used in Electrical Drives It is to note, that this structure rovides the osition information in interval 0 2π rad., because the counters will be reset by every comlete rotation by the marker signal Z. To extend the osition measurement to more rotation the structure has to be rovided with 1 st Pulse block (broken line on Figure 5), which transmits to the counters only the first reset ulse after the switch on. Obviously, if the counters for certain reasons are switched off and again on, the osition information is lost, the shaft has to be rotated to its reference osition and resumes the rotation in the desired osition. 5 Simulation Results Using the above resented functional units the simulation structure resented on Figure 6 was build. The Function Generator block realized using the Reeating Sequence Simulink block, roduces the inut signal ref for encoder (it is equivalent to angular osition of the shaft). Its amlitude and the time-rofile of the variation is editable by the user. The IEnc encoder block resented in Chater 2, generates the, and Z outut signals. ased on and signals the DiD block (described in Chater 3) determines the direction of the rotation. The Poz block has the structure resented in Chater 4. ased on, and Z outut signals counts the number N of imulses and comutes the angular osition of the shaft. ll signals are saved in Matlab s Worksace for further analysis. Function Generator ref IEnc Z Poz DiD ref N S To Worksace Figure 6 The simulation structure of the interconnected functional units. IEnc incremental encoder; Poz - osition comuting block; DiD - direction-detector block The reversal rocess was analyzed. The reference angle generated by function generator has a saw-tooth-like variation versus time. Its arameters were selected in such manner, that all ossible combinations of reversal were catured and resented in Figures 7 a)-d). In all cases the sensing of the reversal is done in a 104
10 th International Symosium of Hungarian Researchers on Comutational Intelligence and Informatics quarter of angular ste. This fact is underlined in the diagrams for case CCW to CW reversal (left column): the S signal starts with 0 default value (corresonding to CW rotation), but after a quarter angular ste the DiD block observes the CCW rotation and rises its S outut to 1, corresonding to CCW rotation. Figure 8 resents the comuted osition in comarison with the reference osition. The generated reference angle start in CW direction with a ram of 80 rad./s, at 0.05 s occurs the reversal in CCW direction, with the same ram. t 0.015 s occurs another reversal and this direction will be reserved until to the end of the simulation. The comuted angular osition follows the reference as is shown in Figure 8a. The incremental character of the comuted osition is reflected by the enlarged detail of both osition angles reresented in Figure 8 b). From CCW to CW From CW to CCW a) b) c) 105
J. J. Incze et al. Modeling and Simulation of an Incremental Encoder Used in Electrical Drives d) Figure 7 The simulation results reresenting all ossible combinations of the reversal rocess. Left column: From CCW to CW, Right column: from CW to CCW, To trace: signal, Middle Trace: signal, Down trace: direction signal S. Reversal occurs at: a) =0, =0; b) =0, =1; c) =1, =0; d) =1, =1. Figure 8 a) shows also, that the marker ulses Z occurs every time when the angle asses through zero value. a) b) Figure 8 The simulation results reresenting the reference angle and comuted angle during reversal. Left, from to to down: reference angle ref, comuted angle, marker outut Z, direction signal S. Right: Detail of the reference angle ref and comuted angle versus time. Figure 9 a) resents at enlarged detail the marker ulse referred to the and outut signals, its width obviously is a quarter angular ste. The direction signal S is changing according to the sense of rotation as is seen in Figure 8 a) and in enlarged details Figure 9 b). The simulation results corresond with those exected. 106
10 th International Symosium of Hungarian Researchers on Comutational Intelligence and Informatics a) b) Figure 9 The simulation results reresenting and comuted angle during reversal. Left: The marker signal referred to oututs and. Right: The direction signal S referred to angular osition (detail). The structure resented in Figure 6 may be integrated in simulation structures of electrical drives. In this case the angular osition the inut signal of the encoder will be rovided by the drive structure; usually it is obtained from the machine model. The control scheme of the drive system will use as osition information the osition determined on base of encoder signals by the Poz block. 6 Exerimental Measurements Exerimental measurements were erformed using a 1XP8001-1 (Siemens) incremental encoder. The encoder has 1024 divisions er 360, and rovides the outut signals,, Z and their negated values N, N, ZN comatible with HTL logic. The encoder was mounted on a 1L7073 series (P N =0.55 kw, n N =2800 rm) induction motor. The rotational seed of the motor was controlled in large limits: (0-200 Hz in stes of 0.01 Hz) by a Micromaster 440 static frequency converter configured in vector-control mode. The converter uses the encoder signals as seed-feedback. The scheme of the exerimental set-u is resented on Figure 9. Figure 10 resents the three encoder signals i.e., and Z catured by a storage scoe at a CW running. Figure 11 shows the and signals at CCW to CW rotation sense reversal. The catured figures corresond with those simulated. 107
J. J. Incze et al. Modeling and Simulation of an Incremental Encoder Used in Electrical Drives PC Scoe TDS1034 Static Frequency Converter,,Z Ua,b,c Exerimental oard Encoder Induction Motor Figure 10 The block scheme of the exerimental set-u Figure 11 Exerimentally catured encoder signals by CW oeration. To: outut, Middle: outut, Down: Marker signal. Figure 12 Exerimentally catured encoder signals by CCW to CW reversal. To: outut, Down: outut. Reversal occurs at =1, =1. The exerimental board (under develoment) is built around of the TMS320F2812 TI DSP based ezds kit from Sectrum Digital. The used software environment is the Matlab/Simulink and Code Comoser. The verified simulation structure is comleted with the Real Time Interface blocks to link to the hardware. ased on this structure automated DSP code generation is erformed. The Code Comoser ermits the download of the code to target-dsp memory, its real-time execution and data acquisition. Conclusions The information rovided by the incremental encoders is inherently digital. The rovided ulses are counted by an electronic counter; their number is roortional to the angular osition of the encoder shaft. The direction of the rotation may be determined by a digital decoding scheme using the two quadrature signals rovided by the encoder. The direction changes are detected in an angular interval equal to or less then a quarter of angular ste of the encoder disc. 108
10 th International Symosium of Hungarian Researchers on Comutational Intelligence and Informatics The resented simulation structure of the incremental encoder may be integrated in any Simulink structure. Due to the fact that the encoder signals are the highest frequency quantities in an electrical drive system, consequently the choose of the simulation ste has to be done accordingly. The simulation results corresond to those exected and are very close to the exerimental one. cknowledgement This work was suorted artially by the National University Research Council (CNCSIS) of Romania. References [1] Kelemen Á., Imecs M.: Vector Control of C Drives. Volume 1: Vector Control of Induction Machine Drives. OMIKK Publisher, udaest, 1991 [2] Koci P., Tuma J.: Incremental Rotary Encoders ccuracy. Proceedings of International Carathian Control Conference ICCC 2006, Roznov od Rashosten, Czech Reublic, 2006,. 257-260 [3] Lehoczky J., Márkus M., Mucsi S.: Szervorendszerek, követő szabályozások. Műszaki Kiadó, udaest, 1977 [4] Miyashita I., Ohmori Y.: New Seed Observer for an Induction Motor using the Seed Estimation Technique. EPE 93, righton, 1993, Vol. 5,. 349-353 [5] Petrella R., Tursini M., Peretti L., Zigliotto M.: Seed Measurement lgorithms for Low Resolution Incremental Encoder Equied Drives: Comarative nalysis. Proceedings of CEMP 2007. odrum, Turkey, 2007,. 780-787 [6] *** Encoder versus Resolver-based Servo Systems. lication Note. ORMEC. www.ormec.com 109