REALIZATION OF 4th ORDER RECURSIVE DIGITAL FILTER WITH PLC CONTROLLER Aleksandar Dodič^ Bojan Jarc^, Rudolf Babič^ ^ Port of Rijeka authority, Rijeka, Croatia ^University of Maribor, Faculty of electrical engineering and computer science, Maribor, Slovenija Key words: digital signal processing, recursive digital filters, IIR filter, eliptic filter, PLC controller realization Abstract: This paper describes the design and realization of the third and fourth order recursive digital filter (IIR digital filter) using PLC controller. The purpose of the filter is elimination of unwanted signals which occur during processing of analog signals in the industrial process automation with PLC controllers. The Siemens S7-315-2DP PLC controller is used in practical realization. In this application, we chose the eliptical filter with a cut-off frequency of 3 Hz and a sampling frequency of 50 Hz. With format long of the filter coefficients values we obtain the expected stop band attenuation of 40 dB as it is designed with MATLAB software. The values of impulse response are applied to compare PLC controller realization of digital filter and simulated structure with MATLAB. The results for the third and fourth order digital filter with format long filter coefficients and with shortened mode format of filter coefficients entry are summarised in tables. A magnitude frequency response of the 4th order digital filter for a cascaded form is displayed as figures, general and detailed for passband. Comparison of errors in impulse response for direct and cascade structure is demonstrated in this article. Finally, in comparison to the third order digital filter where the attenuation of 40 dB is obtained at 7 Hz, with the fourth order filter structure, the attenuation of 40 dB reaches at 4 Hz. Izvedba rekurzivnega digitalnega filtra 4. stopnje s PLC krmilnikom Kjučne besede: digitalna obdelava signalov, rekurzivni digitalni filtri, eliptični filtri, izvedba s PLC krmilnikom Izvleček: V prispevku je opisan postopek načrtovanja in izvedbe rekurzlvnih digitalnih filtrov tretje in četrte stopnje s programlrljivim logičnim krmilnikom (PLC). Uporaben je za izločanje neželenih signalov nizkih frekvenc pri obdelavi analognih vrednosti v sistemu industrijskega krmiljenja s PLC krmilnikom SIEMENS 87-315-DP. Za praktično izvedbo smo izbrali eliptični filter z mejno frekvenco 3 Hz in frekvenco vzorčenja 50 Hz. Vrednosti koeficientov smo zapisali v formatu tipa long. Tako smo dosegli dušenje v zapornem pasu 40 dB, kot smo to pričakovali glede na slmulacijske rezultate dobljene v okolju MATLJ\B. S PLC krmilnikom realizirani digitalni filter in simulacijsko strukturo v okolju MATLAB smo primerjali s pomočjo impulznega odziva. Tabelarično smo podali rezultate za filtra tretje in četrte stopnje s koeficienti zapisanimi v daljšem in krajšem formatu. Grafično smo podali celoten, podrobneje pa le prepustni pas amplitudnega frekvenčnega spektra digitalnega filtra 4 stopnje. Podali smo primerjavo odstopanj impulznih odzivov digitalnega filtra v direktni in kaskadni izvedbi. V primerjavi z digitalnim filtrom tretje stopnje, kjer dušenje 40 dB dosežemo pri frekvenci 7Hz, smo s filtrom četrte stopnje dosegli dušenje 40 dB že pri frekvenci 4Hz. 1. Introduction Processing of analog signals is usual in almost every automation process which is done with PLC controller. The analog input values which we obtain at the input (or as a result of intermediate calculations), are modified in most cases due to the various interferences. Therefore, it is often neccessaryto dump interference with additional equipments, such as software (SW) or hardware (HW) in order to assure undisturbed continuity of the process which we control. For the fact that used sensors and converters do not distinguish among useful and disturbing signals, the controller system receives useful signals corrupted with unwanted signal as interference. Interferences are especially dangerous, if the frequency matches with mechanical resonant frequency of the system. In such cases, the controller becomes completely useless. The interferences can be removed in several ways; by means of the analog filter in the output of controller, or by SW implemented filter inside PLC controller. Analog filter represents a simple way to separate interfer-ent signals. The most used is RC filter. Sometimes it could be enough to use only capacitor because resistance is already included in resistance of contacts, conductors and internal resistance of signal source. The problems appear when loop resistance is changed because at the same time cutt-off frequency will be changed as well. Differences appear at the use of current and voltage inputs of PLC controller. With current inputs, where low resistance is present, it is even harder to remove interferences. With current inputs, we also need a coil for smoothing , even though coil is not so common used as a capacitor. That is why analog filtering in that manner is very rare. Analog filter also becomes completely useless, if we want to separate interferences in the signal which is present as a result of intermediate calculations of one or more different variables. In this article, the way of filtering with digital filter is described. Digital filter is implemented inside the PLC controller, which is used for controlling of the main industrial process. The simple solutions use algorythms for smoothing, which work as non-recursive filter and is used by em-phirical directions. In our example, we designed and made recursive form of the third and fourth order digital filter with exact determinated parameters connected to a cut-off frequency, a gain in passband and attenuation in stop band. The coefficients of the filters are calculated with MATLAB. 2. Basic structures of digital filters The origin for design of filter structure is a system function H(z) and diference equation. For every linear, time invariant discrete system, exist more than one equivalent structure. Structures are canonic or noncanonic. A digital filter structure is said to be canonic if the number of delays in the block diagram representation is exactly equal to the order of the filter /1/. Noncanonic structure we use with processors with floating point arithmetic, because they have only one adder. Within PLC automation applications the second order filter is the most popular structure used. For realization of higher order digital filters, we can use direct canonic or direct transposed structure. In our case both are equal. The only difference makes the number of adders and multipliers needed for realization. For the structure of the higher order, we generally use cascaded /2/ or paralel realization of structures of the 1 st and 2nd order, regardless the filter is IIR or FIR type. 3. PLC controller Programmable logic controller is dedicated microcontroller which is used in industrial automation field and remote controlling of various process. In the beggining, PLC signals were only digital. Also, modern PLC controller handles analog signals. It means that we can carry out digital filter as a part of program. Such filter is equivalent to hard wired filter as equipment. 3.1 Cycle time Cycle time is very important criteria for evaluation of PLC speed. These data give us information about time needed for execution of all functions of PLC controller. Execution of PLC program is cyclic which means that changing of variables during one cycle will not be considered and executed in PLC program. 3.2 Cyclic interupt If we need very fast processing of some signals or functions, e.g. allarms, PID regulators etc., it is possible to use a different models of program executing with interrupt functions so called „watchdog interrupt". A „watchdog interrupt" is an interrupt which is generated at the same periodic intervals. It allows to execute a particular program or function, periodically, independentlyofthe processing time of the cyclic program. Access to this function is different for different maker of PLC devices. It is possible to make cyclic interrupt in different ways with S7-300/400, because it is made with organisation block OB35. There are two possible modes; to generate pulse with 0835 and use this pulse as a clock for digital filter or to call function of digital filter from OB35. In this example, digital filter is implemented in OB35. Time interval for cyclic interupt of OB35 must be longer than time neccessary for executing function which is called from OB35. If this condition is not satisfyed, the operating system calls OB80 (timing interupt). If OB80 has not been programmed, the CPU goes to STOP. /3/. 4. Higher order recursive digital filters The higher order recursive filters are usually performed as a cascaded structure of more structures of first and second order, with exception in a direct form. Although it is possible to obtain rather good results with second order filter compared to empirical filters, with the former it is possible to obtain either greater attenuation or narrower transition band of amplitude frequency characteristic (greater slope). We must bear in mind that such designed filter must not make any interference with main program in PLC, or to make a significant delay in the main program. 4.1 The third order recursive digital filter In our case, we are going to show a design of the 3rd order recursive digital filter which meets the requirements. For this filter, the requirements are: sampling frequency Fs=50 Hz; cutt-off frequency Fm=3 Hz; max attenuation in passband Ap=1 dB; Attenuation (minimal) in stopband As=40 dB. In order to achieve this, it is neccessary to use 2 cascade structures. For this, we made a special function block (FB) that analised behaviour of the filter. Comparison between results of simulation, (obtained with MATLAB) and practical realization with PLC controller, we estimated when comparing impulse responses. Phase frequency characteristic was not important, so we didn't analyse it in this work. To record the impulse response, we modified function block of the 2nd order recursive filter with the „elk" input being active. This input is active, if we trigger FB with internal clock, generated internaly in program. If FB is called from OB35, this input is not active, i.e. must be deactivated. It means that we obtain at each trigger just one output value (value of inpulse response). As input value at the first cycle was 1000.0, and zero for all other cycles. Filter coefficients we calculated with MATI_AB program or directly with FDA toolbox, which is also a part of Matlab. The elliptic filter coefficients in a long form are shown in table 1. Table 1: The coefficients of 3rd order eliiptic filter b3= 0,0136 426 503 0127 a3= 1,00 b2=- 0,0018 096 880 4567 a2=-2,5336 859 770 7381 bl= 0,0018 096 880 4567 al= 2,2493 565 017 9860 b0= 0,0136 426 503 0127 aO=-0,6920 046 002 1359 For transforming of higher order filter in cascade form, we use MATI_AB (FDA toolbox or instruction ZP2S0S), which gives us the second order stucture, SOS matrix in the following form: SOS = b,. (1) In the first row, there are coefficients of the first structure (nominator and denominator), in the second row a second structure, etc. In the matrix, "m" refers to the number of second order structures. If SOS matrix is known, we can write down a general form of the transfer function in the form as follows: it l + a,.-where "g" refers to gain. (2) Forthe 3rd order digital filter, SOS matrix can beexpresed as: SOS = 1,00 1,00 0,00 1,00 -0,818337350 0,00 1,00 -1,132649302 1,00 1,00 -1,715348626 0,845622651 (3) and gain is g = 0,013642650301 For transfer function of digital filter with two cascade structures -b„„ -z'^ -z SOS matrix gives us values of coefficients of each structure, a and b; their coefficients are shown in table 2. It is shown that for 3rd order digital filter, coefficient b0a=0 and a0a=0. Therefore, we will assume gain in the first structure, because of less coefficients and less multipliers. i 1 , I Ii .:E - ciJii. ciki. i 1 '' I 0 köt DEBl DBB 2 •• X ZR J! S t "<),_x:iap od 21, v"' i UÖ1 — _ 1 * J i, 1 ! f ( :' ! 1 ( > J _ ISipiit, uaJ, ni') rs J 1 „' ' , nun — ilO i 1 ^ Ji - A;; - i,; HS . ij - ■.ATK 2XK -UMO« 1 1 1 1 Fig. 2: A part of the organisation block for entry of the coefficients and input variables of 3rd order IIR filter in the first and second cascaded structure A general realization form for the 3rd order IIR filters is shown in figure 1. Since it is a general form for two cascade structure, it can be also used for 4th order IIR filter. Table 2: The coefficients of both cascaded structures for 3rd order eliptic filter b2a = 1,00 bla = 1,00 bOa = 0,00 ala = -0,818337350 aOa = 0,00 b2b = 1,00 bib = -1,132649302 bOb = 1,00 alb = -1,715348626 aOb = 0,8456226513 X(n) Fig. 1: General cascade realization for two structures recursive digital filter The figure 2 shows a mask for input of coefficients in each cascade structure of digital filter. In the proceeding example, the output from the first structure is 32 bits marker double word (MD828), and is the input into the second structure. The output from the filter is MD832. Comparison the impulse response of the 3rd order digital filter, carried out with PLC in the cascade structure and with simulation results, (got from MATLAB), shows us that is in case of long format coefficients, deviation could be neglected, as we already concluded in case of 2nd order 100 60 40 20 -20 „qO 0 5 10 15 20 2S 30 35 40 No. of samples Fig. 3: Impulse response of 3th order IIR digital filter Table 3: The comparision of first 20 values of impulse response of of 3rd order digital filter Practical sample Results of simulation realisation Deviation no. (MATLAB) with PLC % 0 13,642650301273000 13,6426 0,000368706 1 32,756503712783000 32,7564 0,000316617 2 50,497821912436000 50,4977 0,000241421 3 77,347995718632000 77,3478 0,000253036 4 105,0555793178170 105,055 0,000551439 5 127,13935612429400 127,139 0,000280105 6 139,34892221216300 139,349 -5,58223E-05 7 139,83616962670000 139,783 0,0380228 8 128,70340523262500 128,703 0,000314858 9 108,10092058526500 108,101 -7,34635E-05 10 81,12485120469300 81,1248 6,31184E-05 11 51,45073780478000 51,4507 7,34776E-05 12 22,68763570368100 22,6877 -0,000283398 13 -2,10893694285100 -2,10885 0,004122591 14 -20,77181759385600 -20,7717 0,000566122 15 -32,18556365668600 -32,1855 0,00019778 16 -36,28428240826100 -36,2843 -4,8483 lE-05 17 -33,91036398052200 -33,9104 -0,00010622 18 -26,57448525769500 -26,5746 -0,000431776 19 -16,16379328939600 -16,164 -0,00127885 1 20 -4,64461306675500 -4,64483 -0,004670642 filter. The First 20 samples of impulse response are illustrated in table 3. A complete impulse response of digital filter made with PLC is shown in figure 3. According to impulse response we calculated appropriate magnitude frequency characteristic with MATLAB (gain response) as it is shown in figure 4. ok. 1 ;;;;;; ; ; -20 m "U ..30 ^M M 1 M ž i ; i i C 'rö i ..„L.....LJiJ...........i...... -SCI -TO C i 1 i i i li i i 1 1 5 10 1S 20 25 30 35 45 Frequency (Hz) Fig. 4: The magnitude frequency response of 3th order IIR digital filter with cut off frequency 3 Hz The amplitude frequency characteristic correspond with requirements. Attenuation of 40 dB is obtained at 7 Hz, almost at double sampling frequency. 4.2 The fourth order recursive digital filter in direct form Similar to the 3rd order filter, when using a mentioned filter block, we can extend it to the 4th order filter. We are going to analyse a behaviour of the eliptic recursive digital filter with following characteristics: Fs= 50 Hz Fm=3 Hz Ap=1 dB As=40 dB Elliptic (Cauer) filter Lowpass filter We will analyse a deviation of the values of impulse response and frequency amplitude characteristic with shortened coefficients. Block diagram of the filter is shown in the figure 5: ^n)" Y(n) b3 ■>- :-a2 z T .i- ' b2 bl J:0 Fig. 5: Block diagram of the 4th order recursive filter realized in the direct form We can get the coefficient of the filter with partially modif-icated MATLAB script, the same we used for the 2nd order filter, or with FDA toolbox , which is also a part of the same program package. Table 4: The coefficients of 4rd order elliptic filter b4= 0,0128 150 304 a4= 1,00 b3=-0,0308 830 053 a3=-3,5033 975 914 b2= 0,0416 358 137 a2= 4,7510 732 531 bl=-0,0308 830 053 al=-2,9436 272 013 bO= 0,0128 150 304 aO= 0,7021 224 885 If we cut off a certain number of decimal places of coefficients, we will get a deviation of the impulse response values and a deviation of the shape of magnitude frequency response. For analyse, we cut number of decimal places to 3. The table 3 shows the results of comparison of im- pulse response obtained with MATLAB simulation and response of real PLC for the 4rd order digital filter with coefficients in a shortened mode. A deviation is noticed in the input of the coefficients with 3 decimal places. Table 5: Comparison of the first 20 values of impulse response for 4th order digital filter sample no. MATLAB From PLC Deviation % 0 12,81503050 12,0 6,359 1 14,01314165 12,0 14,366 : 2 29,84427179 26,15 12,378 3 44,81855444 39,737 : 11,338 4 60,29166857 ; 53,957 10,506 5 76,30091953 68,731 ; 9,921 6 91,83710540 . 83,006 9,616 : 7 105,23871650 95,126 1 9,609 : 8 114,63757670 : 103,264 9,921 : 9 118,38576890 : 115,5098 10,608 : 10 115,40354470 101,792 11,794 11 105,40486000 90,919 : 13,743 ' 12 88,97838699 : 73,833 17,021 : 13 67,5241582 51,965 : 23,042 14 43,06632776 27,369 36,449 ; 15 17,9783246 : 2,454 ; 86,350 ^ 16 -5,333836469 -20,332 -281,189 17 -24,74190315 I -38,816 : -56,883 : 18 -38,655628 -51,363 -32,873 ; 19 -46,19925186 : -57,072 -23,534 it is evident from the table 5 that a deviation of impulse response values are large in case of cutting off the coefficients. A graph in the figure 6 shows an impulse response for double precision and shortened mode coefficients. -60 Doubis pricisfon cdsff /I fShortens^ mode cpeff. T'T \ / \ / \ Vxii^- Fig. 6: 10 15 20 25 30 35 40 Number of samples Impulse response of the 4th order digital filter for the exact and shortened coefficients Although a deviation of impulse response values is large, a frequency characteristic is not deformated to a great extent. In the figure 7, a frequency characteristic of digital filter for shortened and long (original) coefficients are shown. From this figure it is transparent that characteristic is more degraded in passband, above all in a bigger ripple in passband than it is designed. Figure 8 shows a detail of passband ripple. In the stopband there is a filter with shortened coefficients is even better than originally designed filter (at this design stage, we determine maximal allowed ripple in passband and minimal allowed attenuation in stop-band). 10 16 Frequency (Hz) Fig. 7; The magnitude frequency response of 4th order recursive filter for shortened and long format coefficient A 0 0.5 1 1.5 2 2.5 3 3.5 4 Ffeqiisncy (Hz) Fig. 8: The magnitude frequency response of the 4th order recursive digital filter for shortened and long format coefficient -detail of passband -ripple 4.3 The fourth order recursive digital filter in cascade form Having in mind that a direct form of realization is the most sensitive influence of quantization of the coefficients (in our case cutting off the decimal places), we will continue analysis of the behaviour of the digital filter in a cascade form. All requirements will remain unchanged. With FDA tools, we will calculate coefficients of two cascade structures (SOS matrix). Equations (1) and (2) are given in detail. Following coefficients are: The first structure : b21=b2a= +1,00 1,00 bll=bla= -0,7544 77 551 all=ala= -1,7130 35 557 b01=b0a= +1,00 a01=a0a= +0,7587 40 607 The second structure : b22=b2b= +1,00 1,00 bl2=blb= -1,6555 42 739 al2=alb= -1,7903 62 034 b02=b0b= +1,00 a02=a0b= +0,9253 78 821 and gain g= 0,0128 150 304. Regarding equation 4, we got following (gain and coefficients are shown shortened, for the sake of clarity): l + flj^ //(z) = 0.0128- 1 + fl,^ -z ' +a„. -z ^ l-1.713z"'+0.7587z"' 1-1.7903 z"'+0.9253 z^ D\ D2 where N1, N2; D1 and D2 are nominator and denominator of both functions and g is gain. In function HI is already included gain g. If we use instruction zp2sos instead FDA toolbox for calculation of coefficients, than the gain g is already included in coefficients of the transfer function, i.e. g=1, so it can be omitted. (Regularity of calculation cascade structure, is possible to check with MATU\B instruction conv with following script: N1 = /1 -0.7544 1/ N2=/1 -1.655 1/ g=0.0128150 N= conv(N1,N2); Ng=g*N In this equation, "Ng" is a nominator of the filter in a direct realisation.( Similar goes also for a denominator) With MATLAB, we can represent magnitude response for each structure separately. In the figure 9, there are shown magnitude responses of the first, second and direct realisation of the filter. From the picture is visible that the characteristic of direct realisation is a result of multiplication of the characteristic of the first and second structure (in log. scale , it will be the summ, i.e. H=H1 + H2) 10 15 Frequency (Hz) Fig. 9: Decomposition of frequency characteristic of the 4th order digital fiiter into two second order functions We continued the analysis with quantized coefficients especially those in shortened mode. For analysis, we cut coefficients to 3 decimal places. Table 6 shows results of comparison of impulse response of MATLAB simulation and a real digital filter 4th order, realised with PLC controller, with coefficients in a shortened mode. Deviation (error) is shown for coefficients cut down to 3 decimal places. Table 6: Comparison of the first 20 values of the impulse response, for the 4th order digital fiiter, realised in cascade realisation, with coefficients in long and shortened mode sample no. MATLAB From PLC Deviation % 0 12,81503050 12,8150304 7,6859E-07 1 14,01314165 14,01964326 -0,04639651 2 29,84427179 ; 29,87032369 -0,0872928 3 44,81855444 44,87469011 -0,12525094 4 60,29166857 60,40018669 -0,17998858 5 76,30091953 . 76,48888885 -0,24635262 6 91,83710540 92,13215093 -0,32127049 7 105,23871650 105,6664377 -0,40642949 8 114,63757670 ? 115,2196907 -0,50778637 9 118,38576890 119,138391 -0,63573696 10 115,40354470 : 116,3353537 -0,80743537 11 105,40486000 106,5151964 -1,05340152 12 88,97838699 90,25555199 -1,43536543 13 67,5241582 68,94430001 -2,10316107 14 43,06632776 44,59330464 -3,54563986 15 17,9783246 19,56483705 -8,8245845 16 -5,333836469 = -3,743727912 29,8117231 17 -24,74190315 i -23,20897484 6,19567662 18 -38,655628 -37,24072413 3,66027909 19 -46,19925186 -44,95804954 2,68662861 From results shown in table 6, it is evident, that deviation is significantly smaller than in a direct realization structure. Magnitude frequency characteristic are practically equal for coefficients given in long and short mode, as shown in the figure 10a. A small deviation is still present in pass-band, in the figure 1 b is a detail of characteristic in pass-band. 10 15 Frequency (Hz) Shpftened jmode Doeff. | j i N ,]AI ; ; Double precision coej^'. ; M M Ml ; -^-i... i i i i i i 1 i i 0.5 1.5 b 2 2.5 3 Frequency (Hz) 3.5 4.5 Fig. 10: a) Frequency characteristic of the 4th order digital filter in cascade realization with coefficients In a shortened mode b) detail of characteristic in passband Comparison of deviation of impulse response for entering coefficients in long and shortened mode, for direct realisation, and shortened mode for direct realisation as it is shown in table 7. In this comparison, values calculated with MATLAB, are referent. From the results we have shown so far, we can conclude that entering of shortened coefficients for the 4th order digital filter in a direct realisation, is very important for behaviour of such filter We can not neglect a deviation of impulse response from teoreticaly calculated and actual magnitude response. Fora direct realisation of the higher order filter, realised in a direct form, is it necessary to enter coefficients in exact (long) form. A graphic representation of deviation for the 4th order IIR filter in cascade realisation, for the extact and shortened mode of the coefficients and for a direct realisation is shown in the figure 11. Figure shows absolute values of deviation. Table 7: Comparison of the first 20 values of impulse response for the 4th order digital filter for direct and cascade realisation with coefficients in a long and shortened form. MATLAB X 1000 PLC impulse response Direct form shortened coefFicients Cascaded realisation Long coeificients Shortened coeflFicients 12,81503050 6,35995754 3,88992E-06 7,6859E-07 14,01314165 14,36609791 -5,95899E-05 -0,04639651 29,84427179 12,37849533 -9,45304E-05 ■0,0872928 44,81855444 11,33805967 -0,000101644 -0,12525094 60,29166857 10,50670635 -0,000217991 -0,17998858 76,30091953 9,921138016 -0,000236518 -0,24635262 91,83710540 9,616053733 -0,000320783 -0,32127049 105,23871650 9,609311903 -0,000364398 -0,40642949 114,63757670 9,921333834 -0,000456498 ■0,50778637 118,38576890 10,60834337 0,014924823 -0,63573696 115,40354470 11,7947371 -0,000654489 -0,80743537 105,40486000 13,7430665 -0,001081544 ■1,05340152 88,97838699 17,02142228 -0,000913721 -1,43536543 67,52415820 23,0423579 ■0,001246658 -2,10316107 43,06632776 36,4491903 -0,002025343 -3,54563986 17,97832460 86,35022977 -0,004312944 -8,8245845 -5,333836469 -281,1890394 0,013432533 29,8117231 -24,74190315 -56,883647 0,002518605 6,19567662 -38,65562800 -32,87327787 0,0013659 3,66027909 300 -250 200 150 100 50 0 Cascade form, long Cascade shortened Direct shortened Fig. 11: Error of impulse response of 4th order IIR filter for different realization and lenght of coefficient (in %) 5. Conclusion This article challenges a possibility of realization of the recursive digital filter of the third and fourth order with pic controller. Although sensors and transducters, {we usually have at automation fields with pic controllers), do not distinguish useful signals from unwanted signals (noise and interference) the system does. Therefore, there is a need for additional equipment, SW or HW, which helps to eliminate the disturbances, so the controlled process would continued faultlessly. As the application of automation of industrial processes gets more demanding, appears the demand for digital elimination of unwanted input signals. Regarding this in our applications, the influence of nonlinear phase is not critical for filtering of disturbanced signals, we chose recursive filter applying the coefficients of elliptic filter We chose elliptic filter, because a useful slope of frequency characteristic in passband has lowest order. Also a ripple of amplitude characteristic was not critical if we consider limit values of the system. A description goes furher for a function of the PLC controller and importance of cycle time and interupt, especially with controller Siemens S7 . The coefficients of filter with MATLAB are calculated directly specifically with the aid of FDA toolbox. For digital filter of the 3rd and 4th order, we analysed a detailed influence of cutting the coefficients length to the characteristic of the filter. For realization of the filter, we used structures of 2nd order, which we applied in cascade realization of filter. For recalculation of the 3rd order filter in cascade structure, we used MATLAB, which enabled determination of the second order structures as a matrix structure (SOS matrix). With shown SOS matrix, cascade realization of the 3rd and 4th order filter is simple defined. The figure 2 shows a part of the organization block of PLC controller with the mask for input of coefficients and input variables in each structure. Comparison of impulse responses of the 3rd order digital filter made by PLC in cascade form with simulation results from MATLAB, also specifies a negligible deviation in case of exact values of coefficients (format long). Larger deviations appear just at calculation with shortened coefficients. Deviations are result of recursive mode of calculation. A direct form realization of the 4th order filter with shortened coefficients, reveal large deviations, even though deviation of the amplitude characteristic is not significant. In stop-band, such filter is considered a better option, because it has less ripple than a designed one. With cascade realization of the 4th order filter, we indicate that deviation using coefficients values in long format, can be truncated, they match MATU\B results. For the filter in cascade form realization with shortened coefficients, we proved that deviation of values of impulse response is not neglectful, but is still lower than in a direct realisation. Deviation of amplitude characteristic appears in passband and is really small (<0.5 dB). Comparation of impulse response for different realizations are illustrated in table 7 and figure 11. The obtained amplitude characteristic matches with requirements. Attenuation of 40 dB is obtained at double cut-off frequency, which is essentially better to the 2nd order filter. 6. References /1./ L. Milic, Z. Dobrosavljevič, Uvod u digitalnu obradu signala, Ele-ktrotehničkl fakultet Beograd, 1999. /2./ R. Babič, Dinamika izhodnega signala pri kaskadni obliki izvedbe nerekurzivnih digitalnih sit Informacije MIDEM. - ISSN 0352-9045. - Letn. 31, št. 3 (2001), str. 152-158. /3./ SIEMENS S7-300 manual, programmable controller, hardware and instalation SIEMENSAG, 1998, EWA4NEB 710 6084-002 01 /5./ Aleksander Dodič, Izvedba rekurzivnih digitalnih sit s PLC krmilnikom, magistrska naloga. Univerza v Mariboru, Fakulteta za elektrotehniko, računalništvo in informatiko, Maribor, 2007. /6./ Sanjit K.Mitra, Digital Signal Processing-A computer Based Approach, Mc.Graw Hill, 2002. Mag. Aleksandar Dodič, univ. dipl. inž., Lučl