Software solutions used in industrial measurement devices to facilitate meeting the requirements of the EMC directive

Marek Kryca, Artur Kozłowski

Institute of Innovative Technologies EMAG, Katowice, Poland

Abstract: This paper presents an example of a measuring device to be applied in a coal mine, for which special effort was taken at the design stage to fulfill the requirements for electromagnetic compatibility. Software solutions described in the paper are useful during the EMC certification process for the majority of programmable equipment, because slight modifications of the program can compensate imperfections of hardware design and may decide about passing the certification process.

Keywords: industrial measurements, embedded software, noise immunity, EMC

ndustrial applications of programmable electronic systems allow the implementation of the essential control functions and performing measurements for technological processes monitoring. These tasks are carried out by controllers with constantly growing scale of integration. Commonly used microcontrollers differ in terms of architecture, performance, size and parameters of electronic resources, but they have one thing in common – the implementation of algorithms to improve the reliability of the device and definitely increase its functionality. High reliability requirements are the key feature of industrial measurement systems. The desired feature is the ability to work independently, because usually one cannot depend on the continuous control of the device by the operator and his/her possible intervention to start the suspended program. Often the response time to the incorrect operation of the device due to both hardware and software malfunction is short, and the late response can have serious consequences in the process. Microcontrollers are characterized by very poor resistance to interference, resulting from high speed of the system clock and short duration of digital signals on buses and, on the other hand, as a result of power consumption reduction. All signals often have frequency and energy similar to interfering signals. To maintain high reliability of hardware and software one has to apply special solutions for prevention, detection and correction of any malfunction of the equipment.

1. Certification

All electronic equipment to be sold in Europe must be CE marked. To use CE marking, the producer is obliged to satisfy related EC directives. For Information Technology Equipment, emission regulations and immunity regulations are defined. Although these immunity regulations are prepared by CENELEC, almost all contents are the same as standards issued by IEC or CISPR. Adaptation of the device for working in the presence of electromagnetic disturbances is analyzed during the test cycle known as EMC tests. A properly designed device must meet the safety requirements described in Low Voltage Directive (73/23/EEC), requirements related to electromagnetic compatibility directives (89/336/EEC, 92/31/EEC), as well as the specific requirements connected with the area of application – for example ATEX Directive (94/9/EC). Main role, associated with the fulfillment of the requirements of those directives, is played by the constructors of equipment. An exception are the requirements related to electromagnetic compatibility. It is generally considered that issues connected with electromagnetic immunity and emission are related to the hardware aspects of construction. A wide range of elements in the form of filters, ferrite rings, sleeves, beads and gaskets provided by distributors of electronic components, allow the designers to apply appropriate solutions. Time-consuming and costly changes in design are necessary in the case of negative results. Please note also that the positive test result indicates that the device is resistant to interference of the levels specified by the standard, and the real disturbances that can occur during operation do not necessarily have lower levels. A very important role is played by the software implemented in the electronic systems, which can affect the accuracy of the indications, the quality of the measuring device and quality of the whole system to which the device is connected.

1.1. EMC tests

EMC tests for all constructed devices can be divided into two types:

• tests of immunity ability of the equipment, which has to work properly in the presence of external sources of interference (sensitivity of the device to external disturbances):

– immunity to electrostatic discharge,

– radio frequency electromagnetic field,

– fast transient burst,

– surge,

– immunity to conducted disturbances, induced by radio-frequency fields,

– magnetic field of the power grid frequency,

– pulse magnetic field,

– voltage dips, short interruptions and voltage variations,

– oscillatory waves;

• emission measurements of electromagnetic disturbances (the test device is a source of electromagnetic radiation):

– conducted electromagnetic disturbances (conducted emission),

– radiated electromagnetic disturbances (radiated emission),

– harmonics and inter-harmonics measurements,

– flicker measurement.

The list of the directives related to research is extensive, and the selection of the appropriate and related standards is a separate task.

Electromagnetic Compatibility describes the ability of the equipment or system to function satisfactorily in an electromagnetic environment without introducing intolerable electromagnetic disturbances to anything in that environment. Electromagnetic Interference is the degradation of the performance of equipment, transmission channel or system, caused by an electromagnetic disturbance [1].

2. Equipment under test (EUT)

Both the immunity and emission of interference are strictly connected to the electrical environment at the installation place of the equipment.

Usually they occur simultaneously, and their impact on the operation of the electronic unit is minimized by the use of appropriate hardware and software solutions. Hardware solutions are related to the additional costs incurred in the production of each device. Software solutions are associated with the costs incurred during the designing process.

