Vision system for detection of defects in the electrical connector of electric motors : test rig and algorithms

Electric motors are used in a large number of applications. Those machines are mainly composed of a rotor and a stator. Regarding induction motors, the rate of defects in the stator manufacturing process is larger than in the rotor one, due to its higher complexity. To identify these faulty situations, the most common scenario is human operators performing inspections, but they are subjected to fatigue and lack of attention. This paper presents a vision system with three redundant automatic inspection techniques and a mechanical test rig to inspect the force-induced disconnection of the stator power cables inside the electrical connector, a common defect of electric motor parts in assembly lines. Those defects are normally not detected by typical electrical tests, since in many situations the disconnection occurs after those tests, in operation, thus characterizing a field failure of the motor. The test rig components and its operation to make the defects evident are herein described. Also, a detailed description of each software routine for implementing the proposed inspection principles is presented. A case study using 20 connectors of real motors was proposed for evaluating the developed system and the achieved results are discussed, showing that the system could correctly identify 100% of the defects.


I. INTRODUCTION
HE possible applications of electric motors in different fields of economy are countless.There are different types of motors and they can be powered by direct current or alternating current sources.Given their ruggedness, reliability and low price, alternating current squirrel-cage induction motors are the most used type of motor.For application in industry, three-phase motors are typically used, while for both residential and commercial applications the single-phase configuration is generally preferred.This equipment has two main parts: the rotor and the stator [1,2,3,4].Fig. 1 shows a typical single-phase induction motor and its relevant parts for this study: (1) rotor, (2) stator, and (3) electrical connector.
Stators are more complex to manufacture than rotors, thus they are subjected to many tests from the very beginning of the production line until the last stages of the electric motor assembly.Through the monitoring of production lines of a Bernardo Cassimiro Fonseca de Oliveira, Rodolfo César Costa Flesch, Antonio Luiz Schalata Pacheco and Miguel Burg Demay ________________________________________________________________________________ Vision system for detection of defects in the electrical connector of electric motors: test rig and algorithms T Fig. 1.Parts of a single-phase induction motor.partner induction motor manufacturer, the main sources of defects have been identified and enumerated.In this observation, it was concluded that the defect 'Disconnection of Stator Power Cable' (herein denoted by short as DSPC), is a relevant issue and its detection is difficult to be visually performed by human operators.
In quality control, it is noticeable the increasing use of automatic inspections, in which vision systems (VS) occupy a major space considering their reliability in contactless inspections [5,6,7].Although automatic inspection methods present many advantages, visual inspections in industry are still commonly done by human operators, which are subject to lack of attention, fatigue and subjectivity, and are costlier.Those factors make the use of VS even more interesting [8].Since the inspection of DSPC is typically made by human operators, this potential defect is a strong candidate for automatic inspection.
The great outcomes of VS are well known in literature.The work of [9] has shown the importance of VS in industry.In [10] researchers used an industrial camera to replace a colorimeter to determine the color of meats, which is related to the iron compound quantity and, thus, inferring about their quality.In [11] a vision system has been developed to measure the form of potatoes for automatic grouping of potatoes with regular and irregular forms.A portable measurement system using photogrammetry has been projected to inspect the outer surface of pipelines for the oil industry in [12].Regarding stators, reference [13] consists of an experimental analysis of the required conditions to replace the human inspection of stators by VS.Finally, in [14] the work of the companies Pontiac Coil and Vision Traceability Group about inspecting stators using machine vision techniques is described.It is noticeable that the detection of defects in industry using VS has a large applicability [9].
This paper describes the conception of a vision system to inspect DSPC in single-phase induction motors and presents the main results achieved with its application to inspect electrical connectors with real defects.The proposed system is divided in two main parts: (i) a prototype of test rig with image acquisition system that applies mechanical traction to the connector cables, and (ii) vision inspection algorithms.A case study considering connectors used by a manufacturer of electric motors has been done to evaluate the performance of the proposed system.Results have been gathered and discussed, considering a goal of 99.7% (three-sigma limit) of correct indications.The vision system presented in this paper is an improved version of the one presented in [15], by the authors.
In section II, the defect to be inspected and the proposed system are detailed.In section III, a case study is presented and its results are discussed.Finally, section IV summarizes the main ideas and conclusions of this paper.

