• No results found

Automatic Wire Cutter

N/A
N/A
Protected

Academic year: 2022

Share "Automatic Wire Cutter"

Copied!
67
0
0

Loading.... (view fulltext now)

Full text

(1)
(2)

(3)

Automatic Wire Cutter

Bachelor’s Thesis in Mechatronics

PHILIP HAMILTON RASMUS HOLMSKOV

Bachelor Thesis at ITM Examiner: Nihad Subasic

TRITA-ITM-EX 2019:19

(4)

(5)

Abstract

This bachelor thesis project in mechatronics involved mak- ing a working prototype of an automatic wire cutter and evaluating its accuracy. The accuracy of the machine was increased by analysing measurements of the machine’s ini- tial precision and thereafter performing a calibration to di- minish the effect of unwanted errors. Before calibration the machine’s accuracy was ± 0.73 cm and after calibration it was calculated to be ± 0.06 cm in its intended operating range of 5-20 cm. The main limitations of the machine’s ac- curacy were determined to be slippage in the feeding mech- anism, the mathematical model that was used, the step res- olution of the stepper motors, the offset between the blades in the cutting mechanism as well as the wires bending when being fed.

Keywords: Thesis, mechatronics, electronics, automatic, wire, cutter, accuracy

(6)

Referat

Automatisk kabelklippare

I detta kandidatexamnesarbete inom mekatronik designa- des och tillverkades en fungerande prototyp av en automa- tisk kabelklippare, och dess noggrannhet unders¨oktes se- dan. Maskinens noggrannhet f¨orb¨attrades genom att f¨orst unders¨oka maskinens ursprungliga noggrannhet och d¨arefter kalibrerades maskinen f¨or att minska effekten av o¨onskade fel. F¨ore kalibrering var maskinens noggrannhet ± 0,73 cm och efter˚at r¨aknades den ut att vara ± 0,06 cm i dess tillt¨ankta driftintervall p˚a 5-20 cm. De huvudsakliga be- gr¨ansningarna f¨or maskinens noggrannhet visade sig vara glidning i matningsmekanismen, den matematiska model- len, stegmotorns steguppl¨osning, avst˚andet mellan bladen i klippmekanismen samt att kablarna b¨ojer sig under fram- matning.

Nyckelord: Examensarbete, mekatronik, elektronik, au- tomatisk, klippa, kablar, noggrannhet

(7)

Acknowledgements

We would like to thank everyone who has been involved in our project and helped us along the way, as well as our friends and family for supporting us. A special thanks goes out to the assistants at the KTH Prototype Center who helped us when operating their machines. We would also like to thank Staffan Qvarnstr¨om who supplied us with motors and helped us with ordering our components. Lastly a huge thanks to Seshagopalan Thorapalli Muralidharan who guided us with his knowledge and helped us with troubleshooting.

(8)

Contents

1 Introduction 1

1.1 Background . . . 1

1.2 Purpose . . . 1

1.3 Goals, scope and delimitation . . . 1

1.4 Benefits, Ethics and Sustainability . . . 2

1.5 Methodology . . . 2

2 Theoretical background 4 2.1 Electronics . . . 4

2.1.1 Liquid Crystal Display . . . 4

2.1.2 Rotary Encoder . . . 4

2.1.3 Microcontroller . . . 4

2.1.4 Stepper motor . . . 4

2.1.5 Stepper motor driver . . . 5

2.1.6 Limit switch . . . 5

2.2 Mechanical components . . . 5

2.2.1 Additive manufacturing . . . 5

2.2.2 Bearings . . . 5

2.2.3 Conversion from rotation to translation . . . 6

3 Demonstrator 7 3.1 Electronics . . . 7

3.1.1 Schematic . . . 7

3.1.2 Milled circuit board . . . 7

3.1.3 Electronics enclosure . . . 8

3.1.4 User interaction system . . . 9

3.2 Software . . . 10

3.2.1 Menu . . . 10

3.2.2 Machine instructions . . . 11

3.3 Feeding Mechanism . . . 12

3.3.1 Arm . . . 13

3.3.2 Rollers . . . 13

3.3.3 Spring and spring holder . . . 13

(9)

3.4 Cutting Mechanism . . . 14

3.4.1 Bottom part . . . 14

3.4.2 Carriage . . . 15

3.4.3 Top part . . . 15

3.5 Wire holder and wire guides . . . 15

3.6 Back plate . . . 16

3.7 Finished prototype . . . 18

4 Measurements 19 4.1 Calibration . . . 19

4.2 Final measurements . . . 21

5 Results 23 6 Discussion and conclusion 24 6.1 Discussion . . . 24

6.1.1 Design flaws . . . 24

6.1.2 Validity of the results . . . 24

6.2 Conclusion . . . 25

7 Improvements and future work 26 7.1 Improvements . . . 26

7.2 Future work . . . 26

Bibliography 27 Appendices 28 A Arduino Code 29 A.0.1 Motor class . . . 51

B Measured data 54

(10)

List of Figures

3.1 Schematic of all the electric components . . . 7

3.2 The MCB design . . . 8

3.3 Left and top view of the electronics enclosure, without the lid . . . 9

3.4 Right view of the electronics enlcosure . . . 9

3.5 The user interaction system . . . 10

3.6 All the different menu screens . . . 11

3.7 Flowchart . . . 12

3.8 CAD model of the feeding mechanism . . . 13

3.9 CAD model of the cutting mechanism . . . 14

3.10 Wire holder and spool . . . 15

3.11 The two different kinds of wire guides . . . 16

3.12 The backplate . . . 17

3.13 Front view . . . 18

3.14 Back-side view . . . 18

4.1 Visualisation of the measurements done as basis for calibration . . . 20

4.2 Linear approximation of the error through linear regression . . . 21

4.3 Visualisation of the measurements after calibration . . . 22

(11)

List of Tables

4.1 Roller diameter data. . . 19

4.2 Measurements data used as a basis for calibration. . . 20

4.3 Accuracy measurement data . . . 22

B.1 Calibration data . . . 54

B.2 Accuracy data . . . 54

(12)

List of abbreviations

3D Three-dimensional CAD Computer-Aided Design CNC Computer Numerical Control DC Direct Current

FDM Fused Deposition Modeling

GPIO General Purpose Input and Output GUI Graphical User Interface

KTH Kungliga Tekniska H¨ogskolan (Royal Institute of Technology) LCD Liquid Crystal Display

LED Light Emitting Diode

M3 ISO metric standard for nuts and screws MCB Milled Circut Board

MCU MicroController Unit

(13)

1. Introduction

1.1 Background

When mass producing a product, accuracy is crucial to make sure that the end product turns out the same every time. Companies often spend a vast amount of money and resources to achieve this with high-tech devices. When making projects at home one might be faced with the same problem as companies when mass pro- ducing, although on a smaller scale. For many hobby projects one will be required to repeat the same tiresome task over and over, for example wire cutting, and when doing this by hand it can be hard to repeat the task quickly and still maintain accuracy. Therefore, what is attempted in this project is to create a small, cheap, high precision wire cutting machine that can automatically cut a large amount of cables to a desired length.

1.2 Purpose

The purpose of this degree project is to design and construct an automated wire cutting machine for a relatively low cost and evaluate the precision of the machine.

To narrow down the evaluation, two concrete research questions are to be answered in the thesis project:

