Modeling and Control of a DC Motor Coupled to a Non-Rigid Joint

Throughout this paper, the model, its parameter estimation and a controller for a solution using a DC motor with a gearbox worm, coupled to a non-rigid joint, will be presented. First, the modeling of a non-linear system based on a DC Motor with Worm Gearbox coupled to a non-rigid joint is presented. The full system was modeled based on the modeling of two sub-systems that compose it—a non-rigid joint configuration and the DC motor with the worm gearbox configuration. Despite the subsystems are interdependent, its modelling can be performed independently trough a carefully chosen set of experiments. Modeling accurately the system is crucial in order to simulate and know the expected performance. The estimation process and the proposed experimental setup are presented. This setup collects data from an absolute encoder, a load cell, voltage and current sensors. The data obtained from these sensors is presented and used to obtaining some physical parameters from both systems. Finally, through an optimization process, the remaining parameters are estimated, thus obtaining a realistic model of the complete system. Finally, the controller setup is presented and the results obtained are also presented.


Introduction
DC (direct current) motors are widely used components as electrical actuators, in cars, trains and driving high power hoisting machines, milling machines, among others. A field in which DC motors are also widely used is robotics. Whether using these to change the angle of a joint of a robotic manipulator, to drive a vehicle's traction system, or even to rotate the sensor of a LiDAR (Light Detection and Ranging), there are numerous uses for these in robotics. Another example are the legged-robotic vehicles that can be found in [1]. However, they have a non-linear behavior that results from the fact that they cannot rotate at any supply voltage, always having a minimum rotation torque (starting torque) that prevents rotation until a when a certain voltage is reached, which is commonly denominated by the motor dead zone. To compensate for these, several control methods can be applied, such as [2][3][4], just to state a few.
Worm gearboxes are typically used when compactness is an important factor, as well as an orthogonal redirectioning is required. Yet, one of the greatest advantage of worm gears is its unique self-locking characteristic. This means that the gear can only rotate by its input side, and cannot be actuated through the load side. As Ye and Wu [5] state, these features make worm gearboxes useful for multiple types of robotic vehicles and manipulators. However, any gearbox has a main non-linearity, which is it allows some movement of its output shaft without rotating its input, called backlash.
So, using a DC motor with a worm gearbox is a solution that guarantees that, for example in a robotic manipulator, when the arm's joint reaches the desired angle it does not move until the next required change. It can also be used on vehicles with legged locomotion systems, which can benefit from this type of motors since the joints are blocked in the desired position. Regarding this kind of locomotion, another advantage is that the vehicle can stay immobilized, while guaranteeing the position of the leg, even when the power is down.
To increase safety and robustness in the performance of industrial robots, which otherwise could easily break their joints, or hurt someone, the use of non-rigid joints is increasingly found in the literature and in the industry. These mechanisms contain elastic components (such as springs), which introduce a mechanical energy storage in the system, potentially increasing the maximum output power [6]. In [7], Giusti et al. have designed and implemented successfully a controller based on the analysis of the inverse dynamics of the non-rigid joint, and have applied a structured controller. The testbed mixes rigid and elastic joints on an interesting configuration. The usage of non-rigid joints for exoskeletons is also expanding, possibly due to the decrease in the size of the actuators. An example is the work presented in [8] for a variable viscoelastic joint system. Another interesting application example for non-rigid joints are deployable mechanisms, as the one presented by Zhang et al. [9], where the singularities of a system like the presented are analyzed and successfully avoided. The Quasi-Direct Drive is also an example of the technology applied to actuate an non-rigid joint, as presented in [10] for a quadruped.
As it can be easily understood, all the mentioned research has a same primary step -the modeling phase -applied to mathematically translate the behavior of the system. Modeling the system is crucial to understand its behaviour under multiple conditions and also to develop its control. Having the model, one can put a signal in the process input and analyse how the system react, obtaining the system output. The system's transfer function can be interpreted as the process model. Robotic systems often include DC motors and having a realistic model is crucial to improve the control performance. This is required to be able to design suitable controllers, test them in simulation and obtain relevant results. Thus, the closer to reality the developed model is, the better designed the controller can be in theory and applied in practice. However, all the robotic systems mentioned above include components that adds uncertainties and non-linearities to it, making it more complex to model. Obtaining a realistic model of the system to be controlled is an advantage when defining and tuning the controller. In addition to being more informative to decide which kind of controller is more appropriate, obtaining the system response to various inputs can be done with increased realism. Obtaining a more realistic model allows to know, as close to reality as possible, how the system will behave after designing and tuning the controllers [11]. It also allows to theoretically test, as an instance, the system limits, as well as combinations of controllers, or speed profiles. With such a model, the system's performance also increases significantly. In order to be able to validate the developed approach, PID controllers [12] will be used. These are relatively easy to implement and provide a realistic use case.
Estimation techniques can be applied to help modeling the system, applied to estimate the unknown or difficult to quantify parameters with precision. These techniques can be applied online or offline, as mentioned by Dupuis et al. [13], but can, sometimes, result in an inaccurate estimation of the parameters.
Examples of online parameter identification are present in [14,15], from evolutionary algorithms, such as Montazeri et al. use in [16] to recursive methods as Gonzalez et al. [17] use for their third-order modeling. On offline methods, examples can be [18][19][20]. Multiple techniques can be applied through the use of neural networks, as explained in [21] or even experimentally, as the authors of [22] and [23] present.
Considering that online estimation methods are relatively more complex, as well as that the conditions associated with the motor presumably will not change when it is actuated and that the essential characteristics of the non-rigid joint developed for this work are not expected to suffer structural changes, the estimation of its dynamic parameters will be carried out with offline techniques, performed through real hardware tests. The assumptions made for the models are set by the authors of [19].
The process of modeling the subsystems individually and the whole system, as well as controlling the final system will be presented. An introduction to the topic is performed in Section 1, and the proposed models will be introduced throughout Section 2. Section 3 presents the experimental setup specially built to test the obtained models ans in Section 4 will present the results obtained by the performed experiments. Finally, in Section 5 are presented the conclusions and future work.

