• No results found

Autonomous Beverage Dispenser

N/A
N/A
Protected

Academic year: 2021

Share "Autonomous Beverage Dispenser"

Copied!
45
0
0

Loading.... (view fulltext now)

Full text

(1)

IN

DEGREE PROJECT TECHNOLOGY, FIRST CYCLE, 15 CREDITS

STOCKHOLM SWEDEN 2018,

Autonomous Beverage Dispenser

Autonom dryckesautomat

DANIEL BRUN SAN KHAFFAF

KTH ROYAL INSTITUTE OF TECHNOLOGY

SCHOOL OF INDUSTRIAL ENGINEERING AND MANAGEMENT

(2)

Autonomous Beverage Dispenser

DANIEL BRUN SAN KHAFFAF

(3)
(4)

Abstract

Since the 1970s the technology within autonomous sys- tems has been a fast-growing subject, the main reasons be- ing an increased interest in automation and decreased prices of sensors and hardware components.

There is a wide range of different complexities within different autonomous systems, but this thesis will contribute to an understanding of the basic principles in an autonomous system and its components. This is made by constructing an autonomous beverage dispenser that will fill a glass, re- gardless of its size, with a certain level of liquid. The pur- pose of this thesis is therefore to construct a demonstrator that illustrates how individual components can create an autonomous system.

To make it possible, an ultrasonic sensor and a peri- staltic pump will fill the glass with a certain level of liquid.

Another ultrasonic sensor together with a linear actuator are used to make the system adaptable to different sizes of glasses. With this setup and combining them through a microcontroller the two modules will act as an autonomous system.

The performance of the demonstrator was evaluated by measuring the errors of the registered liquid level in the dif- ferent glasses. Two other experiments were conducted, but on each module individually. The experiments conducted on this system showed results that were within the scope, but there are future improvements that can be made and expansions to support the knowledge of autonomous sys- tems even more.

(5)

Referat

Autonom dryckesautomat

Under de senaste 50 ˚aren har teknologin inom automa- tisering ¨okat kraftigt, vilket speglas i dagens samh¨alle d¨ar m˚anga produkter helt eller delvis ¨ar automatiserade. Den fr¨amsta anledningen till detta ¨ar att intresset inom omr˚adet

¨okat i samband med att priser p˚a ing˚aende komponenter minskat.

Idag finns det ett stort spektrum av olika komplexa au- tomatiserade produkter, men vad denna rapport riktar in sig p˚a ¨ar att ge en f¨orst˚aelse f¨or grunderna inom ett auto- nomt system och hur denna byggs upp av olika ing˚aende komponenter. F¨or att konkretisera detta kommer en auto- nom dryckesautomat konstrueras, vilken ska fylla ett glas med en godtycklig form till en given niv˚a. Syftet med denna rapport ¨ar s˚aledes att konstruera en prototyp som ska kon- kretisera hur individuella ing˚aende komponenter kan bygga upp ett autonomt system.

Detta m¨ojligg¨ors genom att systemet delas upp i tv˚a moduler. I den f¨orsta modulen ing˚ar en ultraljudssensor och en peristaltik pump som tillsammans ska fylla glaset med den givna niv˚an av v¨atska. Den andra modulen best˚ar av en ultraljudssensor och en linj¨araktuator och dessa anv¨ands f¨or att g¨ora systemet mer anpassbar till glas av olika storlekar.

Detta uppl¨agg och kombinationen av komponenter kommer att skapa ett autonomt system genom att koppla samman modulerna med hj¨alp av en mikrokontroller.

Systemets prestanda m¨ats genom att utf¨ora tester p˚a med hur bra precision systemet kan leverera en ¨onskad m¨angd v¨atskeniv˚a till olika glas. Ut¨over detta test kom- mer ytterligare tv˚aindividuella tester genomf¨oras p˚ade tv˚a modulerna. De utf¨orda experimenten uppn˚adde godk¨anda resultat som var inom projektets ramar, men en vidareut- veckling av projektet skulle kunna fr¨amja en ¨okad f¨orst˚aelse av autonoma system samt minska felen.

(6)

Acknowledgements

We would like to thank our examiner Nihad Subasic for his lectures, support dur- ing the project and mainly for being responsible for a course that gave us great insight into mechatronics. A huge thank you to the teaching assistants and Staffan Qvarnstr¨om for their input and guidance whenever we needed help. Finally thank you to our fellow students for their feedback and tips regarding components and methods that could be used in the project. Without them this project would have been significantly worse.