• How high precision does the machine achieve?

• What limits the precision of the machine?

1.3 Goals, scope and delimitation

The main goal of the project is to construct a fully functioning prototype of an automatic wire cutter to take measurements from so that the research questions stated in subsection 1.2 can be answered.

Apart from answering the research questions, goals for the functionality and design of the machine were also set. The machine should have the following functions:

• An interactive user interface

• An option for the user to decide wire length

• An option for the user to decide the number of wires that the machine should cut

• Be able to handle a wide range of wire diameters

• Be compact

(14)

CHAPTER 1. INTRODUCTION

The project is delimited to only use commercially available tools and materials. The scope of the project is set by the limitation in budget and deadline for the project.

The budget is set by the funds provided by KTH, as well as the materials and tools available in the KTH labs.

1.4 Benefits, Ethics and Sustainability

One of the benefits to making a high precision machine is that the waste in form of material loss can be reduced, another is that it will save the user time and work.

This is preferable in both an economic, enviromental and time consumption aspect.

There are no major ethical problems directly related to this project, although one could argue the ethics of automation has to be considered. Large scale automation of traditional manual labour gives rise to questions about how to tackle the job displacement caused by the automation, however, that is far out of the scope of this degree project [1]. The prototype developed in this project is not meant to be mass produced or applied in any large scale operations and will therefore not displace any jobs.

1.5 Methodology

The first step was to research related topics and try to identify the main limitations of the machine and how to handle them.

The next step was to come up with the design of the first prototype. This was done by identifying the key components of the machine and determining the re- quirement specification for each component. Four key components were identified in this process:

• Cutting mechanism - A mechanism that cuts the wires

• Feeding mechanism - A mechanism that feeds the wire into the cutting mech- anism

• Wire guides - Something to guide the wires into the cutting- and feeding mechanism

• User interaction system - A system that allows the user to interact with the machine

When the key components were identified, models were designed with Computer- Aided Design (CAD) in the software Autodesk Fusion 360. The required parts such as motors, switches, rods and bearings were then ordered and the other designed components were 3D printed. Everything was then assembled according to the CAD-models. The completion of a first iteration of the prototype was given high priority so that possible problems with the mechanical design could be discovered in

(15)

CHAPTER 1. INTRODUCTION

could be tested with the rest the of the design to make sure that the design concept worked as intended.

When designing the menu for the user interaction system the online software Tin- kerCad was used which is an online Arduino simulator. This enabled testing of the Graphical User Interface (GUI) without the need for physical components.

With the first iteration complete, the flaws and problems were identified such as vibrations in the cutting mechanism. With this in mind, an improved design was made.

(16)

2. Theoretical background

To aid the reader in understanding the technical report, this chapter will introduce and explain theory related to the topic and field of study which can not be considered common knowledge.

2.1 Electronics

2.1.1 Liquid Crystal Display

A Liquid Crystal Display (LCD) is a flat panel display which has pixels that are arranged in a rectangular pattern, these pixels can be controlled individually to display text or images. The display used in this project contains a blue background and white pixels. Each pixel can be lit individually which is used to display images and text [2]. If a pixel is turned off it appears blue and if the pixel is turned on it appears white.

2.1.2 Rotary Encoder

A rotary encoder is a rotatable switch with a built in shaft that can detect and convert rotational motion, i.e the angular position of the shaft, to an analogue or digital output signal [3].

2.1.3 Microcontroller

A microcontroller is a small computer which is used in embedded systems, it can be programmed to do certain tasks and it has a variety of applications, it is used in everything from controlling Light Emitting Diodes (LEDs), to robots [4]. The MicroController Unit (MCU) used in this project is an Arduino Uno, it has multiple General Purpose Input/Output (GPIO) pins which enable easy connection to other components and it has 32 kB of programmable memory. It is programmed using the language C++ and has its own Integrated Development Environment (IDE) which makes it easy to use [5]. It also offers I2C communication which is used to easily communicate with other devices such as LCDs [6].

2.1.4 Stepper motor

A stepper motor is a high precision motor, the precision of the motor comes from the small steps each full revolution is divided into. This allows for an estimate of the shaft position to be made, which makes it easy to repeat certain movements and rotate the motor shaft to a desired position. [7]. The motor used in this project was a bipolar stepper motor, in order to drive this type of motor a separate driving circuit has to be used.

(17)

CHAPTER 2. THEORETICAL BACKGROUND

2.1.5 Stepper motor driver

Stepper motor drivers come in different configurations, their purpose is to enable accurate positioning and control of stepper motors. One of their features is that they consist of two H bridge circuits that changes the polarity of the voltage applied to the load. This enables the stepper motors to step both clockwise and anti-clockwise.

The rotational angle and speed is controlled by pulses from a micro controller [8].

The stepper motor driver used in this project was a Polulu A4988.

2.1.6 Limit switch

A limit switch is a momentary switch which has two possible initial states, normally open or normally closed which describes its state if it is not pushed. In normally open, the switch is open and no current will be able to flow, normally closed is the opposite. These switches are often used to limit movement of mechanical com- ponents by sending feedback to a microcontroller who controls the machine, this technique is commonly used in 3D-printers [9].

2.2 Mechanical components

2.2.1 Additive manufacturing

Most of the components for the prototype in this project has been made with addi- tive manufacturing. Additive manufacturing, sometimes referred to as 3D-printing, is a manufacturing process based on using computer generated 3D-models to man- ufacture a physical part by adding layers of material onto one another [10]. Al- though 3D-printing and additive manufacturing are sometimes used synonymously, 3D-printing is actually a subset of additive manufacturing. When using additive manufacturing, excess use of material can be largely avoided compared to for exam- ple milling or casting, and it can also make it easier to manufacture complex shapes.

These properties make 3D-printing great for fast manufacturing of prototypes.

During recent years 3D-printers for small scale polymer models have become more commercially available [11]. The most commonly used 3D-printing technique in commercial printers is called Fused Deposition Modeling (FDM).

2.2.2 Bearings

When dealing with moving parts with rough finishes it might be desirable to lower the friction between them. Bearings are mechanical components used to lower the friction between moving components, and they come in many different models and sizes. Commonly used bearings are for example ball bearings, sliding bearings also known as linear ball bearings [12]. The choice of bearings depends on the applications, loads and operating speeds.

(18)

CHAPTER 2. THEORETICAL BACKGROUND

2.2.3 Conversion from rotation to translation

The feeding mechanism will have to convert rotation motion to translating motion which requires some calculations. In this application, it is important to know how many motor steps n is needed to feed a wire of length Lw. If one motor step is equal to an angle it means that there are nf = 360 steps in one full revolution. From this it can be derived that the length Ln of one step is the circumference of a full circle with the radius r divided by the number of steps in a full revolution, that is

Ln= 2fir

nf (2.1)

Now the number of motor steps needed to feed a wire of length Lw can be calculated as

n= Lw

Ln = Lw

2fi ·nf (2.2)

(19)

3. Demonstrator

3.1 Electronics

3.1.1 Schematic

A schematic was created to get a graphical visualisation of how all the electrical components should be connected to each other. This was done with the help of the software Fritzing. Fritzing is an open-source CAD software used to create schematics and circuit board designs. The created schematic is shown in Figure 3.1.

Figure 3.1. Schematic of all the electric components [13].

