35
University of Victoria Department of Electrical and Computer Engineering ELEC 499B / CENG 499B Path Tracking Control for Autonomous Road Vehicles Path Seeker Project Final Report Due Date: April 2, 2004 At the edge of path tracking control Team Members: Jennifer Allan Roberto Armenta Jeff Larson Student #: 0021379 Student #: 0021936 Student #: 0024488 Computer Engineering Electrical Engineering Computer Engineering [email protected] [email protected] [email protected] Project Supervisor: Prof. Ashoka K. S. Bhat

Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

University of VictoriaDepartment of Electrical and Computer Engineering

ELEC 499B / CENG 499B

Path Tracking Control forAutonomous Road Vehicles

Path Seeker ProjectFinal Report

Due Date:April 2, 2004

At the edge of path tracking control

Team Members:

Jennifer Allan Roberto Armenta Jeff LarsonStudent #: 0021379 Student #: 0021936 Student #: 0024488

Computer Engineering Electrical Engineering Computer [email protected] [email protected] [email protected]

Project Supervisor:Prof. Ashoka K. S. Bhat

Page 2: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

Abstract

The Path Seeker is a project to construct a small two-axle autonomousvehicle (1/10 of the scale of a regular car on the street) that can follow apath set by a line of paint of a bright color on top of a dark surface. Thefirst prototype of the Path Seeker has been built with relative success.The vehicle is able to complete the task at hand, but some problemsregarding reliability and sensor sampling frequency were encountered.The Path Seeker project won first place on the IEEE Victoria Sectionawards given to the most outstanding ELEC/CENG 499B projects.

i

Page 3: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

Contents

List of Figures iii

1 Introduction 1

1.1 Proposed Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

1.2 Path Tracking Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

1.3 Scope of the project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

2 Path Seeker 2

2.1 Position Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2.2 Control Scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2.2.1 PID Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

2.2.2 Path Seeker Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

2.2.3 PID Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

2.2.4 Controller Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

3 Testing 8

3.1 Difficulties Encountered . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

3.2 Successes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

4 Recommendations 9

5 Work Load 9

6 Project Website 10

7 Conclusion 10

8 Appendix A

9 Appendix B

10 Appendix C

11 Appendix D

ii

Page 4: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

List of Figures

1 Path Seeker and the Path Seeker team. From left to right Roberto Armenta,Jenny Allan and Jeff Larson. The picture was taken during the final Path Seekertest (March 22, 2004). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2 Path Seeker parts schematic. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

3 Hamamatsu P5587 IR photoreflector [6]. These photoreflectors were used as thecore components of the Path Seeker’s position sensor (shown in Figure 4). . . . . 5

4 Position sensor Printed Circuit Board (PCB) assembling. The array of 32 nicelyaligned photoreflectors can be easily identified on the PCB. . . . . . . . . . . . . 5

5 Control Diagram of the Path Seeker Controller. . . . . . . . . . . . . . . . . . . . 7

6 Path Seeker on its testing track during its final testing (March 22, 2004). . . . . 8

iii

Page 5: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

Path Seeker Project: Final Report

1 Introduction

The proposed ELEC/CENG 499B Path Seeker project has been concluded with success. Thepurpose of this final project report is to present the obtained results. The project proposal wassubmitted on January 9, 2004, and two progress reports have been submitted since then. Thefirst progress report was submitted on January 19, 2004 and the second progress report wassubmitted on March 9, 2004. This report summarizes all the information contained in previousdocuments and presents the final results.

1.1 Proposed Project

The purpose of the project was to construct a small autonomous vehicle (called Path Seeker)that has the ability to follow a trajectory set by a continuous path printed on a planar surface(e.g. a paved road). The aim of the project is to develop a simple low cost platform thatcould ultimately evolve into a test vehicle for path tracking control algorithms, which find theirultimate application in aerospace, robotics and industrial control.

On March 22, 2004, the team completed the first prototype of the Path Seeker (see Figure 1).The Path Seeker is a small two-axle autonomous vehicle (1/10 of the scale of a regular car onthe street) that can follow a path set by a line of paint of a bright color on top of a dark surface.

1.2 Path Tracking Control

In the past two or three decades, a lot of interest has emerged in the development of path trackingcontrol schemes for wheeled vehicles that only move forward on a planar surface and have abounded turning radius. Such a vehicle is called a Dubins’ car in honour of the mathematicianL. E. Dubins, who first addressed this control problem [5].

Definition 1 Dubin’s cars are kinematic models of wheeled vehicles that move onlyforward in a plane and possess a lower bounded turning radius.

The motivation for developing control schemes for Dubins’ cars is that they are an essentialpart of the kinematic models of road vehicles [3]. Dubins demonstrated that a vehicle that canonly move forward with curvature bounds is controllable [5]. A wide variety of control schemeshave been developed for Dubins’ cars (e.g. [2] and [1]). One of the best optimal control schemesfor Dubins’ cars was developed by A. Balluchi and P. Soueres [2]. Most path tracking controlalgorithms, including the one proposed by A. Balluchi and P. Soueres [2], require two pieces ofinformation as inputs: the position of the vehicle with respect to the desired path (using twocartesian coordinates) and the heading angle error of the vehicle.

1.3 Scope of the project

To construct an autonomous vehicle that is able to use a sophisticated path tracking controlalgorithm, such as the one proposed by A. Balluchi and P. Soueres [2], would be extremely

1

Page 6: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

