49
IN DEGREE PROJECT MECHANICAL ENGINEERING, FIRST CYCLE, 15 CREDITS , STOCKHOLM SWEDEN 2019 Autonomous Counterbalance Forklift Autonomous forklift capable of transporting pallets LUDVIG BOCZAR FELIX MYRSTEN KTH ROYAL INSTITUTE OF TECHNOLOGY SCHOOL OF INDUSTRIAL ENGINEERING AND MANAGEMENT

Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

IN DEGREE PROJECT MECHANICAL ENGINEERING,FIRST CYCLE, 15 CREDITS

, STOCKHOLM SWEDEN 2019

Autonomous Counterbalance ForkliftAutonomous forklift capable of transporting pallets

LUDVIG BOCZAR

FELIX MYRSTEN

KTH ROYAL INSTITUTE OF TECHNOLOGYSCHOOL OF INDUSTRIAL ENGINEERING AND MANAGEMENT

Page 2: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading
Page 3: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

Autonomous Counterbalance Forklift

Autonomous forklift capable of transporting pallets

LUDVIG BOCZARFELIX MYRSTEN

Bachelor’s Thesis at ITMSupervisor: Nihad SubasicExaminer: Nihad Subasic

TRITA-ITM-EX 2019:31

Page 4: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading
Page 5: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

AbstractThis thesis explored the possibility to use line followingtechnology to automate forklifts in a warehouse scenario.This was done to reduce the need for staff to always bepresent in the warehouse. A prototype forklift was con-structed with three wheels, where driving and steering wasdone by the rear wheel. To control the forklift an ArduinoUno was used. The line following was done using InfraredRadiation (IR) sensors. Different setups of line followingsensors were tested to achieve a forklift capable of follow-ing a line. Different layouts of the operating area were alsotested.

Line following was found to work best when two sensorswere placed in front of the front wheels when going forwardand two by the back wheel when reversing. The conclusionwas made that a setup of four sensors was enough to achievea line following forklift.

For the operating area, the best layout was found tobe an X-shaped one. Using 90° corners proved to be theeasiest to navigate.

Keywords: mechatronics, forklift, autonomous, line follower.

Page 6: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

ReferatAutonom Motviktstruck

Denna avhandling undersokte mojligheten att anvandalinjefoljningsteknologi for att automatisera gaffeltruckar iett varuhus. Detta gjordes med malet att minska behovetpa att alltid ha personal narvarande. En gaffeltruckspro-totyp konstruerades med tre hjul, bakhjulsdrift och styr-ning pa bakhjulet. For att styra gaffeltrucken anvandes enArduino Uno. Linjefoljningen utfordes av IR sensorer. Tes-ter utfordes pa olika konfigurationer av linjefoljarsensorernafor att uppna linjefoljning. Utformningen pa arbetsomradettestades ocksa.

Linjefoljning visade sig fungera bast nar tva sensorervar placerade framfor framhjulen nar man korde framat ochtva vid bakhjulet nar man backade. Slutsatsen blev att fyrasensorer var tillrackligt for att uppna linjefoljningsformaga.

Den basta utformningen pa arbetsytan konstateradesvara en X-formad yta. Att anvanda 90° horn visade sig va-ra lattast att navigera genom.

Nyckelord: mekatronik, motviktstruck, autonom, linjefoljare.

Page 7: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

Acknowledgements

First, we would like to thank our examiner and supervisor Nihad Subasic for provid-ing lectures and guidance during this project. Secondly, we want to thank StaffanQvarnstrom for his help with components. And finally, we also want to thank SreshtIyer and Seshagopalan Thorapalli for their help with our various questions duringthis project.

Ludvig Boczar, Felix MyrstenStockholm, May 2019

Page 8: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

Contents

1 Introduction 11.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.3 Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.4 Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

2 Theory 52.1 DC motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.2 Servo motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.3 Microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.4 IR sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.5 H bridge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

3 Demonstrator 73.1 Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

3.1.1 Micro switch . . . . . . . . . . . . . . . . . . . . . . . . . . . 73.1.2 Electric motors . . . . . . . . . . . . . . . . . . . . . . . . . . 73.1.3 Line follower sensor IR . . . . . . . . . . . . . . . . . . . . . . 83.1.4 H bridge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83.1.5 Mechanical parts . . . . . . . . . . . . . . . . . . . . . . . . . 83.1.6 Arduino Uno . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

3.2 Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

4 Testing and Results 114.1 Line following . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

4.1.1 Sensor placement and forward motion . . . . . . . . . . . . . 114.1.2 Reversing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

4.2 Layout of operating area . . . . . . . . . . . . . . . . . . . . . . . . . 134.3 Lifting mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

5 Discussion and Conclusion 195.1 Line following . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195.2 Layout of operating area . . . . . . . . . . . . . . . . . . . . . . . . . 205.3 Lifting mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

Page 9: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

5.4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215.5 Recommendations for future work . . . . . . . . . . . . . . . . . . . 22

Bibliography 23

Appendices 24

A Circuit diagram 26

B Code 27

Page 10: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

List of Figures

1.1 The forklift made in Solid Edge . . . . . . . . . . . . . . . . . . . . . . . 3

2.1 Diagram of H bridge configuration. U is the supplied voltage, M is themotor and s 1-4 are the switches. Created in LibreOffice draw. . . . . . 6

3.1 The lifting mechanism made in Solid Edge . . . . . . . . . . . . . . . . . 83.2 The wheelhouse made in Solid Edge . . . . . . . . . . . . . . . . . . . . 93.3 Flowchart of forward func() function. lf = left front, rf = right front,

LOW = sensor detects a light surface, HIGH = sensor detects a darksurface. Made in draw.io . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

4.1 Drive forward then stop. Made in MS Paint. . . . . . . . . . . . . . . . 114.2 Problematic Y-layout. Pallets represented by orange rectangles. Made

in MS Paint. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134.3 Driving pattern to pick up the first pallet. Made in MS Paint. . . . . . 154.4 Driving pattern to pick up the second pallet. Made in MS Paint. . . . . 16

5.1 Problem turning. Made in MS Paint. . . . . . . . . . . . . . . . . . . . . 19

A.1 Circuit diagram made with Fritzing sofware. . . . . . . . . . . . . . . . . 26

Page 11: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

List of Tables

