# Identification, Control, and Characterization of Peristaltic Pumps in Hemodialysis Machines
## 2 Methodology
### System Identification  
System identification is a fundamental technique for modeling and controlling electric motors, especially D.C. motors, as it enables the creation of precise mathematical models from experimental data for efficient controller design. Methods like ARX, ARMAX (which includes a moving average term), and the non-linear least squares method are widely used [12; 13]. Among these, the non-linear least squares method stands out for its ability to accurately estimate transfer function parameters in non-linear systems, even under noise and disturbances, making it ideal where linear methods are insufficient [14]. Its application has proven effective in optimizing robotic motion control and D.C. motor performance, showcasing its adaptability across systems with complex dynamics [15; 16]. In light of the above considerations, it is imperative to convert the encoder pulses to revolutions per minute (RPM) to obtain the system's response data. In order to achieve this, a Hall effect sensor and an integrated encoder within the peristaltic pump were employed. A tally was conducted to ascertain the number of pulses generated by the encoder throughout a complete revolution, with each instance of the Hall effect sensor issuing a signal being recorded. The result was a total of 45,800 pulses per revolution (PPR), which establishes the encoder's resolution, as demonstrated by the following Equation (1):  
\[Resolution=\frac{360^{\circ}}{45800\leavevmode\
obreak\ ppr}=0.0078\frac{{}^{ \circ}}{ppr} \tag{1}\]  
At this stage, the estimation of revolutions per minute (RPM) is initiated. To this end, an interrupt on the TIVA microcontroller was employed to ascertain the number of pulses per millisecond (PPms), thereby facilitating enhanced precision in the estimation of RPM. The calculation is described in detail in Equation (2):  
\[RPM=\frac{PPms}{45800\leavevmode\
obreak\ PPR\left(\frac{1\leavevmode\
obreak\ min}{6000\leavevmode\
obreak\ ms}\right)}=\frac{PPms}{\frac{0.7633\leavevmode\
obreak\ RPM}{ms}} \tag{2}\]  
Given that the TIVA transmits the PPMS data at a rate of one sample per millisecond, this value is divided by 0.7633 to facilitate conversion to RPM. Subsequently, a step input of 24 V, equivalent to 100% of the input, is applied to the system. The RPM data are recorded at a rate of one sample per millisecond, resulting in the system response illustrated in Figure 3.  
Figure 2: Communication diagram for peristaltic pump with microcontroller and LabVIEW. **Caption:** Graphic representation of the automated control system including a TM4C123 GH6 PM microcontroller, an incremental encoder, and its integration with LabVIEW via TTL serial communication. The figure highlights the key elements for data acquisition and control of the peristaltic pump. The oscillations in Figure 3 result from the system's inherent dynamics and transient response to a step input. These oscillations, caused by system inertia and variations in encoder pulses, fluctuate between 72.0524 and 74.6724 RPM. To determine the maximum amplitude representation, the mean value of data from 0.08 to 0.45 s was calculated, yielding 73.3284 RPM, which reflects the system's steady-state behavior under dynamic conditions. In order to estimate the transfer function of a system using sampled data, a curve-fitting process based on the non-linear least squares method was employed. This technique minimizes the residuals between observed and predicted data, ensuring accurate estimation of the transfer function parameters. In this instance, a first-order model was fitted to the experimental RPM data obtained over time, as this function most closely resembled the sampled data. The choice of the non-linear least squares method is grounded in its ability to model non-linear systems with high accuracy, minimizing the impact of noise and experimental disturbances. This approach has proven effective in complex dynamic systems, such as DC motors and peristalic pumps, particularly in medical control applications, as reported in previous studies [14; 15].