(7)

Contents

1 Introduction 3

1.1 Background . . . 3

1.2 Purpose . . . 4

1.3 Scope . . . 4

1.4 Method . . . 4

2 Theory 7 2.1 Arduino Uno . . . 7

2.2 Peristaltic Pump . . . 7

2.3 Ultrasound . . . 7

2.3.1 Ultrasonic Ranging Module . . . 8

2.4 Linear Actuator . . . 8

2.4.1 H-Bridge . . . 9

3 Demonstrator 11 3.1 Problem Formulation . . . 11

3.2 Hardware . . . 12

3.2.1 3D printed parts . . . 13

3.2.2 Ultrasonic Ranging Module . . . 13

3.2.3 Linear Actuator . . . 14

3.2.4 H-bridge . . . 14

3.2.5 Peristaltic Pump . . . 15

3.3 Software . . . 16

4 Results 17 4.1 Experiments one and two . . . 17

4.2 Experiment three . . . 19

5 Discussion and conclusions 21 6 Future improvements 23 6.1 Recommendations . . . 23

6.2 Future work . . . 23

(8)

Bibliography 25

Appendices 26

A Arduino Code 27

B Schematic Diagram 33

(9)

List of Figures

2.1 Illustration of how the ultrasonic sensor, HC-SR04, works. . . 8 3.1 A flowchart illustrating a hardware overview for the Autonomous Bev-

erage Dispenser. . . 12 3.2 Overview of the final demonstrator with components marked. . . 13 3.3 Photograph showing the top of the glass being parallel to the US in

module one. . . 13 3.4 A flowchart illustrating the actions of the software in different stages of

the system. . . 16 4.1 The results of experiments one and two. . . 18 4.2 The results of experiment three. . . 19 B.1 A schematic diagram of the circuit in the autonomous beverage dispenser. 33

(10)

List of Tables

4.1 Relative error and standard deviation for the first two experiments, with the decimal number representing the glass used. . . 18 4.2 Relative error and standard deviation for the first third experiment, with

the decimal number representing the glass used. . . 19

(11)
(12)

List of Abbreviations

US Ultrasonic Sensor

(13)
(14)

Chapter 1

Introduction

1.1 Background

Autonomous systems are an expanding feature in today’s society, which hold the potential benefits of cost reduction and assisting people. According to D. Watson and D. Scheidt in their article about autonomous systems, the definition of such a system is that it can adapt to different circumstances during operation without intervention of humans [1]. Furthermore, the article mentions that during the 1970s the interest in automation increased leading to a drop in the cost of sensors, ac- tuators, and processors. This has been beneficial for the expansion in autonomous systems’ research. This has led to the development of autonomous systems as com- plex as self-driving cars and robotic lawn mowers to those as simple as an automatic beverage dispenser. What they have in common is that they have been given an initial state, a goal, sensors to register the environment, and microcontrollers pro- cessing the input of the sensors to reach the goal.

This thesis will contribute to understanding the basic principles of an autonomous system and how components are connected and interact with each other. It will be shown in an automatic beverage dispenser by having sensors register the height of the glass and determine the maximum liquid level that can be pumped into the glass.

(15)

CHAPTER 1. INTRODUCTION

1.2 Purpose

The purpose of this project is to construct an automated beverage dispenser that will fill a glass to a small distance from the top with liquid with the help of sensors and actuators to control the level of liquid. The most appropriate sensor for this system will be chosen through literature research and evaluated through experiments. The user will start the process by the press of a button and then the system will proceed the operation on its own. The research questions that will be answered to construct such system are:

• How can a combination of sensors determine the height of liquid in a glass independent of its geometry?

• What is an appropriate setup to maximize the accuracy of the system?

Evaluating the performance of the system that is created from the two research question above results in one further research question:

• With what accuracy can the system fill the glass with liquid?

1.3 Scope

This thesis focuses on constructing a beverage dispenser and implementing an au- tonomous system, according to its definition in Section 1.1 , which will fill a glass with liquid. However, due to time and resource limitations the scope was reduced.

First, this is an autonomous system which implies that once the process has begun, it operates automatically till the process is completed. The system will only work under ideal conditions, which in this case implies an environment with low noise interference [2].

Since this project targets the understanding of the basic principles of how to implement an autonomous system, the hardware in this project is made in a smaller scale which limits the range of usable glasses. However, the system is developed to suit any smaller glass since the aim of an autonomous system is to make it as adaptable as possible.