4.1 Result of tests with sensors located at the rear wheel. . . . . . . . . . . 124.2 Result of tests with sensors at the front wheels. . . . . . . . . . . . . . . 124.3 Result of tests when using sensors both at the front and rear wheels. . . 124.4 Result of tests when reversing using the sensors by the rear wheel. . . . 134.5 Result of weight lifting tests . . . . . . . . . . . . . . . . . . . . . . . . . 174.6 Result of weight transporting tests . . . . . . . . . . . . . . . . . . . . . 17

Page 12: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading
Page 13: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

List of Abbreviations

CAD Computer-aided design

CPU Central processing unit

DC Direct current

EU European Union

IR Infrared radiation

PWM Pulse-width modulation

RAM Random access memory

ROM Read only memory

Page 14: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading
Page 15: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

Chapter 1

Introduction

1.1 Background

Is it possible to automate the loading and unloading of semitrailers following theEU standard? This question arose after noticing, by own experience, a problemin the logistics sector. Truck drivers running late due to heavy traffic often arriveto their unloading destination outside of the warehouse’s operating hours, meaningthe driver has to sleep in his truck and wait for unloading until the next morning.This is a great inconvenience for the driver and results in an uneven workload forthe warehouse workers who are greeted by a couple of semitrailers each morningwaiting to be unloaded.

A solution to this problem would be to design an autonomous counterbalanceforklift that could take care of the loading and unloading while the warehouse isunmanned, allowing the driver to drive to his next destination. The idea is thatthe forklift will be positioned in the unloading area waiting for a truck to reverseinto a predetermined parking spot. The parking spots will all be at equal distancefrom the forklift and the rear of the semitrailer will be facing the forklift. When thesemitrailer is in position, the forklift receives a signal and starts to drive towardsthe trailer using infrared sensors that follow a painted path on the ground. Whenthe forklift reaches the rear of the trailer it unloads the pallet and follows the pathon the ground back to the warehouse, drops the pallet then returns to its restingposition in the unloading area waiting for another trailer to appear.

1.2 Purpose

The goal of this project was to explore the potential of an autonomous forklift andhow it can be used to improve the logistics sector. The following research questionswere answered:

• How should an autonomous counterbalance forklift be designed to be able topick up and deliver pallets by itself?

1

Page 16: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

CHAPTER 1. INTRODUCTION

• How many IR sensors are needed and how should they be positioned to allowa forklift to follow a line?

• What is the optimal layout of the operating area that allows the forklift tofunction efficiently?

1.3 Scope

The final prototype was greatly scaled down in comparison to a real forklift, both interms of dimensions and weight. Ideally the forklift would be able to unload trailersfrom the ground, meaning that the forks would have to be raised in order to reachthe pallet. In this project it was assumed that the forklift’s operating area is inlevel with the pallets in the trailer in order to focus on the line following ability.

The forklift’s driving cycle is started manually by the push of a button instead ofautomatically because other parts of the project consumed more time than expected.

1.4 Method

First, a simple prototype was built equipped with two freely rotating front wheelsand a rear wheel mounted to a Direct Current (DC) motor and a servo motor.The three wheeled design was chosen to provide a maneuverable forklift that couldrotate on the spot [1]. This prototype was expected to verify that both driving andsteering can be performed by a single rear wheel. Different DC motors and servomotors were tested until the performance was deemed satisfactory. At first, theDC motors tested were powered through a stationary external power supply, thiswas done to determine the amount of voltage the DC motors require in order tofunction properly with the load applied. When the optimal operating voltage rangewas known a battery with similar specifications was mounted on the prototype.

The next step was to test the prototype’s ability to follow a predetermined pathusing infrared line follower sensors. At first two sensors were used, which should beenough to achieve a line following forklift [2]. Two sensors were placed face-downunder the prototype and black tape was put in between in a path on white coloredground. Due to a turning rear wheel the ability to follow a line could be poor whenreversing, given that only two sensors were used in the front [3]. To counter thismore sensors might be needed. A full computer-aided design (CAD) picture of theforklift can be seen in figure 1.1. IR sensors are represented by red boxes.

2

Page 17: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

1.4. METHOD

Figure 1.1. The forklift made in Solid Edge

When a prototype capable of driving, turning and path-following was built thenext step was to add the forks and lifting mechanism. The lifting mechanism isdriven by a DC motor through a worm drive. By experimentation the maximallifting height was gradually increased until the prototype failed in some way.

3

Page 18: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading
Page 19: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

Chapter 2

Theory

2.1 DC motorThe DC motor is an electrical motor powered by direct current. The motor hasa coil, magnets and a commutator. The coil is located between the magnets andby passing a current through it, a rotation is created. The commutator reversesthe direction of the current every 180° to ensure the motor spins continuously. Therotational direction is controlled by the direction of the current [4].

2.2 Servo motorA servo motor is an electrical motor that allows for precise movement. By using anadditional input signal it can be moved to a desired position. This is achieved byusing a feedback loop where the position and movement of the motor is measured,usually by a potentiometer or a rotary encoder, and compared to the desired value[5].

2.3 MicrocontrollerA microcontroller consists of a central processing unit (CPU), random access mem-ory (RAM), read only memory (ROM) and input/output communication. There-fore, the microcontroller can be programmed through a computer to send or receiveelectrical signals [6].

2.4 IR sensorInfrared radiation (IR) is the electromagnetic radiation with a wavelength of 700nm to 1 mm. The human eye can see waves of about 380 to 740 nm in lenght. IR istherefore outside of the visible light. It is used in sensors where the light is reflectedupon a surface and then measured. The IR sensor has a diode that emits IR and

5

Page 20: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

CHAPTER 2. THEORY

one that measures the amount of reflected light. The amount of reflected light willdepend on the color and can then be used to detect color changes. The sensor willsend either a high (ON) or low (OFF) signal depending on the amount of reflectedlight [7].

2.5 H bridgeThe H bridge is a circuit that uses transistors as switches to change the polarityof a voltage. The switches can be controlled by another input signal, for examplefrom a microcontroller. This can be used to change the polarity of current througha DC motor making it possible to rotate it in both directions. As seen in figure2.1, if switch s1 and s4 are activated, the current runs through the motor in onedirection, and if s2 and s3 are activated the current changes direction [4].

Figure 2.1. Diagram of H bridge configuration. U is the supplied voltage, M is themotor and s 1-4 are the switches. Created in LibreOffice draw.

6

Page 21: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

Chapter 3

Demonstrator

3.1 Hardware

This section will describe the different parts used to construct the forklift. Thecircuit diagram is shown in Appendix A.

3.1.1 Micro switch

The micro switch used in this project was a D2F by Omron [8]. It is a small switchwith a lever that requires very little force to be activated, less than 1 N. The switchwas used to signal that the lifting mechanism is at its lowest position.