Conductive coupling occurs when the device is directly connected with the source of electrical disturbances, usually via a transmission line or wire.

Inductive coupling occurs when the device is located near the electrical disturbances source and the influences of its magnetic field can be observed.

Capacitive coupling has similar nature, but should be referred to electrical field and electrical induction. A block diagram of a typical programmable unit designed for industrial applications is shown in fig 1.

A device for monitoring the process of froth flotation could be a good example. The MPOF 2 Optical Ash Meter is designed for on-line measurement of ash content in hard coal flotation tailings in coal processing plants. The device can work as a stand-alone measuring device for monitoring the coal cleaning process, but mainly is used in the systems for the process of froth flotation control. The MPOF 2 Optical Ash Meter applies the optical method of measurement, based on the visible range of electromagnetic spectrum. Depending on the grey level of the tested material, the light emitted from the device is reflected from the surface of liquid tailings in the direction of measuring photodiode (the photodiode works as a photo element, due to the use of the photovoltaic effect).

Fig. 1. Block diagram of a typical programmable device
Rys. 1. Schemat blokowy typowego, programowalnego urządzenia

Fig. 2. Device prepared for radiated radio-frequency electromagnetic field immunity test
Rys. 2. Urządzenie przygotowane do badań odporności na promieniowane zakłócenia elektromagnetyczne o częstotliwości radiowej

The flotation tailings grey level is proportional to the ash content therein. MPOF-2 has all components usually used in industrial applications:

– analog input for light intensity measurement,

– analog output (4–20 mA range) to be connected to the process control system,

– digital inputs and outputs to be connected with the object (low water level, signaling alarm states, etc.)

– digital transmission line to a SCADA system,

– central processing unit to perform all calculations and measurement algorithm (there are two microcontrollers connected by an internal transmission line),

– random access memory necessary for operational data,

– flash memory for the program and coefficients,

– local display for the human operator and service purposes (calibration, diagnostics),

– power supply.

Designing a robust measuring device is connected with collective effort of software and hardware engineers. The ability to work despite abnormalities in calculations can be checked by error injections, but much more important is a properly conducted design process. The device prepared for the test is shown in fig. 2.

3. Selecting standards for EMC tests

For devices intended for use in industrial environments interfering signal levels are far higher than in the so-called environments with controlled level of interference (offices, homes). The requirements defined by the standards are relevant to this situation. The MPOF2 device was tested in accordance with the standard PN-EN 61326-1:2009 Electrical equipment for measurement, control and laboratory use – EMC requirements.

Before the testing starts, a set of standards based on which the tests will be carried out should be defined along with the validation criteria. That kind of information is very useful during the development process of both hardware and software. It is a very rare case when such requirements are formally defined before the start of the design process, so the designer’s professional experience has particular importance. The standards selected for tests are the following:

– PN-EN 61 000-4-2:2011 Electromagnetic compatibility (EMC) – Part 4-2: Testing and measurement techniques – Electrostatic discharge immunity test,

– PN-EN 61 000-4-3:2007+A1:2008+IS1:2009+A2:2011 Electromagnetic compatibility (EMC) – Part 4-3: Testing and measurement techniques – Radiated, radio-frequency, electromagnetic field immunity test,

– PN-EN 61 000-4-4:2010+A1:2010 Electromagnetic compatibility (EMC) – Part 4-4: Testing and Measurement Techniques – Electrical Fast Transient / Burst Immunity Test,

– PN-EN 61 000-4-5:2010 Electromagnetic compatibility (EMC) – Part 4-5: Testing and measurement techniques – Surge immunity test,

– PN-EN 61 000-4-6:2009 Electromagnetic compatibility (EMC) – Part 4-6: Testing and measurement techniques – Immunity to conducted disturbances, induced by radio-frequency fields,

– PN-EN 61 000-4-11:2007 Electromagnetic compatibility (EMC) – Part 4-11: Testing and measurement techniques – Voltage dips, short interruptions and voltage variations immunity tests,

– PN-EN 55 011:2010+A1:2010 Industrial, scientific and medical (ISM) radio-frequency equipment – Electromagnetic disturbance characteristics – Limits and methods of measurement.

4. Software solutions increasing robustness of the device

4.1. Analog inputs

