# I. INTRODUCTION

Resistance spot welding (RSW) is widely used in modern industry and it is recognized as one of the most productive and competitive methods of joining sheet metal objects [1], [2]. There are two types of RSW machines, which are the single-phase AC RSW and the three-phase medium frequency direct current (MFDC) RSW, based on using different types of power sources. However, the single-phase AC RSW machine is still prevalently used in practical production because of its simplicity and popularity in actual applications [3], [4].

The working principle of a RSW machine is to supply electrical energy to the welding system to make two or more contacted sheet metals melt. Hence, how to deliver a proper amount of heat energy into the welding system is very important. In general, the root-mean-square (RMS) value of the welding current is employed to measure and control the welding process [5]-[8].

In a single-phase AC RSW machine, two parallel silicon-controlled rectifiers (SCRs) are used to control the amount of electrical energy delivered to the workpieces during each control cycle [9]. Each welding control cycle begins when one SCR is triggered by a voltage signal, and then the welding current is generated. After a short while, when the welding current is below the threshold that can trigger the SCR, the SCR is turned off and no welding current passes through the workpieces. Then the other SCR waits to be triggered by next control cycle. During this process, the waveform of the welding current is non-sinusoid and the integrated system is highly nonlinear, which makes it difficult to precisely measure and control the process [10], [11].

During the welding process, the calculation of the RMS value of the welding current should be conducted during each control cycle. The traditional method is successive integration from point to point [12] for all of the collected data of the welding current based on the original definition of the RMS value [13]:

where IRMS is the RMS value of the welding current, i(t) is the instantaneous welding current, and T is the amount of time the welding current passes through the workpieces. The corresponding discrete format of the successive integration calculation from point to point is:

where IRMS(d) is the RMS value described using a discrete format, N is actual number of collected welding current data during one control cycle, and id is original collected welding current data from point to point. Although this method can obtain highly precise results, it requires a lot of online calculations, especially in the intervals between data collection. In addition, it seriously deteriorates the available real time conduction for controlling or other actions.

Some previous works tried to use other methods to calculate the RMS value of welding current in real time. Based on the model derivation, Gao et al [14] used a complex transformation of the model equation, and obtained a mathematical relation between the RMS value and the peak value of the welding current during each control cycle. It then used a statistical analysis and digitized the relation in each different range of the power factor angle to calculate the RMS value. Fang et al [15] also used this relation. Then a neural network was used to train the corresponding coefficients. These two works used the same model but different realization methods. However, because the relation between the RMS value and the peak value of the welding current is highly nonlinear and involves various forms when other variables are different, regardless of establishing the relation by using statistical analysis or a neural network, a lot of different cases should be taken into account. As a result, the integrated structure of the mathematical model in [14] and the neural network in [15] were very complex and had a hard time obtaining results with high precision in all of the ranges. Moreover, Gong et al [16] used the relation between the current zero-crossing derivative and the RMS value of the welding current. However, this method also involved a lot of online mathematical calculations and the neural network has a very complex structure (2×20×30×1 network topology structure) due to the fact that it was established based on a very complicate nonlinear equation. Therefore, it can only be used in some simple applications.

Because the RMS value of welding current is an important control variable, and the process involves a lot of other relative operations, the measurement of welding current needs to obtain results with a high precision, and the calculation time should be as short as necessary. Spending less time, especially decreasing the time consumed during the intervals between two data collections, to accomplish the welding current measurement supplies more time for the operation of other functions, such as online dynamic resistance calculation and analysis. Therefore, a proper control strategy design for process operation is very important in practical welding operations. In this paper, a new algorithm for the online calculation of the RMS value of welding current is developed. This algorithm is based on the model derivation of the electrical system of a single-phase AC RSW machine. In addition, it takes into account both the precision of the measurements and rapid calculation. It does not need a lot of storage space and the integrated calculation structure is simple enough. Finally, actual experiments validated the effectiveness of the algorithm.