1.4 Method

As introduced in the sections above, an autonomous beverage dispenser will be constructed which will be able to adapt to different glass geometries. It will also determine when to stop the peristaltic pump at a given liquid level.

An Arduino Uno microcontroller is used to process data in order to reach the given goal of the system. The data the Arduino Uno receives are from ultrasonic sensors (US). A US is mounted on a fixed location on the upper half of the beverage

4

(16)

1.4. METHOD

dispenser and a 3D-printed platform is mounted on the linear actuator, which travels vertically. The platform travels up vertically with a glass on it and as the top of the glass is registered by the system the linear actuator will stop. A registered height starts the peristaltic pump and the ultrasonic sensor measures the liquid level and switches off the pump when maximum liquid level is reached.

The housing for the beverage dispenser will be 3D-printed which will make it suit together perfectly with the hardware components. During construction of hardware and software there will be experiments taking place to make sure both algorithms and the mechanical parts works and that they can operate together.

(17)
(18)

Chapter 2

Theory

This chapter presents the research conducted to aid in answering the research ques- tions, and building a working prototype.

2.1 Arduino Uno

Arduino is a company that makes open-source hardware and software; Arduino Uno is one of those products, an open-source microcontroller board. The Uno can be connected to a computer using a USB connection and be programmed using the IDE Arduino software. It consists of 14 digital input and output pins, 6 analog input pins, and a flash memory of 32 KB. [3]

2.2 Peristaltic Pump

A peristaltic pump consists of a circular casing with a tube and a rotor with cylin- drical rollers attached to it inside the casing. Once powered by a DC-motor the rotor starts turning and squeezing parts of the tube against the casing [4], this cre- ates a pressure wave which leads to the fluid flowing. Each time one of the rollers squeezes the tube pressure waves are generated. The pump having more than one cylindrical roller is what prevents back-flow, the inlet is always closed prior to the

(19)

CHAPTER 2. THEORY ultrasonic waves and use the echo once the waves are reflected off an object to determine its position and the distance to it. [6]

2.3.1 Ultrasonic Ranging Module

Figure 2.1: Illustration of how the ultrasonic sensor, HC-SR04, works. [7]

The HC-SR04, an ultrasonic ranging module, is a sensor that, as seen in figure 2.1 above, consists of a transmitter and a receiver; it transmits ultrasonic pulses and once echo signals are received, the time between transmitting and receiving can be used to calculate the distance to objects that are 2-400 cm from it. The sensor can measure at an angle of 15 and its accuracy can reach up to 3 mm. Using an ultrasonic ranging module has its benefits with it being relatively low cost, and the sound waves having an inaudible frequency meaning the user will not notice that measurements are being taken. The sensor does however have some disadvantages;

to obtain results with a minimal error, the sensor requires an area of no less than 0.5 m2 and a smooth surface [8]. Ultrasonic distance sensors are susceptible to surrounding noise, and their low sampling rate makes them suboptimal when applied in high speeds [2].

2.4 Linear Actuator

The linear actuator used is the 7230 R010 from Sonceboz[9]. It contains a compact Tin-Can motor (stepper motor) and a screw-nut system. The screw-nut system inside the stator enables the actuator to use the rotation of the motor to create both an axial and a linear movement of the stator along the screw. Each step the motor takes creates a movement of 0.0254 mm, and the stator can move a total of 76.2 mm along the screw. It has a voltage of 12 V , a phase resistance of 25 ohms and a maximum force of 116 N.[10]

8

(20)

2.4. LINEAR ACTUATOR

2.4.1 H-Bridge

To control the rotational direction and speed of a stepper motor an H-bridge can be used. The H-bridge does this by controlling the supplied current, it can be used to regulate when current pulses are applied, in which direction the current will flow, and its pulse ratio. This project uses the L298 dual H-bridge, it has a drive voltage of 5-35V and a drive current of 2·2A, meaning it is compatible with the 12V needed for the linear actuator to function [11].

(21)
(22)

Chapter 3

Demonstrator

3.1 Problem Formulation

This demonstrator gives insight into the process of making an autonomous beverage dispenser to fulfill the purpose and answer the research questions of this project.

To construct a product that gives further insight into the research questions some points had to be considered throughout the process:

• How can the ultrasonic sensors be placed and programmed to interact and fill any glass with an appropriate level of liquid?

• How can the use of a linear actuator contribute to minimizing the error?

(23)

CHAPTER 3. DEMONSTRATOR