Analog inputs often work in a differential mode. It means that a useful signal is obtained as a difference between two wires, in contrast to noise, which is more or less the same on both lines. Analog signals, which are a fundamental part of the measurement system, are particularly vulnerable to interference. Such systems, by their nature, measure small signals, often having characteristics similar to the distortion introduced during EMC testing, while keeping the maximum dynamic range and sensitivity. Often, the path of analog signals is the gateway through which distortions enter the controller, leading to disorders in the work of the whole unit. The programmer’s role is limited to the processing of the measured signal in order not to exceed the limit value by the observed result. Typical solutions are digital filters of FIR or IIR type [4]. The use of this type of algorithms, however, requires high computing power and can be used in microcontrollers equipped with a dedicated multiply-and-accumulate unit (MAC), because just these types of operations are performed repeatedly.

The application of the normal averaging algorithms (simple moving average SMA, cumulative moving average CMA, weighted moving average WMA, exponential moving average EMA or running moving average RMA) is not effective, because of degradation of the whole system dynamics and long lasting disturbances on the device output. Setting the sampling time for analog inputs in relation to the frequency of the power supply network (multiple of 20 ms) allows to suppress the interference of 50 Hz frequency. The simple solution for eliminating glitches is to use the ”triple“ filter. The controller holds in memory the last three results of the measurements: x1, x2 and x3. The only parameter of the filter is coefficient ε, which should be slightly greater than the expected noise at analog input. The microcontroller calculates the absolute value of the three differences:

d1=abs(x1 – x2), d2=abs(x1 – x3), d3=abs(x3 – x2).

The comparison of the enumerated values with the parameter ε can be interpreted as follows:

– (d1 ≤ ε) and (d2 ≤ ε) and (d3 ≤ ε) means that the signal is stable and the result of the measurement is y=(x1+x2+x3)/3,

– (d1 ≤ ε) and (d2 > ε) and (d3 > ε) means that the signal x3 significantly differs from the others, so y=(x1+x2)/2,

– (d1 > ε) and (d2 ≤ ε) and (d3 > ε) means that the signal x2 significantly differs from the others, so y=(x1+x3)/2,

– (d1 > ε) and (d2 > ε) and (d3 ≤ ε) means that the signal x1 significantly differs from the others, so y=(x3+x2)/2.

– In other cases we can expect that the analog signal rapidly changes, and then y=(x1+x2+x3)/3.

4.2. Power supply

The software also influences the level of electromagnetic disturbances emitted by the device which has a strong relationship with the power consumption. Reduction of the input power results in weakening emissions, but at the same time reduces device’s immunity – lowering power consumption means that power of interferences is comparable with the appropriate signals. Reduction of power can therefore be made by disabling unused peripherals. Usually the microcontroller is equipped with many additional subsystems, of which only a part is used. Unused external control signals (e.g. control signals or the signal for the DRAM address latch ALE in MCS-51 microcontrollers) should be excluded, if possible. Decreased activity on the lines of communication to the necessary minimum, and minimized the system clock frequency for the controllers can significantly reduce emissions [6]. Conductive disturbances measured on power supply lines are shown in fig. 3.

Fig. 3. Emitted electromagnetic disturbances (150 kHz – 35 MHz) measured on power supply lines of MPOF2
Rys. 3. Emitowane zakłócenia elektromagnetyczne (150 kHz – 35 MHz) mierzone na liniach zasilających urządzenia MPOF2

4.3. Transmission links

Data transfer from the measuring devices to master systems is widely used and is applied in almost all solutions. There are two modes:

– continuous transmission when each newly developed result is sent to the master (relatively small data packets cyclically transmitted over a large distance),

– sporadic transmission when the device has collected results in its data memory, and then sends with maximum speed the contents of the buffer during a communications session.

Implemented protocols should take into account errors of the transmission channel, and in the case of inconsistence detection should request retransmission of data. The application of the correction codes allows to recover data without the need to retransmit. The data transmission procedure of confirmation is necessary in the case where the results of the measurements must be backed up with some reasons. The application of interference-resistant hardware solutions (current transmission differential) does not eliminate the need for validation. Many types of error information reported by the UART devices (frame error, parity and stop bit) require implementation of appropriate support procedures.

4.4. Digital inputs and outputs

Digital inputs, commonly used to work with switches, should be designed to handle contacts vibrations. Contacts within the switch do not make contact cleanly, but slightly ‘bounce’. If a hardware solution has not been applied, it is necessary to write a piece of code. This algorithm (called de-bouncing) also applies to object-oriented signals, and the frequency of reading the input port and the minimum number of repetitions should be chosen.

4.5. Display