Since there were a lot of connections to the Arduino it seemed impractical to have it on a breadboard, therefore it was decided to create a custom circuit board instead.

The software Eagle was used to design the circuit board.

3.1.2 Milled circuit board

To make the circuitry more compact a Milled Circuit Board [MCB] was designed as a shield for the Arduino. A shield is a circuit board that fits on top of the Arduino and connects directly to its GPIO pins eliminating the use of excess wire. The created MCB is shown in Figure 3.2.

(20)

CHAPTER 3. DEMONSTRATOR

Figure 3.2. The MCB design [14].

The MCB is made by a fibreglass plate with a thin layer of copper on both sides.

Due to all the connections that are required, both sides were used when creating the board. The colour of the tracks in Figure 3.2 shows which side they are on, red indicates the top layer of the board and blue indicates the bottom layer. These tracks were milled by a machine using Computer Numerical Control (CNC). A CNC-machine is a machine which operates after user specified instructions without the need of a manual operator.

3.1.3 Electronics enclosure

An enclosure was designed and 3D-printed to accommodate all the electronics. The enclosure was designed to hold the Arduino Uno and the MCB in place, as well as to hide the cables. A power button which controls the power to the electronics was connected to a female Direct Current (DC) jack placed on the side of the enclosure so that the machine can be powered from a regular power outlet. The enclosure is shown in Figure 3.3 and 3.4.

(21)

CHAPTER 3. DEMONSTRATOR

Figure 3.3. Left and top view of the electronics enclosure, without the lid [15].

Figure 3.4. Right view of the electronics enlcosure [15].

3.1.4 User interaction system

The user interaction system is shown in Figure 3.5 and consists of a liquid crystal display and a rotary encoder. The rotary encoder is used to create inputs for the machine while the display gives visual feedback to the user. The system is mounted on a piece of plywood which is connected to the back plate with the help of 3D- printed hinges which are also shown in Figure 3.5.

(22)

CHAPTER 3. DEMONSTRATOR

Figure 3.5. The user interaction system [15].

3.2 Software

3.2.1 Menu

The menu is divided into two main modes: Manual and Automatic. Visual repre- sentations of the menus are shown in Figure 3.6.

(23)

CHAPTER 3. DEMONSTRATOR

Figure 3.6. All the different menu screens [16].

3.2.2 Machine instructions

When choosing to let the machine run automatically the user first has to input the desired wire length and quantity. Thereafter the machine operates according to the flowchart shown in Figure 3.7

(24)

CHAPTER 3. DEMONSTRATOR Start

Quantity = 0? End

Feed desired length

Cut the cable

Quantity - 1

Yes

No

Figure 3.7. Flowchart [17].

When the cables have been cut the machine returns to its home position and waits for the user to give it a new set of instructions.

3.3 Feeding Mechanism

The purpose of the feeding mechanism is to feed a desired length of wire to the cutting mechanism. The feeding mechanism is composed of two rollers, a stepper motor, a spring, a spring holder, and an arm. All of the components are then attached to a back plate using M3 screws and nuts. The main components are shown in Figure 3.8.

(25)

CHAPTER 3. DEMONSTRATOR

Figure 3.8. CAD model of the feeding mechanism [15].

3.3.1 Arm

The arm is of a fairly simple design. It is attached to the back plate in one end which allows it to pivot up and down, and in the other end the upper roller and the spring is attached. The upper roller sits on a fixed shaft perpendicular to the arm, that has a 608-Z ball bearing attached to it, so that the roller can revolve freely [12].

3.3.2 Rollers

As mentioned above the mechanism has two rollers. The rollers were designed to have a slight equal and opposite curvature so that when placed on top of each other they fit together and keep the wire in place.

The bottom roller was attached to the stepper motor via a shaft coupling since the length of the motor shaft is only 7 mm long, which was insufficient.

Since the material of the rollers does not have very high surface friction it was needed to increase the friction to avoid slippage. Additional friction was achieved by gluing thin sheets of rubber onto the surface of the rollers.

3.3.3 Spring and spring holder

Another way the friction between the rollers was increased was by spring loading the arm where the roller is attached so that it pushes the upper roller down onto the bottom roller, thus increasing the normal and friction forces. Other than increasing

(26)

CHAPTER 3. DEMONSTRATOR

the friction, the spring loading also allows for wires of many different diameters to be fed through the rollers.

One end of the spring push was placed so that it pushes on the arm and the other end was held by a spring holder that was positioned on the back plate above the end of the arm. The spring holder was fastened with M3 screws and nuts into vertical slotted holes so that the tension of the spring could be adjusted by moving the holder up or down.

3.4 Cutting Mechanism

It was decided that the cutting mechanism was to function like a guillotine, with a stationary bottom and top part and a sliding carriage. A detailed description of its components is given in Figure 3.9.

Figure 3.9. CAD model of the cutting mechanism [15].

3.4.1 Bottom part

The bottom part is a stationary component which purpose is to hold a razor blade and act as an end stop for the carriage.

The bottom part is fastened to the two smooth rods with four M3 stops screws.

To make sure that the stop screws have strong threads that were not only made of plastic, slots were made, M3 nuts could be slid into. Stopping the carriage was achieved by incorporating a limit switch which outputs a signal to a microcontroller

(27)

CHAPTER 3. DEMONSTRATOR

when pressed, which then stops the movement of the motors. The razor blade is fastened with a lid that clamps the blade to the bottom part.

3.4.2 Carriage

The carriage is composed of two linear bearings, a lead screw nut, and a razor blade.

The linear bearings reduce friction between the carriage and the smooth rods that add stability and ensure that the system is limited to only one degree of freedom.

The razor blade is fastened in the same way as the razor blade in the bottom part, but offset so that they do not collide when cutting the wire.

The lead screw nut is attached to the carriage and screws down onto the lead screw.

A stepper motor is fastened to the bottom plate and is then connected to the lead screw so that when rotated it drives the carriage up or down.

3.4.3 Top part

The top part of the feeding mechanism is another stationary part whose role is to keep the carriage from moving too far up. It achieves this by using an identical limit switch as the bottom part.

3.5 Wire holder and wire guides

A wire holder and a spool were designed such that the wire being fed into the ma- chine could be stored somewhere during operation, see Figure 3.10

Figure 3.10. Wire holder and spool [15].

(28)

CHAPTER 3. DEMONSTRATOR

To guide the wire into the feeding mechanism two different wire guides were de- signed, see Figure 3.11. One wire guide redirects the wire so that it travels in a 90 angle from the wire holder to the feeding mechanism, and the other guides the wire into the feeding and cutting mechanism.

Figure 3.11. The two different kinds of wire guides [15].

3.6 Back plate

The back plate was designed with CAD and then laser cut from 6 mm thick ply- wood. To ensure that the construction stays rigid, two layers of plywood were glued together. The main feature of the back plate is to hold the other components in place, therefore all the holes needed for the screws were also laser cut according to a CAD-design which specifies the locations of the holes. This is visualised in Figure 3.12.

The back plate is composed of two parts, a bottom horizontal part and a vertical part that sits on top of the bottom part. The bottom and top part were fit together with glue and box joints that were laser cut.

(29)

CHAPTER 3. DEMONSTRATOR

Figure 3.12. The backplate [15].

(30)

CHAPTER 3. DEMONSTRATOR

3.7 Finished prototype

Figure 3.13. Front view [16].