3.1.2 Electric motors

The servo motor used in this project was a Hitec HS-303 [9]. It had a rotationalrange of 180° and was controlled directly in the software to go to a specific angle.The servo motor was used for steering the forklift by turning the driven wheel to adesired angle.

Two DC motors were used in this project, one for driving the forklift and onefor lifting the payload. By testing different DC motors powered through an externalpower supply and with varying loads the conclusion was that motors with a rangeof 12-24 V worked well. To drive the rear wheel a Buhler gear motor 29 flat1.61.065.466 was used [10]. It is a 24 V motor with a gear ratio of 242:1. It wasslow but powerful with a no load speed of 22 rpm and a rated torque of 20 Ncm.

To do the lifting a 12 V DC motor from Dunkermotoren equipped with a gearboxwith gear ratio 250:1 was used [11]. It has a rotational speed of 20 rpm and a torqueof 10 Ncm. This motor was responsible for the lifting by rotating a threaded rod.

Since the DC motors never ran at the same time they were both powered bythe same batteries. The batteries that powered the motors consisted of eight 1.5 Vcells, that is 12 V in total. The Buhler motor was rated for 24 V but 12 V wasconsidered enough.

7

Page 22: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

CHAPTER 3. DEMONSTRATOR

3.1.3 Line follower sensor IR

The forklift travelled by following a line on the ground in order to get to the desti-nation. To be able to detect the line IR sensors were used [12]. The sensor required5V and had one output, high or low. The sensor’s sensitivity could also be changedto respond to a darker or lighter area. The sensors were placed on either side of adark line on a light surface. If the forklift started to drive in the wrong directionone of the sensors would detect the line and signal to the servo that it is time toturn the rear wheel, thus making the forklift drive in the right direction again.

3.1.4 H bridge

To be able to rotate both DC motors in both directions, two H bridges were needed.The H bridges used were STMicroelectronics L9997ND with a DC supply voltageof -0.3 to 26V which covered the voltage range of both DC motors [13].

3.1.5 Mechanical parts

To lift the payload the forks were fitted onto a fixed nut on a threaded rod. The rodwas then rotated by one of the motors which moved the forks up or down dependingon rotational direction. To transfer the power from the motor to the rod, two gearswere fitted, one to the motor and one to the rod. The lifting mechanism can beseen in figure 3.1. This lifting mechanism is more energy efficient than a hydraulicmechanism [14].

Figure 3.1. The lifting mechanism made in Solid Edge

8

Page 23: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

3.2. SOFTWARE

The forklift was fitted with three wheels, two in the front and one in the rear.The forklift had rear wheel drive and the steering was also done by the rear wheel.The rear wheel was fitted directly onto the motor that powered it and together theywere built in to a wheelhouse which was fastened to the servo motor. The servomotor could then rotate the whole wheelhouse to change the angle of the rear wheelto achieve steering. The wheelhouse is shown in figure 3.2.

Figure 3.2. The wheelhouse made in Solid Edge

3.1.6 Arduino Uno

To control the forklift an Arduino Uno was utilized. Arduino Uno is a board withdigital input/output pins, pulse-width modulation (PWM), analog input pins and amicrocontroller that can be programmed to process the input and return the desiredoutput. The microcontroller on the Uno is the ATmega328P [15]. The Arduino waspowered by a 9V battery.

3.2 Software

The software was written in C using the Arduino integrated development environ-ment. Since the forklift was expected to follow a predetermined path (figure 4.3 and4.4) large sections of the code could be reused multiple times during one drivingcycle. To achieve this a couple of functions were used, for example one functionthat handled the turning part of the driving and one that handled reversing. Thesefunctions could then be called to by the main program which resulted in a wellorganized structure. The path to be followed by the forklift could easily be changedby simply adding or removing some functions in the main code, without having tomodify the function itself.

9

Page 24: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

CHAPTER 3. DEMONSTRATOR

The output signals from the IR sensors were used for programming the functionsresponsible for driving and steering. Each combination of signals resulted in adifferent steering angle. A flowchart to represent the function responsible for drivingforward can be seen in figure 3.3. This function ended with a counter in the softwareincreasing its value by one. This allowed the forklift to be aware of where it waspositioned during a driving cycle and what maneuvers to do next.

Since the other functions were written in a similar way they are not explainedhere but can be found, together with the rest of the code, in Appendix B.

Figure 3.3. Flowchart of forward func() function. lf = left front, rf = right front,LOW = sensor detects a light surface, HIGH = sensor detects a dark surface. Madein draw.io

The lifting mechanism is controlled by two functions, one for raising and onefor lowering. Raising is done by powering the DC motor a set amount of time andfor lowering the DC motor simply rotates the other way lowering the forks until aswitch is reached.

10

Page 25: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

Chapter 4

Testing and Results

4.1 Line following

The first test conducted was to test different setups for the line following IR sensors.Firstly, only motion straight forward was tested, when this was achieved turningand reversing was added. The sensors were placed underneath the sides of theforklift and therefore the black line which was to be followed had to be almost aswide as the forklift. A thin black stripe running across the thick black line was usedto signal to the forklift that it should stop, turn or reverse. Throughout the rest ofthe text the thick black line will simply be referred to as ”line” while the thin lineswill be called ”stripes”.

Figure 4.1 illustrates a drive forward then stopping, note that the IR sensorsare represented by circles that turn red when a reflective surface is present and thatthe front wheels are not included. The rear wheel can be seen turning.

Figure 4.1. Drive forward then stop. Made in MS Paint.

4.1.1 Sensor placement and forward motion

Three different setups for the sensors were tested, two sensors in the back by therear wheel, two in front of the front wheels and using two sensors both in the frontand in the back. The forklift was tested on its ability to stay on a straight blackline when there was an initial angle error. The length of the test track was 160cm. Different values for the angle the back wheel turns when correcting were alsotested. The results can be seen in table 4.1, 4.2 and 4.3. For each starting angle and

11

Page 26: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

CHAPTER 4. TESTING AND RESULTS

correction three tests were done and to pass, all three had to be successful. A testwas passed if the forklift managed to align itself and keep on following the line withonly minor corrections. There was also the case of unstable drive when the forkliftmanaged to follow the line but never reached a stable state meaning it continuedto turn back and forth.

Table 4.1. Result of tests with sensors located at the rear wheel.

Sensors rearStarting angle Correction