3.2 Hardware

Module 1

Arduino Uno

Module 2 12V Battery

12V battery

Linear Actuator H-bridge Ultrasonic Sensor

Ultrasonic Sensor Peristaltic Pump

5V Battery

Figure 3.1: A flowchart illustrating a hardware overview for the Autonomous Beverage Dispenser. Drawn in draw.io.

In figure 3.1 above, a hardware overview is shown for the autonomous beverage dispenser. The dotted lines and the filled in lines represent control signals and power supply respectively.

As displayed in figure 3.1 the hardware was separated into two modules for the construction of the demonstrator. The two modules were constructed to work as separate entities and then connected to create the final product. For example the peristaltic pump was connected to the US in module two to make the flow of liquid stop once the distance to an object was below a certain value. This simplified the process of making the product since there was always one functioning part before moving on and expanding the capabilities of the product. It also allowed testing of the components and seeing whether they were appropriate for the autonomous beverage dispenser without having to make modifications to every circuit and the software programmed for each component. The final circuit can be seen in Appendix B.

12

(24)

3.2. HARDWARE

Figure 3.2: Overview of the final demonstrator with components marked. Edited in Keynote.

3.2.1 3D printed parts

To make a housing for the demonstrator that was perfectly fitted to each component the parts were designed in Siemens Solid Edge ST9 and 3D-printed [12]. This allowed for a cheap method of making the product while making the positioning of the hardware components simple due to the precise measurements being decided while designing the housing. The 3D-printed housing can be seen in figure 3.2 above.

3.2.2 Ultrasonic Ranging Module

(25)

CHAPTER 3. DEMONSTRATOR As seen in figure 3.1 an US was used in both modules of this project. In module one the US continuously calculates the distance as the linear actuator raises the platform the glass is standing on. Once the top of the glass reaches the height of the US it reads a smaller distance to the nearest object, this leads to the linear actuator stopping and the height of the glass can be calculated. The US in module two is used to measure the liquid level inside the glass at all times, once the liquid level is 2.5 cm from the top of the glass the US stops the peristaltic pump. The distance between the ultrasonic sensors in module one and two is constant, this leads to an easier calculation of the liquid level inside the glass. Since the top of the glass is parallel to the US in module one, as can be seen in figure 3.3, the US in module two can have a set distance at which to stop the peristaltic pump, this is set at 2.5 cm from the top.

This setup of the sensors allows for measuring the level of liquid inside a glass independent from the geometry of the glass, and therefore answers the first research question: How can a combination of sensors determine the height of liquid in a glass independent of its geometry?

The HC-SR04 was chosen in this project for multiple reasons; the use of ultra- sound means that apart from seeing the sensor itself the user will not notice that something is being measured, where for example a laser would be noticeable. Its measuring range is as mentioned in Section 2.3.1, 2-400 cm, which is within the range necessary for this project.

3.2.3 Linear Actuator

To raise the platform with a glass on it, a linear actuator is used. Once the glass is placed on the platform and the user presses the button to start the beverage dispenser, the linear actuator starts to move upwards until the US detects the top of the glass and it has reached the correct height. After the glass is filled the platform is lowered to its original position. The linear actuator is mainly used because it can, as mentioned in Section 2.4, easily move the platform in a linear motion, handle a high force, and the stepper motor it uses enables an easy measurement of steps taken thus it can be programmed to reverse the same amount of steps and return to its original position once the process of filling the glass is complete.

3.2.4 H-bridge

Connecting the linear actuator to the Arduino Uno is the L298 dual H-bridge; the H- bridge enables control of the rotational direction of the linear actuator by regulating the direction in which the current flows. Since it assists in control of the rotational direction, the H-bridge makes the movement of the platform upwards and down possible. As mentioned in Section 2.4.1 the voltage and current necessary for the linear actuator to function is within the drive voltage of the L298, hence its use in the project.

14

(26)

3.2. HARDWARE

3.2.5 Peristaltic Pump

Filling the glass with liquid is done using the peristaltic pump. When the glass is at the correct height as measured by the US in module one, the peristaltic pump starts filling the glass until the US in module two measures an appropriately filled glass.

The low flow-rate of the peristaltic pump mentioned in Section 2.2 is advantageous in this project as it makes for a smoother surface inside the glass which, as seen in Section 2.3.1, minimizes the error of the liquid level measured by the US. To enable the control of the peristaltic pump a transistor is used, which in operation with Arduino Uno can enable or disable current flow through the circuit.