Figure 3.14. Back view [16].

(31)

4. Measurements

When the working prototype was finished, measurements of the accuracy were taken, first to serve as a basis for calibration and then once more to answer the thesis re- search questions. All measurements were done using copper wires with a diameter of 1 mm.

4.1 Calibration

The first measurement that needed to be done was of the diameter of the driving roller in the feeding mechanism. This was needed because adding a layer of rubber onto the roller changed the diameter in an irregular way. The measurements were taken with the help of a caliper at pseudo random places along the circumference of the roller. The measurement data is shown in Table 4.1.

Measured diameter [mm]

1 36.2

2 36.4

3 36.6

4 37

5 36.1

6 36.2

7 36.4

Mean 36.41

Table 4.1. Roller diameter data.

After determining the diameter of the roller, a total of seven series of measurements, consisting of six measurements each, was done to determine the accuracy of the machine before calibration. The measurement series were performed as follows: a specific wire length was given as user input and three pieces of wire of that length were cut by the machine. Each piece of wire was then measured once by two different persons, and a mean of those two measurements was calculated. When all measurements were done, a mean of the whole series was calculated. This was then repeated for seven different wire lengths as machine input (see Table 4.2).

The absolute error for each series was then calculated and plotted against the input to examine how the error propagated, as shown in Figure 4.1.

(32)

CHAPTER 4. MEASUREMENTS

Input [cm] Mean [cm] Absolute error [cm]

5 4.74 0.26

8 7.58 0.42

10 9.58 0.41

12 11.48 0.52

15 14.22 0.78

20 18.76 1.24

30 28.51 1.49

Table 4.2. Measurements data used as a basis for calibration.

To get a sense of the overall accuracy of the machine the mean absolute error was calculated, which gave an accuracy of ± 0.73 cm before calibration [19].

Figure 4.1. Visualisation of the measurements done as basis for calibration [18].

When examining the graph in Figure 4.1, it was found that the error could be ap- proximated to be propagating linearly for inputs between 5-20 cm. Linear regression of the measurement data was used to find a linear approximation of the propagation [20], which can be seen in Figure 4.2.

(33)

CHAPTER 4. MEASUREMENTS

Figure 4.2. Linear approximation of the error through linear regression [18].

This linear approximation was then used to calibrate the machine by adding the approximated error to the input in an attempt to diminish the effects of the error.

In other words, for an input x, the length of wire l to be fed would now be

l= x + E = x(1 + 0.0651) ≠ 0.1534 (4.1)

4.2 Final measurements

After the machine had been calibrated, a more thorough analysis of its accuracy was done within its linear operating region (5-20 cm). Six series of measurements consisting of a total of 20 measurements each were performed (see Table 4.3). The measurement series were done in the same way as for the calibration. The error calculation was also done in the same way as before. The results were then plotted against the input, as shown in Figure 4.3, to see how it propagated after the machine had been calibrated.

(34)

CHAPTER 4. MEASUREMENTS

Input Mean [cm] Absolute error [cm]

5 5.03 0.03

8 7.99 0.01

10 9.94 0.06

12 12.02 0.02

15 14.83 0.17

20 19.94 0.06

Table 4.3. Accuracy measurement data

Figure 4.3. Visualisation of the measurements after calibration [18].

The mean absolute error of the machine was calculated to be ± 0.06 cm in the operating range of 5-20 cm [19].

(35)

5. Results

How high precision does the machine achieve?

The mean absolute error of the machine was calculated to be ± 0.06 cm in the operating range of 5-20 cm.

What limits the precision of the machine?

The limitations of the machine are mainly how precise it can feed and cut the wires. There are a lot of factors that can affect this. The limitations of the feeding mechanism are the mathematical model, slippage between the rollers and the step resolution of the stepper motor.

The limitations in the mathematical model behind the feeding mechanism are that it builds upon the assumption that the roller diameter is constant which is possible in theory but not in reality. Slippage occurs when the feeder loses grip of the cable due to the lack of friction. This happens mainly in the acceleration phases when the forces are at their greatest.

There are some sources of error in the cutting mechanism as well. When the wire is fed into the cutting mechanism it is not completely straight, it has some natural curvature to it which affects the length that is being cut. When cutting the wire there is a small offset between the razor blades which causes an error.

(36)

6. Discussion and conclusion

6.1 Discussion

6.1.1 Design flaws

During the construction and testing of the machine a few unexpected problems occurred, one of them was that the two razor blades used in the cutting mechanism were weaker than expected. This resulted in them bending when trying to cut thicker wire which caused the motor to stall. This also occurred after a while with thinner wire due to the razor blades were quickly wearing out. Another source of error was the feeding of the wire. Since the wire was fed from a spool it had some natural curvature to it when entering the feeder, which lead to the wire not travelling entirely straight. Wire guides were made to lead the wire into the cutting mechanism yet they proved insufficient, in some cases the bent wire curved away from the razor blades so that it missed the blades.

6.1.2 Validity of the results

According to the measurements and calculations done in this project the machine achieves excellent precision, but there are some things one should have in mind when reading the report.

Firstly, since the project was limited to only using the tools available, the only way of measuring the lengths of the wires was a normal ruler. The ruler used can not be guaranteed to be absolutely perfect and it also has a maximum measurement resolution of ± 0.5 mm, which sets a limit for how accurate the measurements can be. Other than instrumentation errors, errors introduced by human factors should also be considered.

The design of the measurements series also plays a role when trying to determine the accuracy, for example when the machine operates there is some amount of failures where the machine does not manage to cut the wires. Should such failures be considered as a length of zero millimetres, or should the measurement be scrapped?

In this project such measurements were scrapped, which in turn means that the stated accuracy only is applicable to a machine with a failure rate of zero percent, or in other words the calculated accuracy is correct when the machine is working as intended.

Lastly, the accuracy is given in a specific operating range which we deemed to be the most used range, therefore nothing can be said about the accuracy of the machine outside of this range. Due to economical and sustainability aspects more measurements were not done even though it might have given a more reliable result.

(37)

CHAPTER 6. DISCUSSION AND CONCLUSION

6.2 Conclusion

In conclusion, the accuracy stated in the results can not and should not be regarded as an absolute truth, although the conclusion is that the result gives a good estimate of the accuracy. When considering that the machine was intended for small scale hobby use, the achieved accuracy is very satisfactory. The limitations to the accu- racy that were found are not severe enough to have a large impact on the machine.

Even though the machine achieves a high precision when working as intended there is of possible future work to be done that can improve the design and the overall reliability of the machine.

(38)

7. Improvements and future work

7.1 Improvements

The improvements suggested in this section could possibly resolve the design flaws that were found.

The issues regarding the razor blades could be solved with stronger steel blades which would prevent the blades from bending and therefore prevent the motor from stalling. Changing to stronger blades would also reduce the wear on the blades.

A solution to the wire bending would be to install a wire straightening system to straighten the wire before entering the cutting mechanism.

7.2 Future work

A useful feature that was not implemented in this design is a wire stripper mecha- nism that removes the wire insulation. If an improved design for the cutting machine was to be implemented such a feature could probably be made for the current de- sign. The research questions in this project mainly regarded the accuracy of the machine, therefore it would be interesting to expand the research question to also cover the accuracy of the suggested wire stripping mechanism.