15° 25° 35°0° Fail Fail Fail15° Fail Fail Fail20° Fail Fail Fail25° Fail Fail Fail30° Fail Fail Fail

Table 4.2. Result of tests with sensors at the front wheels.

Sensors frontStarting angle Correction

15° 25° 35°0° Pass, 3 turns Pass 3 turns Unstable, 9 turns15° Pass, 7 turns Pass, 4 turns Unstable, 8 turns20° Fail Pass, 4 turns Unstable, 8 turns25° Fail Pass, 6 turns Unstable, 8 turns30° Fail Fail Unstable, 10 turns

Table 4.3. Result of tests when using sensors both at the front and rear wheels.

Sensors both front and rearStarting angle Correction

15° 25° 35°0° Fail Fail Fail15° Fail Fail Fail20° Fail Fail Fail25° Fail Fail Fail30° Fail Fail Fail

As seen by the tables above sensors placed at the front were best when it cameto driving forward, as a result this setup was chosen to be used in further testing.

12

Page 27: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

4.2. LAYOUT OF OPERATING AREA

4.1.2 ReversingBecause the front sensors provided best results when driving forward the assumptionthat the rear sensors would be best when reversing was made. The first reversingtests quickly showed that the assumption was correct. The results, as shown in thetable 4.4, were very good so no further experimenting with sensor placement wasneeded.

Table 4.4. Result of tests when reversing using the sensors by the rear wheel.

ReversingStarting angle Correction

15° 25° 35°0° Pass, 2 turns Pass, 3 turns Pass, 3 turns15° Pass, 3 turns Pass, 3 turns Pass, 3 turns20° Pass, 4 turns Pass, 4 turns Pass, 4 turns25° Pass, 6 turns Pass, 5 turns Pass, 4 turns30° Pass, 6 turns Pass, 5 turns Pass, 5 turns

4.2 Layout of operating areaWhen both driving forward and reversing was achieved testing different layouts ofthe operating area began. Firstly, a layout that would require small turns wasconstructed, which resulted in a Y-shaped track seen in figure 4.2.

Figure 4.2. Problematic Y-layout. Pallets represented by orange rectangles. Madein MS Paint.

This layout quickly proved to be problematic due to the rather wide dark areawhere the line splits into two. The two front sensors had to cover a large dark areawhich resulted in difficulties following the desired path, often resulting in failure.

To eliminate this problem an X-shaped layout, that has been proven to be oneof the most effective on a larger scale [16], was tested and can be seen in figure 4.3and 4.4.

This layout, consisting of orthogonal light and dark lines and stripes of differentsize, turned out to be a solution that worked really well with the sensors being placed

13

Page 28: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

CHAPTER 4. TESTING AND RESULTS

at the corners of the forklift. When turning 90° or 180° the rear sensors could makeuse of the straight line which resulted in an aligned position after completing theturn, something that proved difficult with the previous Y-layout. The dark andlight stripes allowed to split up the path into different segments, thus making theforklift able to keep track of what to do next. This ability to differentiate betweensegments of the path was made possible by a programmed counter that incrementsits value by one each time a light or dark stripe is reached.

The final driving cycle can be seen in figure 4.3 and 4.4 where the differentsegments of the path are represented by arrows. The driving cycle was initiated bythe push of a button and the pallets were located on the ground. The driving cyclestarted with the forklift driving to the intersection and then turning right when theblack stripe was reached by the front sensors. Then the forklift went to pick up thefirst pallet and then reversed until the front sensors reached the white stripe wherethe forklift was told to make a 90° right turn. The forklift then drove forward todeliver the first pallet and then reversed and made a 180° turn. Now to pick upthe second pallet the forklift drove as follows: drive forward, pick up pallet, reverse,turn 180°, drop off pallet, reverse, turn 180°. Now the driving cycle was completedand the forklift is awaiting to start a new cycle. When the second pallet was to bedelivered it simply pushed the previous pallet so they ended up positioned in a lineon the ground.

In figure 4.3 and 4.4 pallets are represented by orange rectangles and the drop-offzone is marked by a black rectangle. Blue is forward motion and green is reverse.The green asterisk represents a 90° clockwise rotation.

14

Page 29: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

4.2. LAYOUT OF OPERATING AREA

Figure 4.3. Driving pattern to pick up the first pallet. Made in MS Paint.

15

Page 30: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

CHAPTER 4. TESTING AND RESULTS

Figure 4.4. Driving pattern to pick up the second pallet. Made in MS Paint.

4.3 Lifting mechanism

To test the lifting mechanism weights placed on a pallet were used and the liftsability to lift them during one minute was measured. The ability to transport theweight was also tested. When testing the lift the maximum weight was found to be600 g, that is 35% of the forklift’s weight (1720 g). The transport test showed that600 g was also the maximum. The limiting factor was not the lift itself, the problemwas that the forklift started to tip above 600 g. During testing the batteries (one9 V and one 12 V ) were moved as far back as possible to provide counter balanceto the lifting. The results of the lifting test can be seen in table 4.5. The results ofthe transport test can be seen in figure 4.6.

16

Page 31: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

4.3. LIFTING MECHANISM

Table 4.5. Result of weight lifting tests

Weight lifted during one minuteWeight (g) Height (cm)

0 6100 6200 6300 6400 6500 6600 6700 0

Table 4.6. Result of weight transporting tests

Weight transportedWeight (g) Pass/Fail One driving cycle (min:sec) Relative (%)

0 Pass 6:00100 Pass 6:02 +1200 Pass 6:06 +2300 Pass 6:10 +3400 Pass 6:15 +4500 Pass 6:21 +6600 Pass 6:23 +6

17

Page 32: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading
Page 33: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

Chapter 5

Discussion and Conclusion

5.1 Line following

Three different setups of line following sensors were tested: sensors by the rearwheel, sensors by the front wheels and using both. The tests showed that usingonly two sensors by the front wheels was superior for driving forward. This wasbecause when the sensors were placed by the front wheels they got input muchquicker than if they were by the rear wheel. Thus the forklift didn’t travel as faraway form the line and the correction didn’t have to be as large, resulting in asmoother ride.

Using sensors both in the front and rear resulted in a very unstable drive wherethe forklift was constantly over correcting and thus kept turning back and forth overthe line. A major problem with using sensors in the back was the forklift not alwaysturning the correct way, as seen in figure 5.1. Just a slight misalignment of the rearend of the forklift changes the way the rear wheel will turn, which potentially couldresult in the forklift driving in a completely wrong direction. The conclusion wasthat four sensors did more harm than good when compared to only two sensors.