# II. WORKING PRINCIPLE OF THE RSW SYSTEM

The electrical circuit of a single-phase AC RSW machine consists of two inverse parallel SCRs, which are alternatively used to control the electrical energy delivered to the welding loads via a step-down welding transformer. A schematic figure of this type of circuit is shown in Fig. 1 where Lp and Rpare the equivalent inductance and resistance in the primary coil of the welding transformer, Ls and Rs denote the same parameters in the secondary coil, and RL is the welding load, which is between the upper and lower electrodes. The working frequency of AC RSW is twice the frequency of the AC power source. Hence, it is a low frequency system, and the influence of the parasitic parameters can be neglected [10], [17], [18].

**Fig.1**Schematic figure of electrode circuit of single phase AC RSW.

During each control cycle, the firing angle of the SCR, which is also called the trigger time based on the control frequency, is the sole control variable of the system. In this paper, α is used to denote this variable. As in [10], [11], [19], an equivalent model, which transfers all of the components in the secondary coil of Fig. 1 into the primary coil and neglects the welding transformer, is employed in this work as shown in Fig. 2 where all of the resistances and inductances in Fig.1 are considered as one equivalent resistance R and one equivalent inductance L, and U(t) is the equivalent voltage [17]. This is a typical R-L circuit. In addition, two hypotheses, which were mentioned in [10] and [19], are used. The first is that the SCR forward resistance during its conduction is zero, and that the forward drop can be neglected. The second is that the backward resistance is infinite. Then it can be assumed that one SCR is turned on at time t=0, and the corresponding loop equation for one control cycle can be presented as:

where u and i are the instantaneous voltage and current, U is the effective voltage during one control cycle, ω is the angular frequency of the system, its value is ω=2πf, and f is the frequency of the AC power source.

**Fig. 2.**Equivalent model of the circuit.

By solving equation (3), the instantaneous welding current can be obtained:

where φ is the power factor angle of the system. It is induced by the existence of the inductive components in the circuit, and the mathematical description is φ = arctan(ωL/R). During the welding process, R and L are time-varying variables. In this work, it is assumed that their values are constants during each control cycle because their variations are tiny during this short duration.

The welding current consists of two components, a force component i1 and a free component i2. Where i1 is a standard sinusoidal form, and i2 an exponential decay form. All of the components of the circuit can be shown in Fig. 3 where θ is the conduction angle, which denotes the duration when the welding current passes the welding load, and γ is the angle corresponding to the peak of the welding current. Hence, the RMS value of the welding current can be described as [17]:

**Fig. 3.**Electrical working wave form of RSW.

In addition to the model-dependent variables Z and U, this mathematical description involves three important variables. These are the firing angle α, conduction angle θ and power factor angle φ. The firing angle α is the input of the system, while the conduction angle θ can be measured through monitoring the welding current in real time. In [17], a new method for online measurement of the power factor angle φ was proposed as follows:

where N is the total number of collected current data during one control cycle, M is the number of collected current data from the beginning of the cycle to the peak of the current value, id is the actual collected data of the welding current, and Ts is the time interval of each data collection. Hence, except for the coefficient , the components in equation (5) are obviously only relative to the three variables: α, θ and φ. After each control cycle, the values of these three variables can be known using online calculation.

# III. PROPOSED ALGORITHM OF CALCULATING THE RMS VALUE OF WELDING CURRENT

The online calculation of the RMS value of the welding current is based on equation (5). This equation consists of two parts. The first part is the model-dependent part, which is . This part is related to the individual welding model and experiment facility. The remaining part is the model-independent part, whose value is only related to the nonlinear relation between the three important variables: α, θ and φ.

The first step is to obtain the value of . In equation (6), the peak value of the welding current during one control cycle has been used to measure the power factor angle φ. It can also be used to obtain the value of online. After one control cycle and the welding current resumes to zero, some important variables, α, θ, φ and γ can be obtained. In addition, the peak of the welding current during this welding cycle is recorded. According to equation (4), the peak of the welding current can be described as:

Hence, the value of can be obtained after each control cycle:

Then the second part can be obtained in real time. The RMS value of welding current, except , is denoted as IRMS1, whose mathematical definition is:

This is a definite integral format and can be directly solved. For the sake of simplicity, the integration elements in equation (9) can be written as:

where A, B, and C are used to substitute for each item above. Then, respectively solving the three components in equation (10), the results can be written as:

It is obvious that the values of A, B and C can be obtained after one control cycle, and the RMS value of the welding current can be directly obtained in real time by solving equation (6, 8, 9-11), which is the first method for obtaining this result by only solving the governing equations.

In the general case, the RSW machine uses a Digital Signal Processor (DSP) or other micro-processor to conduct the operations. The welding action involves a lot of other relative operations, such as constant current/voltage control [9], data collection of the electrode displacement or velocity [20]-[22], dynamic resistance measurement [23], [24], and so on. As a result, little CPU time should be consumed for calculating the welding current in reality. Hence, the goal of the algorithm design is to make the calculating time as short as possible. The online calculations of trigonometric functions and exponential functions occupy a lot of CPU time. In equation (6) and (8), there are a few particular functions that need to be calculated. In addition, there are some complex functions in equations (9)-(11). Therefore, a more convenient method is needed to save CPU time in this part.

Though equations (9)-(11) have complex structures, the equations only involves three parameters: α, θ and φ. In addition, in numerical research, the relation between these three parameters can be confirmed using a more direct equation. In equation (4), i(t)=0 when ωt=θ. Then, the following equation can clearly show the relation:

In other words, φ can be presented as a function of α and θ, i.e. φ=g(α, θ). Hence, equation (9) can be written as:

To simplify the calculation, a substitute neural network can be employed to simply the calculation of IRMS1 based on known values for α and θ. The neural network uses the Back-Propagation (BP) format. In general, the value range of α is [15°, 165°]. According to [25], a relation between α, θ and φ can also be approximated as:

Though this description cannot be used for precisely obtaining the value of φ, it can be used to confirm its value range due to the fact that the error is tiny when φ approaches its upper and lower limits. For each α, according to the actual value range of φ, which is (0, 90°), the corresponding value of θ is ((180°-α), 2(180°-α)). In addition, the upper limit of θ is 180°, and the actual range of θ should be [(180°-α+1°), min (2(180°-α)-1°, 180°)] to guarantee the safety of the calculation. The training process can be conducted using a PC offline. The process does not need any actual experiment data, offline numerical data is enough. Hence, for each pair of α and θ, the corresponding IRMS1 can be obtained based on equations (6, 9)-(11). Therefore, the neural network established is a general and model-independent format, which can be used in any circuit with a similar structure.

The number of hidden layers should be as few as possible so as to minimize the total calculation time. In other words, the simpler the structure of the neural network, the less CPU time. Therefore, some complex and elaborate neural network structures cannot be considered under this circumstance. On the other hand, the training precision must be guaranteed, so that they can be considered as equilibrium in the design of the neural network. After a lot of offline attempts with candidate neural network structures, one hidden layer containing five neural nodes was chosen. The network topology architecture, which is 2×5×1, is shown in Fig. 4.

**Fig. 4.**Neural network topology architecture.

After offline training, the relative weights and biases can be obtained. They are denoted as WI=[wij]5×2, WII=[wi]1×5, BI=[bij] 5×1 and BII= [bij] 5×1. Then for each pair of α and θ, it is denoted as P= [α, θ]T, and IRMS1 can be calculated step by step:

T1 is a matrix with 5 rows and 1 column. For each element:

where T2 is also a matrix with 5 rows and 1 column, and then:

Hence, except for the conventional arithmetic, there are only five exponential functions in one calculation process. This can save more CPU time in practical applications. To clearly illustrate the procedure, detailed instructions can be shown as follows:

Step1: Confirm the value ranges of α, θ and φ;