Proposed Models
Across this section, the model for the DC motor with worm gearbox will be presented. After that, the model for the non-rigid joint will be introduced. To estimate the parameters of the sub-systems, some experimental tests must be performed. For this, an experimental setup was created, being further presented in Figure 5.

DC Motor and Worm Gearbox Model
Along this subsection, the generic model for a DC motor will be presented, which is equivalent to the motor-gearbox system. Also, taking into account that some hardware tests must be performed to estimate some parameters, they will also be detailed. Despite what was mentioned in previous paragraph, all the tests were performed with the gearbox coupled to the motor, in order to obtain a reliable model of the motor+gearbox system.
Taking into account the above mentioned considerations, the motor model is further described using the equations associated with it. These are present all over the literature associated with DC motors, so no references will be presented to specific publications. Thus, the general model of a DC motor is as follows: where v i is the voltage applied to the system (V), i is the electrical current (A), R the resistance (Ω), L the inductance (H), and E v the Back Electromotive Force (V). This force is obtained through the second presented equation, where k is the motor constant, and ω the angular speed (rad/s). In Equation (3), J represents the moment of inertia (kg·m 2 ), T m the motor torque (N·m), obtained by the fourth equation, B v the viscous friction coefficient (N·m·s) and T q (N·m) the static friction torque. The model used for the static friction T q assumes that the T q = T m while T m < T q_max . This explains the existence of the motor dead zone, which is a non-linear element of the model. Despite this, it is neglected, since otherwise it will turn the system into a non-linear one, and as one can see from the first Figure  presented in Section 4, the dead zone is almost nonexistent.
In the Laplace domain, the system can be represented as: The transfer function of the system will then be: Adjusting some variables, to facilitate its later use in the estimation of some parameters, it becomes: There are some hardware tests that allow to estimate some unknown motor constants, like R, k, B v and T q . These tests are simple to perform and consist on: • Powering the motor with multiple pre-known values of supply voltage, allowing it to reach the steady-state -This test consists in powering the motor with several different pre-known supply voltages and measure the angular speed ω at the steady-state throughout the process; • Input a voltage step to the motor terminals -This test consists in powering the motor with a voltage step and obtain its response to this signal, to verify which model suits the best to the tested model;

Non-Rigid Joint Model
For the non-rigid joint construction, a passive system was designed and developed. Applying 4 springs, attached to a circular support part as further represented in Figure 6, a rotational force is applied in the support's centre of rotation, is passed to the next link through the springs, providing elasticity and cushioning to the rotational movement. To connect all the parts, as can be noticeable by the mentioned figure, bearings are applied to decrease the rotational friction, as well as to allow a tighter connection between all the parts.
The mathematical/physical representation of the system, with its respective constants, velocities and torques present in Figure 1. Given the proposed non-rigid joint, its model will become as follow: Considering that the initial conditions can be not null, the following variables take values: Similar to what was described in the above subsection, for modeling the non-rigid joint, as well as for estimating the parameters associated with it, some hardware tests will also be performed, in order to obtain parameters J, K and B, consisting of:

•
Pulling the link attached to the non-rigid joint to a certain angle -In this test, the link attached to the non-rigid joint is pulled manually for a certain set of increasing angles. For those angles the torque is measured. Then, the link is rotated in the same way to the negative side and the same procedure is applied; • Pulling the link attached to the non-rigid joint and releasing it, capture the angular speed an the angle until it stabilizes -Through this test, the link attached to the non-rigid joint is pulled manually and, after reaching a determined angle, is released and left to stabilize until it reaches the rest angle. The angular speed, the torque and the angle are sampled with a period of 10 ms;

Control
Taking into account its use for a robotic manipulator joint, it was then decided to use an motor with a worm gearbox, specifically the JGY-371 one. This motor has a rotary encoder, it is powered at 12VDC and it was defined that the motor speed would be 20 rpm, which is the best solution for the purpose defined for the project. With this choice, despite the low maximum angular speed of the motor, the joints can benefit from more torque. The issue of the sudden changes in speed can shorten the life of the motor.
Therefore, the decision of creating an acceleration ramp when the controller activate or deactivate was taken, having the system 3 sub profiles (acceleration, steady state, deceleration). Temporal divisions are called t 0 , t 1 , t 2 and t f , dividing areas A, B and C of the profiles. To achieve this, there were created functions for the angular acceleration, velocity and position of the motor shaft. To obtain a smoother velocity ramp, it was decided to go with a profile with cubic function. Having decided this, it was necessary to produce a quadratic function for the angular acceleration, which is described below These acceleration α(t) (rad/s 2 ) functions were defined to obtain the desired velocity profile, as mentioned. In the presented equations the term α m represent the maximum desired acceleration, while t 1 , t 2 , t 3 and t f are the time limits for each sub-area. These are more explicit when looking at Figure 2.
The previous equations represent the intended angular velocity profile. The nomenclature used is also presented in the acceleration equations, with the exception of the ω(t) (rad/s), which represents the angular velocity.
Finally, the equations for calculating the angular position of the motor shaft are presented above, with θ(t) representing the angle (rad). Since the velocity profile reaches the wanted ω when t = t 1 , ω m can be obtained through the equation and the instant t 1 can be calculated through the formula presented next · ω m α m Based on all the mentioned equations, and to become clearer what, theoretically, must be the motor behaviour, the profiles for angular acceleration, velocity and position are presented in Figure 2, in a graphical form. Figure 3 represents the profiles, already after the mentioned functions were implemented in programming, having obtained the graphics that are presented.  As already mentioned, the controllers to be used will be PID controllers. Thus, in order to validate the developed models, a cascade controller was designed, with the use of a position and a speed controller. It was chosen to only introduce a block of Feed Forward in the latter, and the set was represented in the block diagram in Figure 4.

Experimental Setup Hardware
Throughout this section, the hardware used to create the experimental testbed is detailed. It is worth mentioning that, in order to understand the impact that the gearbox had on the obtained data, it was decoupled from the motor shaft, and the same tests were carried out. The conclusion is that the obtained data are practically the same, only affected by the correction factors related to speed and torque, due to the reduction of the gearbox.
Taking into account the decision of using a motor with a worm gearbox, it was decided to use an off-the-shelf solution, specifically the DC Motor with Permanent Magnets -JGY-371, which is a low cost popular actuator, being a 12 V motor with built-in encoders, attached to a 340:1 reduction worm gearbox. This reduction factor was chosen so that the motor speed would be 20 rpm. With this choice, despite the low maximum angular speed of the motor, the joints can benefit from more torque. In addition to the fact that the incorporated encoder can be applied to collect data in the modeling process, it will also be extremely useful during the motor movement, making it possible to control in closed-loop with access to speed information in real time.
From the motor model point of view, these experiments allow to collect some important variables such as motor speed, motor withdraw current, and applied motor voltage. For the acquisition of the mentioned variables, there were used the following sensors, being the referred acquisition system shown in the right side of Figure 5: • Built-in encoder -measuring the angular displacement of the motor; • Current sensor -measuring the current that the motor withdraws; • Voltage sensor -measuring the instant and real voltage applied to the motor terminals; As mentioned, a passive non-rigid joint system was designed and developed, making it possible to test the model and apply the desired controllers. This system is presented in Figure 6.
For this joint tests, there is the need to know its angular position, as well as the applied torque. So, to obtain the exact angular displacement, an absolute encoder, consisting in a contactless absolute angular position sensor, with 14-bit resolution and immune to external magnetic stray fields, was placed exactly concentrically with the axis of rotation of the joint. Also, to obtain the torque, a straight bar load cell, capable of measuring forces up to 10kg, was placed in the center of the link to evaluate the exerted force which can, using the distance to the rotational axis, be converted to the applied torque. The left side of Figure 5 presents the implemented solution, and the interaction between the subsystems. The whole system was powered by a 12VDC power supply to perform the tests. How these values are applied in practice will be detailed in Section 4.