It could also be interesting to evaluate how well a filament feeder used in 3D-printers would work instead of the feeding mechanism used in this project. Such a solution would most likely prove to be more compact, and possibly more reliable.

(39)

Bibliography

[1] Carl Benedikt Frey, Michael A. Osbourne. ”The future of employment: How susceptible are jobs to computerisation?”, 29 September 2016. [Online]. Avail- able: https://doi.org/10.1016/j.techfore.2016.08.019. [Accessed, Feb, 12, 2019].

[2] TechTerms, ”LCD”, June 8, 2017. [Online]. Available: https://techterms.

com/definition/lcd [Accessed, Apr, 15, 2019].

[3] Techopedia, ”Incremental Rotary Encoder”, N.D. [Online] Available: https:

//www.techopedia.com/definition/9053/incremental-rotary-encoder [Accessed, Apr, 17, 2019].

[4] Margaret Rouse. ”microcontroller”, June 2017. [Online]. Available:

internetofthingsagenda.techtarget.com/definition/microcontroller [Accessed, Feb, 13, 2019].

[5] Yusuf Abdullahi Badamasi. The working principle of an Arduino”, 2014 11th In- ternational Conference on Electronics, Computer and Computation (ICECCO), 29 Sept.-1 Oct 2014, Abuja, Nigeria [Online]. Available: IEEE Xplore, https://

ieeexplore.ieee.org/document/6997578 DOI: 10.1109/ICCIC.2017.8524539.

[Accessed, May, 1, 2019].

[6] H. Johansson, P. Lindahl, R. Meyer, M. Grimheden, W. Sandqvist and M.

Paulson. ”Elektroteknik”, 2013 edition.

[7] Dynamic perception. ”What Is The Difference Between DC Motors And Stepper Motors?”, N.D. [Online]. Available:

https://support.dynamicperception.com/hc/en-us/articles/

202986595-What-is-the-difference-between-DC-motors-and-Stepper-motors- [Accessed Feb, 12, 2019].

[8] ”Stepper Motors, Stepper Motor Drivers and Controllers”, Orientalmotor. [On- line]. Available: https://www.orientalmotor.com/stepper-motors/index.

html#stepperMotors [Accessed, Apr, 18, 2019].

[9] T. Subhasankari, A Sharvin Infant, A Viswasundar, M. Venkatesan, N.

Mithran. ”Integration of Hall Sensor in a 3D Printer as a Limit Switch”, 2017 IEEE International Conference on Computational Intelligence and Com- puting Research (ICCIC), 14-16 Dec. 2017, Coimbatore, India [Online]. Avail- able: IEEE Xplore,https://ieeexplore.ieee.org/document/8524539 DOI:

10.1109/ICCIC.2017.8524539 [Accessed, May, 2, 2019].

(40)

BIBLIOGRAPHY

[10] Alexandros Beiker Kair, ”Additive Manufacturing and Production of Metal- lic Parts in Automotive Industry : A Case Study on Technical, Economic and Environmental Sustainability Aspects” [Online] Available: http://kth.

diva-portal.org/smash/record.jsf?pid=diva2%3A740682&dswid=57536 [Accessed, May, 2, 2019].

[11] GE Additive. ”What is additive manufacturing?”, Alexandros Beiker Kair, Sofos, Konstantinos [Online] Available: http://kth.diva-portal.org/smash/

record.jsf?pid=diva2%3A740682 [Accessed, Feb, 12, 2019].

[12] SKF koncernen (January 2014). ”SKF rullningslager”. [Online].

Available at https://www.skf.com/binary/28-121486/

Rullningslager---10000_2-SV.pdf, accessed on February 12th 2019.

[13] Self drawn in the software Fritzing. Available: www.http://fritzing.org/

home/

[14] Self drawn in the software Eagle. Available: https://www.autodesk.com/

products/eagle/overview

[15] 3D model captured with Fusion 360 with arrows drawn in Photoshop. Available:

https://www.autodesk.com/products/fusion-360/overview#banner Available: https://www.adobe.com/products/photoshop.html

[16] Picture captured with phone camera.

[17] Flowchart drawn in LaTeX.

[18] Image drawn in Matlab. Available https://se.mathworks.com/products/

matlab.html

[19] Cort J. Willmott, Kenji Matsuura. ”Advantages of the mean absolute error (MAE) over the root mean square error (RMSE) in assessing average model performance”, December 19, 2005. [Online] Available at https://www.int-res.

com/abstracts/cr/v30/n1/p79-82/, DOI: 10.3354/cr030079 [Accessed, May, 2, 2019].

[20] The MathWorks, Inc, ”Linear Regression”. [Online]. Available at https://www.

mathworks.com/help/matlab/data_analysis/linear-regression.html, [Ac- cessed Apr, 18, 2019]

(41)

A. Arduino Code

/* Automatic wire cutter

* Author: Philip Hamilton

* Course: MF133X

* School: KTH

* This is the code for our bachelor degree project in

* Mechatronics by Philip Hamilton and Rasmus Holmskov

*/

/******************************************************/

// Including libraries for the Liquid Crystal Display.

/******************************************************/

#include "Wire.h" // For I2C

#include "LCD.h" // For LCD

#include "LiquidCrystal_I2C.h"

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7);

/******************************************************/

// Creating custom characters for the Liquid Crystal Display.

/******************************************************/

byte Arrow[8] = { B00000,

B10000, B11000, B11100, B11100, B11000, B10000, B00000

};byte returnArrow[8] = { B11110,

B00011, B00101, B01101, B11111, B11110, B01100, B00100 };

(42)

APPENDIX A. ARDUINO CODE

byte forwardArrow[8] = { B00100,

B01100, B11110, B11111, B01101, B00101, B00011, B11110 };

/******************************************************/

//Variables for handeling the menu

/******************************************************/

int menuNumber = 0;

bool updateFlag = 0;

bool cutting = 0;

bool * pointerToCutting = &cutting;

bool feeding = 0;

bool * pointerToFeeding = &feeding;

int subMenuNumber = 0;

int *pointerToSubmenuNumber = &subMenuNumber;

bool choosingLength = 0;

bool *pointerToChoosingLength = &choosingLength;

bool choosingQuantity = 0;

bool *pointerToChoosingQuantity = &choosingQuantity;

int wireLength = 0;

int *pointerToWireLength = &wireLength;

int quantity = 0;

int *pointerToQuantity = &quantity;

int chosenQuantity = 0;

int *pointerToChosenQuantity = &chosenQuantity;

/******************************************************/

//Variables for handling the Rotary Encoder

/******************************************************/

const int clkPin = 3;

const int dtPin = 4;

const int switchPin = 2;

(43)

APPENDIX A. ARDUINO CODE int lastButtonState = 1;

int pushed = 0;

int * pointerToPushed = &pushed;

int lastPosition = 0;

volatile int virtualPosition = 0;

volatile int *pointerToVirtualPosition = &virtualPosition;

int previousVirtualPosition = 0;

int *pointerToPreviousVirtualPosition = &previousVirtualPosition;

void initializeRotaryEncoder() { pinMode(clkPin, INPUT);

pinMode(dtPin, INPUT);

pinMode(switchPin, INPUT_PULLUP);

attachInterrupt(digitalPinToInterrupt(clkPin), isr, LOW);

attachInterrupt(digitalPinToInterrupt(switchPin), push_ISR, CHANGE);

}

/******************************************************/

//Interrupt Service Routines!

