Arduino control of a pulsatile flow rig
aa r X i v : . [ phy s i c s . i n s - d e t ] J u l Arduino control of a pulsatile flow rig
S. Drost a , B. J. de Kruif b , D. Newport a, ∗ a Bernal Institute, School of Engineering, University of Limerick, Limerick, Ireland b Design Factors, Faculty of Science and Engineering, University of Limerick, Limerick,Ireland
Abstract
This note describes the design and testing of a programmable pulsatile flowpump using an Arduino micro-controller. The goal of this work is to builda compact and affordable system that can relatively easily be programmed togenerate physiological waveforms. The system described here was designed tobe used in an in-vitro set-up for vascular access hemodynamics research, andhence incorporates a gear pump that can deliver up to around 1.5 l/min (steadyflow) in a test flow loop. After a number of simple identification experimentsto assess the dynamic behaviour of the system, a feed-forward control routinewas implemented. The resulting system was shown to be able to produce thetargeted patient-specific waveform with less than 3.6% error. Finally, we outlinehow to further increase the accuracy of the system, and how to adapt it tospecific user needs.
Keywords: pulsatile flow pump, in-vitro, hemodynamics, Arduino, feedforward control
1. Introduction
In-vitro experiments are a useful tool in hemodynamics research, offering awide range of applicable experimental techniques, combined with good accuracyand reproducibility. To simulate physiologically realistic pulsatile flow, a dedi-cated pumping system is used in these experiments. This can either be a mock ∗ Corresponding author
Email address: [email protected] (D. Newport)
Preprint submitted to Elsevier July 21, 2017 oop representing the full circulatory system [8, 9], or a pump that reproducesa waveform measured locally in-vivo [4, 5, 6, 7, 12].For both cases, pumps are commercially available. However, researchers of-ten employ in-house built systems, for example because of cost considerations,or to add specific functionality. Examples of pumping systems that were devel-oped to reproduce physiological waveforms are a gear pump driven by a steppermotor or servomotor, the rotation rate of which is controlled by a microcom-puter (Hoskins et al. [5]) or personal computer (Plewes et al. [7]), a controlledpiston pump (Chaudhury et al. [4]), or a combination of both: a gear pump todeliver the steady flow component, and a piston pump to generate the pulsatilecomponent (Tsai and Sava¸s [12]).With so many options already available, the goal of our current work is notso much to develop a superior system as to design a system that is affordable andrelatively simple to set up, using off-the-shelf components. With this in mind,the full source code for the control of the pump is included as a supplement tothis note.The system that is presented in this technical note is designed to reproducea waveform typical for an arterio-venous fistula for hemodynamics, more specif-ically, a waveform with a mean flow of O (1) l/min, a frequency content up to4 Hz, and a pulsatility index (peak-to-peak flow over mean flow) of 0.4. We con-sciously chose to use the simplest possible control strategy, first identifying thesystem, and subsequently using a feed-forward controller in combination witha run-to-run controller to achieve the target waveform. The present system isaimed to be used in an in-vitro flow rig to test different modalities for vascularaccess for hemodynamics, but with suitable parts selection, the approach weused is expected to be useful for a wider range of cardiovascular flows as well.
2. Materials and method
The experimental set-up is shown schematically in Figure 1. The flow loopthat was used for the experiments consists of a straight poly(methyl methacry-2ate) (PMMA) tube with an inner diameter, ID, of 5 mm and a length of 500 mm,connected to an open reservoir ( ±
500 ml) and to the pump by flexible polyethy-lene tubing (ID 6 mm). This is the simplest possible set-up to study fullydeveloped steady or pulsatile laminar flow, up to a Reynolds number of 2000,while the ID of the straight tube is representative for vascular access. Tap waterat room temperature was used as a test liquid. An in-line flow sensor (Tran-sonic TS410 ME 6PXN), placed around 50 cm from the pump outlet, was usedto monitor the flow rate, its signal was sent to a data acquisition card (NationalInstruments, NI USB-6001), which in turn was read out using Matlab. Eventhough, when used in the prescribed range of rotation rates, gear pumps pro-duce negligible ripple, care was taken to place the flow sensor sufficiently farfrom the pump outlet.The pumping system consists of a gear pump (excess from the medical man-ufacturing and spare parts for a Gambro C3/CS3 dialysis machine, equivalentto a Diener Extreme Series 1000 ml/min with 9 mm gear set), magneticallydriven by a core-less DC motor (Premotec, 30 V DC). A 24 V DC power supplyis used, in combination with a solid-state relay (SSR) to control the voltagesupplied to the motor. This setup results in a one quadrant controller that canonly apply a positive torque with a positive velocity.An Arduino micro-controller (Genuino MEGA 2560) sends a pulse widthmodulation (PWM) signal to the SSR to achieve the required waveform duringthe experiment. The Arduino has a resolution of 8 bits, which means that thePWM signal can be set to integer values between 0 and 255, to achieve a motorvoltage between 0 and 24 V. To be more flexible during the design phase of thesystem, we used a PC with Matlab to send the calculated pump voltages tothe Arduino. To emphasise that this communication only happens during thedesign phase, the connection in Figure 1 is dashed. Arduino offers the optionof a Secure Digital (SD) card module, so that eventually the waveform can bestored on an SD-card and the Arduino can operate as a stand-alone controller.The total cost of the system (excluding the Transonic system) was approxi-mately e
350 ( ≈ $ 393: ± e
250 for the pump and motor, e
50 for the Arduino,3 low
Q RPT A ssrN PC
Figure 1: Experimental set-up (not to scale): Flow loop, consisting of reservoir (R), flexibletubing, perspex tube (T), Transonic flow sensor (Q), and gear pump (P). Control loop, con-sisting of an Arduino (A) with a Solid State Relay (SSR). For monitoring and identificationa data acquisition card (N) and PC are used. and e
50 for the remaining parts), which is considerably less than the typicalcost for a commercial system ( ± $ O (10 ), estimate based on personal commu-nication with suppliers). The targeted velocity waveform for our experiments is representative forthe waveforms encountered at the proximal arterial side of an arterio-venousfistula used for hemodialysis [2, 3, 10, 11]. It is constructed as a Fourier seriesprescribing the flow rate, Q ( t ), in l/min: Q ( t ) = N X n = − N c n exp (cid:18) i πntT (cid:19) , (1)with a period, T , of 1 s, N = 4, and coefficients, c n given in table 1 (for a graph-ical representation see Figure 6). To be able to reproduce this waveform, thenon-linear and dynamic behaviour of our system are identified, and a controlleris designed based on this. The system is considered as a combination of a linear dynamic system witha static non-linear output function. The equations that describe this behaviour4 able 1: Coefficients for Fourier series to construct waveform ( c ∗ n denotes the complex conju-gate of c n ). n c n − . − i2 − . − . − · − + 1 . · − i4 − .
012 + 6 · − i c − n c ∗ n are: ˜ Q = P ( s ) u, Q = f ( ˜ Q ) . (2)In this, ˜ Q denotes a virtual flow (in arbitrary units), while Q represents the trueflow in litres per minute, s is the Laplacian variable, and P the linear transferfunction of the system. The input u is the voltage to the pump. Although a firstprinciples physical model is not made of the system, the non-linearitiy expectedto be dominant is the flow - gear wheel relation due to back flow (“slip”: notall fluid on the intake side is transported to the outlet side by the gears. Thiseffect is particularly noticeable at higher rotation rates, and for low viscosityworking fluids).In order to identify the relation in (2) two dedicated experiments are per-formed. The output non-linearity is identified by applying a series of differentinput voltages to the pump and measuring its steady state output. A smoothfunction is fitted through these measurement points, minimising the weightedsum-of-squares error. The weighting in this fitting procedure is done to optimisethe fit in the range of flow rates present in the target waveform.To identify the transfer function, a set of step functions with different am-plitudes is applied. Based on the response, the Matlab function ‘tfest’ is usedto find the linear dynamic response. The number of zeros and poles is varied toget a minimal system with good response.The system identification procedure is carried out semi-automatically, byrunning first the Arduino script Identify.ino and the Matlab script nidaq i-dentify.m (to control the pump and read the resulting flow rates, respectively),5 f (PF) -1 f -1 cyclemean cyclemeanQ r (cid:1) Q r (cid:0) Q Qc-Q r -Q (cid:2) + -+ +++ u ff Arduino (cid:3) T Figure 2: Control scheme of the system. and then the Matlab script
IdentifyPump.m for the actual identification (seesupplementary material for the code).
Figure 2 shows the control scheme that was used. The control of the pumpis based on a feed forward controller to achieve the desired tracking behaviour,and a run-to-run controller that adds a constant voltage to the feed forwardsignal during each period. The value of this constant, c , is adapted at the endof each period as c := c + γ ( ¯ Q r − ¯ Q ), where ¯ Q r is the mean reference flow, ¯ Q is the measured mean flow, and γ is a proportionality constant regulating thestrength of the run-to-run controller, set to 5.0 in our case (trial-and-error). Inthe control scheme block ∆ T is a delay of one pulse cycle. The advantage ofusing a run-to-run controller is that it will result in a correct mean flow, even ifthere are estimation errors in the non-linear mapping and the dynamic response(equations 4 and 5, respectively). The feed forward signal, u ff , is calculated as: u ff = ( P ( s ) F ( s )) − ˜ Q r + c, F ( s ) = ω c ( s + 2 ζω c s + ω c )( s/ω c + 1) (3)The low pass filter F ( s ) is needed to make the complete system strictly properand hence invertible, ω c is the cut off frequency of this filter in radians persecond (set to 10 Hz in our case, using trial-and-error to balance between asufficiently fast response on the one hand, and highly oscillatory behaviour onthe other) 6 . Experiments The experiments are divided into an identification part, and the actual wave-form testing. Because the output flow rate of the gear pump in our set-updepends not only on the input voltage, but also on the resistance, inertia andcompliance in the flow loop (e.g. flow phantom geometry, material, test fluidproperties), the system identification must be done every time the flow loop ischanged.
A set of driving voltages were set on the input of the pump system, and theresulting steady flow rates were measured. The result is shown in Figure 3. Thedots show the measured steady state values, and the line is the fitted function.The relation between the flow and the virtual flow is given by: Q = p ln( p ˜ Q + p ) + p . (4)This relation is not based on the underlying physics, but on providing a goodfit. The applied weight vector is w = [0 . , . , , , , , , , A set of steps is applied to the pump and the actual flow is measured toidentify the linear dynamic response. The non-linear mapping (2) is inverted tocalculate the virtual flow in the step test. Figure 4 shows this virtual flow withthe gray line. The black line is the fitted response. For the present fit a quantitylike the root mean square error (RMSE) would not give much useful information,as its value would be mainly determined by the noise level of the measured signal.Analysing the signals in the frequency domain would be a better option, but isconsidered to be beyond the scope of this work. Therefore the quality of thefitted response was assessed visually, and only the final waveform was analysedquantitatively. The corresponding transfer function is P ( s ) = 4617( s + 2 . s + 2 . s + 1580) . (5)7Sfrag replacements Q ( l / m i n ) u (V)0 5 10 1500 . . . . . . The first part of the denominator represents the exponential increase/declinedue to a step, with a time constant of 2.9 sec, which can be seen in Figure 4.The second part of the denominator coincides with the characteristic equationof a standard second order system, s + 2 ζω r + ω r , with a relative dampingof the characteristic equation, ζ = 0 .
03, and a resonance frequency, ω r = 6 . The feed forward signal was calculated in Matlab using (3), and sent tothe Arduino over a serial port (using the Matlab script
SendWaveform.m andthe Arduino script
Waveform.ino , see supplementary material). The result isshown in Figure 5. Note that roughly between t = 0 .
4s and t = 0 . t (s) v i r t u a l fl o w ( - ) pwm units). Dashed line: input signal, grey: actual measurement data, black: fit of the linearsystem. to a deviation of the mean flow if not corrected by the run-to-run controller. Figure 6 shows the measured waveform signal, together with the target wave-form. The flow rate was measured using the Transonic flowmeter system, andread out at a sampling frequency of 1 000 Hz. The filtering on the Transonicsystem was set to 160 Hz, and the signal was low-pass filtered in Matlab af-terward, using a zero-phase filtering with a 5 th -order Butterworth filter with acut-off frequency of 10 Hz. The effect of the feed forward signal being restrictedto positive values is clearly visible between t = 0 .
4s and t = 0 . t = 0 .
97 s) is unclear and should be investigated inmore detail. The average error (average difference between the measured signaland the reference signal during one period) is 1.3% of the target value, whilethe maximum error is 3.6%, at t = 0 . t (s) v i r t u a l fl o w ( p w m ) . . . . − pwm units. Note: roughly between t = 0 . PSfrag replacements t (s) Q ( l / m i n ) . . . . . . . . . . Conclusions and recommendations A programmable pulsatile flow pumping system was built, using an Arduinomicro-controller to implement a feed forward signal computed in Matlab. Eventhough the used set-up is relatively simple, it was shown to be able to reproducethe desired waveform with an error of less than 3.6% of the target value (1.3%on average). This result shows that the assumption that the system can bemodelled as a linear dynamic system with a static non-linear output functionprovides a good enough approximation of the true system for our application.A drawback of the current system, and of systems of this type in general, isthat the output flow rate not only depends on the input voltage, but also on theproperties of the components present in the system, like the flow loop geometryand test fluid properties. This necessitates an identification step every time thegeometry or test fluid are changed. Even though this identification step canbe done semi-automatically (see code in supplementary material), and hencedoes not take much time, it should be done carefully, as the equation used tocompute the virtual flow is exponential.The observed resonance frequency at 6.3 Hz, and the inability of the currentsystem to actively decelerate the flow (i.e. apply a negative voltage), limit thewaveforms that can be reproduced with our set-up. The response of the systemwill decrease quickly at frequencies higher than the resonance frequency. Asa result, frequencies that are above 6.3 Hz in the reference signal need largedriving voltages to be tracked correctly. The maximum voltage that can beapplied to the DC motor in our set-up is 30 V, so in practice it will not bepossible to track signals that exceed the resonance frequency.Addition of a feedback controller is not expected to improve the trackingof the required waveform. The bandwidth of a feedback controller for the cur-rent transfer function cannot exceed approximately one third of the resonancefrequency, as the phase margin would become too small and excessive oscilla-tions would result. In the current situation that would mean a bandwith ofapproximately 2 Hz for feedback control, while the targetted waveform contains11requencies up to 4 Hz.For the application in vascular access hemodynamics the limitation on theattainable waveforms does not pose a serious problem, as the frequencies en-countered in the flow upstream of a vascular access site are typically below 5 Hz.For other applications it is important to keep in mind that not only the pumpcapacity, but also the dynamics of the system as a whole should be taken intoaccount when selecting components.To further improve the accuracy of the current system, iterative learningcontrol (ILC) can be applied [1], taking advantage of the repetitive character ofthe targeted pulsatile flow. This goes beyond the concept of a simple scheme forthe control of pulsatile flow, but it is expected to increase the performance ofsystems like the one described in this note. Also, changing the electronics froma one-quadrant setup to a four-quadrant setup would improve the performance.The flow could be actively stopped, while we are now limited by the dampingpresent in the system. It would require more electronics to facilitate this.For applications like the one discussed here, in which the targeted waveformcontains a relatively large DC-component, also delivering this DC- componentseparately can improve the accuracy. This can for example be done by combiningtwo separate power supplies, or two separate pumps (see e.g. Tsai and Sava¸s[12]).Finally, the availability of Matlab may be an issue in some situations. Thisshould not be a problem, however, as the system identification, controller designand communication with Arduino and DAQ can alternatively be done withPython, which is freeware.
Acknowledgments
This project has received funding from the European Unions Seventh Frame-work Programme for research, technological development and demonstrationunder grant agreement no. 324487.Competing interests: none declared.Ethical approval: not required. 12 eferences [1] S. Arimoto, S. Kawamura, and F. Miyazaki. Bettering operations of robotsby learning.
Jorunal of Robotic Systems , 1(2):123–140, 1984.[2] L. D. Browne.
Quantifying the hemodynamic characteristics of an arteri-ovenous fistula for hemodialysis . PhD thesis, University of Limerick, 2015.[3] L. D. Browne, M. T. Walsh, and P. Griffin. Experimental and numeri-cal analysis of the bulk flow parameters within an arteriovenous fistula.
Cardiovascular Engineering and Technology , 6(4):450–462, 2015.[4] R. A. Chaudhury, V. Atlasman, G. Pathangey, N. Pracht, R. J. Adrian,and D. H. Frakes. A high performance pulsatile pump for aortic flow ex-periments in 3-dimensional models.
Cardiovascular Engineering and Tech-nology , 7(2):148–158, 2016.[5] P. R. Hoskins, T. Anderson, and W. N. McDicken. A computer controlledflow phantom for generation of physiological Doppler waveforms.
Physicsin Medicine and Biology , 34(11):1709–1717, 1989.[6] J. Petersen. Digitally controlled system for reproducing blood waveformsin vitro.
Medical & Biological Engineering & Computing , 22:277–280, 1984.[7] D. Plewes, S. Urchuck, S. Kim, and I. Soutar. An MR compatible flowsimulator for intravascular pressure simulation.
Medical Physics , 22:1111–1115, 1995.[8] S. Schampaert, K. A. M. A. Pennings, M. J. G. van de Molengraft, N. H. J.Pijls, F. N. van de Vosse, and M. C. M. Rutten. A mock circulationmodel for cardiovascular evaluation.
Physiological Measurement , 35:687–702, 2014.[9] P. Segers, F. Dubois, D. de Wachter, and P. Verdonck. Role and relevancy ofa cardiovascular simulator.
Cardiovascular Engineering , 3(1):48–56, 1998.1310] M. Sigovan, V. Rayz, W. Gasper, H. F. Alley, C. D. Owens, and D. Sa-loner. Vascular remodeling in autogenous arterio-venous fistulas by MRIand CFD.
Annals of Biomedical Engineering , 41(4):657–668, 2013.[11] S. Sivanesan, T. V. How, R. A. Black, and A. Bakran. Flow patternsin the radiocephalic arteriovenous fistula: an in vitro study.
Journal ofBiomechanics , 32:915–925, 1999.[12] W. Tsai and ¨O. Sava¸s. Flow pumping system for physiologial waveforms.