(27)

CHAPTER 3. DEMONSTRATOR

3.3 Software

In Section 1.1 the definition of an autonomous system was introduced and for the system to operate without interference of a user there has to be an operating system that drives on different inputs from the ultrasonic sensors. The main component that can process the inputs is the Arduino Uno in which the code is implemented.

The programming is accomplished in the Arduino software environment and the complete code is found in Appendix A.

Figure 3.4: A flowchart illustrating the actions of the software in different stages of the system. Drawn in draw.io.

The flowchart in figure 3.4 describes the algorithm briefly and what is expected of the system from inputs of the ultrasonic sensors. When creating the software, the code connects the two modules into one operating system. As the first US detects an object within the given distance the first module stops and the code proceeds to the next module which operates till the second US identifies the liquid level within the given distance. At this point the linear actuator starts again and returns to its starting position.

16

(28)

Chapter 4

Results

To determine the accuracy of the liquid level the system provides, and thus gain an understanding of the quality delivered by the ultrasonic sensors, three experiments were conducted. Each experiment consisted of ten tests measuring errors in the system and the experiments were done twice with different sized glasses.

4.1 Experiments one and two

The first experiment examined the error regarding the height the platform was raised by the linear actuator before the US detected the glass. The desired height of the platform was measured and for each test the deviation between the desired height and the result was registered. From the ten tests conducted for each glass the standard deviation and the relative error in percent were calculated.

The second experiment had the platform at the desired height from test one and was used to determine the error in module two. For each test, the glass was filled until the US measured that the liquid level was 2.5 cm from the top of the glass. The liquid level was measured after each test and registered to calculate the standard deviation and the relative error of the experiment for each glass.

(29)

CHAPTER 4. RESULTS

1 2 3 4 5 6 7 8 9 10

Test number 65

65.5 66 66.5 67 67.5 68 68.5 69 69.5 70

Height [mm]

Accuracy of platform height, module 1 Measured height of platform Expected height of platform

(a)

1 2 3 4 5 6 7 8 9 10

Test number 58

58.5 59 59.5 60 60.5 61 61.5 62 62.5 63

Height [mm]

Accuracy of platform height, module 1 Measured height of platform Expected height of platform

(b)

1 2 3 4 5 6 7 8 9 10

Test number 21

22 23 24 25 26 27 28 29

Distance from the top of the glass

Accuracy of liquid level, module 2 Measured liquid height Expected liquid height

(c)

1 2 3 4 5 6 7 8 9 10

Test number 21

22 23 24 25 26 27 28 29

Distance from the top of the glass

Accuracy of liquid level, module 2 Measured liquid height Expected liquid height

(d)

Figure 4.1: The results of experiments one and two. All graphs created in Matlab.

(a) Graph showing the accuracy of the height glass number one was raised. (b) Graph showing the accuracy of the height glass number two was raised. (c) Graph showing the water level filled in glass number one. (d) Graph showing the water level filled in glass number two.

Experiment 1.1 Experiment 1.2 Experiment 2.1 Experiment 2.1

Standard deviation 0.8756 0.9661 1.7029 1.5239

Relative error [%] -1.3235 -2.2581 -1.2000 4.4000

Table 4.1: Relative error and standard deviation for the first two experiments, with the decimal number representing the glass used.

The results for experiment one and two are displayed in figure 4.1 and the cal- culated standard deviation and relative error are presented in table 4.1. Evaluating these results can aid in determining the suitability of the ultrasonic sensors for their

18

(30)

4.2. EXPERIMENT THREE

respective functions, and therefore aid in finding a conclusion to the research ques- tion: How can a combination of sensors determine the height of a glass and the level of liquid in it?

4.2 Experiment three

In the third experiment the entire system was run through to measure the liquid level and accuracy obtained as a result of the errors from the two ultrasonic sensors and other factors in the system as a whole. The desired liquid level was 2.5 cm from the top of the glass.

1 2 3 4 5 6 7 8 9 10

Test number 21

22 23 24 25 26 27 28 29

Distance from the top of the glass [mm]

Accuracy of the system

Measured liquid height Expected liquid height

(a)

1 2 3 4 5 6 7 8 9 10

Test number 21

22 23 24 25 26 27 28 29

Distance from the top of the glass [mm]

Accuracy of the system

Measured liquid height Expected liquid height

(b)

Figure 4.2: The results of experiment three. Both graphs created in Matlab. (a) Graph showing the water level filled in glass number one. (b) Graph showing the water level filled in glass number two.