DC Motor with Worm Gearbox
Both tests mentioned in the previous section were performed in the motor-gearbox system. For the first set of tests, an average of the measurements was obtained, namely motor speed, voltage applied to the motor, absorbed current and power. The voltage applied to the motor terminals started at 0.5 VDC and was increased in steps of 0.5 VDC until it reached the 12 VDC. Finally, the values were processed when required and presented in the graphs from Figures 7-9.
By slightly changing Equations (1)-(4), it is possible to obtain first-degree functions, which can be compared with the trendlines obtained in the graphs and consequently obtained the values of the mentioned constants. Note that, for these changes it was considered the steady state where, for instance, the value of L · di dt is zero, as well as dω dt , becoming:  Analyzing the trendlines, and since Equation (20) corresponds to the Figure 8, it is possible to directly obtain that the motor resistance R and constant k are with values 8.6538 Ω and 0.0174, respectively. Also, considering that Equation (21) is depicted in Figure 9, the values of T q and B v are 0.608 × 10 −3 and 5.975 × 10 −7 , respectively. These values associated with the motor-gearbox system are presented in Table 1.
At this point, it is possible to estimate the parameters that are missing from the model, using the already calculated parameters. Thus, considering the values of R, k, B v and T q , it is possible to estimate the values of L and J associated with the system. For this estimation, the second test was performed, in which the system's response to a voltage step in the motor input is analyzed over time.  To analyze the adequacy of the model to the real system, first and second order models were used, as described in Equations (22), (24) and (25), respectively. These models represent functions with one and two poles, being Equations (22), (24) and (25) representative of W(s). Then, Equations (23) and (27) refer to that same system, but in the time-domain ω(t).
Using a 1 as the average of the angular speeds after the system stabilizes, reaching the steady-state, and solving the equation to obtain the minimum error between the real and the model's angular speed, the values of k 1 and a 1 are 0.3684 and 42.4062, respectively.
The second-order model has parameters k 2 , a 2 and b 2 , and the optimization cycle was also performed to reach the minimum error between the real and estimated angular speed. From the data obtained from this optimization, the parameters k 2 , a 2 and b 2 reached values 0.3684, 315.9816 and 47.7916, respectively. The representation of the step response for both models can be found in Figure 10, where the blue graphic represents the obtained data, the green one is the first-order system and the orange one represents the second-order system. Also, Figure 11 represents the value of the absolute error from the first and second order models over time and these errors are summarized in Table 2.   As can be seen, the second order model is undoubtedly the most suitable model, so its values will be used for the estimation of the motor parameters. Thus, it is found that J and L are, approximately, 8.51 Kg·m 2 and 0.0238 H, respectively.

Non-Rigid Joint
In order to perform the hardware tests, a system with the components presented in Figure 5 was built. This is presented in Figure 12, and it was designed by the authors, being subsequently 3D printed. The parts already provide space specially allocated for the load cell, as well as for its amplifier, and also for the absolute encoder. The most complicated task was to physically align the rotation axis of the joint, which has the magnet placed in its center, and the center of the Hall sensor. Taking into account the collected data, this task was considered to be performed successfully, since the angular displacement red by the sensor and by a physical angle meter were very similar. For the first set of tests, the system was acquiring data continuously, in order to recognize the variations in force exerted on the cell, with information of the angle. This test allows to know what is the behavior of the joint when its the center of rotation is locked, and the posterior link is applying a force on it. This force is traduced to a torque, since it was put with some distance to the center. The results from this test are presented graphically in Figure 13. Since the joint is already coupled to a motor attached to a gearbox system, and since the gearbox presents some backlash, the joint presents a dead zone. This behaviour is clearly visible in the figure, in the red line of the graph where, although the exerted force is practically zero, the angle has a significant variation. Considering that the motor is stopped, the difference between the angles of the motor shaft and the joint is obtained by the angle in the absolute encoder. So, using Equation (9), and calculating the average of the straight slopes of the values from the positive and the negative torques, the value of K is obtained and is equal to 7.3035. Then, to find the value of J and B, it was necessary to proceed to a second set of tests. This consists of placing the system to acquire data, rotating the posterior link to a certain angle and releasing it, allowing its free oscillation until reaching the equilibrium point again. Using Equation (19), and the inverse Laplace transform, the following Equations could be used to represent the system in the time domain.
Having defined the approximation function, and since the value of K was already estimated, the optimization process that minimizes the absolute error to the obtained angular position was put to run and the values of the variables for Equation (28) were found. Establishing the parallelism between the function in the Laplace domain used and Equation (19), after the optimization process, the values found for B and J were 0.0416 and 0.0085.
Considering a simple pendulum configuration, J = m · r 2 . If a weight of 269 gr. is put on a known point of the link, there is a known moment of inertia. Taking the value obtained for J = 0.0085, and placing the known mass approximately 18 cm from the axis of rotation, one obtain an estimated value for the distance r = 17.78 cm, an error of less than 1%, which indicates that the estimation of the parameters associated with the joint has been carried out successfully. All the obtained estimated parameters are compiled in Table 3. In Figure 14, in blue there is the real measured behaviour of the joint, while in red there is the estimated model of the joint. Actually, approximately from t = 1s, it begins to be noticed that the model differs somewhat from the performed measurements. However, this difference can be explained by the non-linear behavior presented by the dead zone of the joint, which will have to be compensated by a suitable controller. Error results from the model are presented in Table 4, while the value of the dead zone is approximately 0.23 rad, as can be seen in Figure 13. Also, as it can be inferred by Figure 14, the second-order model does not fit very well after the 1s mark, approximately, because of joint's backlash, since the model is optimized for bigger oscillations. Figure 15 represents the absolute error along the time, with respect to Figure 14.