Figure 5.1. Problem turning. Made in MS Paint.

The amount the forklift should turn the back wheel to correct its path was alsotested. Three different degrees were tested, 15° , 25° and 35°. For driving forward15° turned out to be to little and the forklift had trouble getting back to the line,35° was to much and the forklift sometimes over corrected but 25° worked fine.

Since using sensors in the front was best when going forward, the assumption

19

Page 34: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

CHAPTER 5. DISCUSSION AND CONCLUSION

was made that using only the rear sensors would work well when reversing. Thisalso proved to be the case. Using anything other than only the rear sensors resultedin similar problems described above. The amount the back wheel turned duringreversing was chosen to 15° because it proved to be enough and with a smallercorrection the forklift had a smoother drive. As shown by the results reversingactually performed better than driving forward. This was to be expected sincevehicles with front wheel steering (the opposite to this forklift) require the moststeering input when reversing, something every car driver has experienced whentrying to maneuver a car in reverse. Since front wheel steering would be problematicto implement due to space in the front being occupied by the lifting mechanismand the fact that forklifts often operate while in reverse solving this problem isunnecessary and would lead to a much more complex prototype.

During testing it was noted that the forklift was pulling slightly to one side. Thiswas found to be because the front wheels were not exactly even and one rotatedeasier than the other. It did however not pose a problem since the forklift easilycorrected itself when it pulled too far off course. This means the forklift is capableof driving straight even though it might be unevenly loaded.

Turning 90° and 180° was not a problem and worked flawlessly. A turn wasinitiated when the front sensors detected a black stripe. During the turn only theinput from the rear sensors was used. When a predetermined pattern of inputsignals was detected the forklift had completed its turn.

5.2 Layout of operating area

The initial idea described in the introduction was to make a layout where the forkliftwas placed at the position where all the different paths intersect. The Y-shapedlayout illustrated in figure 4.2 was meant to be a simple first prototype to whichmore paths would be added later on. As mentioned in the previous chapter thislayout quickly proved to be problematic due to the large dark areas in the middle ofthe intersection. The solution to this problem turned out to be an X-shaped layout.The forklift having the shape of a rectangle with sensors at each corner togetherwith the orthogonal lines of the new layout turned out to be a great combinationthat allowed the forklift to maneuver with ease and consistency.

Another reason this X-shape was chosen was because it is the most commonlayout-pattern in warehouses equipped with autonomous robots. This X-shapedlayout allows the warehouse to be divided into multiple zones and therefore makingit possible for multiple robots to work simultaneously [17].

Because of this layout having a great potential to be used in an autonomouswarehouse with multiple robots and knowing that the forklift handles really well onit, it was concluded that the X-shaped layout was the optimal one.

20

Page 35: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

5.3. LIFTING MECHANISM

5.3 Lifting mechanism

By choosing a powerful motor with a high gear ratio the vertical speed of the liftbecame independent of the weight being lifted, which can be seen in Table 4.5.Each test with different weights managed to lift the pallet 6cm in one minute. Theconsistency of the lifting speed meant only one micro switch at the bottom couldbe used, while raising was simply done by running the motor for a set amount oftime.

On the other hand the time to complete a full driving cycle increased withincreased weight applied. But this was not considered to be a big problem since thedifference between a drive unloaded and fully loaded was only 6%.

The forklift’s operating times being almost independent from the weight trans-ported is a great feature that allows the forklift to behave in a controlled way andthus potentially allowing it to cooperate with other autonomous robots.

5.4 Conclusion

To conclude this project a summary of the research questions will be presented.

• How should an autonomous counterbalance forklift be designed to be able topick up and deliver pallets by itself?

A three wheeled forklift with two freely rotating front wheels and a rear wheelresponsible for driving and steering was a great design that offered superbmaneuverability. A mechanical lifting mechanism consisting of two cogwheels,a worm screw and a nut to which the forks are mounted was an efficientsolution that was capable of lifting heavy loads at a constant time. To makethe forklift user-friendly the software was designed to make use of functions.To change the forklift’s driving simply add or remove functions without havingto change the functions itself, that often contain a more complicated code.The forklift was capable of navigating by itself thanks to four IR sensors anda micro switch.

• How many IR sensors are needed and how should they be positioned to allowa forklift to follow a line?

Four IR sensors, one underneath each corner of the forklift, provided the bestresults. When driving forward only the front sensors were used and whenreversing only the rear sensors were used.

• What is the optimal layout of the operating area that allows the forklift tofunction efficiently?

The best layout was an X-shaped one. This layout worked best with the IRsensors being positioned at each corner of the forklift.

21

Page 36: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

CHAPTER 5. DISCUSSION AND CONCLUSION

5.5 Recommendations for future workTo make the forklift work completely without human interaction sensors that signalwhen a pallet is nearby would be needed. This would mean the forklift could startto drive automatically without anyone having to initiate it manually by the pushof a button.

Sensors in the forks would also be a good idea since it would allow the forkliftto adjust itself in order to unload pallets from trailers with varying height.

If this forklift was to be used in a warehouse with humans there would have to bea safety system monitoring the operating area. To avoid equipping the forklift withmore sensors a recommendation would be to install sensors outside of the operatingarea. These sensors would guard the operating area and in case something got insidethe forklift would stop immediately.

22

Page 37: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

Bibliography

[1] Y. Liu, B. Xiao, Z. Jiang, and Y. He, “Optimal control of three-wheel steeringforklift with steer-by-wire,” in 2017 36th Chinese Control Conference (CCC),July 2017, pp. 4719–4723, doi: https://doi.org/10.23919/ChiCC.2017.8028097.

[2] K. M. Hasan, , and A. Al Mamun, “Implementation of autonomous line followerrobot,” in 2012 International Conference on Informatics, Electronics Vision(ICIEV), May 2012, pp. 865–869, doi: https://doi.org/10.1109/ICIEV.2012.6317486.

[3] S. Liawatimena, B. T. Felix, A. Nugraha, and R. Evans, “A mini forkliftrobot,” in The 2nd International Conference on Next Generation Informa-tion Technology, June 2011, pp. 127–131, doi: https://doi.org/10.1109/ICIEV.2012.6317486.

[4] H. Johansson, Elektroteknik. Stockholm: Institutionen for maskinkonstruk-tion, Tekniska hogsk., 2006.

[5] Science buddies, introduction to servo motors. (Last accessed 2019-03-29).[Online]. Available: https://www.sciencebuddies.org/science-fair-projects/references/introduction-to-servo-motors