Experiment 3.1 Experiment 3.2 Standard deviation 2.1213 2.1187

Relative error [%] 2.000 2.4000

(31)
(32)

Chapter 5

Discussion and conclusions

The results show that the project was successful in constructing a functioning bev- erage dispenser that with certain errors achieves the desired task of autonomously filling a glass with liquid.

Answering the first research question, How can a combination of sensors deter- mine the height of liquid in a glass independent of its geometry? required research into different sensors. This was necessary to determine which ones were appropriate and concluding which method to use to make these sensors work together to achieve the desired result. After researching several methods of measuring distance the US, HC-SR04, was ultimately decided upon due to the qualities named in Section 3.2.2.

The combination of ultrasonic sensors and the linear actuator created a simple yet effective method to determine the correct liquid level in the glass. When consider- ing the setup of the linear actuator with the US that detects the top of the glass having the platform be stationary and instead moving the US to detect the height was considered. However, due to the literature research revealing that the US is sensitive to movement and would give less accuracy to the system, this method was ruled out. Instead both sensors were decided to be stationary, with the platform being raised until the US in module one detects the top of the glass followed by the second US measuring the liquid level till the correct level was obtained. Despite the adaptability provided by this setup regarding different glass geometries; there is a restriction dependent on the shape of the surface that reflects the ultrasonic

(33)

CHAPTER 5. DISCUSSION AND CONCLUSIONS glass closer to the mouth of the tube, minimizing the error of the measurements by the US. During the first iteration of conducting the experiments to analyze the results it was discovered that the US that measures the liquid level gave some large errors sporadically. To compensate for this, a check case was implemented in the code. The check case ensured that the pump did not stop because of a faulty measurement, to stop the pump the US had to detect two distances within the specified range in a row.

The results from the experiments shown in Chapter 4 display how different ge- ometries of a glass affect the accuracy of the system. This answers the research question: With what accuracy can the system fill the glass with liquid? The small variations to the standard deviation and the relative error shown in table 4.2, demon- strate an adaptability within the system, supporting the claim to it being an au- tonomous system. From table 4.1 it can be concluded that the module having the larger impact on the accuracy of the system is module two. An improvement to the sensor in module two would therefore be the most beneficial to the system.

Despite the possibility of improving the system the finished demonstrator is a functioning autonomous system that always produces a result within a 4 mm range from what is desired.

22

(34)

Chapter 6

Future improvements

This bachelor thesis has resulted in a successfully working system, which is able to fill different cups with a certain level of liquid. The results of the experiments reveal that there are some errors that can be minimized by making improvements to the system; this chapter will discuss both potential improvements and future work of this system.

6.1 Recommendations

The overall performance of the system satisfied the expected results based on the research made in Chapter 2, however there are additional improvements that can be done to the system as a whole.

To make the prototype more useful and adaptable, one should consider imple- menting a peristaltic pump which has a higher flow rate. In this project, a literature study was conducted to choose hardware components such as the US. However, the choice of sensors should be based on both a literature research but also by testing how their performance is suited for this purpose. This could contribute to under- stand how the errors are changing with different sensors and thus choose the most appropriate ones for this purpose.

(35)

CHAPTER 6. FUTURE IMPROVEMENTS surements. This could be done by implementing a platform for a smartphone in which the system is controlled by a Bluetooth device connected to the Arduino.

24

(36)

Bibliography

[1] D. P. Watson and D. H. Scheidt, “Autonomous systems,” Johns Hopkins APL technical digest, vol. 26, no. 4, pp. 368–376, 2005.

[2] S. Shin, M.-H. Kim, and S. B. Choi, “Improving efficiency of ultrasonic distance sensors using pulse interval modulation,” in SENSORS, 2016 IEEE, pp. 1–3, IEEE, 2016.

[3] Arduino, “arduino uno,” cited 2018-02-12. https://store.arduino.cc/

arduino-uno-rev3.

[4] Electrokit, “V¨atskepump peristalisk 12v silikonslang,” cited 2018-02-12. http:

//www.electrokit.com/vatskepump-peristalisk-12v-silikonslang.

51119/.

[5] J. Klespitz and L. Kov´acs, “Peristaltic pumps - a review on working and control possibilities,” in Applied Machine Intelligence and Informatics (SAMI), 2014 IEEE 12th International Symposium on, pp. 191–194, IEEE, 2014.