difficult in only four months, the time ELEC/CENG499 students have to complete their projects.Such a vehicle would require wireless position sensing that is able to compute both the positionof the vehicle with respect to the desired path and the heading angle error for any arbitraryposition of the vehicle with respect to the path.

To be able to propose a project that could be completed in four months, the team decided tolimit the scope of the project to build a small two-axle autonomous vehicle that resembles acommon road vehicle with a simple position sensor mounted on the front axle that computes theposition of the vehicle with respect to the desired path for a limited range of path deviations.Since most of the state of the art path tracking control algorithms also require the headingangle error information to be implemented, it was decided to control the vehicle using a simpleProportional-Integral-Derivative (PID) control scheme. The first prototype of the Path Seekerwas, therefore, built using a position sensor and a PID controller.

It is important to note that a path tracking algorithm that uses a PID controller and does notuse the heading angle error information, is not, in theory, guaranteed to converge to a solution ofthe controllability problem. Nevertheless, a PID controller scheme will work for low (somewhatconstant) speeds and very simple paths consisting of relatively large circles and straight lines.

The motivation behind this approach is that, in a future project, a replica of the position sensorthat was installed on the front axle could be added to the rear axle of the vehicle to providea second reference point. The extra reference point would provide an approximation to theheading angle error. With the extra heading angle error information a more robust controlscheme could, in principle, be implemented.

An overview of the functionality of the constructed vehicle and its main components is nowpresented.

2 Path Seeker

The path seeker is composed of seven main components, all of which are shown in Figure 2:

1. Microcontroller: Handyboard microcontroller based on Motorola’s 68HC11. It wasdeveloped for small robotics applications and can be programmed in Interactive-C.

2. Position Sensor: Printed Circuit Board (PCB) designed by the Path Seeker team, itindicates the position of the center of the car with respect to the desired path; it usesHamamatsu P5587 IR photoreflectors as its core component.

3. Chasis: hybrid Team Associated RC10L3/Serpent/Bolink graphite chassis.

4. Steering Servo: Futaba 4000 series servo (PWM controlled).

5. Speed Controller: composed of a Futaba 4000 series servo (PWM controlled) and amechanical position switch.

6. Motor: DC, rated 7.6V.

7. Batteries: Three sets of nickel cadmium batteries; one set powers the microcontroller,another powers the position sensor and the remaining one powers the motor.

The Path Seeker works in a fairly simple manner. The core component of the path seeker isthe position sensor, which is composed of an array of 32 photoreflectors laid across the front of

2

Page 7: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

Figure 1: Path Seeker and the Path Seeker team. From left to right Roberto Armenta, JennyAllan and Jeff Larson. The picture was taken during the final Path Seeker test (March 22, 2004).

the car’s chassis. Each of the photoreflectors outputs 0V if it detects a bright surface and 5Vif it detects a dark surface. The 32 photoreflectors are connected to one of the two 8-bit digitalinput ports of the microcontroller using multiplexors. By looking at the value of the outputof the photoreflectors, the microcontroller is able to calculate the position of the path just infront of it with respect to the center of the front axle of the vehicle. Using this information themicrocontroller updates the steering servo to keep the center of the Path Seeker aligned withthe position of the path. The speed of the vehicle is controlled through a servo that opens andcloses a mechanical switch that makes the car move forward (at a very low speed) or stop.

2.1 Position Sensor

The design of the position sensor was the most time consuming part of the project. A printedcircuit board was designed to be able to mount the array of photoreflectors (labeled 0-31) atthe desired position and to be able to interface them with the microcontroller. Figure 3 showsa picture of the photoreflector IC that was used (P5587 IR photoreflector). A picture takenduring the sensor’s assembly process is shown in Figure 4.

2.2 Control Scheme

An overview of how the Path Seeker is controlled is now given.

3

Page 8: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

Figure 2: Path Seeker parts schematic.

4

Page 9: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

Figure 3: Hamamatsu P5587 IR photoreflector [6]. These photoreflectors were used as the corecomponents of the Path Seeker’s position sensor (shown in Figure 4).

Figure 4: Position sensor Printed Circuit Board (PCB) assembling. The array of 32 nicelyaligned photoreflectors can be easily identified on the PCB.

5

Page 10: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

2.2.1 PID Controller

The standard form of the PID control action in analog controllers is given by [7]

m(t) = K

[e(t) +

1Ti

∫ t

0e(t)dt + Td

de(t)dt

](1)

where e(t) is the input to the controller, m(t) is the output of the controller, K is the proportionalgain, Ti is the integral time (or reset time), and Td is the derivate time (or rate time).

Since the control scheme was implemented using a discrete device (i.e. a microcontroller), thePID control action in digital form was used, which is given by [7]

m(kT ) = K

[e(kT ) +

T

Ti

k∑h=1

e((h− 1)T ) + e(hT )2

+Td

T[e(kT )− e((k − 1)T )]

](2)

where T is the sampling period and k is the sample number. Equation (2) can also be expressedin the Z-transform domain as

M(z) = K

[1 +

T

2Ti

1 + z−1

1− z−1+

Td

T(1− z−1)

]E(z). (3)

This last equation can be rewritten in the form

M(z) =[KP +

KI

1− z−1+ KD(1− z−1)

]E(z) (4)

whereKP = K − KT

2Ti= proportional gain, (5)

KI =KT

Ti= integral gain, (6)

KD =KTd

T= derivative gain. (7)

2.2.2 Path Seeker Controller