[6] D. E. Bolanakis, Microcontroller Education: Do it Yourself, Reinvent theWheel, Code to Learn (Synthesis Lectures on Mechanical Engineering). Mor-gan & Claypool Publishers, 2017.

[7] H. Young, Sears and Zemansky’s university physics with modern physics : tech-nology update. Harlow, Essex: Pearson Education, 2014.

[8] Omron ultra subminiature basic switch. (Last accessed 2019-05-02). [Online].Available: https://www.electrokit.com/uploads/productfile/41011/03587326.pdf

[9] Hitec hs-303 datasheet. (Last accessed 2019-03-25). [Online]. Avail-able: http://www0.cs.ucl.ac.uk/staff/S.Friston/supplementarymaterials/latencymeasurementinvirtualenvironments/downloads/HS303.pdf

23

Page 38: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

BIBLIOGRAPHY

[10] Buhler motor. (Last accessed 2019-03-25). [Online]. Available: https://www.oem.co.uk/ui/product-resources/oem/29mm-flat-gear-motor-datasheet--152391.pdf?att=False&hash=907C0E720835658EFC1E9C9FD4AB25ED

[11] Directindustry dunkenmotoren dc motor. (Last accessed 2019-03-26). [On-line]. Available: http://www.directindustry.com/prod/dunkermotoren-gmbh/product-14411-1472615.html

[12] Line follow sensor infromation. (Last accessed 2019-03-26). [Online].Available: https://www.electrokit.com/uploads/productfile/41015/41015707- Line Follower.pdf

[13] H bridge l9997nd data sheet. (Last accessed 2019-03-28). [Online]. Available:https://www.st.com/resource/en/datasheet/l9997nd.pdf

[14] L. Wang, D. Zhao, Y. Wang, L. Wang, Y. Li, M. Du, and H. Chen,“Energy management strategy development of a forklift with electric liftingdevice,” Energy, vol. 128, pp. 435 – 446, 2017. [Online]. Available:https://doi.org/10.1016/j.energy.2017.04.012

[15] Arduino uno. (Last accessed 2019-03-26). [Online]. Available: https://store.arduino.cc/arduino-uno-rev3

[16] J. J. Bartholdi and K. R. Gue, “The best shape for a crossdock,”Transportation Science, vol. 38, no. 2, pp. 235–244, 2004. [Online]. Available:http://www.jstor.org/stable/25769194

[17] D. Roy, A. Krishnamurthy, S. S. Heragu, and C. J. Malmborg, “Performanceanalysis and design trade-offs in warehouses with autonomous vehicletechnology,” IIE Transactions, vol. 44, no. 12, pp. 1045–1060, 2012. [Online].Available: https://doi.org/10.1080/0740817X.2012.665201

24

Page 39: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

25

Page 40: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

APPENDIX A. CIRCUIT DIAGRAM

Appendix A

Circuit diagram

Figure A.1. Circuit diagram made with Fritzing sofware.26

Page 41: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

Appendix B

Code

1 /∗ Pro j ec t name : Autonomous Counterbalance F o r k l i f t2 ∗ Date : 2019−05−053 ∗ Desc r ip t i on : This program i s used to c o n t r o l a l i n e f o l l o w e r4 ∗ f o r k l i f t that has a predetermined dr iv ing−c y c l e .5 ∗ I t i s a l s o equipped with a l i f t n i n g mechanism that6 ∗ can be r a i s e d and lowered .7 ∗/89

10 #inc lude <Servo . h>11 i n t forward = 8 ; // pin f o r r ea r motor12 i n t back = 7 ; // pin f o r r ea r motor13 i n t s e n s o r l f = 2 ; // senso r l e f t f r o n t14 i n t s e n s o r r f = 3 ; // senso r r i g h t f r o n t15 i n t s e n s o r l r = 4 ; // senso r l e f t r ea r16 i n t s e n s o r r r = 5 ; // senso r r i g h t r ea r17 i n t v a l l f ; // value from s e n s o r l f18 i n t v a l r f ; // value from s e n s o r r f19 i n t v a l l r ; // value from s e n s o r l r20 i n t v a l r r ; // value from s e n s o r r r21 i n t up = 9 ; // pin f o r f r o n t motor22 i n t down = 10 ; // pin f o r f r o n t motor23 i n t myswitch ; // micro switch24 i n t myswitch val = 11 ; // value from myswitch25 Servo myservo ; // i n i t i a l i z i n g servo26 i n t pos = 0 ; // servo pos t i on27 i n t s = 0 ; // a v a r i a b l e needed f o r turn ( ) func t i on28 i n t s2 = 0 ;29 i n t b lack = 0 ; // a counter that keeps t rack o f where the f o r k l i f t30 // i s located , incremented by one when a black l i n e31 // i s detec ted323334 void setup ( ) {35 // s e t t i n g p ins as e i t h e r input or output36 pinMode ( forward , OUTPUT) ;37 pinMode ( back , OUTPUT) ;

27

Page 42: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

APPENDIX B. CODE

38 pinMode ( s e n s o r l f , INPUT) ;39 pinMode ( s e n s o r r f , INPUT) ;40 pinMode ( s e n s o r l r , INPUT) ;41 pinMode ( s e n s o r r r , INPUT) ;42 pinMode (up , OUTPUT) ;43 pinMode (down , OUTPUT) ;44 pinMode ( myswitch val , INPUT) ;45 myservo . attach (13) ; // s e t t i n g servo to pin 13464748 /∗ Making sure the f o r k l i f t i s s t a t i o n a r y with r ea r wheel turned49 to the middle (92) and f o r k s lowered ∗/50 myservo . wr i t e (92) ;51 d i g i t a l W r i t e ( forward , LOW) ;52 d i g i t a l W r i t e ( back , LOW) ;53 lower ( ) ;545556 // The dr iv ing−c y c l e beg ins here :5758 // forward #1, counter becomes : b lack = 159 f o rward func ( ) ;6061 // turn 90 #162 turn ( ) ;6364 /∗ F o r k l i f t d r i v e s forward f o r 1 sec to makemake sure the f r o n t65 s e n s o r s are not above white ∗/66 d i g i t a l W r i t e ( back , LOW) ;67 d i g i t a l W r i t e ( forward , HIGH) ;68 delay (1000) ;69 /∗ This while−loop makes sure that the f r o n t s e n s o r s have passed70 the blacked l i n e and are above white when the program cont inues ∗/71 whi le ( t rue ) {72 v a l l f = d ig i t a lRead ( s e n s o r l f ) ;73 v a l r f = d ig i t a lRead ( s e n s o r r f ) ;74 i f ( v a l l f == LOW && v a l r f == LOW)75 break ;76 }7778 // forward #3, counter becomes : b lack = 279 f o rward func ( ) ;8081 // F o r k l i f t has a r r i v e d to f i r s t p a l l e t and t h e r e f o r e s tops82 d i g i t a l W r i t e ( forward , LOW) ;8384 // r a i s e f u n c #185 r a i s e f u n c ( ) ;8687 // r e v e r s e #188 r e v e r s e ( ) ;89 delay (1000) ;90 /∗ This while−loop a l l ows the f r o n t s e n s o r s to be ” i n a c t i v e ” whi l e91 t r a v e l l i n g a c r o s s a black area be f o r e reach ing a white s t r i p e ∗/