[6] Nationalencyklopedin, “ultraljud,” cited 2018-02-12. http://www.ne.se/

uppslagsverk/encyklopedi/enkel/ultraljud.

[7] R. N. Tutorials, “Complete guide for ulstrasonic sensor hc- sr04,” cited 2018-04-03. https://randomnerdtutorials.com/

complete-guide-for-ultrasonic-sensor-hc-sr04/.

[8] ElecFreaks, “Ultrasonic ranging module hc-sr04,” cited 2018-02-09.

(37)

BIBLIOGRAPHY [12] P. Siemens, “Software. solid edge st9,” 2018-05-15. https://solidedge.

siemens.com/en/.

26

(38)

Appendix A

Arduino Code

/ Univers ity : Royal I n s t i t u t e of Technology , KTH

Course : MF133X, Degree Project in Mechatronics

TRITA number : ITM≠EX 2018:52

Authors : Daniel Brun and San Khaffaf

Name of the program : CMAST15

Name of the p r o j e c t : Autonomous beverage d i s p e n s e r F i n a l i z e d : 2018≠05≠09

This code i s used to c o n t r o l the two modules ,

making i t p o s s i b l e to adjust the height of the platform and f i l l the g l a s s with l i q u i d . First , the platform w i l l

r a i s e t i l l the US d e t e c t s the g l a s s . This t r i g g e r s the next module to s tart , which w i l l s t a r t the pump that w i l l f i l l the g l a s s with a s e t l e v e l of l i q u i d . When f i n i s h e d with that , the platform w i l l lower down to i t s i n i t i a l i z e d s t a t e .

/

//≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠

(39)

APPENDIX A. ARDUINO CODE // I n i t i a l i z e d pins f o r module 1

const i n t triggerPinMod1 =2;

const i n t echoPinMod1=3;

const i n t stepsPerRevolution = 50;

// I n i t i a l i z e d data types long distanceMod1 ;

long distanceMod2 ; long pre distanceMod2 ; long duration ;

i n t stepCounter = 0 ; i n t a n t a l s t e g ; i n t i ;

// I n i t i a l i z e the stepper l i b r a r y on pins 8 through 11:

#i n c l u d e <Stepper . h>

Stepper myStepper ( stepsPerRevolution , 8 , 9 , 10 , 1 1 ) ; // I n i t i a l i z e d pins f o r module 2

const i n t motorPin =4; // Pin that turn on the motor const i n t triggerPinMod2 =5;

const i n t echoPinMod2=7;

//≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠

/ In t h i s s e c t i o n we w i l l do a l l the setup f o r the pins that are being used .

/

void setup ( ) {

myStepper . setSpeed ( 6 0 ) ; // Set the speed at 60 rpm

pinMode ( triggerPinMod1 ,OUTPUT) ; // Sets pin 8 , t r i g g e r , to an output pinMode ( echoPinMod1 ,INPUT ) ; // Sets pin 7 , echo , to an input

S e r i a l . begin ( 1 2 0 0 ) ;

pinMode ( motorPin , OUTPUT) ; // Pin 4 to c o n t r o l the t r a n s i s t o r pinMode ( triggerPinMod2 ,OUTPUT) ; // Sets pin 8 , t r i g g e r , to an output pinMode ( echoPinMod2 ,INPUT ) ; // Sets pin 7 , echo , to an input

S e r i a l . begin ( 1 2 0 0 ) ; }

//≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠

28

(40)

/ This i s tha main function , whitch c a l l s f o r the sub≠functions that w i l l execute the a c t i o n s .

/

void loop ( ) {

i n t a n t a l s t e g = r a i s e P l a t t f o r m ( ) ; // Module 1

f i l l G l a s s ( ) ; // Module 2

i n t a n t a l s t e g s l u t = lowerPlattform ( a n t a l s t e g ) ; // Module 1

while (1) { // I n f i n i t y loop

} }

//≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠

/ This s e c t i o n s w i l l r a i s e the platform t i l l the US d e t e c t s an o b j e c t ( the g l a s s ) . The d i s t a n c e are measured in ”mm” .

We w i l l run a while≠loop t i l l the v a r i a b e l ” found ” change

i t s s t a t e to True , which i t w i l l do i f the d i s t a n c e measured by the US i s l e s s than 50mm. A counter v a r i a b l e i s implemented which w i l l add f i v e each time the stepper motor takes on step . This v a r i a b l e i s used in a l a t e r f u n c t i o n .

/

