Vietnam National Universities – HCMC International University Biomedical Engineering Department DESIGN AND DEVELOPMENT OF A LABORATORY THERMOSTATIC WATER BATH By Doan Tin Duc BEBEIU16041 A thesis submitted to the School of Biomedical Engineering in partial fulfillment of the requirements for the degree of Engineer Ho Chi Minh City, Vietnam August – 2020 1 Vietnam National Universities – HCMC International University Biomedical Engineering Department DESIGN AND DEVELOPMENT OF A LABORATORY THERMOSTATIC WATER BATH APPROVED BY: ________________________________ , Pham Thi Thu Hien, Assoc. Prof., Advisor ________________________________ , Vo Van Toi, Prof., Chair ______________________________ Nguyen Thanh Tam, Ph.D., Reviewer ______________________________ Pham Thi Thu Hien, Assoc. Prof., Member ______________________________ Ngo Thanh Hoan, Dr., Member ______________________________ Ngo Thi Lua, Dr., Secretary THESIS COMMITTEE 2 Vietnam National Universities – HCMC International University Biomedical Engineering Department ACKNOWLEDGEMENTS First and foremost, I would like to express my greatest gratitude to Mrs. Pham Thi Thu Hien, my advisor who guided me through this thesis with her useful advices, feedbacks, and encouragements. I would not be able to come this far without her dedication and kindness, which motivated me to improve even further. I would like to give my thanks to Mr. Nguyen Le Y, for inspired me to start this project and helped me materialize my ideas. There were some difficult problems I would never work out myself if not for his knowledges and enthusiasm. Furthermore, I want to thank Mr. Do Tuan Anh, Ms. Nguyen Le Hoang Cam, Ms. Ha Nguyen Yen Nhi, Mr. Tran Hong Gia Bao, and Ms. Lam Khanh Van for staying by my side through thick and thin, aiding me in different problems, both in school and in life. It was thanks to them that my life in university was so enjoyable. I want to give my thanks to all my friends in my department, who accompanied with me through difficult times when doing our thesis together, for supporting me whenever I need them, no matter how big or small. Finally, I want to show my deepest gratitude to my family, who raised me to be the person I am now and gave me unconditional love and support. Thank you for being my source of power to face and overcome any difficulties or challenges. I would never achieve this accomplishment without them. 3 Vietnam National Universities – HCMC International University Biomedical Engineering Department TABLE OF CONTENTS ACKNOWLEDGEMENTS ................................................................................................ 3 TABLE OF CONTENTS .................................................................................................... 4 LIST OF FIGURES ............................................................................................................ 8 LIST OF TABLES ............................................................................................................ 11 ABSTRACT...................................................................................................................... 12 CHAPTER I INTRODUCTION ....................................................................................... 14 1.1. Problem statement .............................................................................................. 14 1.2. Objectives and scope of the project.................................................................... 15 1.3. Structure of the thesis report .............................................................................. 15 CHAPTER II LITERATURE REVIEW .......................................................................... 17 2.1. Different methods in temperature control .......................................................... 17 2.1.1. Electric heating ........................................................................................... 17 2.1.2. Vapor compression refrigeration ................................................................ 17 2.1.3. Thermoelectric cooling ............................................................................... 18 2.2. Current commercialized products ...................................................................... 20 2.2.1. Memmert Water Bath WNB 7 .................................................................... 20 2.2.2. PolyScience Cryoprecipitate Bath .............................................................. 21 4 Vietnam National Universities – HCMC International University Biomedical Engineering Department 2.2.3. 2.3. Julabo Shaking Water Bath ......................................................................... 22 Practical applications of the laboratory water bath ............................................ 23 2.3.1. Plasma ......................................................................................................... 23 2.3.2. Preparation process ..................................................................................... 25 2.4. Design requirements ........................................................................................... 25 2.4.1. Specification ............................................................................................... 25 2.4.2. Decision matrix ........................................................................................... 27 CHAPTER III METHODOLOGY ................................................................................... 29 3.1. Principle of Thermoelectric effect in temperature control ................................. 29 3.2. PID controller in temperature control ................................................................ 30 3.2.1. Overview ..................................................................................................... 30 3.2.2. PID value .................................................................................................... 31 3.3. System components and operation ..................................................................... 32 3.3.1. System components .................................................................................... 32 3.3.2. System operation ......................................................................................... 36 3.4. Hardware development: ..................................................................................... 37 3.5. Software implementation: .................................................................................. 46 3.5.1. PID algorithm.............................................................................................. 48 5 Vietnam National Universities – HCMC International University Biomedical Engineering Department 3.5.2. Pulse width modulation control .................................................................. 49 3.5.3. LCD display ................................................................................................ 50 3.6. Experiment procedures ....................................................................................... 51 3.6.1. Accuracy test ............................................................................................... 51 3.6.2. Plasma test .................................................................................................. 52 CHAPTER IV RESULTS ................................................................................................. 54 4.1. Final product ...................................................................................................... 54 4.2. Experiments on the thermostatic water bath system .......................................... 57 4.2.1. Thermocouple testing.................................................................................. 57 4.2.2. Plasma samples testing ............................................................................... 59 4.3. Device comparison ............................................................................................. 61 CHAPTER V DISCUSSION AND IMPLEMENTATIONS ........................................... 63 5.1. Beneficial features .............................................................................................. 63 5.2. Shortcomings...................................................................................................... 64 5.3. Implementations ................................................................................................. 65 CHAPTER VI CONCLUSION ........................................................................................ 66 REFERENCES ................................................................................................................. 67 APPENDIX SOFTWARE CODE SCRIPT ...................................................................... 70 6 Vietnam National Universities – HCMC International University Biomedical Engineering Department 7 Vietnam National Universities – HCMC International University Biomedical Engineering Department LIST OF FIGURES Figure 1: A simple vapor compression refrigeration cycle ............................................... 18 Figure 2: Memmert Peltier cooling device ....................................................................... 19 Figure 3: Memmert's Water bath WNB 7 ......................................................................... 20 Figure 4: Sketch of the Water bath WNB 7 ...................................................................... 21 Figure 5: PolyScience Cryoprecipitate bath ..................................................................... 22 Figure 6: Julabo SW22 Shaking Water Bath .................................................................... 23 Figure 7: Blood components [10] ..................................................................................... 24 Figure 8: Schematic of a thermoelectric couple [6]. ......................................................... 29 Figure 9: Arduino Uno Rev3 ............................................................................................ 33 Figure 10: DS18B20 digital thermocouple ....................................................................... 33 Figure 11: IBT-2 H-Bride module .................................................................................... 34 Figure 12: TEC1-12710 Peltier module............................................................................ 34 Figure 13: AVC heatsink .................................................................................................. 35 Figure 14: Lock&Lock LLG205 ....................................................................................... 35 Figure 15: DC power supply ............................................................................................. 36 Figure 16: Flowchart of the water bath system ................................................................. 37 Figure 17: Aluminum heatsink and DC power source...................................................... 38 Figure 18: First version of the device with 2 electric fans on the sides ............................ 39 8 Vietnam National Universities – HCMC International University Biomedical Engineering Department Figure 19: First version of the device with the heat-resistant glass bath .......................... 39 Figure 20: New heatsink with the prototype thermal insulation chamber ........................ 40 Figure 21: Side view of the heatsink................................................................................. 41 Figure 22: 8x8cm rectangular holes through both side of the case................................... 42 Figure 23: The barrier covered with polyethylene foam .................................................. 43 Figure 24: The barrier was made to fit perfectly with the heatsink and case ................... 43 Figure 25: The thermal insulation chamber ...................................................................... 44 Figure 26: The lid and the body connected by a hinge ..................................................... 45 Figure 27: Solidworks sketch for the case of the circuit ................................................... 45 Figure 28: Flowchart of the control system ...................................................................... 47 Figure 29: Schematic of the controlling circuit ................................................................ 48 Figure 30: Pulse width modulation [23] ........................................................................... 50 Figure 31: Information menu ............................................................................................ 51 Figure 32: Mode select menu ............................................................................................ 51 Figure 33: Temperature set menu ..................................................................................... 51 Figure 34: Pro'sKit MT-1706 and the thermocouple ........................................................ 52 Figure 35: V-730 UV-Visible Spectrophotometer ............................................................ 53 Figure 36: Plasma samples labeled from A to C (left to right, respectively).................... 53 Figure 37: Front view of the final product ........................................................................ 54 9 Vietnam National Universities – HCMC International University Biomedical Engineering Department Figure 38: Top down view of the final product ................................................................ 55 Figure 39: Front view of the control panel ....................................................................... 55 Figure 40: Back view of the control panel ........................................................................ 56 Figure 41: Power outlet of the DC supply ........................................................................ 56 Figure 42: Measuring sensor readings .............................................................................. 59 Figure 43: UV-VIS absorption of sample A (top) in comparison to sample B (bottom) . 60 Figure 44: UV-VIS absorption spectrum of sample A (top) in comparison to sample C (bottom)............................................................................................................................. 61 10 Vietnam National Universities – HCMC International University Biomedical Engineering Department LIST OF TABLES Table 1: Requirements for the device ............................................................................... 27 Table 2: Development board ............................................................................................. 27 Table 3: Temperature sensor ............................................................................................. 28 Table 4: Peltier module ..................................................................................................... 28 Table 5: Temperature readings ......................................................................................... 57 Table 6: Paired Samples Test by T-test ............................................................................ 58 Table 7: Sample thawing time .......................................................................................... 59 Table 8: Device specifications comparison ...................................................................... 62 Table 9: Comparison with WNB7 and SW22 water bath model ...................................... 62 11 Vietnam National Universities – HCMC International University Biomedical Engineering Department ABSTRACT In laboratory, thawing or heating process can be a very difficult problem such as many operating procedures require specific temperature to carry out. Hence, a water bath is needed for indirect temperature control by adjusting the temperature of the intermediate environment such as water. In this study, the thermostatic water bath based on thermoelectric effect (e.g. Peltier effect, Seebeck effect…) was designed, calibrated and examined with plasma samples. The device in this project used thermoelectric cooler (TEC) to maintain and control the setting temperature of a container made of heat-resistant glass. The system was then put inside a thermal-insulated chamber to prevent exchanging heat with the environment. The electrical system included an Arduino UNO microcontroller, an IBT-2 H-bridge motor driver module, and a DS18B20 temperature sensor. To improve the stability of the temperature, PID algorithm was applied into the program. The temperature value inside the container is collected real-time through the sensor and displayed on the LCD panel. The TEC is driven by an IBT-2 module which is controlled by the Arduino through PWM signal. The performance and accuracy of the system was calibrated with an industrial thermocouple sensor (Pro’sKit MT-1706), and then tested with plasma samples. The experimental results showed that the accuracy of the device had positive results with the error of ±0.3oC. Moreover, the plasma samples also had significant improvement in thawing time in comparison with thawing at room temperature (by an average of 65%). Using the UV-VIS spectrophotometer, the spectra of the samples also exhibited no difference between two thawing methods. In conclusion, the 12 Vietnam National Universities – HCMC International University Biomedical Engineering Department system will aid in different preparation processes in the laboratory and greatly reduce the time consumed. In the future, the system can be further developed to have more function such as timer, adjustable rising time, and wireless control. Keywords: water bath, thermoelectric cooling, Peltier effect, Arduino Uno, PID algorithm. 13 Vietnam National Universities – HCMC International University Biomedical Engineering Department CHAPTER I INTRODUCTION 1.1.Problem statement Cold storage and cryopreservation are among the most common forms of storing and maintaining organic samples. When the sample’s temperature is reduced, biological and chemical reactions are also slowed down, resulting in longer storing time. Furthermore, keeping the sample at low temperature environment is also aimed to prevent any harmful germs from growing and damaging it. However, thawing or raising their temperature to a usable or specific condition is another concern. In laboratory, there are some experiments that require a specific temperature, or preparation procedures including proteins or materials that have unique melting or freezing points. In blood transfusion, where fresh frozen plasma (FFP) and plasma frozen within 24 hours (PF24) are widely used, the samples are required to be defrosted before transfusing. Hence, a safe and quick method for thawing is much needed, and a water bath is a device that can satisfy all the requirements. In the recent years, the need of developing more compact, portable cooling technology has gathered a lot of attention of many manufacturers, and thermoelectric cooling is one of the emerging methods in thermal control. What makes thermoelectric cooling really stand out among others cooling methods is its effectiveness when operating in a very limited space with low energy consumption. Many companies have developed different devices 14 Vietnam National Universities – HCMC International University Biomedical Engineering Department based on thermoelectric cooling. In laboratory, a thermoelectric-based water bath is a perfect device that can offer a wide range of applications within a very small area. 1.2.Objectives and scope of the project This project aimed to develop a thermostatic water bath using thermoelectric effect, which is a phenomenon where temperature difference is created by applying a current to the intersection between two different materials [1]. This effect is utilized as a method of controlling the temperature of the water bath. A closed-loop PID temperature control system is implemented using an Arduino Uno, a DS18B20 thermocouple, and a TEC112710 Peltier module driven using IBT-2 H-Bridge module. The final product is a water bath system with simplified and straightforward control. The heat insulation chamber shows positive results in increasing the efficiency of the system. Throughout different tests, the water bath exhibits significant improvement in thawing time in comparison to leaving the samples at room temperature. However, the PID controller of the system still need to be working on since instantaneous transition between heating and cooling is not possible. The water bath holds a lot of potential for further developments such as modifying rising time, timer, or wireless controlling. 1.3.Structure of the thesis report According to the information, the structure of the thesis report is explained below: - Chapter II provides general information on common methods of temperature control, current commercialized products, and practical applications. 15 Vietnam National Universities – HCMC International University Biomedical Engineering Department - Chapter III gives details on how the system is designed: its principle, hardware, and software development. - Chapter IV exhibits the results of the device, and how it performed. - Chapter V gives insights on the results and discussion for further upgrades and developments. - Chapter VI gives conclusion on the project including the potentials in the future - The appendix shows the script for the Arduino code and decision matrices. 16 Vietnam National Universities – HCMC International University Biomedical Engineering Department CHAPTER II LITERATURE REVIEW 2.1.Different methods in temperature control 2.1.1. Electric heating Electric heating is famous for its straightforward applications in different fields that require high temperature such as water heating, welding… It is a process where a heating element radiates heat when electric current is applied [2]. Although fuel combustion is more energy-efficient, but electric heating is more generally applied due to its compactness and cleanliness. The downside of this method is its inability to operate below ambient temperature. 2.1.2. Vapor compression refrigeration Vapor compression refrigeration system is one of the most common method for cooling. A typical system is made of an evaporator, a compressor, a condenser, and an expansion valve (Figure 1). Principle of the system is described below [3], [4]: - Refrigerant start from a low pressure and temperature gas state. It is then compressed and enters high pressure, high temperature state. - In the next phase, the refrigerant enters the condenser and exchange heat with a secondary fluid which has a lower temperature and become liquid state. 17 Vietnam National Universities – HCMC International University Biomedical Engineering Department - The liquid refrigerant enters the expansion valve and undergoes Joule-Thompson effect, which cause the refrigerant to partially evaporate and exit the valve in low pressure and temperature (liquid vapor mixture) state. - The refrigerant then enters the evaporator where the refrigerant has lower temperature than the environment, causing it to vaporize, resulting in the cooling effect of the environment. Qc Condenser Expansion Compressor valve Evaporator Qe Figure 1: A simple vapor compression refrigeration cycle 2.1.3. Thermoelectric cooling Thermoelectric cooling is an emerging technology in temperature control and has been developing ever since the establishment of thermoelectric material science [5]. A 18 Vietnam National Universities – HCMC International University Biomedical Engineering Department thermoelectric cooler functioned as a heat pump that when provided with an electric current, heat is transferred from one side of the cooler to the other [6]. Comparing to conventional cooling, Depending on different scenarios and how it is applied, thermoelectric cooling can have very distinctive benefits, such as [7], [8]: - Freely alternate between heating and cooling by controlling the direction of the electric current. - Noise-free and vibration-free. - Require less maintenance. - Operating regardless of position. With its advantages outweigh disadvantages, thermoelectric cooling device could become a very promising field in the future. Figure 2: Memmert Peltier cooling device 19 Vietnam National Universities – HCMC International University Biomedical Engineering Department 2.2.Current commercialized products Many medical corporations have developed a lot of water bath with different types and functions suitable for every need in the laboratory. This thesis introduced three types of typical water bath for general use in the laboratory. 2.2.1. Memmert Water Bath WNB 7 Memmert is one of the most well-known corporation in developing laboratory equipment and especially water bath and oil bath. One of their products is the WNB 7 (Figure 3, 4). Figure 3: Memmert's Water bath WNB 7 20 Vietnam National Universities – HCMC International University Biomedical Engineering Department Figure 4: Sketch of the Water bath WNB 7 The WNB 7 is a general-use laboratory water bath with working range from 5oC up to 95oC above ambient (room) temperature. The reservoir is made with stainless steel provide highest quality of sturdiness and reliability. The water bath also provides heating on all surface which improve the temperature uniformity and heating efficiency. 2.2.2. PolyScience Cryoprecipitate Bath PolyScience is famous in manufacturing different types of baths such as refrigerated circulating bath, recirculating coolers, water baths… Figure 5 is their cryoprecipitate water bath. 21 Vietnam National Universities – HCMC International University Biomedical Engineering Department Figure 5: PolyScience Cryoprecipitate bath The device is made specifically to prepare for retrieving cryoprecipitated antihemophilic factor (also known as cryoprecipitate) by thawing fresh frozen plasma at 4oC. The bath can maintain the temperature at fixed setpoint 4oC with high accuracy at ±0.1oC. 2.2.3. Julabo Shaking Water Bath Shaking water bath is one of the essential equipment in the laboratory, especially in cell laboratories. A shaking water bath can aid in growing cell culture or mixing and heating simultaneously. 22 Vietnam National Universities – HCMC International University Biomedical Engineering Department Figure 6: Julabo SW22 Shaking Water Bath Julabo shaking water bath SW22 (Figure 6) working temperature ranging from 20oC to 99.9oC above ambient temperature with an accuracy of ±0.2oC. Also, the shaking frequency can be freely adjusted between 20 and 200 RPM. 2.3.Practical applications of the laboratory water bath 2.3.1. Plasma Plasma is a part of the blood component, along with red blood cells, white blood cells, and platelets (Figure 7). Plasma is used in treatment for severe bleeding and disseminated intravascular coagulation since it contains high concentration of blood clotting factors and other elements [9]. 23 Vietnam National Universities – HCMC International University Biomedical Engineering Department Figure 7: Blood components [10] Usually, plasma is stored by freezing at -18oC or lower after collected. Plasma that is frozen around 6 to 8 hours after collected is called fresh frozen plasma (FFP), and plasma that is frozen within 24 hours after collected is called plasma frozen within 24 hours (FP24), both are stored at -18oC or lower. Comparing to FFP, FP24 has reduced FV and FVIII [9], however, FP24 has the same usability except for cases that specifically need to replace FV or FVIII. 24 Vietnam National Universities – HCMC International University Biomedical Engineering Department 2.3.2. Preparation process Before plasma is used in experiments or transfusion, a water bath is required in different procedures of thawing plasma depending on the scenario. Usually, a unit of plasma between 210-250ml can be thawed in the water bath of 37oC in 45 minutes when put in a plastic bag [11]. After the plasma is thawed, it should be stored at 1-6oC for no more than 4 days or the quality of clotting proteins would suffer. Another application of the water bath in plasma preparation is cryoprecipitate manufacturing. In this process, FFP is thawed in the water bath between 1oC to 6oC and is then centrifuged for cryoprecipitate retrieval [12]. 2.4.Design requirements 2.4.1. Specification In this thesis, there are some aspects that the design must consider for maximized efficiency and suitable for the project. Such requirements are: • • • • • Working principle Size Working temperature range Power Rising time (time required for the temperature to reach setpoint) The device is designed for laboratory general use; therefore, it should be portable and able to cover a wide temperature range. There were different methods of thermal control introduced in this report. One of them is electric heating, a simple form of heating which comes in all kinds of sizes suitable for different purposes. The downside of electric heating 25 Vietnam National Universities – HCMC International University Biomedical Engineering Department is that it cannot work below ambient temperature. Another method is vapor compression refrigeration which would greatly increase the cost and complexity of the device, also, it is hard to maintain the desired compactness. On the other hand, thermoelectric cooling, which is based on Peltier effect, is the most suitable method since it can behave as both heating and cooling unit. What makes thermoelectric cooling superior in this scenario is that it can operate even in a very limited space while requires little to no maintenance. This project aimed to aid in the plasma preparation process, such as thawing or preparing cryoprecipitate. Usually, plasma is thawed at 30-37oC [13], or even 56oC in emergency cases [11](e.g. transfusion), and 4oC for cryoprecipitate retrieval. Therefore, the temperature range of the device should be able to heat up to 56oC and cool down to 4oC. Since most commercialized models have the accuracy of ±0.2 or lower, this was used as a reference point for the device. Plasma samples are stored in vacutainer or Eppendorf tube ranging from 0.5ml to 10ml or higher, a bath size of 500ml should be able to provide enough room for the operation while maintaining a minimum place. The rising time of the bath should match with the required time for any prior preparation process such as retrieving the samples from the freezer. In the author’s laboratory, this process may take up to 20 minutes, hence the rising time of the bath should fall within this period. This left us with the last problem, which was the heating power. The device should be able to provide enough heat to raise the temperature of 150ml water (about one-third the volume of the bath) from 24oC (room temperature) to 56oC in 20 minutes, which the minimum power required was 17W after calculation. Taken the heat conductance 26 Vietnam National Universities – HCMC International University Biomedical Engineering Department of the bath material into account, the power should be higher than expected. The requirements for the device are described in the table below: Table 1: Requirements for the device Factor Minimum temperature range Rising time Accuracy Bath size Minimum heating power Value 4oC ~ 56oC 20 minutes ±0.2oC 500ml 17W 2.4.2. Decision matrix The main components of the device are the development board, the temperature sensor, and the thermoelectric module which directly affect the working operation. Therefore, to select the right part and maximize the efficiency of the system, comparison between different options was made using decision matrix method. In these matrices, each factor was rated on the scale from 0 (bad) to 5 (excellent). The results are presented below: Table 2: Development board Factor Price Size Power jack Support libraries Total Mega 3 2 5 3 13 Uno 5 4 5 5 19 27 Nano 4 5 2 4 15 Vietnam National Universities – HCMC International University Biomedical Engineering Department Table 3: Temperature sensor Factor Temperature range Accuracy Communication Price Total RTD K-type 3 4 3 4 14 DS18B20 4 3 5 5 17 PT100 5 5 3 2 15 Table 4: Peltier module Factor Power Current required Heatsink required Price Total 12706 3 4 5 5 17 12710 4 5 5 4 18 28 12712 4 4 4 4 16 12715 5 3 3 3 14 Vietnam National Universities – HCMC International University Biomedical Engineering Department CHAPTER III METHODOLOGY 3.1.Principle of Thermoelectric effect in temperature control The research on temperature controlling technology has been widely studied since it plays an irreplaceable role in daily life such as preparation or preservation procedures. In this regard, thermoelectric cooling has proved effective in localized operations for having no moving part or circulating fluid [14]. With its advantages outshine disadvantages, thermoelectric cooling has been widely utilized in different fields such as refrigeration, aviation, and laboratory applications. The definition of thermoelectric effect is the absorption of heat through the conjunction of two conductors (Figure 8) [7]. The heat absorbed can be controlled by modifying the Figure 8: Schematic of a thermoelectric couple [6]. 29 Vietnam National Universities – HCMC International University Biomedical Engineering Department direction and power of the electric current. With the material used for the module, the heat can be determined: 𝑸𝛱 = (𝛱1 − 𝛱2 )𝑱 (1) Where Π1,2 are the material’s Peltier coefficients, and 𝑱 is the current density. Thermoelectric devices operate on DC current, which makes it easier to control its behavior by modifying the input current. Provided with how the output of the device can be controlled to either heating or cooling and utilizing the PID controller, a constant and precise temperature can be achieved [15]. 3.2.PID controller in temperature control 3.2.1. Overview Proportional-Integral-Derivative (PID) is a controlling algorithm that has become universally applied in different fields that require precise response, both personal and industrial use for its versatility and effectiveness in most controlling process. The PID controller is used in a feedback loop control system where it adjusts the process variable to match a setpoint, or a desired value. A PID controller processes upon the difference between the process variable and the setpoint, also known as “error”, after and attempts to minimize it after each loop by modifying the output according to the signal received. A PID controller works on three parameters, with their own specific roles and characteristics: Proportional, Integral, and Derivative. 30 Vietnam National Universities – HCMC International University Biomedical Engineering Department 3.2.2. PID value Each term of the PID controller has their own function and effect on the output of the system, a detail explanation is provided below[16], [17]: Proportional: the proportional value (or P-term) decides how aggressive the system reacts to the instantaneous value of the system’s error. However, there exists a limit that the error is too insignificant when reaching closer to the desired value that the system cannot trigger enough output for the process variable to meet the setpoint, which is called “steady state error”. Even if the proportional value is set large enough so the setpoint can be met, it would cause the system to be unstable and oscillations will occur. Therefore, the performance of a proportional controller is very limited in most systems. Integral: the integral term (or I-term) of the PID controller tracks the difference of the process variable and setpoint over time and compensate the controller’s output with the value that proportional to the accumulated error, which also force the steady state error to zero. The integral value is crucial because it enables the P-only controller to reach setpoint. Although the integral value makes up for the steady state error of the P-only controller, it also enhances the disturbance in the output. This means that if the system has very little overshoot in the output can cause a huge spike in the system, resulting in a longer time for the system to stabilize. In a very sensitive system, unsuitable integral value can heavily damage the structure of the system. 31 Vietnam National Universities – HCMC International University Biomedical Engineering Department Derivative: derivative term (or D-term) takes the derivative of the system’s process variable over time and compensating the output variable with significant adjustments when the system detects errors in high frequency. This acts as a counteracting method for the overshoot by negating any spikes or sudden changes during the system’s operation. Although derivative term works very effective in dampening the output signal, it can become a source of disturbance in the output in response to setpoint change or noise from measuring process. It is necessary to ensure that Proportional and Integral term are enough for the system as using Derivative term can increase the complexity in the tuning process and causing the system to be more noise sensitive. 3.3.System components and operation 3.3.1. System components The system consists of an Arduino Uno R3, an IBT-2 H-Bridge module, a TEC1-12710 Peltier module, heatsink for the Peltier module, and DC power source. Below are images and detailed description of the system: 32 Vietnam National Universities – HCMC International University Biomedical Engineering Department 3.3.1.1.Main processing unit - Microcontroller: ATmega328P - Operating voltage: 5V - Work as the main processing unit for the PID controller. Figure 9: Arduino Uno Rev3 3.3.1.2.Thermocouple - Voltage supply: 3~5V - Temperature range: -55oC to 125oC - Accuracy: ±0.5oC - Resolution: 9-bit to 12-bit - Interact through 1-Wire library. Figure 10: DS18B20 digital thermocouple 33 Vietnam National Universities – HCMC International University Biomedical Engineering Department 3.3.1.3.Driver module - Power supply: 6 ~ 27V - Control the direction and output of the DC current to control the TEC module through PWM channel of the Arduino. Figure 11: IBT-2 H-Bride module 3.3.1.4.Peltier module - Voltage supply: 12V - Current supply: 10A - ∆TMax: 67oC - QcMax: 105.8W - Serve as the heat source of the system. - Hot side and cool side of the module can be inverted by changing the direction of Figure 12: TEC1-12710 Peltier module the current. 34 Vietnam National Universities – HCMC International University Biomedical Engineering Department 3.3.1.5.Heatsink - Power supply: 12V - Prevent the hot side of the Peltier module from rising too high and damage the module. Figure 13: AVC heatsink 3.3.1.6.Container - Size: 120x120x65mm - Heat-resistant glass. - Durable against sharp temperature change. Figure 14: Lock&Lock LLG205 35 Vietnam National Universities – HCMC International University Biomedical Engineering Department 3.3.1.7.DC power supply - Voltage input: 220VAC - Voltage output: 9VDC~14VDC - Current output: 10A Figure 15: DC power supply 3.3.2. System operation The system’s working operation starts with the DS18B20 sensor reads the temperature signal of the water inside the insulation chamber. The signal is collected by the Arduino to control the IBT-2 module, which is connected to the DC power source, and the TEC112710 Peltier device. By controlling the PWM signal from Arduino, the output of the Peltier module can be modified through the IBT-2 module in response to the temperature signal of the sensor. The working operation of the device is described (Figure 16) below: 36 Vietnam National Universities – HCMC International University Biomedical Engineering Department Figure 16: Block diagram of the water bath system 3.4.Hardware development: The design of the system has gone through a series of prototypes and improvements, but in general, the water bath consists of a thermal insulation chamber, a Peltier-heatsink system, and the controlling circuit. The water bath was constructed to hold all the component together and sturdy enough to prevent any outside force to affect the device. The main point of the design is to optimize the efficiency of the heatsink by modifying airflow inside the system, which also maximize the cooling power of the Peltier module since the performance of the cooling process depends on the efficiency of the heatsink [18]. The case of the device is made of stainless 37 Vietnam National Universities – HCMC International University Biomedical Engineering Department steel, and the chamber is constructed with acrylic sheets. Details on how the device was developed will be described below: The first version of the device was designed to fit everything into the case; therefore, it only consisted the case, aluminum heatsink with a 12-Volts electric fan (Figure 17), and the heat-resistant glass container. After a test run, the minimum temperature could only reach 24oC. Airflows inside the case was badly designed so the heat could not escape, caused the walls of the case to heat up and increased the temperature even higher. Therefore, two 12-volts electric fan was installed on the sides (Figure 18) to help dissipating part of the residual heat. the insides were also covered with polyethylene foam to prevent the sides from heating up. After the fan was installed, the temperature of the Peltier module is stabilized (minimum temperature was 22oC), but it is still not enough for the needs of the water bath. Figure 17: Aluminum heatsink and DC power source 38 Vietnam National Universities – HCMC International University Biomedical Engineering Department Figure 18: First version of the device with 2 electric fans on the sides Figure 19: First version of the device with the heat-resistant glass bath 39 Vietnam National Universities – HCMC International University Biomedical Engineering Department Hence, the heatsink was upgraded to another one that has better performance (Figure 20, 21). This heatsink comes with two 12-Volts electric fan offered superior heat dissipation. Using the new heatsink, the Peltier module could reach the minimum temperature of -10oC. This meant that the bath could even reach freezing point if there were no heat exchanging activity with the environment. Figure 20: New heatsink with the prototype thermal insulation chamber 40 Vietnam National Universities – HCMC International University Biomedical Engineering Department Figure 21: Side view of the heatsink This left us with the airflow problem of the case since the power of the side fans was not enough to manage all the heat inside and it would badly affect the overall performance of the system. Therefore, rectangular holes of 8cm x 8cm (same size as the heatsink electric fan) was created on both sides (Figure 22), forming an air passage through the case. 41 Vietnam National Universities – HCMC International University Biomedical Engineering Department Figure 22: 8x8cm rectangular holes through both side of the case To ensure that the air is circulated the right way and to prevent any heat going inside the system, a barrier made of acrylic was also installed. It enclosed the heatsink, forced the air to travel along the case without leaving any excess heat entering the system. The barrier was also covered with polyethylene foam to provide better heat prevention (Figure 23, 24). 42 Vietnam National Universities – HCMC International University Biomedical Engineering Department Figure 23: The barrier covered with polyethylene foam Figure 24: The barrier was made to fit perfectly with the heatsink and case 43 Vietnam National Universities – HCMC International University Biomedical Engineering Department In order to achieve stable temperature and maximize efficiency, it is crucial to ensure that the environment is excluded in the operation. Therefore, a thermal insulation chamber plays an essential role in the system. In this project, the insulation chamber was designed and constructed using acrylic and the interior was covered with polyethylene foam to prevent escaping heat from the inside and exchanging heat with the outside (Figure 25). Figure 25: The thermal insulation chamber The chamber also came with a lid and was connected to the body by a hinge (Figure 26) for easier operation and to made sure that every components of the device was connected to each other. Overall, the thermal insulation chamber was enough to sealed off any thermal activity with the environment. 44 Vietnam National Universities – HCMC International University Biomedical Engineering Department Figure 26: The lid and the body connected by a hinge Additionally, the case for the control circuit was designed using Solidworks to fix the board onto the case (Figure 27). It also served the purpose of protecting the wires and aesthetic. Figure 27: Solidworks sketch for the case of the circuit 45 Vietnam National Universities – HCMC International University Biomedical Engineering Department 3.5.Software implementation: The software operation is a feedback loop control system where the Arduino Uno records the temperature data from the DS18B20 sensors and calculates the value of the offset of the reading from the setpoint, which is called “error”. Next, the error is processed through PID algorithm with the output is the PWM signal. The output is then exported to the IBT-2 H-Bridge module to drive the TEC1-12710 Peltier module with a 12V DC power supply. The information on the current temperature, setpoint, and PWM signal of the system are displayed through an LCD1602 LCD screen module. Also, users can interact 46 Vietnam National Universities – HCMC International University Biomedical Engineering Department with the device using a rotary encoder to change its setpoint, cooling or heating mode. Figure 28 is the flowchart of the process and Figure 29 is the schematic of the system. Figure 28: Flowchart of the control system 47 Vietnam National Universities – HCMC International University Biomedical Engineering Department Figure 29: Schematic of the controlling circuit 3.5.1. PID algorithm PID algorithm is the key component that makes up all the controlling process. A welltuned PID controller can reduce errors and oscillations completely while maintaining a desired rising time. PID algorithm operates on the “error”, which is a difference between process value and setpoint. In this context, process value is the value of the real temperature 48 Vietnam National Universities – HCMC International University Biomedical Engineering Department and setpoint is the desired value of the water bath. After computing the error, the system then proceeds to calculate the PID value [17], [19]: 𝜏 𝑑 𝑢(𝑡) = 𝐾𝑝 . 𝑒(𝑡) + ∫0 𝐾𝑖 . 𝑒(𝑡)𝑑𝑡 + 𝐾𝑑 . 𝑑𝑡 . 𝑒(𝑡) (2) Where Kp is the proportional term – it decides how aggressive the output responses to the error, Ki is the integral term – a low-frequency compensator for steady-state error, and Kd is the derivative term – a high-frequency compensator for short-term error. Although derivative term can help minimize the time required for the system to stabilize by reducing overshoot, it is more likely to add unnecessary complexity in tuning process while having little to no impact on the performance in slow response system [20](e.g. temperature control). Therefore, a PI-controller was enough for this project. 3.5.2. Pulse width modulation control Pulse width modulation (PWM) is a method where pulses of various width is created by switching digital signal on and off consecutively in a period. to simulate output that resembles analog input [21]. These pulses are described by the ratio in percentage between active time and inactive time of the signal in a period, this ratio is called “duty cycle” (Figure 30). For example, a 50% duty cycle means that the digital signal is high for half a 49 Vietnam National Universities – HCMC International University Biomedical Engineering Department period and low for the other half, this also equals to an average of 50% of the maximum voltage is transmitted for an analog input [22]. Figure 30: Pulse width modulation [23] Therefore, an Arduino Uno can utilize PWM to control the MOSFET to adjust the power source that go into the load. In this project, the load is the TEC and is driven by an IBT-2 module, which consists of 2 MOSFETs connected in a H-bridge circuit, and a 12V DC power source. 3.5.3. LCD display The water bath also includes an LCD screen to display the information of the system and the user can interact directly with the device using a rotary encoder located on the control panel next to the LCD screen. The LCD display contains 3 menus, which are information display menu (Figure 31), “Mode select” (Figure 32), and “Set Temperature” (Figure 33). Mode select menu is where user can change between heating and cooling mode. Since their operations run on different sets of PID value so the user is required to manually select between the two. The “Set Temperature” menu is where the user can select the set temperature by rotating the encoder, 50 Vietnam National Universities – HCMC International University Biomedical Engineering Department turning clockwise to increase the setpoint by 0.5oC and counterclockwise to decrease the setpoint by 0.5oC. Finally, the information menu displays the current temperature in the thermal insulation chamber, setpoint, and PWM signal from the Arduino. Figure 31: Information menu Figure 32: Mode select menu Figure 33: Temperature set menu 3.6.Experiment procedures 3.6.1. Accuracy test The accuracy of the water bath was tested using a thermocouple. The purpose of this experiment was to examine if the sensor read the temperature correctly and how the system 51 Vietnam National Universities – HCMC International University Biomedical Engineering Department response to it. The thermocouple used in this project was the Pro’sKit MT-1706 (Figure 34). Figure 34: Pro'sKit MT-1706 and the thermocouple The test was carried out by changing the value of the temperature setpoint and measure the temperature after the system stabilized. The temperature was recorded in the range of 12oC to 40oC with the increment of one unit. Cooling mode was set for setpoints below room temperature and heating mode for setpoints above room temperature. 3.6.2. Plasma test The practical performance of the water bath was tested using blood plasma, which was taken directly from the author. The plasma samples were collected in vacutainer after centrifuged and stored at -18oC freezer immediately after retrieval. 52 Vietnam National Universities – HCMC International University Biomedical Engineering Department The experiment was conducted by thawing plasma samples in two conditions: in the water bath at 37oC and room temperature. After the plasma had completely defrosted, they were diluted by 500 times and analyzed using the V-730 UV-Visible spectrophotometer (Figure 35). Figure 35: V-730 UV-Visible Spectrophotometer The samples were labeled A, B, and C (Figure 36), sample A was thawed at room temperature and the other two were thawed in the water bath at 37oC. Figure 36: Plasma samples labeled from A to C (left to right, respectively) 53 Vietnam National Universities – HCMC International University Biomedical Engineering Department CHAPTER IV RESULTS 4.1.Final product After trying and different designs and improvements, the final product was constructed and assembled with every component of the device firmly connected with each other. The final look of the device is shown in Figure 37 and 38. The case for the control panel was also 3D printed and fixed into the front of the device using M3 bolts and nuts (Figure 39, 40). Figure 37: Front view of the final product 54 Vietnam National Universities – HCMC International University Biomedical Engineering Department Figure 38: Top down view of the final product Figure 39: Front view of the control panel 55 Vietnam National Universities – HCMC International University Biomedical Engineering Department Figure 40: Back view of the control panel Additionally, the cover for the power source is also 3D printed to protect the connection with the device from exposing to the environment. The cover also comes with a 220V power outlet socket and built-in switch and fuse (Figure 41) so the user can directly turn the power on and off directly on the power source. Figure 41: Power outlet of the DC supply 56 Vietnam National Universities – HCMC International University Biomedical Engineering Department 4.2.Experiments on the thermostatic water bath system 4.2.1. Thermocouple testing The whole process was repeated three times and the results is described in table 5 and 6. Table 5: Temperature readings o Setpoint ( C) 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 (room temperature) 27 28 29 30 31 32 33 34 35 36 37 Recorded temperature 1st (oC) 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Sensor readings (oC) 2nd 3rd 12.3 12.9 13.8 14.8 15.7 16.7 18 18.7 19.9 21 22.1 22.8 24.1 24.9 12 13.1 13.7 15.1 16.1 17 17.9 18.9 20.1 21.2 21.8 23 24.2 24.8 12.1 13 14.1 15.2 15.9 17.2 18 18.9 20 20.9 21.8 22.9 24.1 25 26 26.2 26.1 26.2 27 28 29 30 31 32 33 34 35 36 37 26.9 27.9 28.8 30 30.9 32 33 33.8 34.8 35.7 36.8 27 28.1 28.9 30.1 31 31.9 33.1 33.7 34.8 35.9 37.1 27.1 28 28.8 29.8 31 32 32.8 34.1 35 36.1 37.2 57 Vietnam National Universities – HCMC International University Biomedical Engineering Department 38 39 40 38 39 40 38.1 38.9 39.8 38 38.8 40.1 38.1 38.8 40 Table 6: Paired Samples Test by T-test Paired Samples Test Paired Differences Mean Std. Deviation Record – 1st .09310 .15337 Record – 2nd .01724 .14160 rd Record – 3 -.00345 .12951 Where recorded temperature Std. Error Mean 95% Confidence Interval of the Difference Lower Upper t df Sig. (2tailed) .02848 .03476 .15144 3.269 28 .003 .02629 -.03662 .07110 .656 28 .517 .02405 -.05271 .04582 -.143 28 .887 is the values measured by MT-1706, and sensor readings is the value measured by the sensor of the water bath. The graphs of the sensor readings comparing to the thermocouple are also provided for better illustration (Figure 42): 58 Vietnam National Universities – HCMC International University Temperature (oC) Biomedical Engineering Department Comparison between thermocouple and device 42 40 38 36 34 32 30 28 26 24 22 20 18 16 14 12 10 8 6 Reference 1st evaluation 2nd evaluation 3rd evaluation 12 16 20 24 28 32 36 40 Measuring point Figure 42: Measuring sensor readings 4.2.2. Plasma samples testing After the experiment, the total thawing time and the UV-VIS absorption spectra of the samples was recorded for comparison. The results of the experiment are presented below, Table 7 is the thawing time of the sample and Figure 43 and 44 are their absorption spectra. Table 7: Sample thawing time Sample A B C Thawing time 14 minutes 2 seconds 5 minutes 20 seconds 4 minutes 30 seconds 59 Vietnam National Universities – HCMC International University Biomedical Engineering Department Figure 43: UV-VIS absorption of sample A (top) in comparison to sample B (bottom) 60 Vietnam National Universities – HCMC International University Biomedical Engineering Department Figure 44: UV-VIS absorption spectrum of sample A (top) in comparison to sample C (bottom) 4.3.Device comparison The device was compared with the requirements table in chapter 2 (Table 8) and other commercialized product: the water bath model WNB7 (by Memmert), and the shaking water bath model SW22 (by Julabo) (Table 9). 61 Vietnam National Universities – HCMC International University Biomedical Engineering Department Table 8: Device specifications comparison Specification Temperature range Heating power Rising time Bath size Accuracy Requirements 4oC ~ 56oC 17W 20 minutes 500ml ±0.2 Final product 4oC ~ 70oC 92W 17 minutes 300ml ±0.3 Table 9: Comparison with WNB7 and SW22 water bath model Specifications Temperature range Temperature accuracy Bath size Boiling mode Cooling mode Timer Shaking mode WNB7 +10oC ~ +95oC ±0.15 7l Yes No Yes No SW22 +20oC ~ +99.9oC ±0.2 8l Yes No Yes Yes 62 Final product 4oC ~ 70oC ±0.3 300ml No Yes No No Vietnam National Universities – HCMC International University Biomedical Engineering Department CHAPTER V DISCUSSION AND IMPLEMENTATIONS 5.1.Beneficial features As can be seen from the temperature reading result, the water bath has exhibited excellent accuracy in the test with the thermocouple. The controller of the system responded to the sensor effectively with the accuracy of ±0.3oC. Additionally, the task of calibrating the PI-term for the algorithm had been successfully carried out with an acceptable rising time and stability. The device also showed significant improvement in the thawing time of the samples (62% shorter for sample B and 68% shorter for sample C in comparison to sample A which was at room temperature). The UV-VIS test was to analyze the component of the samples after they are thawed, by comparing the UV-VIS absorption spectra of the samples, it can be decided if the samples were affected by rapid thawing using the water bath. Therefore, the spectra of the plasma samples shown little to no significant difference. The most prominent features of the spectra are the peaks in the range of 283nm and 295nm were maintained in both conditions. Comparing with the requirements in chapter 2, the final product has achieved almost every subject except for the bath size. Because of limited space, a 500ml container couldn’t fit inside the thermal insulation chamber, therefore, the container was reduced to 300ml. Although the bath size was smaller, the performance remains unaffected. 63 Vietnam National Universities – HCMC International University Biomedical Engineering Department In practice, the water bath could be utilized not only in thawing process but also in any experiment that require a specific temperature to occur. It can even be used in heating proteins, drugs, or materials that have unique melting point. Another advantage is that the device was based on thermoelectric, which require very little power to operate, and the compactness makes it easier to fit in any space of the laboratory. The control procedure of the device was simplified so the user can interact with the device quickly and easily with only spin-and-click actions. 5.2.Shortcomings However, the water bath also has its limitations. The first thing to mention is that the control system cannot directly change from cooling mode to heating mode and vice versa. The PID algorithm run on accumulated errors, but cooling and heating process have different sets of tuning. Therefore, when the user switches from one mode to the other while keeping the same error, it would cause the values from different tuning values to add up and affect the accuracy of the controller. Another thing to add is the cooling efficiency of the water bath is dependent on the performance of the heatsink, hence it is heavily affected by ambient temperature. Therefore, the device is best suited to work at an AC-controlled room temperature, and it is advised to use more specialized cooling method in more extreme environment. 64 Vietnam National Universities – HCMC International University Biomedical Engineering Department 5.3.Implementations For further development, the controlling program of the water bath can be upgraded. For example, the algorithm can be improved to be able to change between different modes directly or to adjust the rising time of the system at will. The temperature readings can be recorded real time so the user can track the performance of the device and give appropriate calibration. The interaction with the water bath can be made wireless so the user can access the device anywhere while still be able to follow the status of it, further information on this can be referred to [24]. 65 Vietnam National Universities – HCMC International University Biomedical Engineering Department CHAPTER VI CONCLUSION To sums up, the thermostatic water bath can offer a variety of applications in the laboratory regarding thawing or heating processes. It can aid in different procedures and significantly reduced the time required for preparing materials or samples. Every component was designed to connect sturdily with very little to no excess parts, reducing the size of the system as much as possible. Although there are some limitations which can be improved, the thermostatic water bath is a reliable device to be utilized in the laboratory. It also has many rooms for improvement in the future that can be upgraded to provide more utilities and functions for the users. Additionally, thermoelectric technology is still an innovative method for temperature control, and it is expected to be developed further to give even better performance in the future. 66 Vietnam National Universities – HCMC International University Biomedical Engineering Department REFERENCES [1] T. M. Tritt, “Thermoelectric Materials: Principles, Structure, Properties, and Applications,” K. H. J. Buschow, R. W. Cahn, M. C. Flemings, B. Ilschner, E. J. Kramer, S. Mahajan, and P. B. T.-E. of M. S. and T. Veyssière, Eds. Oxford: Elsevier, 2002, pp. 1–11. [2] S. Kubba, “Chapter Nine - Impact of Energy and Atmosphere,” S. B. T.-H. of G. B. D. and C. (Second E. Kubba, Ed. Butterworth-Heinemann, 2017, pp. 443–571. [3] R. J. Dossat and T. J. Horan, Principles of refrigeration. Upper Saddle River, N.J.: Prentice Hall, 2002. [4] F. To, B. E. Cooled, and E. Valve, “6 . 5 Simple Vapor Compression Refrigeration System :” [5] M. S. Dresselhaus et al., “New Directions for Low-Dimensional Thermoelectric Materials,” Adv. Mater., vol. 19, no. 8, pp. 1043–1053, Apr. 2007. [6] T. Guclu, E. Cuce, and A. Besir, A systematic overview of thermoelectric coolers (TECs). 2017. [7] Y. Gurevich and J. Velázquez-Pérez, “Peltier Effect in Semiconductors,” 2014, pp. 1–21. [8] T. Guclu, E. Cuce, and A. Besir, A systematic overview of thermoelectric coolers (TECs). 2017. [9] R. Benjamin and L. McLaughlin, “Plasma components: Properties, differences, and 67 Vietnam National Universities – HCMC International University Biomedical Engineering Department uses,” Transfusion, vol. 52 Suppl 1, pp. 9S-19S, May 2012. [10] “Blood plasma - HORIBA.” [Online]. Available: https://www.horiba.com/en_en/technology/measured-and-controlledobjects/liquid/blood-plasma/. [Accessed: 26-Aug-2020]. [11] R. G. Westphal, B. Tindle, P. L. Howard, E. A. Golden, and G. A. Page, “Rapid thawing of fresh frozen plasma,” Am. J. Clin. Pathol., vol. 78, no. 2, pp. 220–222, 1982. [12] J. L. Callum, K. Karkouti, and Y. Lin, “Cryoprecipitate: The Current State of Knowledge,” Transfus. Med. Rev., vol. 23, no. 3, pp. 177–188, 2009. [13] R. D. Plotz and R. T. Ciotola, “Thawing of Fresh-Frozen Plasma at 45 °C versus 37 °C: Comparison Using Satellite Packs of the Same Donor Units,” Am. J. Clin. Pathol., vol. 89, no. 3, pp. 381–384, Mar. 1988. [14] T. Guclu and E. Cuce, “Thermoelectric Coolers (TECs): From Theory to Practice,” J. Electron. Mater., vol. 48, no. 1, pp. 211–230, 2019. [15] D.-Y. Pang, T. K. Kwon, and S.-C. Lee, “Temperature Control of Aluminum Plate by PWM Current Control of Peltier Module,” J. Korean Soc. Precis. Eng., vol. 23, Jan. 2006. [16] W. J. Palm, “Basic Control Systems Design,” Eshbach’s Handb. Eng. Fundam. Fifth Ed., pp. 760–801, 2009. [17] D. Bista, “Understanding and design of an Arduino-based PID controller,” 2016. 68 Vietnam National Universities – HCMC International University Biomedical Engineering Department [18] R. Chein and G. Huang, “Thermoelectric cooler application in electronic cooling,” Appl. Therm. Eng., vol. 24, no. 14, pp. 2207–2217, 2004. [19] K. H. Ang, G. Chong, and Y. Li, “PID control system analysis, design, and technology,” IEEE Trans. Control Syst. Technol., vol. 13, no. 4, pp. 559–576, 2005. [20] K. J. Åström and T. Hägglund, “The Future of PID Control,” IFAC Proc. Vol., vol. 33, no. 4, pp. 19–30, 2000. [21] R. D. Christ and R. L. Wernli, “Chapter 7 - Power and Telemetry,” R. D. Christ and R. L. B. T.-T. R. O. V. M. (Second E. Wernli, Eds. Oxford: Butterworth-Heinemann, 2014, pp. 141–161. [22] R. D. Christ and R. L. Wernli, “Chapter 7 - Power and Telemetry,” R. D. Christ and R. L. B. T.-T. R. O. V. M. (Second E. Wernli, Eds. Oxford: Butterworth-Heinemann, 2014, pp. 141–161. [23] L. D. Pyeatt and W. Ughetta, “Chapter 11 - Devices,” L. D. Pyeatt and W. B. T.-A. R. M. 64-B. A. L. Ughetta, Eds. Newnes, 2020, pp. 405–444. [24] N. Hasim, M. F. Basar, and M. S. Aras, “Design and development of a water bath control system: A virtual laboratory environment,” in 2011 IEEE Student Conference on Research and Development, 2011, pp. 403–408. 69 Vietnam National Universities – HCMC International University Biomedical Engineering Department APPENDIX SOFTWARE CODE SCRIPT #include <DS18B20.h> #include <PID_v1.h> #include <SPI.h> #include <OneWire.h> #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27, 16, 2); //define sensor pin DS18B20 ds(13); //define BTS7960 pins int R_PWM = 6; //cooling pin int L_PWM = 11; //heating pin //define rotary pin int clk = 8; int dt = 9; int sw = 10; unsigned long inittime, lasttime; //menu value int last; int curr; int PID_value_fixed = 0; int menu_act = 0; int button_pressed = 0; unsigned long lastBtnPress = 0; String mode; String modeoff = String("Off"); String modecooling = String("Cooling"); String modeheating = String("Heating"); //Set initial PID controller variables double kp, ki, kd; //PID specifications double realtemp=0, pwm=0; //PID input and outputs double settemp=22; float diff; //initial tuning parameters PID myPID(&realtemp, &pwm, &settemp, kp, ki, kd, DIRECT); void(*controlTEC)(); //Pointer control TEC void setup() { //Interrupt settings 70 Vietnam National Universities – HCMC International University Biomedical Engineering Department PCICR |= (1 << PCIE0); //Enable PCMSK0 scan PCMSK0 |= (1 << PCINT0); //Set pin D8 as state change interrupt PCMSK0 |= (1 << PCINT1); //Set pin D9 as state change interrupt PCMSK0 |= (1 << PCINT2); //Set pin D10 as state change interrupt pinMode(clk, INPUT); pinMode(dt, INPUT); pinMode(sw, INPUT); last = digitalRead(clk); //PID settings pinMode(R_PWM, OUTPUT); pinMode(L_PWM, OUTPUT); myPID.SetOutputLimits(-255,255); myPID.SetMode(AUTOMATIC); mode = modeoff; controlTEC = &state; //Initial state lcd.init(); lcd.backlight(); Serial.begin(115200); } void loop() { realtemp = readThermocouple(); //Write thermocouple data as input diff = realtemp - settemp; //State control controlTEC(); Serial.println(realtemp); Serial.println(mode); //Main menu inittime = millis(); if ((inittime - lasttime) > 200) { //LED refresh rate if (menu_act == 0) { lcd.clear(); lcd.setCursor(0,0); lcd.print("Set temperature"); lcd.setCursor(0,1); lcd.print(settemp); } if (menu_act == 1) { lcd.clear(); lcd.setCursor(0,0); lcd.print("Mode"); lcd.setCursor(0,1); lcd.print(mode); 71 Vietnam National Universities – HCMC International University Biomedical Engineering Department } if (menu_act == 2) { lcd.clear(); lcd.setCursor(0,0); lcd.print("T:"); lcd.setCursor(2,0); lcd.print(realtemp,1); lcd.setCursor(9,0); lcd.print("S:"); lcd.setCursor(11,0); lcd.print(settemp,1); lcd.setCursor(0,1); lcd.print("PWM:"); lcd.setCursor(4,1); lcd.print(pwm,1); } lasttime = inittime; } } //Thermocouple reading double readThermocouple() { float v; while (ds.selectNext()){ v = ds.getTempC(); } return v; } //Interrupt vector ISR(PCINT0_vect) { if (menu_act == 1) { curr = digitalRead(clk); if (curr != last && curr if (digitalRead(dt) != mode = modecooling; } else { mode = modeheating; } } last = curr; delay(1); } if (menu_act == 0) { curr = digitalRead(clk); if (curr != last && curr if (digitalRead(dt) != settemp += 0.5; } else { == 1) { curr) { == 1) { curr) { 72 Vietnam National Universities – HCMC International University Biomedical Engineering Department settemp -= 0.5; } } last = curr; delay(1); } //button menu if (digitalRead(sw) == LOW) { if (millis() - lastBtnPress > 50) { button_pressed = 1; } lastBtnPress = millis(); } else if (button_pressed == 1) { if (menu_act == 2) { menu_act = 0; PID_value_fixed = 1; button_pressed = 0; delay(1000); } if (menu_act == 1) { menu_act += 1; button_pressed = 0; delay(1000); } if (menu_act == 0 && PID_value_fixed != 1) { menu_act += 1; button_pressed = 0; delay(1000); } PID_value_fixed = 0; } } void state(){ //Change state of the TEC module if (mode == modecooling) { controlTEC = &cooling; } else if (mode == modeheating) { controlTEC = &heating; } else if (mode == modeoff) { controlTEC = &off; } } //PID control value void cooling(){ kp = 200; ki = 2.4; kd = 0; 73 Vietnam National Universities – HCMC International University Biomedical Engineering Department myPID.SetTunings(kp, ki, kd); myPID.SetOutputLimits(-255,0); myPID.Compute(); analogWrite(R_PWM, abs(pwm)); analogWrite(L_PWM, 0); if (true) controlTEC = &state; } void heating(){ kp = 35; ki = 1.3; kd = 0; myPID.SetTunings(kp, ki, kd); myPID.SetOutputLimits(0,255); myPID.Compute(); analogWrite(R_PWM, 0); analogWrite(L_PWM, abs(pwm)); if (true) controlTEC = &state; } void off(){ analogWrite(R_PWM, 0); analogWrite(L_PWM, 0); if (true) controlTEC = &state; } 74