/******************************************************/

/******************************************************/

//If rotary encoder is rotated, change the virtual position /******************************************************/

void isr() {

static unsigned long lastInterruptTime = 0;

unsigned long interruptTime = millis();

//Handling debouncuing

if (interruptTime - lastInterruptTime > 5) { if (digitalRead(dtPin) == LOW) {

virtualPosition--;

}else {

virtualPosition++;

} }

updateFlag = 1;

lastInterruptTime = interruptTime;

}/******************************************************/

//If button is pushed, update the menu

/******************************************************/

(44)

APPENDIX A. ARDUINO CODE void push_ISR() {

buttonState = digitalRead(switchPin);

if (buttonState != lastButtonState && buttonState == LOW) { pushed++;

updateFlag = 1;

//Debounce delay delay(5);

}lastButtonState = buttonState;

}

/******************************************************/

// Including libraries and variables for the Motors.

/******************************************************/

#include "motor.h"

#define ROLLDIAMETER 36.4

//rollDiameter = [36.2, 36.4, 36.6, 37, 36.1, 36.2, 36.4,36.4]

#define ONEREVSTEP 200

#define MATH_PI 3.14159265

const int fDir = 13;

const int fStep = 12;

const int fEnable = 11;

const int cDir = 10;

const int cStep = 9;

const int cEnable = 8;

const int PulseTime = 800;

const int cutOffset = 300;

Motor feedingMotor(fStep, fDir, fEnable, PulseTime);

Motor cuttingMotor(cStep, cDir, cEnable, PulseTime);

int emergencyExit;

/******************************************************/

// Variables for the limit switches

/******************************************************/

(45)

APPENDIX A. ARDUINO CODE

const int botSwitch = 7;

/******************************************************/

void setup() {

Serial.begin(9600);

pinMode(topSwitch, INPUT);

pinMode(botSwitch, INPUT);

/******************************************************/

// Initializing components

/******************************************************/

feedingMotor.initialize();

cuttingMotor.initialize();

initializeRotaryEncoder();

initializeLCD();

/******************************************************/

// Printing some text on the LCD.

/******************************************************/

lcd.clear();

startUpMenu();

lcd.clear();

homingCutter();

/******************************************************/

// Setting cutter in its home position

/******************************************************/

homeCutter();

updateMenu(menuNumber);

}

void loop() {

updateCursorPosition(menuNumber);

/******************************************************/

// Updates the Menu

/******************************************************/

if (updateFlag) {

(46)

APPENDIX A. ARDUINO CODE

menuNumber = getMenuNumber(pushed, virtualPosition);

Serial.print("pushed = ");

Serial.print(pushed);

Serial.print(" virutalPosition = ");

Serial.print(virtualPosition);

Serial.print(" menuNumber = ");

Serial.println(menuNumber);

updateMenu(menuNumber);

updateFlag = !updateFlag;

}

/******************************************************/

// Handling manual Feeding and cutting

/******************************************************/

if (menuNumber == 2) { //In FeedingMode

if (previousVirtualPosition != virtualPosition) { if (previousVirtualPosition < virtualPosition) {

stepMotor(1, 1);

} else {

stepMotor(1, 0);

}previousVirtualPosition = virtualPosition;

} }

if (menuNumber == 3) { // In CuttingMode

if (previousVirtualPosition != virtualPosition) { if (previousVirtualPosition < virtualPosition) {

stepMotor(0, 0);

} else {

stepMotor(0, 1);

}previousVirtualPosition = virtualPosition;

} }

/******************************************************/

//Handling Automatic cutting

/******************************************************/

if (menuNumber == 7) { //Automatic Cutting!

//Pree cut existing wire

(47)

APPENDIX A. ARDUINO CODE removeExcessWire();

cutExcessWire();

delay(1000);

lcd.clear();

while (quantity > 0) { Serial.println(pushed);

updateMenu(menuNumber);

delay(500);

emergencyExit = feedNCut(wireLength);

if (emergencyExit == 1) { menuNumber = 4;

updateFlag = 1;

virtualPosition = 0;

break;

}quantity--;

if (quantity == 0) { menuNumber = 8;

updateMenu(menuNumber);

delay(2000);

pushed = 1;

wireLength = 0;

virtualPosition = 0;

menuNumber = 4;

updateFlag = 1;

} } }

/******************************************************/

// Reseting cursor position if in Automatic

/******************************************************/

if (menuNumber == 9 || menuNumber == 10 || menuNumber == 11) { if (menuNumber == 9) {

virtualPosition = 1;

}if (menuNumber == 10) { virtualPosition = 0;

}if (menuNumber == 11) { virtualPosition = 0;

}menuNumber = 4;

(48)

APPENDIX A. ARDUINO CODE pushed = 1;

delay(2000);

updateFlag = 1;

}

/******************************************************/

//Limits the cursor position

/******************************************************/

if (pushed == 0) {

if (virtualPosition <= 0) { virtualPosition = 0;

}if (virtualPosition > 1) { virtualPosition = 1;

} }

/******************************************************/

}

/******************************************************/

//Functions to handle which menu that should be displayed /******************************************************/

int getMenuNumber(int pushed, int cursorPosition) { if (subMenuNumber == 0) {

if (pushed == 0) { //MainMenu menuNumber = 0;

}if (pushed == 1) {

if (cursorPosition == 0) { //ManualMode menuNumber = 1;

*pointerToPreviousVirtualPosition = virtualPosition;

*pointerToSubmenuNumber = 1;

}if (cursorPosition == 1) { //AutomaticMode menuNumber = 4;

*pointerToPreviousVirtualPosition = virtualPosition;

*pointerToVirtualPosition = 0;

*pointerToSubmenuNumber = 2;

} } }

(49)

APPENDIX A. ARDUINO CODE if (pushed == 2) {

if (cursorPosition == 0 && cutting == 0) { //Feeding mode

*pointerToPreviousVirtualPosition = virtualPosition;

menuNumber = 2;

*pointerToFeeding = 1;

}if (cursorPosition == 1 && feeding == 0) { //Cutting

*pointerToPreviousVirtualPosition = virtualPosition;

menuNumber = 3;

*pointerToCutting = 1;

}if (cursorPosition == 2 && feeding == 0 && cutting == 0) { //We’re on return menuNumber = 0;

*pointerToVirtualPosition = 0;

*pointerToPushed = 0;

*pointerToSubmenuNumber = 0;

}

}if (pushed == 3) { //Return from selection menuNumber = 1;

virtualPosition = 0;

*pointerToFeeding = 0;

*pointerToCutting = 0;

*pointerToPushed = 1;

} }