28

Page 43: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

92 whi le ( s2 != 1) {93 v a l l f = d ig i t a lRead ( s e n s o r l f ) ;94 v a l r f = d ig i t a lRead ( s e n s o r r f ) ;95 i f ( v a l l f == HIGH && v a l r f == HIGH) {96 /∗ This a way o f t e l l i n g the f o r k l i f t that a black s t r i p e has97 been reached once ∗/98 black = 3 ;99 /∗ While both f r o n t s e n s o r s on black , keep r e v e r s i n g u n t i l a

100 white s t r i p e i s encountered ∗/101 whi le ( b lack == 3) {102 v a l l f = d ig i t a lRead ( s e n s o r l f ) ;103 v a l r f = d ig i t a lRead ( s e n s o r r f ) ;104 // i f white s t r i p e encountered105 i f ( v a l l f == LOW && v a l r f == LOW) {106 s2 = 1 ;107 /∗ break the loop and s i n c e s2 = 1 the outermost108 while−loop a l s o s tops ∗/109 break ;110 }111 }112 }113 }114115 // turn 90 #2116 turn ( ) ;117118 // forward #3, counter becomes : b lack = 4119 f o rward func ( ) ;120121 /∗ Motor keeps r o t a t i n g forward f o r 2 sec . This i s done when122 a black s t r i p e i s to be ignored . This combination o f123 running the motor toge the r with a de lay i s used qu i t e124 f r e q u e n t l y in the r e s t o f the code , t h e r e f o r e i t w i l l not125 be commented again . ∗/126 d i g i t a l W r i t e ( back , LOW) ;127 d i g i t a l W r i t e ( forward , HIGH) ;128 delay (2000) ;129130 // forward #4, counter becomes : b lack = 5131 f o rward func ( ) ;132 d i g i t a l W r i t e ( back , LOW) ;133 d i g i t a l W r i t e ( forward , LOW) ;134135 // lower #1136 lower ( ) ;137138 // r e v e r s e #2139 r e v e r s e ( ) ;140 d i g i t a l W r i t e ( back , LOW) ;141 d i g i t a l W r i t e ( forward , LOW) ;142 delay (1000) ;143144 // turn 180 #1145 turn ( ) ;

29

Page 44: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

APPENDIX B. CODE

146 d i g i t a l W r i t e ( back , LOW) ;147 d i g i t a l W r i t e ( forward , LOW) ;148 delay (1000) ;149150 // forward #5 // counter becomes : b lack = 6151 f o rward func ( ) ;152 d i g i t a l W r i t e ( back , LOW) ;153 d i g i t a l W r i t e ( forward , HIGH) ;154 delay (2000) ;155156 // forward #6 // counter becomes : b lack = 7157 f o rward func ( ) ;158 d i g i t a l W r i t e ( back , LOW) ;159 d i g i t a l W r i t e ( forward , HIGH) ;160 delay (1000) ;161162 // forward #8 // counter becomes : b lack = 9163 f o rward func ( ) ;164 S e r i a l . p r i n t ( b lack ) ;165 d i g i t a l W r i t e ( back , LOW) ;166 d i g i t a l W r i t e ( forward , LOW) ;167168 // r a i s e f u n c #2169 r a i s e f u n c ( ) ;170171 // r e v e r s e #3172 r e v e r s e ( ) ;173 d i g i t a l W r i t e ( back , HIGH) ;174 d i g i t a l W r i t e ( forward , LOW) ;175 delay (1000) ;176177 // r e v e r s e #4178 r e v e r s e ( ) ;179 d i g i t a l W r i t e ( back , LOW) ;180 d i g i t a l W r i t e ( forward , LOW) ;181 delay (1000) ;182183 // turn 180 #2184 turn ( ) ;185 d i g i t a l W r i t e ( back , LOW) ;186 d i g i t a l W r i t e ( forward , LOW) ;187 delay (1000) ;188189 // forward #9, counter becomes : b lack = 10190 f o rward func ( ) ;191 d i g i t a l W r i t e ( back , LOW) ;192 d i g i t a l W r i t e ( forward , HIGH) ;193 delay (2000) ;194195 // forward #10, counter becomes : b lack = 11196 f o rward func ( ) ;197 S e r i a l . p r i n t ( b lack ) ;198 d i g i t a l W r i t e ( back , LOW) ;199 d i g i t a l W r i t e ( forward , LOW) ;

30

Page 45: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

200201 // lower #2202 lower ( ) ;203204 // r e v e r s e #4205 r e v e r s e ( ) ;206 d i g i t a l W r i t e ( back , LOW) ;207 d i g i t a l W r i t e ( forward , LOW) ;208 delay (1000) ;209210 // turn 180 #3211 turn ( ) ;212 d i g i t a l W r i t e ( back , LOW) ;213 d i g i t a l W r i t e ( forward , LOW) ;214 delay (1000) ;215216 // forward #11, counter becomes : b lack = 12217 f o rward func ( ) ;218 d i g i t a l W r i t e ( back , LOW) ;219 d i g i t a l W r i t e ( forward , HIGH) ;220 delay (2000) ;221222 /∗ Here the f o r k l i f t has returned to i t s s t a r t i n g p o s i t i o n and223 t h e r e f o r e the motor i s stopped and the r ea r wheel i s turned224 s t r a i g h t . ∗/225 d i g i t a l W r i t e ( back , LOW) ;226 d i g i t a l W r i t e ( forward , HIGH) ;227 myservo . wr i t e (92) ;228 delay (1000) ;229 d i g i t a l W r i t e ( forward , LOW) ;230231 }232233234 void loop ( ) {235 }236237238 // func t i on f o r d r i v i n g forward239 void forward func ( ) {240 v a l l f = d ig i ta lRead ( s e n s o r l f ) ;241 v a l r f = d ig i t a lRead ( s e n s o r r f ) ;242 d i g i t a l W r i t e ( back , LOW) ;243 d i g i t a l W r i t e ( forward , HIGH) ;244 // as long as a black s t r i p e i s not encountered245 whi le ( v a l l f == LOW | | v a l r f == LOW) {246 v a l l f = d ig i t a lRead ( s e n s o r l f ) ;247 v a l r f = d ig i t a lRead ( s e n s o r r f ) ;248 // i f both s e n s o r s on white , turn r ea r wheel s t r a i g h t249 i f ( v a l l f == LOW && v a l r f == LOW) {250 myservo . wr i t e (92) ;251 delay (200) ;252 }253 /∗ i f l e f t f r o n t s enso r on black and r i g h t f r o n t s enso r on white ,

31

Page 46: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

APPENDIX B. CODE

254 turn r ea r wheel to the r i g h t ∗/255 i f ( v a l l f == HIGH && v a l r f == LOW) {256 myservo . wr i t e (67) ;257 delay (200) ;258 }259 /∗ i f l e f t f r o n t s enso r on white and r i g h t f r o n t s enso r on black ,260 turn r ea r wheel to the l e f t ∗/261 i f ( v a l l f == LOW && v a l r f == HIGH) {262 myservo . wr i t e (117) ;263 delay (200) ;264 }265 }266 // increment counter by one267 black = black + 1 ;268 }269270271 // func t i on f o r turn ing c l o ckw i s e272 void turn ( ) {273 d i g i t a l W r i t e ( forward , LOW) ;274 d i g i t a l W r i t e ( back , LOW) ;275 // turn r ea r wheel to the l e f t276 myservo . wr i t e (173) ;277 // de lay to make sure r ea r wheel has f i n i s h e d turn ing278 delay (500) ;279 d i g i t a l W r i t e ( back , LOW) ;280 d i g i t a l W r i t e ( forward , HIGH) ;281 // de lay to make sure that v a l l r i s LOW ( on top o f white )282 delay (3000) ;283 /∗ This while−loop ends when a s p e c i a l pattern o f input s i g n a l s284 from the s e n s o r s has been detec ted ∗/285 whi le ( t rue ) {286 v a l l r = d ig i t a lRead ( s e n s o r l r ) ;287 v a l r r = d ig i t a lRead ( s e n s o r r r ) ;288 /∗ F i r s t s tage o f the pattern . The f o r k l i f t has j u s t s t a r t e d289 turn ing so l e f t r ea r s enso r i s on white and r i g h t r ea r290 s enso r i s on black . ∗/291 i f ( s == 0 && v a l l r == LOW && v a l r r == HIGH) {292 s = 1 ;293 }294 /∗ Second s tage o f the pattern . The f o r k l i f t has j u s t295 detec ted the new black l i n e to be f o l l owed . ∗/296 i f ( s == 1 && v a l l r == HIGH && v a l r r == LOW) {297 // Le f t r ea r s enso r on black and r i g h t r ea r s enso r on white .298 s = 2 ;299 }300 /∗ Fina l s tage o f the pattern . The f o r k l i f t has completed301 the turn . Le f t r ea r s enso r on white and r i g h t r ea r302 s enso r on black . ∗/303 i f ( s == 2 && v a l l r == LOW && v a l r r == HIGH) {304 // r e s e t t i n g v a r i a b l e305 s = 0 ;306 d i g i t a l W r i t e ( forward , LOW) ;307 myservo . wr i t e (92) ;

32

Page 47: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

308 delay (1000) ;309 // break the while−loop310 break ;311 }312 }313 }314315316 // func t i on f o r r e v e r s i n g317 void r e v e r s e ( ) {318 myservo . wr i t e (92) ;319 d i g i t a l W r i t e ( forward , LOW) ;320 d i g i t a l W r i t e ( back , HIGH) ;321 v a l l r = d ig i t a lRead ( s e n s o r l r ) ;322 v a l r r = d ig i t a lRead ( s e n s o r r r ) ;323 // as long as a black s t r i p e i s not encountered324 whi le ( v a l l r == LOW | | v a l r r == LOW) {325 v a l l r = d ig i t a lRead ( s e n s o r l r ) ;326 v a l r r = d ig i t a lRead ( s e n s o r r r ) ;327 // i f both s e n s o r s on white turn r ea r wheel s t r a i g h t328 i f ( v a l l r == LOW && v a l r r == LOW) {329 myservo . wr i t e (92) ;330 delay (200) ;331 }332 /∗ i f l e f t r ea r s enso r on black and r i g h t r ea r s enso r333 on white , turn r ea r wheel to the r i g h t ∗/334 i f ( v a l l r == HIGH && v a l r r == LOW) {335 myservo . wr i t e (77) ;336 delay (200) ;337 }338 /∗ i f l e f t r ea r s enso r on white and r i g h t r ea r s enso r339 on black turn r ea r wheel to the l e f t ∗/340 i f ( v a l l r == LOW && v a l r r == HIGH) {341 myservo . wr i t e (107) ;342 delay (200) ;343 }344 }345 myservo . wr i t e (92) ;346 }347348349 // func t i on f o r r a i s i n g the f o r k s350 void r a i s e f u n c ( ) {351 d i g i t a l W r i t e (down , LOW) ;352 // motor s t a r t s to l i f t353 d i g i t a l W r i t e (up , HIGH) ;354 // 10 sec de lay to make sure the p a l l e t i s l i f t e d from the ground355 delay (10000) ;356 d i g i t a l W r i t e (up , LOW) ;357 }358359360 // func t i on f o r lower ing the f o r k s361 void lower ( ) {

33

Page 48: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

APPENDIX B. CODE

362 // read ing the value o f the switch363 myswitch = d ig i ta lRead ( myswitch val ) ;364 d i g i t a l W r i t e (up , LOW) ;365 // motor s t a r t s to lower the f o r k s366 d i g i t a l W r i t e (down , HIGH) ;367 // whi l e switch i s not pre s sed368 whi le ( myswitch == 0) {369 myswitch = d ig i ta lRead ( myswitch val ) ;370 }371 // when switch i s pre s sed the motor s tops .372 d i g i t a l W r i t e (down , LOW) ;373 }

34

Page 49: Autonomous Counterbalance Forklift - Diva1373807/...A solution to this problem would be to design an autonomous counterbalance forklift that could take care of the loading and unloading

TRITA ITM-EX 2019:31

www.kth.se