Writing data to the output buffers, as well as showing the last measurement results on the display do not relieve the developer from continuous update of the outputs. When consecutive results appear rarely, there is a risk of distortion of the output buffer or data damage being sent to the display. Rapid correction of LEDs indicators or the numerical value on the display allows to maintain the functionality of the device. Information latched in the outputs buffer and display should be refreshed independently of the measurement cycle. Such an action will eliminate cases when the effect of the distortion has been shown on the screen for a prolonged time.

4.6. Program memory

There are always unused areas in memory where a program code is stored. One should ensure that they are filled with a value that will be interpreted by the microcontroller as a NOP (no operation) or as a jump to the appropriate procedure [3]. In the case where the value of the program counter is disturbed and the microcontroller will execute a code outside the range, there will be no undesirable actions.

4.7. Non-volatile data memory

The measuring device settings are very important – setting determination is often associated with a long process of scaling. Values are unique for each device, and their reproduction can be cumbersome and costly. The distortion of the software execution can lead to overwriting data by accidental values and the indication of false values. The software should detect this situation and have an implemented data recovery mechanism. An example of these features implementation is to attach to each data block a control sum of all the settings. After starting the program the algorithm reads the block of coefficients, computes the checksum and compares it to the stored value. In the case of a difference, the data should be read from the backup memory block. Storing of new coefficients must be finished with updating the checksum and making a backup copy of all data.

4.8. CPU Central Processing Unit

The primary mechanism for the continuous control of the instrument, which should be obligatorily applied in industrial applications, is the watchdog. This is a hardware element of the microcontroller in the form of a counter, which at the time of the overflow will restart the software. The initialization of the counter content must follow after the confirmation of the correct operation of the program. Electrical interferences occurring in industrial environments can cause data corruption resulting in task internal blocking, or performing the endless loop. EMC tests will allow to detect hidden problems in hardware and confirm the effectiveness of the programmer’s work. When designing the software that uses the WDT (watchdog timer), one should take into consideration that some hardware failures may lead to cyclic restart of the device, which can be difficult to see for the user of the system. In this case one should limit the number of reboots in a given period of time and pass an appropriate message to request support. How to organize the work of the program responsible for the control of correctness depends on the number, type, time and frequency of the tasks in the system. Therefore:

– periodic tasks performed in less time than overflow time of the WDT can be secured in a very easy way,

– periodic tasks that appear less frequently than the overflow of the WDT require delaying loop,

– tasks that can work periodically, or should be inactive for a certain period, should be able to change the mode of WDT before the suspension. An example of such a task can be connection with the master (periodically turned on data transmission).

When designing the system, one should analyze potential problems that can occur in the software and make sure that WDT will detect them. The effectiveness of the WDT action is the result of the following general principles used in the design process:

– there is only one type of action acceptable of WDT: reset of the microcontroller and connected devices. Other solutions using for example NMI (non-maskable interrupt) to secure the task context can be ineffective. The suspension of the microcontroller does not necessarily mean the execution of the wrong program code, but may mean the stop of CPU work,

– an important parameter is the system initialization time, which is usually longer than the period of WDT. The first launch of the software, after connecting to power supply, is worry-free, because WDT is started at the end of the initialization procedures. After a reboot the system initialization time is limited by watchdog overflow time. The software must take into account that situation and secure the microcontroller before permanent reset.

In the case of programs being a set of tasks with different priorities, execution times and the calling frequency, organizing effective mechanism for checking the correctness of the algorithm realization requires special measurements. Tasks are often performed in an independent manner, which means that the problems with one of them may not result in the blockage of another. The operation of the watchdog timer refreshing should be treated as a separate task carried out by the device’s software [5]. It should be noted that the program has the only place, where direct access to the watchdog is implemented.

There are two strategies to organize the work of WDT:

– by analyzing the number of calls to individual tasks within a certain period of time and comparing them with the values measured during the tests,

– by analyzing the intervals between successive calls to the task.

A solution based on the analysis of the number of calls to each of the tasks is shown in fig. 4.

Fig. 4. Organization of the control task based on the call counters
Rys. 4. Organizacja zadania kontroli poprawności działania sterownika oparta o liczniki wywołań

Fig. 5. Organization of the control task based on the measurements of the time between successive calls
Rys. 5. Organizacja zadania kontroli poprawności działania sterownika oparta o pomiary czasów między kolejnymi wywołaniami

All tasks under control have their own counters that are incremented when you call or end tasks [2]. The counters are periodically checked by a validation task and compared with the maximum and minimum values stored in nonvolatile memory. Limit values must be determined to guarantee that the situation when all the conditions are met took place before overflow of WDT.

An important element of the control task is to reset all counters before clearing WDT. This is protection against blocking the program during the control task.