if (subMenuNumber == 2) { if (pushed == 2) {

if (cursorPosition == 0 && choosingQuantity == 0) { //Set length menuNumber = 5;

*pointerToChoosingLength = 1;

}if (cursorPosition == 1 && choosingLength == 0) { //Set quantity menuNumber = 6;

*pointerToChoosingQuantity = 1;

}

/******************************************************/

// Handeling case where no quantity or wire length are selected /******************************************************/

(50)

APPENDIX A. ARDUINO CODE

if (cursorPosition == 2 && wireLength != 0 && quantity != 0) { //Run

*pointerToChosenQuantity = quantity;

menuNumber = 7;

}if (cursorPosition == 2 && wireLength != 0 && quantity == 0) { menuNumber = 9;

}if (cursorPosition == 2 && wireLength == 0 && quantity != 0) { menuNumber = 10;

}if (cursorPosition == 2 && wireLength == 0 && quantity == 0) { menuNumber = 11;

/******************************************************/}

/******************************************************/

// Clear all set values

/******************************************************/

if (cursorPosition == 3 && choosingQuantity == 0 && choosingLength == 0) {

*pointerToWireLength = 0;

*pointerToQuantity = 0;

*pointerToPushed = 1;

menuNumber = 4;

}

/******************************************************/

// We are on the return button, return to the previous menu.

/******************************************************/

if (cursorPosition == 4 && choosingQuantity == 0 && choosingLength == 0) { //Return menuNumber = 0;

virtualPosition = 0;

*pointerToPushed = 0;

*pointerToSubmenuNumber = 0;

} }

/******************************************************/

// Set length

/******************************************************/

if (choosingLength == 1 && choosingQuantity == 0) { menuNumber = 5;

(51)

APPENDIX A. ARDUINO CODE

}

/******************************************************/

//Set quantity

/******************************************************/

if (choosingLength == 0 && choosingQuantity == 1) { menuNumber = 6;

setQuantity(cursorPosition);

/******************************************************/} //Set cursor position depending on previous choices.

/******************************************************/

if (pushed == 3) {

if (choosingLength == 1 && choosingQuantity == 0) {

*pointerToVirtualPosition = 0;

}if (choosingLength == 0 && choosingQuantity == 1) {

*pointerToVirtualPosition = 1;

}

*pointerToChoosingLength = 0;

*pointerToChoosingQuantity = 0;

*pointerToPushed = 1;

//virtualPosition = 0;

menuNumber = 4;

} }

/******************************************************/

if (pushed > 3) { //Preventing a bug which causes pushed to exceed the limit

*pointerToPushed = 3;

}return menuNumber;

}

/******************************************************/

// Updates the displays the correct menu

/******************************************************/

void updateMenu(int menuNumber) { lcd.clear();

(52)

APPENDIX A. ARDUINO CODE switch (menuNumber) {

case 0: // MainMenu mainMenu();

break;

case 1: //ManualMode manualMode();

break;

case 2: //FeedingMode feedingMode();

break;

case 3: //CuttingMode cuttingMode();

break;

case 4: //AutomaticMode automaticMode();

break;

case 5: //ChooseLength automaticMode();

break;

case 6: //ChooseQuantity automaticMode();

break;

case 7: //Run runMode();

break;

case 8: //Completed completed();

break;

case 9:

warning(1);

break;

case 10:

warning(2);

break;

case 11:

warning(3);

break;

} }

/******************************************************/

// Set the desired Length

(53)

APPENDIX A. ARDUINO CODE

void setLength(int cursorPosition) {

static int preCursorPosition = cursorPosition;

if (cursorPosition > preCursorPosition) { (*pointerToWireLength)++;

}if (cursorPosition < preCursorPosition) { (*pointerToWireLength)--;

}if (wireLength < 0) { wireLength = 0;

}preCursorPosition = cursorPosition;

}

/******************************************************/

// Set the desired quantity

/******************************************************/

void setQuantity(int cursorPosition) {

static int preCursorPosition = cursorPosition;

if (cursorPosition > preCursorPosition) { (*pointerToQuantity)++;

}if (cursorPosition < preCursorPosition) { (*pointerToQuantity)--;

}if (quantity < 0) { quantity = 0;

}preCursorPosition = cursorPosition;

}

/******************************************************/

//Updates the cursor to the correct position that is chosen on the rotary encoder /******************************************************/

void updateCursorPosition(int menuNumber) { switch (menuNumber) {

case 0:

if (virtualPosition == 0) { lcd.setCursor(0, 2);

lcd.write(byte(0));

}

(54)

APPENDIX A. ARDUINO CODE if (virtualPosition == 1) {

lcd.setCursor(9, 2);

lcd.write(byte(0));

}if (virtualPosition > 1) { virtualPosition = 1;

}if (virtualPosition < 0) { virtualPosition = 0;

}break;

case 1:

if (virtualPosition == 0) { lcd.setCursor(4, 2);

lcd.write(byte(0));

}if (virtualPosition == 1) { lcd.setCursor(11, 2);

lcd.write(byte(0));

}if (virtualPosition == 2) { lcd.setCursor(18, 3);

lcd.write(byte(0));

}

if (virtualPosition > 2) { virtualPosition = 2;

}if (virtualPosition < 0) { virtualPosition = 0;

case 2: //FeedingMode}

break;

case 3: //CuttingMode break;

case 4:

lcd.noCursor();

if (virtualPosition == 0) { lcd.setCursor(0, 0);

lcd.write(byte(0));

}

(55)

APPENDIX A. ARDUINO CODE lcd.setCursor(0, 1);

lcd.write(byte(0));

}if (virtualPosition == 2) { lcd.setCursor(0, 3);

lcd.write(byte(0));

}if (virtualPosition == 3) { lcd.setCursor(5, 3);

lcd.write(byte(0));

}if (virtualPosition == 4) { lcd.setCursor(18, 3);

lcd.write(byte(0));

}

if (virtualPosition > 4) { virtualPosition = 4;

}if (virtualPosition < 0) { virtualPosition = 0;

}break;

case 5: // ChoosingLength lcd.setCursor(11, 0);

lcd.cursor();

break;

case 6: //ChoosingQuantity lcd.setCursor(11, 1);

lcd.cursor();

break;

} }

/******************************************************/

// Functions to display the menu

/******************************************************/

/******************************************************/

// Displaying the startup menu

/******************************************************/

void startUpMenu() {

(56)

APPENDIX A. ARDUINO CODE lcd.setCursor(3, 1);

lcd.print("Automatic Wire");

lcd.setCursor(6, 2);

lcd.print("Cutter");

delay(2000);

lcd.clear();

lcd.setCursor(8, 0);

lcd.print("by");

lcd.setCursor(2, 1);

lcd.print("Philip Hamilton");

lcd.setCursor(8, 2);

lcd.print("&");

lcd.setCursor(2, 3);

lcd.print("Rasmus Holmskov");

delay(2500);

}

/******************************************************/

// Displaying the homing of the motor

/******************************************************/

void homingCutter() { lcd.setCursor(5, 1);

lcd.print("Homing the");

lcd.setCursor(4, 2);

lcd.print("cutting motor");

}

/******************************************************/

// Displaying the removal of excess wire

/******************************************************/

void removeExcessWire() { lcd.setCursor(2, 1);

lcd.print("Removing excess");

lcd.setCursor(7, 2);

lcd.print("wire");

}

/******************************************************/

// Displaying the options in the main menu

/******************************************************/

(57)

APPENDIX A. ARDUINO CODE lcd.setCursor(4, 0);

lcd.print("Choose mode:");

lcd.setCursor(1, 2);

lcd.print("Manual");

lcd.setCursor(10, 2);

lcd.print("Automatic");

}

/******************************************************/

// Displaying the options in manual mode

/******************************************************/

void manualMode() { lcd.setCursor(4, 0);

lcd.print("Choose mode:");

lcd.setCursor(5, 2);

lcd.print("Feed");

lcd.setCursor(12, 2);

lcd.print("Cut");

lcd.setCursor(19, 3);

lcd.write(byte(1));

}/******************************************************/