Step2: Solve equations (9)-(11) numerically and obtain the value of IRMS1;

Step3: Choose the candidate neural network structure using

P= [α, θ]T as the input and IRMS1 as the output to train the neural network;

Step4: Use the trained neural network to calculate I’RMS1 based on each P= [α, θ]T, then chose the best network which can obtain the minimum error between IRMS1 and I’RMS1.

In summary, according to above statements, the integrated online calculation process can be shown in Fig. 5:

**Fig. 5.**Block diagram of the calculating process.

During this process, α is the input of the RSW machine operation. After each control cycle, θ can be measured online. Then, φ can be solved using these two data and current values. IRMS composes of two parts, and IRMS1. The first part can be obtained using equations (6)-(8), while the second part can be obtained using equations (9)-(11) or the neural network shown in Fig. 4. It is supposed that the neural network can save more CPU time. Actual experiments are conducted in the next section to validate the proposed algorithm and to determine which method consumes less CPU time.

# IV. ACTUAL EXPERIMENTS AND ANALYSIS

To validate the new algorithm for online calculation of the RMS value of welding current, actual experiments were conducted on a 63 kVA single-phase AC RSW machine. The electrode geometry was a truncated cone with a 5mm face diameter and a 160° angle. All of the welding operations and data processing in the experiments were implemented by a dsPIC6014, which is a DSP chip manufactured by Microchip Technology Inc. and is used prevalently in actual welding machines. The discrete value of the welding current was obtained by a Rogowski coil, which is a very common transducer for measuring very large alternating currents [17]. The welding machine, as well as the current measuring device, is shown in Fig. 6 [26].

**Fig. 6.**Welding machine and the current measuring device.

The original data was transmitted into the DSP via an analog-digital (AD) interface. The working frequency of the AC power source employed in this experiment is 50Hz, which means that the control frequency of the welding operation is 100 Hz, because one control action is conducted in each half cycle of the AC power source. On the other hand, the frequency of the AD data collection is 6.4 kHz. This means that during each control cycle, which lasts 0.01s, the maximum number of discrete current collected is 64. The instruction cycle of the DSP is about 5.4×10-7 s. In actual operation, an instruction time of 1843 means 0.001s (1 ms). This data was important for obtaining the actual calculation time during the process.

In an actual experiment, the original data of the discrete welding current was stored. Then the data can be calculated from point to point successive integration offline using a PC, according to equation (2). The calculation data can be considered as ideal values of the welding current, and Iref is used to denote this value. This value can be used to evaluate the effectiveness of the proposed method.

To validate the new proposed algorithm, different trigger times were employed in these experiments. Though the adjustable value range of the trigger time of each SCR is very large, in general cases, the actual available value range of the trigger time is limited. The workpieces used in these experiments were mild steel sheets with a width of 15mm. The actual welding currents ranged from 8000 A to 12000 A. In addition, the operational safety must be considered, and some negative phenomena, such as expulsion and cold welds, should be avoided. Hence, in these experiments, only trigger times between 5.8ms and 6.7ms were employed.