i n t r a i s e P l a t t f o r m ( ) { found = False ;

while ( found==False ){

d i g i t a l W r i t e ( triggerPinMod1 ,HIGH) ;

(41)

APPENDIX A. ARDUINO CODE found = True ;

return stepCounter ; }e l s e {

myStepper . step(≠stepsPerRevolution ) ; stepCounter = stepCounter + 5 ;

} } }

//≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠

/ This s e c t i o n w i l l f i l l the g l a s s as soon as the s e c t i o n above ( f u n c t i o n : r a i s e P l a t t f o r m ) i s f i n i s h e d . The code i s s i m i l a r to the one above , but with the exception that we are c o n t r o l l i n g a DC motor ( the pump) and not a stepper motor .

The while≠loop w i l l run t i l l the s t a t e of the varable ” found ” i s changed to True . I t turns True i f the d i s t a n c e to the

l i q u i d l e v e l i s equal or l e s s than 47mm. There i s a f i l t e r

implemented to avoid random e r r o r s in the measurment made by the US.

/

void f i l l G l a s s (){

delay ( 1 0 0 0 ) ; found = False ;

while ( found==False ){

d i g i t a l W r i t e ( triggerPinMod2 ,HIGH) ; delayMicroseconds ( 1 0 0 0 0 ) ;

d i g i t a l W r i t e ( triggerPinMod2 ,LOW) ; duration=pulseIn ( echoPinMod2 ,HIGH) ; distanceMod2=duration 0 . 3 4 / 2 ;

pre distanceMod2 = distanceMod2 ; distanceMod2=duration 0 . 3 4 / 2 ; S e r i a l . p r i n t (” Distance2 : ” ) ; S e r i a l . p r i n t l n ( distanceMod2 ) ; S e r i a l . p r i n t (” Distance21 : ” ) ; S e r i a l . p r i n t l n ( pre distanceMod2 ) ;

i f ( pre distanceMod2 <47 && distanceMod2 <47){ // Two d i s t a n c e s

// in a row must s a t i s f y d i g i t a l W r i t e ( motorPin , LOW) ; // Turn o f f the motor

30

(42)

found = True ; return ;

}e l s e {

d i g i t a l W r i t e ( motorPin ,HIGH) ; // Turn on the motor }

} }

//≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠

/ This s e c t i o n i s the l a s t one , which w i l l lower the platform as soon as the s e c t i o n where the g l a s s i s f i l l e d i s f i n i s h e d . In the s e c t i o n where we r a i s e the platform a counter i s

implemented where i t adds f i v e each step the stepper motor takes . So t h i s f u n c t i o n w i l l decrease the counter by f i v e each

step the stepper motor takes in r e v e r s e .

When i t reaches zero t h i s f u n c t i o n w i l l stop and return . /

i n t lowerPlattform ( i n t a n t a l s t e g ){

while ( a n t a l s t e g >0){

myStepper . step ( stepsPerRevolution ) ; a n t a l s t e g= a n t a l s t e g ≠ 5;

}return a n t a l s t e g ; }

//≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠≠

(43)
(44)

Appendix B

Schematic Diagram

(45)

TRITA ITM-EX 2018:52

www.kth.se

References

Related documents

Generally, a transition from primary raw materials to recycled materials, along with a change to renewable energy, are the most important actions to reduce greenhouse gas emissions

För att uppskatta den totala effekten av reformerna måste dock hänsyn tas till såväl samt- liga priseffekter som sammansättningseffekter, till följd av ökad försäljningsandel

The increasing availability of data and attention to services has increased the understanding of the contribution of services to innovation and productivity in

Av tabellen framgår att det behövs utförlig information om de projekt som genomförs vid instituten. Då Tillväxtanalys ska föreslå en metod som kan visa hur institutens verksamhet

Generella styrmedel kan ha varit mindre verksamma än man har trott De generella styrmedlen, till skillnad från de specifika styrmedlen, har kommit att användas i större

Parallellmarknader innebär dock inte en drivkraft för en grön omställning Ökad andel direktförsäljning räddar många lokala producenter och kan tyckas utgöra en drivkraft

Närmare 90 procent av de statliga medlen (intäkter och utgifter) för näringslivets klimatomställning går till generella styrmedel, det vill säga styrmedel som påverkar

I dag uppgår denna del av befolkningen till knappt 4 200 personer och år 2030 beräknas det finnas drygt 4 800 personer i Gällivare kommun som är 65 år eller äldre i