II. PROBLEM DESCRIPTION AND PROPOSED SOLUTION
This section begins with DSPC description, in subsection A. Then, in subsection B the proposed test rig is characterized.After that, the proposed algorithms for image processing are explained in subsection C.

A. Defect description
The electric motor stators analyzed in this work have three external electrical connection points: one for the primary winding, one for the auxiliary winding, and a common connection point.These connection points are attached to cables, which have terminals of the "clip" type in one of its ends.The three terminals are attached into a plastic housing and this assembly is called electrical connector (Fig. 2), which will be divided in three zones (A, B, and C) to facilitate its description in the following sections.This electrical connector can present defects due to: (a) an improper positioning or attachment of one or more clips to the plastic housing during the assembly process, (b) one or more defective clips that do not have the fixing element or the right dimensions for proper fixation, or (c) a defective plastic housing.In all those cases, one or more terminals are not properly attached to the plastic housing, so they can move.If the clips move out of the correct position, there may be no electrical contact between the clips and the power supply plugs, which are inserted into the housing orifices.Thus, the connection of one or both windings can be threatened and, as a result, the motor may not work or may present a failure after put into operation.DSPC can be visually identified as a partial obstruction of the housing orifice (Fig. 3(a)) or as a clip appearing on the upper region of the plastic housing (Fig. 3(b)).In Fig. 3(a), the clip in zone C is partially moved up and it is possible to see part of its wall in addition to its connecting opening in the region highlighted with the red circumference.Also in Fig. 3(a), it is possible to see that the other two clips, in zones A and B, are properly placed, so that it is just possible to see their connecting openings through the housing orifices.In Fig. 3(b), the clips in zones B and C are partially pulled out the housing and it is possible to see part of the clips on the upper region (highlighted with red circumferences).Also in Fig. 3(b), it is possible to notice that both defects cannot be detected by inspecting the housing orifices, since there is no evidence of defect in those regions.Therefore, both housing orifices and upper regions must be visually inspected to guarantee the reliability of the inspection.
There are situations in which the attachment is not proper, but the clips are apparently in the correct position, since it is not possible to see the wall of the clip neither through the housing orifices nor the housing upper region.However, during the assembly of the motor in its final application (fan, pump, machine tool etc.) the clips can move and, in this case, a disconnection occurs.Consequently, to allow the visual identification of such cases, the cables have to be tensioned in a controlled way in order to make the defect visible in one of the inspection regions.A test rig designed to tension the cable and capture the images is described in subsection B.

B. Test rig
Before acquiring the image to be processed by the proposed algorithms, the proposed test rig needs to make the defects evident, thus allowing them to be identified from an image.That is necessary because many defective clips do not appear to be a defect until they are pulled somehow, as mentioned in subsection II.A.According to the manufacturer of the tested samples, each non-defective electric clip resists being strained by an equivalent force of 34 N without coming loose from the plastic housing.So, a prototype of test rig was designed and implemented to apply a slightly lower load than 34 N on each clip.Defective clips or the ones which are not well attached to the housing will be moved, while the ones without defect will remain fixed to the plastic housing.
Pictures of the implemented test rig are presented in Fig. 4(a) (front view) and Fig. 4(b) (rear view).The rig is composed by a 1 MPa, pneumatic cylinder with a course of 25 mm and spring mechanism to load correctly each cable (the three springs of this mechanism can be seen in Fig. 4(b)), a base structure made of AISI 1020 steel, and a locking mechanism to hold the electrical connector (upper part of Fig. 4(a)).The pneumatic cylinder was chosen according to the load needed to strain the three cables at the same time.In order to guarantee the independence of each cable, a mechanism with springs was projected in a way that it enables the attachments without defect to overcome the load and the cables connected to defective attachments to be moved with a single movement from the pneumatic cylinder.
Fig. 5 shows how the mechanism works.On stage 1, the compressed air enters the piston, forcing it to move up with all the independent spring mechanisms for loading each cable.As the upper structure with the springs moves up, it starts to pull the cables that are connected to the clips, which were supposed   to be attached into the plastic housing of the electrical connector.When the mechanism applies the admissible load to each cable on stage 2, either the clips can hold the movement by compressing the spring (the ones that are correctly attached to the plastic housing), or they are pulled out (the clips with poor attachment), unloading the respective spring (stage 3).This allows the defect to be visually detectable using the camera, as can be seen in Fig. 3(a) or in Fig. 3(b).Also, the state of each spring on stage 3 can be used as confirming information about the quality of the attachment of the clips to the plastic housing.
After the defects are evidenced, an image can be captured.This image will be processed by the algorithms described in section II.C.Aiming on the development of a low-cost system, the camera used in this test rig was a 2 MP USB webcam.Its main characteristics are presented in Table I.