// Displaying how to operate the machine in feeding mode /******************************************************/

void feedingMode() { lcd.setCursor(3, 0);

lcd.print("Rotate knob to");

lcd.setCursor(5, 1);

lcd.print("feed wire.");

lcd.setCursor(4, 4);

lcd.print("Push to exit");

}

/******************************************************/

// Displaying how to operate the machine in cutting mode /******************************************************/

void cuttingMode() { lcd.setCursor(3, 0);

lcd.print("Rotate knob to");

lcd.setCursor(3, 1);

lcd.print("cut the wire.");

(58)

APPENDIX A. ARDUINO CODE lcd.setCursor(4, 4);

lcd.print("Push to exit");

}

/******************************************************/

// Displaying the options in automatic mode

/******************************************************/

void automaticMode() { lcd.setCursor(1, 0);

lcd.print("Length :");

lcd.setCursor(11, 0);

lcd.print(wireLength);

determinePlaceForUnits(wireLength, 0);

lcd.print("cm");

lcd.setCursor(1, 1);

lcd.print("Quantity:");

lcd.setCursor(11, 1);

lcd.print(quantity);

lcd.setCursor(1, 3);

lcd.print("Run");

lcd.setCursor(6, 3);

lcd.print("Clear");

lcd.setCursor(19, 3);

lcd.write(byte(1));

}

/******************************************************/

// Displaying the remaining number of cables to cut when its running /******************************************************/

void runMode() {

lcd.setCursor(2, 0);

lcd.print("Cutting ");

lcd.print(chosenQuantity);

lcd.print(" cables");

lcd.setCursor(2, 1);

lcd.print("with a length of");

lcd.setCursor(6, 2);

lcd.print(wireLength);

lcd.print(" cm.");

if (quantity < 10) { lcd.setCursor(1, 3);

(59)

APPENDIX A. ARDUINO CODE lcd.setCursor(0, 3);

}lcd.print(quantity);

lcd.print(" wires remaining");

}

/******************************************************/

// The displayed text on startup of the machine

/******************************************************/

void startUpDisp() { lcd.setCursor(6, 0);

lcd.print("Automatic");

lcd.setCursor(5, 1);

lcd.print("Wire Cutter");

}

/******************************************************/

// The displayed text when the cutting is completed /******************************************************/

void completed() { lcd.setCursor(6, 1);

lcd.print("Cutting");

lcd.setCursor(5, 2);

lcd.print("completed!");

}

/******************************************************/

// The displayed warning text if there are not enough inputs in automatic mode /******************************************************/

void warning(int selection) { lcd.setCursor(4, 0);

lcd.print("Please enter:");

if (selection == 1) { //No quantity lcd.setCursor(6, 2);

lcd.print("Quantity");

}if (selection == 2) { //No length lcd.setCursor(6, 2);

lcd.print("Length");

}

(60)

APPENDIX A. ARDUINO CODE if (selection == 3) {

lcd.setCursor(5, 2);

lcd.print("Length &");

lcd.setCursor(5, 3);

lcd.print("Quantity");

} }

/******************************************************/

// Determine place for units

/******************************************************/

void determinePlaceForUnits(int unit, int heightPos) { if (unit < 10) {

lcd.setCursor(13, heightPos);

}if (unit >= 10) {

lcd.setCursor(14, heightPos);

}if (unit >= 100) {

lcd.setCursor(15, heightPos);

} }

/******************************************************/

// Controlling the stepper motors

/******************************************************/

void stepMotor(bool Feeder, bool Forward) {

int steps = 75; // Value to move the motor when rotating the rotary encoder.

int i;

if (Feeder) { if (Forward) {

for (i = 0; i < steps; i++) { feedingMotor.stepForward();

} else {}

for (i = 0; i < steps; i++) { feedingMotor.stepBackwards();

} } }else {

if (Forward) {

(61)

APPENDIX A. ARDUINO CODE

for (i = 0; i < steps; i++) { cuttingMotor.stepDown();

} } } else {

if (digitalRead(topSwitch) != 1) { for (i = 0; i < steps; i++) {

cuttingMotor.stepUp();

} } } } }

/******************************************************/

// Function to convert mm to steps

/******************************************************/

int convertmmToSteps(int cm) { //Before calibration

//int steps = mm / (2 * MATH_PI * ROLLDIAMETER / (2 * ONEREVSTEP));

//After calibration

int steps = (cm + 0.0651 * cm - 0.1534) / (2 * MATH_PI * ROLLDIAMETER / (2 * ONEREVSTEP)) ; return steps;

}

/******************************************************/

// Function that feed and cut the wires

/******************************************************/

int feedNCut(int mm) {

int steps = convertmmToSteps(10 * mm);

int i;

int state = digitalRead(botSwitch);

int emergencyExit = 0;

for (i = 0; i < steps; i++) { feedingMotor.stepForward();

}

while (state != 1) {

cuttingMotor.stepDown();

state = digitalRead(botSwitch);

if (pushed == 3) { emergencyExit = 1;

(62)

APPENDIX A. ARDUINO CODE return emergencyExit;

} }

for (i = 0; i < cutOffset; i++) { cuttingMotor.stepUp();

}return 0;

}

/******************************************************/

// Function that cuts the excess wire before it starts the feed and cut function /******************************************************/

void cutExcessWire() {

int state = digitalRead(botSwitch);

while (state != 1) {

cuttingMotor.stepDown();

state = digitalRead(botSwitch);

}for (int i = 0; i < cutOffset; i++) { cuttingMotor.stepUp();

} }

/******************************************************/

// Sets the cutting motor to its home position

/******************************************************/

void homeCutter() {

int state = digitalRead(topSwitch);

int topOffset = 200;

while (state != 1) { cuttingMotor.stepUp();

state = digitalRead(topSwitch);

}for ( int i = 0; i < topOffset; i++) { cuttingMotor.stepDown();

} }

/******************************************************/

(63)

APPENDIX A. ARDUINO CODE

/******************************************************/

void initializeLCD() {

lcd.begin (20, 4); // 20x4 LCD module lcd.setBacklightPin(3, POSITIVE);

lcd.setBacklight(HIGH);

lcd.createChar(0, Arrow);

lcd.createChar(1, returnArrow);

lcd.createChar(2, forwardArrow);

}

A.0.1 Motor class Header file

#ifndef motor_h

#define motor_h class Motor {

public:

Motor(uint8_t stepPin, uint8_t dirPin, uint8_t enablePin, uint16_t delayBetweenPulses);

void initialize();

void stepForward();

void stepBackwards();

void stepUp();

void stepDown();

private:

uint8_t _stepPin;

uint8_t _dirPin;

uint8_t _enablePin;

uint16_t _delayBetweenPulses;

};#endif

C++ file

#include "Arduino.h"

#include "motor.h"

/******************************************************/

//Assigning motor variables

/******************************************************/

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

Från den teoretiska modellen vet vi att när det finns två budgivare på marknaden, och marknadsandelen för månadens vara ökar, så leder detta till lägre

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

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

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

På många små orter i gles- och landsbygder, där varken några nya apotek eller försälj- ningsställen för receptfria läkemedel har tillkommit, är nätet av

Detta projekt utvecklar policymixen för strategin Smart industri (Näringsdepartementet, 2016a). En av anledningarna till en stark avgränsning är att analysen bygger på djupa