The strategy presented in fig. 5 is based on time control of tasks calls suitable for applications where WDT overflow time is comparable to or smaller than the time intervals between successive calls to the tasks. Note that in both cases counters are symbols, to which the access is possible from more than one point of the program. One should pay attention to the instructions that ensure the data will not be corrupted in the middle of counter incrementing. In the case when data are not modified during one cycle, temporary blocking mechanisms should be used to access the data and obtain the correct value. The program should not include the optional codes to disable WDT, which could be useful during the startup of the device. The part of the program monitoring the correctness of operation of the equipment should make a decision on possible clearing of the WDT counter. Distortion of the device caused by, e.g. electrostatic discharge can result in anomalies in the control task and then cause the initialization of the microcontroller.

Validation of the control task can also be made using the technique of control flow checking [3]. Taking of control by a subroutine is associated with the modification of specific cells of RAM, which can be proven by this procedure. The detection of anomalies will hold clearing the watchdog timer, leading to the restart of the device.

5. Conclusion

The paper presents an example of measuring equipment for application in a coal mine, for which special effort was taken at the design stage to fulfill the requirements for electromagnetic compatibility. The paper shows the need for cooperation between hardware and software engineers and the role of EMC tests. The authors have shown that the slight modifications of the software can compensate imperfections of hardware design and may decide about passing the certification process. Incorrectly written software can cause that the correctly designed hardware will not pass EMC tests. Taking into consideration the requirements during the design process of new devices will lead to increasing their reliability, allowing long operation in industrial environments.

References

1. Murata Manufacturing Co., Ltd., Noise Suppression Techniques. Conditions for Electromagnetic Interfe-rence and Future Trends, [www.murata.com/ products/emc/knowhow/index.html].

2. Ganssle J., Watching the watchdog, “Embedded Systems Programming”, Vol. 16, No. 3, 2003.

3. Carlton R., Racino G., Suchyta J., Improving The Transient Immunity Performance of Microcontroller-Based Applications, Freescale Semiconductor Application Note AN2764, [http://cache.freescale.com /files/microcontrollers/doc/app_note/AN2764.pdf?fsrch=1&sr=1].

4. Brotz J., Software techniques for comprehensive EMC testing of embedded systems, “EE Times Design”, 2008, [www.eetimes.com/design/embedded/4007591/ Software-techniques-for-comprehensive-EMC-testing-of-embedded-systems].

5. STMicroelectronics, Software techniques for impro-ving microcontroller EMC performance, Application note AN1015, [www.datasheetcatalog.org/datasheet /SGSThomsonMicroelectronics/mXyytzw.pdf].

6. Ferguson M., Noise Issues and Solutions in MCU-Based Systems, Embedded Systems Conference, Silicon Valley, April 2008, [http://am.renesas.com/ media/company_info/news_and_events/mcu_promo/ESC-120_Ferguson_PPT.pdf].

Rozwiązania programowe stosowane w przemysłowych urządzeniach pomiarowych ułatwiające spełnienie wymagań dyrektyw EMC

Streszczenie: W artykule przedstawiono przykład urządzenia pomiarowego przeznaczonego do stosowania w kopalniach, którego oprogramowanie zostało zaprojektowane tak, aby ułatwić spełnienie wymagań związanych z kompatybilnością elektromagnetyczną. Rozwiązania opisane w niniejszym artykule są przydatne podczas procesu certyfikacji EMC dla większości programowalnych sterowników i pokazują, że niewielkie modyfikacje programu mogą zrekompensować niedoskonałości konstrukcji sprzętu, co może zadecydować o pozytywnym przejściu przez proces certyfikacji.

Słowa kluczowe: pomiary przemysłowe, oprogramowanie wbudowane, odporność na zakłócenia, EMC

leg Marek Kryca, PhD

chief engineer of mineral processing technology in the Institute of Innovative Technologies EMAG. He is an electronics engineer and holds PhD in computer science (Silesian University of Technology, Poland). He has over 25 years of experience in the design and manufacture of measurement devices, mainly for coal mines. Co-author of 9 patents. His main area of interest is embedded programming.

e-mail: marek.kryca@emag.pl

AK0002 Artur Kozłowski, PhD

Manager, Head of R&D Department, chief engineer of electrical engineering in the Institute of Innovative Technologies EMAG. He is graduated engineer in power electronics and holds PhD in electrical engineering (Wrocław University of Technology, Poland). He has over 10 years of experience in the design and manufacture of automation systems, protection devices, power supplying devices, mainly for coal mines. Co-author of 3 patents.

e-mail: artur.kozlowski@emag.pl