The form given by equation (4) was used to implement the PID controller of the Path Seeker.A diagram of the complete control scheme is shown in Figure 5. The controller receives tworeference inputs r1(kT ) and r2(kT ), where

r1(kT ) = motor control signal ={

1 if the motor is on0 if the motor is off

, (8)

and

r2(kT ) =target location of the center of the path

in terms of photoreflector number= 15.5 for all k. (9)

To understand why r2(kT ) = 15.5 we need to understand the nature of c(kT ), which is definedas

c(kT ) =photoreflector number where themeasured center of the path lies

. (10)

6

Page 11: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

Figure 5: Control Diagram of the Path Seeker Controller.

The value of c(kT ) is constrained to be a number bounded by 0 ≤ c(kT ) ≤ 31 since theposition sensor has 32 photoreflectors. The center of the front axle of the vehicle lies betweenphotoreflectors number 15 and 16. Since the target position of the center of the path must bethe center of the axle of the vehicle, r2(kT ) was set to 15.5.

The signal e(T ) is the error signal given by e(kT ) = r2(kT )− c(kT ) and the signal m(k) is theoutput of the PID controller.

2.2.3 PID Parameters

The parameters KP , KI and KD of the PID controller were determined experimentally (bytrial and error). Note that knowledge of KP , KI and KD does not imply knowledge of T ,the sampling period. In fact, the controller parameters were obtained without ever obtainingan accurate estimate of the sampling period T . Nevertheless, from microcontroller programexecution times, the value of T is known to lie between 0.2 to 0.5 seconds.

2.2.4 Controller Implementation

The controller scheme described in Figure 5 was implemented in Interactive-C, a programminglanguage that was developed for robotics applications. A copy of the source code file of theentire control program has been included in Appendix D for reference. The source code includesall the error detection and position calculation as well as the actual PID controller. Some of themain difficulties encountered during the project came out during the controller implementation.This point is discussed in more detail in section 3.1.

7

Page 12: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

Figure 6: Path Seeker on its testing track during its final testing (March 22, 2004).

Now that it has been explained how the Path Seeker works and how it is controlled, the resultsof the Path Seeker tests are now presented.

3 Testing

The path seeker was tested on a a simple and relatively smooth track with a rectangular trajec-tory that was set up specially for this purpose (see Figure 6). The test was relatively successful.The Path Seeker performs as expected at relatively low speeds (2 to 5 km/hour); nevertheless,the outputs of the photoreflectors are not very stable, which tends to produce erroneous inputsthat drive the Path Seeker into fail safe mode in a relatively short period of time (a few secondsto half a minute).

A CD has been attached at the end this report that includes a promotional video (in variousformats) that was taken during the Path Seeker final testing (March 22, 2004). The video showsthe Path Seeker in action and it was first presented at the ELEC/CENG 499B project displayon March 26, 2004.

3.1 Difficulties Encountered

Three main difficulties were encountered during the construction and testing of the Path Seeker.They are summarized below:

1. Instability of the position sensor. Due to causes that have not yet been determined,the photoreflectors in the position sensor exhibit random interference that alters its correctbehaviour. The interference is strong enough to make the control algorithm fail (i.e.the microcontroller detects an incorrect or undefined input). Various theories have been

8

Page 13: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

formulated on the reason behind the interference, but we have no solid information thatpoints towards a specific cause (there is reason to believe that the input ports of themicrocontroller are not properly isolated, but, again, more research will have to be done).

2. The microcontroller is too limited for the task at hand. The chosen microcon-troller (Handyboard) is not powerful enough to yield a satisfactory sampling rate. Thisis one of the reasons why the Path Seeker had to be tested at very low speeds. Also, theteam was going to use a PWM scheme to control the motor instead of an on-off switch.Unfortunately, all the processing power went into the controller and there was no resourcesleft to be able to output a PWM signal of the desired frequency to control the motor. Thedeadlines of the project were tight and we were not able to buy a suitable more powerfulmicrocontroller to replace the Handyboard.

3. Excessive battery weight. Due to the need to isolate the power supply of the differentcomponents, three separate sets of batteries were installed on the Path Seeker. The threesets of batteries significantly increase the load on the motor and the Path Seeker’s powersupply tends to run out fairly fast (5 to 10 minutes). Some power saving strategy will beneeded in the future if a large vehicle range is desired.

3.2 Successes

Even though there is still a lot of room for improvement and even though some significantdifficulties have been encountered, the project has had some successes. During the ELEC/CENG499B project display, the Path Seeker project won first place on the IEEE Victoria Section awardsgiven to the most outstanding ELEC/CENG 499B projects.

4 Recommendations

The first prototype of the Path Seeker has been built with relative success and a lot of valuablelessons have been learned for the next prototype, among the most important are:

1. RF circuit analysis of the photoreflectors must be carried out to ensure that all the possiblesources of interference are limited. Given the fact that RF circuit analysis will probably beneeded for any future prototype, it might be worthwhile to consider a more robust wirelesssensing scheme.

2. A faster microcontroller with significantly more memory will be needed for any futuredesign. An FPGA could be a relatively low cost alternative.

3. It would be a desirable feature to include sensors that allow the Path Seeker to interactwith its environment and detect obstacles on its path. This would make the testing simplerand less dangerous for the integrity of the vehicle. In the project proposal, it was proposedto include a sonar sensor in front of the vehicle to detect objects obstructing the vehicle’spath, but, due to time constraints, this was not done and should be considered.

5 Work Load

All the members of the team worked hard to be able to complete this project with relativesuccess. All the members of the team put significantly more time into this project than what was

9

Page 14: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

expected from them (9 hours/week according to the ELEC/CENG499B guideliness). However,to fulfill a specific request from Dr. Bhat (the project supervisor), a table is included below thatdetails how the workload was divided among the different members of the team.

Team member Task

Jenny Allan1. Design of the position sensor PCB in Protel99 (100%)2. Testing (33.3%)3. Reports and presentations (20%)

Roberto Armenta

1. Project conception and preliminary research (100%)2. Parts / Vehicle and PCB assembly (100%)3. Reports and presentations (80%)4. Testing (33.3%)

Jeff Larson

1. Control program implementation (100%)2. Project website (100%)3. Promotional Video (100%)4. Testing (33.3%)

Note that even though some tasks give 100% credit to a single member of the team, all teammembers were always aware of what was being done by each other and all decisions were takenby consensus.

6 Project Website

A final version of the project website has been finished and it is located at two mirror sites:

http://www.engr.uvic.ca/~jlarson/pathseeker/index.php

http://www.jeffothy.com/pathseeker/index.php

All the relevant project information, including reports and promotional video are included onthe website.

7 Conclusion

In summary, the first prototype of the Path Seeker has been constructed with relative success;recommendations have been presented aimed at trying to overcome some of the difficultiesencountered. The team is satisfied with the project results and is looking forward to have theopportunity to build an improved prototype.

All previous reports have been included as appendixes for reference (as requested by the ELEC/CENG499B guideliness). Appendix A contains a copy of the project proposal. Appendix B contains acopy of the first progress report, and Appendix C contains a copy of the second progress report.Some of the previous reports contain appendixes, but they were not included to avoid confusion;nevertheless, a full version of each of the reports can be found in the project website.

As a final comment, the team would like to express its gratitude to the Electrical and ComputerEngineering department at UVic for the financial help provided to manufacture the PCB of theposition sensor.

10

Page 15: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

References

[1] A. Balluchi, A. Bicchi, A. Blestrino and G. Casaliano. “Path Tracking Control for Dubin’sCars”.in Proc. 1996 IEEE International Conference on Robotics and Automation, pp. 3123-3128.

[2] A. Balluchi and P. Soueres.“Optimal Feedback Control of Dubins’ Car Tracking CircularReference Paths”.in Proc. 1996 IEEE Conference on Decision and Control, pp. 3558-3563,1996.

[3] A. Balluchi, P. Soures, and A. Bicchi. Hybrid Feedback Control for Path Tracking with aBounded–curvature Vehicle. Submitted to Automatica: a Journal of IFAC, 2002.

[4] J. J. Craig. Robotics. 2nd ed. New York: Addison-Wesley, 1989.

[5] L. E. Dubins, “On curves of minimal length with a constraint on average curvature andwith prescribed initial and terminal positions and tangents”, American J. of Mathematics,vol. 79, pp. 497-516, 1957.

[6] Handy Board website. Available at http://www.handyboard.com

[7] K. Ogata. Discrete-Time Control Systems. 2nd ed. New Jersey: Prentice Hall; 1997.

[8] Polaroid Sensors. Available at: http://www.robotstorehk.com/sensor.html

11

Page 16: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

Appendix A: Path Seeker Project Proposal

Introduction

The purpose of this proposal is to give a description of the proposed project, to emphasize itsobjectives and motivations, and to describe what type of equipment will be needed from theengineering labs in order to complete it. A previous version of this project proposal was alreadypresented in September of 2003. This is the final version.

Team Members and Supervisor

The project was started early due to the large amounts of work that it will require. The teammembers are:

Name Student # E-mail DisciplineRoberto Armenta ID#: 0021936 [email protected] EE

Jennifer Allan ID#: 0021379 [email protected] CEJeff Larson ID#: 0024488 [email protected] CE

This is the definitive list of members. The project supervisor will be Dr. Ashoka K. S. Bhat.The team has already spoken to him and he has agreed to be the project supervisor.

Project Objectives

The purpose of the project will be to construct a small autonomous vehicle that has the abilityto follow a trajectory set by a continuous path printed on a flat surface. If time permits, a sensorwill be added to allow the vehicle to detect objects in front of it and avoid collisions. The aimof the project is to develop a simple low cost platform that could ultimately be used as a testvehicle for path tracking control algorithms.

We intend to build a two axis vehicle (that resembles a commercial sedan) that is 1/10 of thesize of a regular car and that can follow a line on the floor. The vehicle will be an autonomousvehicle controlled by an on board programmable microcontroller. The line on the floor is to bea thin line of a bright material on a black surface and will be a relatively simple and smoothpath with curvature constraints. A position sensor will be placed underneath the front axel ofthe vehicle to provide the microcontroller with the position of the vehicle with respect to thedesired path. As mentiond before, if time allows, a sonar will placed on the front of vehicleto allow a more robust interaction with the external environment. The proposed autonomousvehicle will be called Path Seeker (PS).

Path Tracking Control

In the past two or three decades, a lot of interest has emerged in the development of path trackingcontrol schemes for wheeled vehicles that only move forward on a planar surface and possess a

1

Page 17: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

bounded turning raduis. Such a vehicle is called a Dubins’ car in honour of the mathematicianL. E. Dubins, who first addressed this control problem [5].

Definition 1 Dubin’s cars are kinematic models of wheeled vehicles that move onlyforward in a plane and possess a lower bounded turning radius.

The motivation for developing control schemes for Dubins’ cars is that they are an essentialpart of the kinematic models of road vehicles, aircraft cruising at constant altitudes and seavessels [3].

Dubins demonstrated that a vehicle that can only move forward with curvature bounds is con-trollable [5]. A wide variety of control schemes have been developed for Dubins’ cars (e.g. [2]and [1]). An optimal control scheme for Dubins’ cars was developed by A. Balluchi and P.Soueres [2]. This optimal control algorithm requires two pieces of information as inputs: theposition of the vehicle with respect to the desired path and the heading angle error of the vehicle.

Scope of the Project

To construct a vehicle with position sensing that computes both the position of the vehicle withrespect to the desired path and the heading angle error, would be extremely difficult in onlyfour months. In this project we will attempt to build a position sensor that computes only theposition of the vehicle with respect to the desired path. This sensor will be tested using a simplePID controller.

A path tracking vehicle that uses a PID controller, and does not use the heading angle errorinformation, is not guaranteed to converge to a solution of the controlability problem. Never-theless, the PID controller will work for very simple paths consisting of relatively large circlesand straight lines.

The motivation behind this approach is that, in a future project, a replica of the position sensorthat will be installed on the front axel could be added on the rear axel of the vehicle to providea second reference point. The extra reference point would provide an approximation to theheading angle error. With the extra heading angle information the optimal control schemecould be implemented.

Project Motivation

Even though the ELEC 499 / CENG 499 guidelines recommend to take advantage of outsidesponsors to undertake a project, we have decided to propose our own project for various reasons.First, the problem of motion control is a standard engineering problem of a manageable size thatdirectly combines all the basic concepts of analog/digital control, motor control, signal processingand digital design that we have learned in some third and fourth year level courses. The problemis not focused on a very specialized research subject or complex industrial application, it is ratherfocused on system integration, a very valuable skill. Second, the subject of control of autonomousvehicles is one of interest for the members of the team and we wish to pursue a project in thisarea. Finally, we understand that there are many advantages in taking a project from an outsidesponsor; nevertheless, due to constraints in time and resources and group preferences, we decidedto propose our own project.

2

Page 18: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

Technical Specifications of the Vehicle

The 1/10 scale vehicle will consist of the following components:

1. Vehicle chasis and body.

2. Microcontroller based on the MC68HC11 that can be programmed in C like language byusing a PC and a serial communications port (might change if a better one is found).

3. Position encoding sensor mounted at the bottom of the car body.

4. One DC motor for propulsion and a speed controller (PWM control).

5. One DC servo to control the steering of the vehicle.

6. Two sets of batteries: one for the motor and another for the microcontroller.

7. One sonar sensor to detect objects in front of the vehicle.

Vehicle’s chasis and body

The body and the chasis of the car will not be built from scratch. A standard 1/10 scale carchassis we will be used to build on top of it. A picture of the chassis that will be used is includedin Figure 7. The body will be a simple plastic structure attached to the chasis.

Microcontroller

The proposed microcontroller was developed for robotics applications and has some featuresthat make it easy to interface sensors and motors. A programming platform has been developedfor the microcontroller (with libraries to control some sensors); it is called the MIT HandyBoardSystem. A picture of the microcontroller is shown in Figure 2. The microcontroller might bechanged if we do not find it convenient for the task at hand. All the technical details of themicrocontroller can be found in reference [6].

Position sensor

The position encoding sensor is the only component of the entire project that has not beendeveloped or purchased. Up to now there are two preliminary ideas on how to build such device.The first solution will be to try to develop such a sensor using an array of photoreflectors. Thedatasheet of the proposed photoreflector is included in a ∗.pdf file attached to this document.There are still debates on how such a circuit will be constructed since an encoder will probablybe needed to encode all the possible states of the photoreflectors.

Sonar

If time allows, a sonar will be used and interfaced with the microcontroller to detect the distanceof objects in front of the vehicle. The sonar to be used is a Polaroid 6500 sonar module. Apicture of the sonar is shown in Figure 3. This specific sonar was designed to operate with thechosen microcontroller so it is assumed that it will be relatively easy to interface it. The sonarhas already been acquired.

3

Page 19: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

Figure 1: Proposed vehicle chasis [9].

Figure 2: Handyboard Microcontroller [6].

4

Page 20: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

Figure 3: Polaroid 6500 sonar [8].

Project Phase Goals Completion Date

Phase onePhysical Construction of the vehicle mustbe completed. All of the required lab in-frastructure must be arranged.

January 12, 2004

Phase two Finish a working prototype of position en-coder sensor.

February 3, 2004

Phase three

Mount the onboard microcontroller. Pro-gram the vehicle to follow a line on thefloor at constant speed. Modify the posi-tion encoder sensor and make a new pro-totype if needed.

March 26, 2004

Phase fourAdd a sonar sensor to the vehicle andmodify the control program.

March 26, 2004 (if time allows)

Table 1: Project schedule.

Project Schedule

As stated before, the project is divided in four major phases. The project schedule was developedbased on this task organization and it is shown in Table 1. Evaluations of this project schedulewill be carried out on January 18 and March 9 of 2004 when the progress reports are due.The technical feasibility of the project will not be fully determined until phase two has beencompleted successfully. An early deadline has been set for the development of the position sensor(the first week of February) so that if there is no success in building one, there is still time tointroduce modifications to the project.

Equipment Requirements

Besides all the vehicle parts (most of which already have been purchased), access to the ELWequipment and facilities will be required. The following things will be required:

1. A PC with Windows 95 or a more recent version with Internet access.

5

Page 21: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

2. 100MHz two channel oscilloscope or better.

3. Pulse generator.

4. Multimeter.

5. DC power supply.

6. Locked storage space.

The team is willing to bring a PC into the lab and leave it there as long as the lab access isrestricted and interntet access is available.

Conclusion

The team belives that this project will satisfy the difficulty requirements expected from an ELEC499 / CENG 499 project, but we are opened to any suggestions. As it already stands, it willnot be an easy project to complete.

6

Page 22: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

References

[1] A. Balluchi, A. Bicchi, A. Blestrino and G. Casaliano. “Path Tracking Control for Dubin’sCars”.in Proc. 1996 IEEE International Conference on Robotics and Automation, pp. 3123-3128.

[2] A. Balluchi and P. Soueres.“Optimal Feedback Control of Dubins’ Car Tracking CircularReference Paths”.in Proc. 1996 IEEE Conference on Decision and Control, pp. 3558-3563,1996.

[3] A. Balluchi, P. Soures, and A. Bicchi. Hybrid Feedback Control for Path Tracking with aBounded–curvature Vehicle. Submitted to Automatica: a Journal of IFAC, 2002.

[4] J. J. Craig. Robotics. 2nd ed. New York: Addison-Wesley, 1989.

[5] L. E. Dubins, “On curves of minimal lenght with a constraint on average curvature andwith prescribed initial and terminal positions and tantengs”, American J. of Mathematics,vol. 79, pp. 497-516, 1957.

[6] Handy Board website. Available at http://www.handyboard.com

[7] K. Ogata. Discrete-Time Control Systems. 2nd ed. New Jersey: Prentice Hall; 1997.

[8] Polaroid Sensors. Available at: http://www.robotstorehk.com/sensor.html

[9] Team Associated website. Available at: http://www.teamassociated.com

7

Page 23: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

Appendix B: Path Seeker Project Report #1

Introduction

The purpose of this report is to summarize the current status of the project as required by theELEC 499B / CENG 499B guidelines. The project proposal was presented in January 9, 2004and the work started immediately after it was presented.

Project Schedule

In the project proposal a project schedule was presented. The project schedule is presentedagain in Table 1.

According to the project schedule, phase one of the project had to be finished by January12, 2004. Phase one consisted of obtaining the required lab infrastructure and completing thephysical construction of the car. Both tasks were completed on time.

As far as the construction of the car goes, all the mechanical structure of the car has beenassembled; the only task that remains is to mount the car’s motor (a straightforward task).As far as the lab infrastructure goes, we already have all the necessary equipment and all theparts that we requested from Lynn Palmer. However, due to renovations, we did not receive thelab space required until January 15, 2004 (instead of January 5, 2003 as originally expected).This delay is expected to cause a one week delay in the completion of phase two; therefore, thedeadline for phase two will be moved to February 10, 2004. We do not expect this problem tocause a delay in the subsequent phases.

The updated project schedule is presented in Table 2.

Technical Updates

Here are the main highlights of what has been completed from a technical point of view:

1. All the required equipment has been obtained and we have done preliminary tests in allof the components to confirm that they work.

2. We have a preliminary design for the position encoder sensor and we plan to start buildinga prototype next week.

Other Remarks

The team has set up a dedicated computer for this project in one of the corners of ELW A321(the ELEC/CENG 499 lab). On top of the computer there is a black logbook that details onan every day basis what was achieved on all of the occassion in which the team met to work.Anyone is welcomed to take a look at it to know what is happening on a daily basis.

1

Page 24: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

Project Phase Goals Completion Date

Phase onePhysical construction of the vehicle mustbe completed. All of the required lab in-frastructure must be arranged.

January 12, 2004

Phase two Finish a working prototype of position en-coder sensor.

February 3, 2004

Phase three

Mount the onboard microcontroller. Pro-gram the vehicle to follow a line on thefloor at constant speed. Modify the posi-tion encoder sensor and make a new pro-totype if needed.

March 26, 2004

Phase fourAdd a sonar sensor to the vehicle andmodify the control program.

March 26, 2004 (if time allows)

Table 1: Project schedule.

Project Phase Goals Completion Date

Phase onePhysical construction of the vehicle mustbe completed. All of the required lab in-frastructure must be arranged.

January 12, 2004

Phase two Finish a working prototype of position en-coder sensor.

February 10, 2004

Phase three

Mount the onboard microcontroller. Pro-gram the vehicle to follow a line on thefloor at constant speed. Modify the posi-tion encoder sensor and make a new pro-totype if needed.

March 26, 2004

Phase fourAdd a sonar sensor to the vehicle andmodify the control program.

March 26, 2004 (if time allows)

Table 2: Updated project schedule.

Conclusion

In summary, so far the project is on schedule, and we have updated the project schedule toinclude a one week delay on phase two. We are still optimistic about the project.

2

Page 25: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

Path Appendix C: Seeker Project Report #2

Introduction

The purpose of this second report is to summarize the current status of the project (as requiredby the ELEC 499B / CENG 499B guidelines). The first project report was presented on January19, 2004 and this second report summarizes all the work that has been completed since then.

Project Schedule

In the project proposal (presented on January 9, 2004) the project work was divided into fourmajor phases. A project schedule was given in the project proposal as well as in the first report.The project schedule as given in the first report is shown again in Table 1. In the first projectreport, phase one, which consisted of the physical construction of the structure of the vehicle,was reported as completed. The remaining three phases were left to be completed.

Phase Two

According to the project schedule, phase two of the project had to be finished by February 10,2004. Phase two consisted of finishing a working prototype of the position encoding sensor. Aworking prototype of the position encoding sensor has been completed, but it was not finisheduntil February 23, 2004. This constitutes a two week delay in the expected completion date;however, this delay was caused by paperwork reasons, and we do not expect a delay on phasethree of the project.

Prototype Construction

The prototype of the position encoding sensor was built using photoreflectors (HamamatsuP5587) as the main component. These sensors are such that they output high if they detect abright surface and low if they detect a dark surface. A Printed Circuit Board (PCB) was designed(in Protel99) to be able to mount a one-dimensional array of 32 sensors across the front of thevehicle with the appropriate biasing and I/O circuitry. The idea behind the prototype is that,using the information provided by the output of the sensors, the vehicle’s microcontroller willbe able to tell where the desired path is and take the required control steps to remain on thepath.

A picture of the printed circuit board (fresh from the shop) is included in Figure 1. All thesensors and required biasing components have been mounted on the PCB. A picture taken duringthe soldering process is shown in Figure 2.

Prototype Testing

Once all the components of the position encoder sensor were mounted on the PCB, the PCBwas mounted on the car and its functionality was tested. A picture of the PCB mounted on thevehicle is shown in Figure 3. It was quite a challenge to get the PCB working, we had to replace

1

Page 26: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

Figure 1: Position encoder prototype Printed Circuit Board (PCB).

Figure 2: Position encoder prototype Printed Circuit Board (PCB) soldering.

2

Page 27: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

Project Phase Goals Completion Date

Phase one

Physical construction of the vehicle’sstructure must be completed. All of therequired lab infrastructure must be ar-ranged.

January 12, 2004

Phase two Finish a working prototype of position en-coder sensor.

February 10, 2004

Phase three

Mount the onboard microcontroller. Pro-gram the vehicle to follow a line on thefloor at constant speed. Modify the posi-tion encoder sensor and make a new pro-totype if needed.

March 26, 2004

Phase fourAdd a sonar sensor to the vehicle andmodify the control program.

March 26, 2004 (if time allows)

Table 1: Project schedule.

three of the originally mounted sensors and fix a large number of false contacts in the process.The prototype of the position encoder sensor works now as expected; nevertheless, this doesmean that the vehicle is now working. The team still has to get the control program workingand test the whole integrated system, which brings us to phase three.

Phase Three

Phase three is expected to be completed by March 26, 2004 (the day scheduled by the ELEC499 / CENG 499 coordinator for the project demonstrations in the Engineering Law Wing).Phase three, as shown in Table 1, consists of mounting the microcontroller, interfacing it withthe car and implementing the control program. The microcontroller has already been mountedon the car and interfaced with the board. We did not experience any problems interfacing thePCB with the microcontroller, but we are still working on the control program. A picture of thewhole vehicle, with all the components that have been currently mounted, is shown in Figure 4.We expect to be able to test the whole system by March 16, 2004.

Phase Four

Phase four was included in the project proposal as a tentative idea to add a sonar to the vehicleto allow it to detect objects that might obstruct its path. We still do not know whether thiswill be carried out or not.

Other Remarks

Website

A website for the project has already been set up. The URL is

http://www.engr.uvic.ca/~jlarson .

3

Page 28: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

Figure 3: Position encoder PCB prototype mounted on the Path Seeker.

Figure 4: Path Seeker during the position encoder PCB tests.

4

Page 29: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

The site contains all the information relevant to the project. A final version of the website willbe completed by April 2, 2004 (when the final project report is due).

Conclusion

In summary, the project is so far on schedule. A prototype of the position encoder sensor, themost crucial component of the project, has been finished and we are expecting to be able to getthe vehicle working by the demonstration day (scheduled for March 26, 2004).

5

Page 30: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

Path Appendix D: Path Seeker Controller Implementation Code

/* Path Seeker : Main Program */

/* Declare Global Variables Here */persistent int NUM_SENSORS = 32;persistent int NUM_HISTORY = 10;/*#define NUM_SENSORS 32;#define NUM_HISTORY 5;*/

/* int sensor_values[NUM_SENSORS];*//* int center_history[NUM_HISTORY];*/int sensor_values[2][32]; /* current sensor readings */int csa = 0; /* current sensor array */float center_history[10]; /* last ## found line centers */float k_values[3]; /* input values for P.I.D. control */float max_speed; /* speed at which we would LIKE to be at currently */float current_speed; /* speed at which we ARE at (degs) */float speed_step = 5.0; /* inc/dec size step(degs)to change speed servo */int motor_enabled = 0; /* allows pid to update motor speed if 1 */

void main() {/* declaring/init of variables */

int m,pid;

/* initialization of servos */steer_init();

/* initialization of digital outputs */

/* allow adjustment of K’s */path_init();

printf("Start Sensors and Steering?\n");start_press();

pid = start_process(get_sensors());printf("Steering: ON\n");

/* now wait 5 seconds to start motor */sleep(5.0);/* motor_init(); */

/* for (m=5; m>0; m--) {printf("Motor Accelerate in %d seconds\n",m);sleep(1.0);

1

Page 31: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

}*/

/* while (!stop_button()) {}kill_process(pid); */

}

void steer_init() {/* Note that the steering servo is 0*/servo_on();servo_deg(0,90.0);

}

void path_init() {printf("Adjust K?\n");while (!start_button()) {

if (stop_button()) {printf("\n");return;

}}while (start_button()) {}show_k();return;

}

void motor_init() {/* gradually increase speed of motor up to a certain mark *//* servo_deg(1,90.0); *//* printf("Motor Accelerating... \n");sleep(3.0); */

/* allow PID controller to update motor speed */motor_enabled = 1;printf("Steering: ON Speed : ON\n");return;

}

void do_steer(int index) {int i;int first_index;

/* using a constant for K temporarily */float k_p = (90.0 - 65.0) / 15.5;float k_i = 0.0;float k_d = 0.0;

float new_angle = 90.0;float angle_pro = 0.0;

/*float angle_int = 0.0;

2

Page 32: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

float error_int = 0.0;float angle_der = 0.0;

first_index = (index+1) % 10;*/angle_pro = k_p * (center_history[index] - 15.5) + 90.0;

/*angle_der = k_d * ((center_history[index] - 15.5) - (center_history[first_index] - 15.5));

for (i=0; i<10; i++) {error_int = error_int + (((center_history[(index+1+i)%10] - 15.5) + (center_history[(index+2+i)%10] - 15.5))/2.0);

}angle_int = k_i * error_int;

new_angle = angle_pro + angle_int + angle_der; */new_angle = angle_pro;

/* printf("ang=%f\n",new_angle); */servo_deg(0,new_angle); /* 0 is steer servo */return;

}

void do_motor(int index) {/* make decisions on speed changed from center info */if (current_speed > max_speed) {

current_speed = current_speed - speed_step;}else if (current_speed < max_speed) {

current_speed = current_speed + speed_step;}

servo_deg(1,current_speed); /* 1 is speed servo */return;

}

void get_k(int k) {/* analog 24,25,26 used for potentiometers for inputting K values */k_values[k] = (float) analog(k+24);/* these values will be 0 -> 255 so we need to change to 0.0 -> 1.0 */k_values[k] = k_values[k] / 255.0;

}

void show_k(void) {/* shows k[0] -> k[2] on LCD, updates constantly */int i;printf("\n");for (i=0; i<3; i++) {

while (!start_button()) {if (stop_button()) {

printf("\n");

3

Page 33: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

return;}get_k(i);printf("K%d= %f\n",i,k_values[i]);sleep(0.1); /* slow down LCD updating */

}while (start_button()) {}

}printf("\n");return;

}

void show_all_digital(void) {/* Shows what’s stored in the sensors */int j=0;for (j=0; j<NUM_SENSORS; j++) {printf("%d",sensor_values[csa][j]);}

printf("\n");}

float find_line_centre(void) {/* declare local variables */int temp[32];int onecount = 1;float center = -1.0;int stage = 0;int c;

/* Make sure we don’t overwrite the original values, this works */for (c=0; c<NUM_SENSORS; c++) {

temp[c] = sensor_values[csa][c];}

while (onecount != 0) {onecount = 0;stage = stage + 1;

for (c=0; c<NUM_SENSORS-stage; c++) {if (temp[c] && temp[c+1]) {

temp[c] = 1;onecount = onecount + 1;center = (float) c;

}else {

temp[c] = 0;}

}

/* if we can’t find center return -1 */

4

Page 34: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

if (stage >= 32) {return -1.0;

}}

/* center is now the centre of the current stage size *//* so we need to return the scaled up version of center */center = center + (float) (stage/2);

/* HERE WE MUST ALSO SET THE MAX_SPEED AS A FUNCTION OF center */

/* printf("center = %f\n",center); */return (32.0-center);

}

void get_sensors(void) {int i = 0;

while (1) {for (i=0; i<NUM_HISTORY; i++) { /* save NUM_HISTORY previous centers *//* Receive inputs in 4 chunks of 8 */input_select(0);get_digital(0);input_select(1);get_digital(1);input_select(2);get_digital(2);input_select(3);get_digital(3);

/* show_all_digital(); *//* find centre of line to follow and change max_speed */

center_history[i] = find_line_centre();/* printf("Centre of sample %d is %d\n",i,center_history[i]); */do_steer(i);if (motor_enabled) {

do_motor(i);}

}}}

void get_digital(int sel) {/* The sensors inputs start at 16 and go to 23 */

/*int in_offset = 16;

int i=0;for (i=0; i<8; i++) {sensor_values[csa][i*4+sel] = digital(in_offset+i);}

*/

5

Page 35: Path Seeker Project Final Report · An overview of how the Path Seeker is controlled is now given. 3. Figure 2: Path Seeker parts schematic. 4. Figure 3: Hamamatsu P5587 IR photoreflector

sensor_values[csa][sel] = digital(16);sensor_values[csa][4+sel] = digital(17);sensor_values[csa][8+sel] = digital(18);sensor_values[csa][12+sel] = digital(19);sensor_values[csa][16+sel] = digital(20);sensor_values[csa][20+sel] = digital(21);sensor_values[csa][24+sel] = digital(22);sensor_values[csa][28+sel] = digital(23);}

int input_select(int sel) {/* Set the 2 select bits to digital outputs 0 and 1*/int sel_0 = 0;int sel_1 = 1;

if (sel <= 0) {clear_digital_out(sel_0);clear_digital_out(sel_1);}if (sel == 1) {set_digital_out(sel_0);clear_digital_out(sel_1);}if (sel == 2) {clear_digital_out(sel_0);set_digital_out(sel_1);}if (sel >= 3) {set_digital_out(sel_0);set_digital_out(sel_1);}}

6