C. Algorithms
An image captured by the camera using the proposed test rig is shown in Fig. 6.Based on this image, the algorithm follows the steps shown in the flowchart of Fig. 7.
The first step of the algorithm is to locate the connector in the acquired image.An example of image acquired by the rig is shown in Fig. 6.This recognition is done based on a normalized cross-correlation pattern detection function, which uses a database of reference gray-level images of connectors under different lighting conditions.The region of the acquired image with the highest cross-correlation coefficient with respect to a pattern image is regarded as the connector.The crosscorrelation coefficient c is determined using Equation (1) for all the possible positions of the templates on the acquired image.

𝑐(𝑢
where (, ) are the coordinates of the center of the template in the captured image coordinate system, (, ) are the coordinates of the pixels,  is the captured image matrix,  ̅ , is the mean gray level of the pixels in the region of the captured image with the same size of the template that is under evaluation,  is the template matrix and  ̅ is the mean gray level of the template pixels.
The pattern detection function output is a new coordinate system in which all the positions of connection holes and cables are known due to a priori real-world measurements.This is important because all the following operations require the knowledge of the electrical connector feature positions in the image.
Once the positions of the connector features are known, the next step is to apply a threshold filter to the image aiming at the accuracy enhancement of the following operations due to the contrast improvement of the region of the holes, location in which is possible to directly inspect the clip position.This tool works according to the expression in Equation ( 2): where  ′ (, ) is the binary value of the pixel (, ) after the use of the filter and (, ) is its gray level in the original image.The value which was used to establish the threshold was the default 127 (50% of the grayscale of an 8-bit image), since it has presented a good result on preliminary tests and the illumination conditions do not vary significantly from test to test.This step is illustrated in Fig. 8.In this figure, an electrical connector with all proper clip attachments (a) and one with a defective attachment (c) are presented.In (b) and (d), the  that the threshold function helps to enhance the detectability of a defect, since it is easier to notice the partially obstructed hole in the defective case.This difference can be observed using both the shape and dimensions of the circles that represent the hole on the image.After enhancing the detectability of the defects using the threshold function, it is now possible to use computational tools to automatically detect defective units.Three different techniques have been developed to be used redundantly, in order to enhance the reliability of the tests: techniques α, β, and γ.The image used for all the algorithms is the same, thus the only disadvantage of using redundant identification techniques is the computational cost associated to them.After optimizing the developed code, the whole inspection process (including image acquisition) can be performed in 0.7 s using a PC with i5 2.8 GHz processor and running Windows 7 as operating system.This time is one tenth of the cycle time of the production line used as case study in this paper and it is not critical, even considering the necessity of connecting the stator under inspection to the test rig and disconnecting it after the inspection is finished.
The first technique, identified in this paper as technique α, searches for the three orifices of the electrical connector in the thresholded image.Each hole is represented by a circle in the acquired image and can be found using a circumference detection function.In the proposed system, a function based on the Euclidian distance mapping is used to find the circumferences.For each pixel of the binary image, the Euclidian distance to the nearest border is efficiently computed using Danielsson's algorithm [16].The candidates for the center points are the local maxima which result in circumferences with diameters within a predefined interval of ±2% around the nominal hole diameter.The value of the interval was determined based on the tolerance of fabrication of the plastic housing and on the resolution of the camera used for inspection.Since there are three holes in the electrical connector and they have the same nominal diameter, if a proper electrical connector (one without any defective attachment) is analyzed, the function returns the number "3" as the number of circles with the diameter of interest in the image.If one or more holes are obstructed by defective clips, the function will not find a circle (at least not within the measured interval of ±2%) and it will return a number different from "3".The possible results of this technique can be seen in: Fig. 9(a The second technique, called technique β, also analyzes the holes of the electrical connector and measures their diameters.The main difference between both techniques is that the main information extracted by technique α is related to the shape of the orifices, while the main information extracted by technique β is related to the diameter of the orifices.Technique β measures the diameter of each hole in the image and verifies if they are within the same predefined interval, already discussed in the description of technique α.In technique α the diameter is used to avoid counting very small particles, such as noise, as a circumference, such as image noise.In technique β, the diameter of each orifice in the vertical direction is measured and compared to the reference value.This is done using edge detection and distance measurement, regardless of the shape of the identified hole.The edge detection tool uses the gradient of gray level intensity to determine if there is an edge on the image according to the difference of gray levels in neighboring pixels.Each of the three lines is a Region Of Interest (ROI) of this edge-detection technique is a vector () with gray levels from the pixels of those lines, and  = 1, 2, … , , where N is the number of pixels of each line.The function interprets that a border is found in the first point at which the condition in Equation ( 3) is met: where ∆ is the difference of gray levels which characterize a border.Since the analyzed image is binary, it can be said that if ∆ = 1, the interface between these two pixels is considered a border.As can be seen in Fig. 9(c), vertical blue lines are used as ROIs to the edge detection algorithm, which determines the limit points (red rhombuses) at each end of each hole.The distance between those points is measured and compared with Finally, the third technique, called technique γ, is slightly different from the previous two.While the first and second ones analyze the holes of the electrical connector, this one monitors its upper part.When the cables with defective attachment are tensioned, it is possible that their clips are partially pulled out from the housing and therefore the clip, which usually would appear as an obstruction in the holes in the image, now appears on the upper part of the housing because the clip is situated above the hole, as can be seen in Fig. 10.In this figure, it is possible to notice that the cable at the right side and the middle one present defective clips and these defects cannot be detected in the holes (red circumferences), because there is no evidence of their existence there.Thus, it is necessary to inspect the upper part to identify the defect (green circumferences).In the upper part in Fig. 3(b), it is also possible to notice that the clips are thicker than the cables and that characteristic may be used to detect the presence of defects in the present technique.Using the red ROIs shown in Fig. 10 together with an edge detection tool as described in technique β, measuring the distance between the detected edges, and comparing the result with the expected widths of cables and clips of ±1.5%, it is possible to detect the defect.The interval of ±1.5% was obtained by the variation observed during successive measurements of the widths of interest.If that distance is greater than the cable width measured a priori, the function indicates the presence of a defect.
After implementing and testing each technique, they have been integrated in a software tool for the automatic inspection of connectors.As can be seen in Fig. 7, the results of each technique enter in a decision matrix in order to give the final result, which is the indication of one or more defective attachments in the electrical connector.Section III describes the performed tests and presents their main results.

III. CASE STUDY AND RESULTS
This initial validation study has been performed in a laboratory environment.Once validated, the next step is to test it in a production line, in order to evaluate its performance considering factors as the number of inspected workpieces and the rate of occurrences of DSPC.
Twenty electrical connectors from the same model were available to test the proposed system.In eight of them, defects which represent real DSPCs have been introduced, representing a rate of defective connectors larger than the rate presented in the production line of the partner manufacturer, which is usually about 0.2%.Since the objective of those initial tests was to evaluate the performance of the proposed system, a rate that is higher than the real one was used to expose it to a larger number of different defective situations.
Table II shows which zones present DSPC for each of the tested electrical connectors.It is also shown in this table which detection technique correctly detected the defect.In this table, it is possible to see that the success rates of the techniques α, β and γ are 85.7%, 76.2% and 95.2%, respectively.From the results of this test, it was noticed that in all the proposed cases the mechanisms used to evidence the defective clips without damaging the good ones worked properly.Thus, the test rig itself functioned appropriately, evidencing the defects so that they could be identified by vision inspection methods.The complete vision system also worked properly considering the studied cases, being able to correctly identify all the electric connections with defect, considering the use of redundant algorithms.It is important thus to perceive that the use of redundant techniques could enhance the reliability of the inspection process, since in some cases two techniques failed but the third one allowed the algorithm to identify the defect.When the techniques were redundantly employed, all the analyzed defects were detected.It is also important to notice that the proposed system is intended to be used in a situation in which a very low percentage of defective parts is desired, so it is preferred to have false positives than allowing a defective part to pass (false negative).In this case, it is assumed that if one technique indicates a defect, the connector will be inspected in detail.Given this situation, in the case that an algorithm presents a result that is in a region of doubt, it reproves the inspected connector.This choice produced 2 false positives among the 20 connectors used in this case study (connectors #06 and #15).Suggestions to reduce the number of false positives are presented in each specific case in the sequel.
One example of the situation where two techniques fail and the third one is well succeeded can be illustrated by the electrical connector #10, which actually is the sample shown in Fig. 3(b).In this figure, it is possible to see two cables (02 and 03) presenting DSPC, but the defects could only be detected by technique γ, as can be seen in Table II.This happened because both clips were pulled to a position that is above the connector hole, thus inspection methods based on analyzing the hole characteristics failed, but technique γ was able to identify it.Some other cases reassure the importance of having three different algorithms working together in order to enhance the test reliability and to guarantee that all the defects can be detected.Besides the previously discussed situation, which is illustrated in Fig. 3(b) and characterized by cases #01 and #10, other cases presented conflicting indications among the proposed methods: cases #06, #13, #15, and #16, all illustrated in Fig. 11.It is possible to notice here that even with both technique α and technique β analyzing the holes of the electrical connector, since the methods of investigation are different, different results were obtained for some cases.
The conflicts observed in cases #06 and #15 have the same reason: technique β pointed to an error which does not exist in fact.It is possible to say that it happened due to the measurement uncertainty of the distance used to evaluate if the holes are obstructed by clips.Considering that this detection failed, it is interesting to evaluate again this distance in order to improve the performance of technique β.It would also be possible to monitor the state of each spring to make the decision towards the defect presence, but this could represent an additional cost which may jeopardize the low-cost property of the system.
Case #13 presents the only case in which technique γ presented a wrong indication.Even though the connector is properly assembled and its clips are well attached to the plastic housing, a defect is indicated in the upper right part of the image.This happened because the cable on the right side is wider than a regular cable and technique γ identified it as a clip.
The same considerations presented with respect to cases #06 and #15 are valid here to mitigate this case of a false positive.In addition, it is possible to use the color information from the original image (Fig. 3(b)) to distinguish between a cable (white) and a clip (gray).Finally, case #16 illustrates the only problem observed in technique α.In this case, the diameter found by the algorithm was smaller than the measured one as the minimal correct diameter of the box holes.Since the clip is correctly assembled, the same consideration given to electrical connectors #06 and #15 applies to this case.

IV. CONCLUSIONS
This paper proposes a low-cost vision system to inspect the disconnection of the stator power cables inside the electrical connector, a common defect of electric motor stators.Three image processing techniques were developed to work redundantly, enhancing the reliability of the proposed system.A test rig has been projected and built to evaluate the algorithms.A case study with 20 electrical connectors was executed and the proposed system could identify 100% of the defective connectors.Even though the number of connectors under analysis was relatively small, tests were repeated under different conditions and the results remained the same.Next steps will be oriented towards improving the measurement uncertainty of hole diameters to reduce the number of false positives and validating the proposed vision system in an industrial production line.

Fig. 6 .
Fig. 6.An image captured by the test rig.
), a defective connector; in Fig 9(b), one without any defect.

Fig. 8 .
Fig. 8.Comparison of images with and without the defect: (a) electrical connector without defect; (b) thresholding of (a); (c) electrical connector with defect; (d) thresholding of (c).

9 .
Resulting images after processing: (a) DSPC detected in zone B by technique α; (b) flawless connector processed by technique α; (c) flawless connector processed by technique β.

TABLE II RESULTS
OF THE DETECTIONS DOI:ISSN: 2594-3553