Control
To validate the models, the control block shown in Figure 4 was implemented, which allowed the defined profiles to be tested in the experimental setup. To check the multiple types of controllers, a function has been developed that allows to choose the controller to be used. To test the differences, two experiments were carried out:

•
Using only a position controller, with a step reference -This test consists in obtaining the motor response to a step reference, using only a position controller and evaluating its response through the angular position from the absolute encoder; • Using a position and a velocity controller, using to the developed profiles as references -This test is similar to the previous one consisting in obtaining the motor response to the references created by the developed profiles, using position and velocity controllers and again evaluating its response through the angular position from the absolute encoder; In each test, the reference for the angular position was defined as 1.2 radian. In Figure 16 the position reference was set with a step, being the velocity left uncontrolled. When the position is reached, the motor stops its movement and the non rigid joint keeps oscillating until the position is reached. In Figure 17, the position and velocity profiles are given as a reference, and the position is reached without any oscillation and without any overshoot. Both experiments are overlapped to be compared in Figure 18 and it is clear that the modeled profiles are a better option than the first one. From Figure 18, it can be analyzed that, despite the red curve does not have any overshoot, while the yellow controller has, the settle time is also smaller. Table 5 also helps to evaluate the errors in steady-state.

Conclusions and Future Work
Considering the experimental part of the work, the physical implementation of the idealized and modeled prototype of a novel non-rigid joint have met the expectations, adding a damping component to the joint. The addition of the 4 springs allowed the joint to have an non-rigid behavior with only passive components, and consequently without energy consumption. Also, the coupling of a worm gearbox motor to the joint allows to save some energy, since it only consumes when the motor moves, blocking when it is stopped.
Then, it can be concluded that, based on a purely low-cost sensor acquisition system, it is possible to carry out tests and consider measurements that allow to estimate parameters of this complex model. The monitored variables were the force exerted on the link, the angular displacement and the angular position. The angular speed of the motor, as well as its current consumption, and the supply voltage are also variables required to estimate the system parameter.
Regarding the joint, the tests allowed to obtain approximate physical model parameters, like the damping constant and moment of inertia. Comparing the obtained data and the simulated second-order model, it is easily verified that the considered model is suitable. However, differences are effectively noticed, which come from the joint's dead zone.
For the DC motor subsystem, based on the obtained data, it was possible to obtain a set of measures that allowed, using equations from the physical model of the DC motor, to estimate simpler parameters related to the system, namely its resistance and constant. Then, two models, first and second order, were considered. Using previously obtained data and optimizing to minimize the estimated angular velocity error, it was possible to verify that the second-order model is the one that best reflects the physical behavior of the motor and to model its impedance and moment of inertia parameters.
Finally, regarding the developed controller, the obtained experimental results show clearly that it was a good choice, since it can work with the specificities of both the worm gearbox and the non-rigid joint, obtaining minimum overshoot, low settle time and accurate angular positioning.
In terms of future work, it will be interesting to use the developed setup to one of the mentioned applications and evaluate its behaviour. it will also been carried out a study about the behaviour of the system under disturbances. The first one will probably be to use the developed work as a 4DOF manipulator with non-rigid joints, for industrial purposes.

Conflicts of Interest:
The authors declare no conflict of interest.