First, the neural network was trained using a PC offline. For the firing angle α, the array of data from 15° to 165° with 0.01° was used. For each α, the corresponding conduction angle θ should be an array from ((180°-α+1) to (min (2(180°-α)-1°, 180°)) with a (180/64)° interval based on the actual operation and measurement angle. Therefore, 1556 array data can be collected. The Matlab toolbox functions for training neural networks were employed. Then a different array of weights and biases regarding the network topology architecture shown in Fig. 4 can be obtained. One array, which can make the least errors between IRMS1, calculated from neural network, and that obtained from the original theoretical solution using equations (9-11) was chosen after several attempts. The maximum error using this neural network is 0.0032(0.12%). Then using the neural network and equations (7-8), actual experiment results can be obtained. Fig. 7 shows a comparison between the welding currents obtained from using the proposed method and the offline successive integration from point to point. The trigger times were 5.8 ms, 6.1 ms, 6.3 ms, 6.5 ms, and 6.7 ms, which corresponded the 104.4°, 109.8°, 113.4°, 117°, and 120.6° firing angles, respectively.

**Fig. 7.**(a) Comparison of welding currents obtained from two methods and corresponding errors (trigger time: 5.8 ms). (b) Comparison of welding currents obtained from two methods and corresponding errors (trigger time: 6.1 ms). (c) Comparison of welding currents obtained from two methods and corresponding errors (trigger time: 6.3 ms). (d) Comparison of welding currents obtained from two methods and corresponding errors (trigger time: 6.5 ms). (e) Comparison of welding currents obtained from two methods and corresponding errors (trigger time: 6.7 ms).

Moreover, two indices, which are percentages of the mean absolute error and the maximum value of the absolute error, were introduced to evaluate the performance of the proposed method. The definitions of these two indices are:

where emb is the percentage of the mean absolute error, emax is the percentage of the maximum value of the absolute error, N is the number of welding currents collected, and Isample is the welding current values collected from the proposed methods. TABLE I shows a comparison of Isample and Iref for each experiment.

**TABLE I**THE ERRORS BETWEEN CURRENTS OBTAINED FROM PROPOSED ALGORITHM AND NUMERICAL CALCULATION

The experiment result showed that the proposed algorithm can accomplish the online measurement of the RMS value of the welding current with satisfactory results. All of the mean values of the absolute errors in each experiment were below 2%, while the maximum values of the absolute error were below 4%. During each experiment, only few errors were above 300 A. The errors may be induced by the data obtained from different calculation methods. However, they can satisfy the actual production requirements.

In addition, the CPU time consumed during each calculation was investigated. The average of CPU times for each experiment shown in Fig. 7 and TABLE I were: 2.5821 ms, 2.5776 ms, 2.5917 ms, 2.6117 ms, and 2.5783 ms. The times were approximately the same because the calculations have a very small difference. The data monitoring guaranteed that the calculations did not influence the next trigger. However, if the neural network was not used to substitute for the original complex equations (9-11), more CPU time may have been consumed. The calculation time for directly solving the equations (9-11) was also monitored in real time in other experiments. The average times for two experiments, whose trigger times were 6.5 ms and 6.7 ms, were 4.00 ms and 3.98 ms. This means that the neural network saved about 40% of the CPU time when compared to directly solving the original equations. In addition, the CPU times had very small differences if the same calculation methods were employed. In the experimental system, only trigger times above 6.5 ms were not affected by the long calculation times from using equations (9)-(11). When the trigger time was equal to or less than 6.3 ms, the long calculation time may delay the next trigger for the other SCR and the actual trigger time for the next control cycle may be later than 6.3 ms. Obviously, this can make errors in actual operation and should be avoided. TABLE II shows a comparison of times consumed by the neural network and the nonlinear equations (9)-(11):

**TABLE II**COMPARISON OF TIMES CONSUME BY NEURAL NETWORK AND NONLINEAR EQUATION (9-11)

This means that if a large range of current values is needed, the neural network must be employed. Additionally, although the neural network is used in the proposed algorithm, the neural network is based on the fixed mathematical relation as shown in equation (12) instead of individual experiments. As a result, the training process can be conducted offline, which can save more CPU time when compared to directly solving the nonlinear equations.

# V. CONCLUSION

The RMS value of welding current is a commonly used as a measuring and controlling variable in actual welding production. Although there were some previous works dealing with this issue, the methods were very complex and cannot be effectively employed in general cases. In this work, an analytical mathematical description of the RMS value of welding current was derived by means of previous work. Because the mathematical description was so complex that it consumed a lot of CPU time, a simple neural network was employed to substitute for the model-independent part. This part follows a fixed mathematical structure and can be applied in any occasion having a similar electrical structure. Experiment results showed that in terms of calculation precision and calculation time savings, the proposed algorithm presents excellent performances.