Вы находитесь на странице: 1из 20

Old Dominion Univeristy Dept.

of Electrical and Computer Engineering

ECE 485W: Electrical Engineering Design I Instructor: Chung-Hao Chen, Ph.D Fall 2013 9:30pm - 10:45pm TR, KH 229

LAB # 6 Arduino Experiment 6 George Micros UIN: 00757376 November 12, 2013

Honor Pledge

I pledge to support the Honor System of Old Dominion University. I will refrain from any form of academic dishonesty or deception, such as cheating or plagiarism. I am aware that as a member of the academic community it is my responsibility to turn in all suspected violations of the Honor Code. I will report to a hearing if summoned. Signed

Contents
1 Introduction 1.1 Contemporary Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Experimental Design 2.1 Hardware Configuration 2.2 Experimental Procedure 2.3 Analysis, Testing . . . . . 2.4 Realistic Constraints . . 3 Scientific Data 4 Results 5 Discussion 5.1 Ethical Implications . . . . . . . . . . . . . . 5.2 Lifelong Learning . . . . . . . . . . . . . . . 5.3 Knowledge/Skills from Earlier Courses . 5.4 Educational Benefits . . . . . . . . . . . . . 5.5 Individual Student Contribution . . . . . . 6 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 4

5 . 6 . 7 . 7 . 10 11 11 13 13 15 15 15 16 16

7 Source Code Appendix 16 7.1 Part I Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 7.2 Part II Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

Lab Report # 6: Arduino Experiment 6: Servo Motor Experiment


George Micros, Electrical and Computer Engineering Department Old Dominion University

Abstract

The typical engineering curriculum ends with a course designed to challenge students critical thinking and give seniors the opportunity to apply knowledge and information from courses to realistic engineering problems. The general aim of the course is to loosely guide students through the process of designing and testing electronic subsystems that reect real-world applications. The setting and environment mimic that of industry, requiring students to work in groups and eectively communicate with co-workers. Given the rapid advances in embedded programmable systems and their widespread use in industry this course focuses on projects that will be implemented on an open-source micro-controller, i.e. Arduino. The projects will begin with introductory concepts and gradually grow in complexity to prepare students for the nal project. The current project will demonstrate the speed of the Arduino microcontroller and quantify the built-in delay function. The hardware conguration is similar to previous experiments but diers in the code put on the Arduino microcontroller and in the use of the delay function. The delay function is used to insert a break period in the instructions that the Arduino is executing and is designated by a time value. However, the delay function is not ideal and there is some error assosiated with its operation.

Introduction

The Arduino Uno is an open-source micro-controller prototyping board based on the ATmega328. It has 14 digital input/output pins, of which 6 can be used as PWM outputs, 6 analog inputs, a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button. It contains everything needed to support the micro-controller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started. The massively popular Arduino Uno board is the perfect board to start any budding electronics engineer. With this board you have endless possibilities from the simple LED blinking to energy monitoring to controlling unmanned vehicles. Arduino is an excellent was to do simple microcontroller design and data acquisition. For production products, using the sole micro-controller is usually best, but for quick data acquisition and test and measurement tasks, Arduino is a good way to get the data quickly. The servo motors are common driving mechanisms for robots. The servo motors are capable of going multiple speeds in either direction by controlling the input to the servo. The input line to the servo is a variable number (between 0 and 180). In theory, 0 corresponds to full forward, 90 causes no movement, and 180 sets the motor to full reverse. The goal of this lab is to program the Arduino to operate two servo motors (as the driving mechanism for a robot), and understand what values to use to move the robot in any direction. In this experiment we will begin by studying the behaviour of the servo motor and how it operates under varying input signals. The input line to the servo is a variable number (between 0 and 180). In theory, 0 corresponds to full forward, 90 causes no movement, and 180 sets the motor to full reverse. However, in practical situations this may not be the case and we must map the various values and determine the relationship between then input value and the rotational speed of the motor. This will be done by creating an experimental conguration that will allow us to easily vary the input signal and at the same time measure the rotational speed of the servo. In order to properly measure the rotational speed of the motor and its relationship to the input value we must establish a closed and secure experimental setting. This will be done by creating an experimental conguration that will allow us to easily vary the input signal and at the same time measure the rotational speed of the servo. In this situation the Arduino was connected to the servo motor, the LCD display and a rheostat. The Arduino read the voltage across the rheostat and mapped that value to the range 0 to 180. This newly mapped number was then sent to the servo and output to the screen. This particular setting allowed us to easily change the servo speed, without modifying the code continuously and make other time consuming adjustments. In this experiment we initially tested the left servo motor with the wheel attached. We chose values between 0 to 180 at xed increments of 10 and increased the sampling of the data near ranges that provided interesting behavior and variation of the speed. The speed was measured manually. The wheel contained a small sticker and a corresponding one was placed on the frame. The observer counted the revolutions that were performed in a 10 second time interval and the value was extrapolated for the revolutions per minute. Depending on the speed of rotation the measurement time window was varied to ensure that proper and correct collection of data. This process was then repeated for the right wheel in a similar way. At values of the input were the servo speed demonstrated drastic change data was collected on shorter intervals to gain a better idea of the behavior of the servo in those regions. The input line to the servo is a variable number (between 0 and 180). In theory, 0 corresponds to full forward, 90 causes no movement, and 180 sets the motor to full reverse. However, the ideal case is far dierent. The reality of the servo is that there are no discontinuities between forward, stop and reverse, but rather steep, dierentiable transitions. It is vital that this transition be carefully mapped and 3

understood in order to be able to navigate the robot with precision and accuracy. For these reasons the behavior of each motor individually must be studied. The main goal of this experiment is to determine the input-speed relationship of each servo. The experiment requires data collection and measurement of the roational speed produced by the servo at a given input value. In order to properly measure the rotational speed of the motor and its relationship to the input value we must establish a closed and secure experimental setting. This will be done by creating an experimental conguration that will allow us to easily vary the input signal and at the same time measure the rotational speed of the servo. In this situation the Arduino was connected to the servo motor, the LCD display and a rheostat. The Arduino read the voltage across the rheostat and mapped that value to the range 0 to 180. This newly mapped number was then sent to the servo and output to the screen. This particular setting allowed us to easily change the servo speed, without modifying the code continuously and make other time consuming adjustments. Once the behavior of the two servos has been determined then a table will be compiled that contains the rough values that produce motion in certain directions in order to determine which combinations will be needed to navigate the robot. At values of the input were the servo speed demonstrated drastic change data was collected on shorter intervals to gain a better idea of the behavior of the servo in those regions. The input line to the servo is a variable number (between 0 and 180). In theory, 0 corresponds to full forward, 90 causes no movement, and 180 sets the motor to full reverse. However, the ideal case is far dierent. The reality of the servo is that there are no discontinuities between forward, stop and reverse, but rather steep, dierentiable transitions. It is vital that this transition be carefully mapped and understood in order to be able to navigate the robot with precision and accuracy. For these reasons the behavior of each motor individually must be studied. Finally, the circumference of the wheel is measured and using the collected data that maximum linear speed of the robot is determined. This theoretical calculation is then compared with the actual top speed that is attainable by the robot. This was done by programming the robot at the maximum speed and then allowing it to move while measuring the time it requires to cover a certain distance. THis result will be compare with the theoretical calculation. The deliverable of this experiment will include an interface that will allow for the input signal of the servo motor to be varied by the user and that value displayed on the LCD screen. This experiment will also result in the between understand og the behavior and capabilities of the servo motors and a mopping of their rotational velocity to the input signal value. The programming infrastructure that can be used in the future.

1.1

Contemporary Issues

This experiment focuses on the relationship between the input signal value and the rotational speed of a servo motor. This is a very important relationship to gain an understanding of before the implementation of a servo motor in an embedded system. Variations and uctuations in this relationship should be well documented and understood a priori otherwise this can lead to undesirable behaviour and dangerous istuations. The issues associated with this particular experiment are concerned with the accuracy of measurements and the importance of error in calculations. The theoretical behavior of all servo motors is that there are three states of operation, forward, no motion and backwards. However, this is completely unrealistic and impossible to occurs. Thus the transition between these three states must be determined and studied to understand the behavior of the servo in these regions. Also, the othe assumption is that all servo motors are identical and thus has the same maximum rotational 4

speed. The input line to the servo is a variable number (between 0 and 180). In theory, 0 corresponds to full forward, 90 causes no movement, and 180 sets the motor to full reverse. The reality of the situation is that there does not exist a discontinuous transition between theses three states, but a steep and rapid transition that bridges the gap between any two states.Also, the assumption that the value of 90 provides a full stop is also under speculation since the servo requires calibration and adjustments to make sure that it does not move when there is no value applied to it. The other issue that occurs is that since the speed is under speculation is is reasonable to consider whether the rotational speed of the forward direction and the reverse direction are equal. Essentially if the two speeds are equal. This lab requires the use of two servos. Given that not all servos has identical behavior and that the there are variations in their behavior. The two servos must be operated at in uni-some. If we wish to have the desired performance we must apply the respective values to each servo to obtain the necessary behavior. The signicance of measurement error must no be under-estimated and the error must be take in context of the application at hand. The percentage error for this specic application is tolerable, but %0.1 error in the trajectory of an airplane or a missile, will not necessarily be negligible and my have devastating consequences. Understanding statistics about the error is vital, but this values must be seen in the scope of the specic application. Tolerances and condence limits must be dened based on the application and the demand for accuracy. Also there is much importance in the idea of variations across products and their specications. The specications of a device typically should include the mean value and the variance from the central value that is present in the population of the devices. This is of signicance when the specication of an application exceed the specication of the device that is being used. In such a situation the error produced will not be bound at the desired value and can never be meet unless device specications are made more strict. It is the task of the engineer to determine the acceptable error for an application and decide on a design that will guarantee operation within the maximum error limits. It is the task of the engineer to be aware of the presence of error in any process and have knowledge of its distribution and be able to control it. Also in this experiment, the importance of user friendly design and ease of operation are emphasized. The user interface device is the largest and most important aspect of any design. Engineers and technologists are familiar with the many tools accessible to solve problems, even in the solution requires some work and eort to obtain. However it is vital that the information obtained be presented in a clear and straight forward manor to the user. There are numerous devices that perform identical task. However some achieve commercial success and acceptance, while others fail to produce any prot. In a commercial setting it is important to make the user interface as simple and intuitive as possible. The importance of good user interfacing is not only vital in the commercial sector, but also in industry. Equipment that is dicult to use or not well designed for easy operation may lead to accidents and error. User interface is just as important as the functionality the device performs itself.

Experimental Design

In this experiment we will drive an external LED circuit through one of the input/ouput (I/O) pins of hte Arduino. The LED will be connected in series with a resistor to the Arduino. The resistor is present to ensure that current limitations of the LED are not exceeded. The circuit conguration used in the experiment is presented below.

2.1

Hardware Configuration

The hardware used in this experiment is: Arduino UNO micro-controller Two Servo Motors LCD display 10 k rheostat Breadboard Jumper wires

Figure 1: Breadboard Diagram of the Experimental conguration

2.2

Experimental Procedure

The design of this experiment was to accomplish the following: Write a basic program that can spin one of the wheels in any direction. Interface the LED display with the Arduino and successfully display the input signal value. For the left Servo wheel, vary N from 0 up to 180, using about 20 values inbetween 0 and 180, including 90. Record the frequency of rotation of the wheel. Count the number of revolutions for a xed period and then extrapolte that value to revolutions per minute. Repeat this for the right wheel. Compile all of this data into one table Measure the circumference of the wheels (cm). Program your robot to the fastest speed, and experimentally determine the fastest speed (cm/s) that the robot can travel on at ground. The breadboard diagram and the schematic provide a visual representation on the experimental conguration used in this lab. In this lab the Arduino was connected to a trimmer potentiometer, and LCD display and two servo motors. All these components were connect to the power, 5V, and ground, 0V, rails of the Arduino prototyping board. The variable resistor of the pot was connected to analog pin 0, A0, on the Arduino breadboard to read the value of the voltage from the pot. The Tx pin provides all the physical interface between the Arduino and the LCD controller. All commands to the LCD are transmitted serially through the Tx pin. The two servo motors are connected to pins 8 and 9. Also there is much importance in the idea of variations across products and their specications. The specications of a device typically should include the mean value and the variance from the central value that is present in the population of the devices. This is of signicance when the specication of an application exceed the specication of the device that is being used. In such a situation the error produced will not be bound at the desired value and can never be meet unless device specications are made more strict. It is the task of the engineer to determine the acceptable error for an application and decide on a design that will guarantee operation within the maximum error limits. It is the task of the engineer to be aware of the presence of error in any process and have knowledge of its distribution and be able to control it.

2.3

Analysis, Testing

The analysis and testing of the circuit was performed once the circuit was constructed and completed. The roations speed of each servo was measured and recorded in the following table The signicance of measurement error must no be under-estimated and the error must be take in context of the application at hand. The percentage error for this specic application is tolerable, but %0.1 error in the trajectory of an airplane or a missile, will not necessarily be negligible and my have devastating consequences. Understanding statistics about the error is vital, but this values must be seen in the scope of the specic application. Tolerances and condence limits must be dened based on the application and the demand for accuracy.

Figure 2: Schematic Diagram of the Experimental conguration Despite the accuracy and precision that the Arduino microcontroller provides there is still some error associated with its performance that must be considered and included in any experimental design. The main focus of this lab is the analog to digital conversion. The device takes a analog signal and performs the conversion by sampling and quantizing the signal. The sampling of the waveform is high enough as to proven aliasing of the waveform of interest. However the quantization of the signal amplitude is subject to error. This is the main constraint that is placed on the accuracy of the device. The signicance of measurement error must no be under-estimated and the error must be take in context of the application at hand. The percentage error for this specic application is tolerable, but %0.1 error in the trajectory of an airplane or a missile, will not necessarily be negligible and my have devastating consequences. Understanding statistics about the error is vital, but this values must be seen in the scope of the specic application. Tolerances and condence limits must be dened based on the application and the demand for accuracy. The signicance of measurement error must no be under-estimated and the error must be take in context of the application at hand. The percentage error for this specic application is tolerable, but %0.1 error in the trajectory of 8

Table 1: Servo Motor Rotational Speed Measurements N 0 10 20 30 40 50 60 70 80 84 88 90 92 93 LEFT(RPM) 48.2 48.2 48.2 48.2 48.2 48.2 48.2 48.2 48.2 44.5 30.8 15.2 3.8 0 RIGHT(RPM) -59.7 -59.7 -59.7 -59.7 -59.7 -59.7 -59.7 -59.7 -59.7 -56.4 -42.2 -21.3 -7.2 0 N 93 94 95 96 98 100 110 120 130 140 150 160 170 180 LEFT(RPM) 0 -3.7 -12.4 -15.8 -30.6 -42.3 -48.2 -48.2 -48.2 -48.2 -48.2 -48.2 -48.2 -48.2 RIGHT(RPM) 0 4.7 10.5 18.2 36.5 45.6 57.8 57.8 57.8 57.8 57.8 57.8 57.8 57.8

an airplane or a missile, will not necessarily be negligible and my have devastating consequences. Understanding statistics about the error is vital, but this values must be seen in the scope of the specic application. Tolerances and condence limits must be dened based on the application and the demand for accuracy.

Figure 3: Experimental Cngureation for the Speed Recording

2.4

Realistic Constraints

This experiment focuses on the relationship between the input signal value and the rotational speed of a servo motor. This is a very important relationship to gain an understanding of before the implementation of a servo motor in an embedded system. Variations and uctuations in this relationship should be well documented and understood a priori otherwise this can lead to undesirable behaviour and dangerous istuations. The issues associated with this particular experiment are concerned with the accuracy of measurements and the importance of error in calculations. The theoretical behavior of all servo motors is that there are three states of operation, forward, no motion and backwards. However, this is completely unrealistic and impossible to occurs. Thus the transition between these three states must be determined and studied to understand the behavior of the servo in these regions. Also, the othe assumption is that all servo motors are identical and thus has the same maximum rotational speed. The input line to the servo is a variable number (between 0 and 180). In theory, 0 corresponds to full forward, 90 causes no movement, and 180 sets the motor to full reverse. The reality of the situation is that there does not exist a discontinuous transition between theses three states, but a steep and rapid transition that bridges the gap between any two states.Also, the assumption that the value of 90 provides a full stop is also under speculation since the servo requires calibration and adjustments to make sure that it does not move when there is no value applied to it. The other issue that occurs is that since the speed is under speculation is is reasonable to consider whether the rotational speed of the forward direction and the reverse direction are equal. Essentially if the two speeds are equal. This lab requires the use of two servos. Given that not all servos has identical behavior and that the there are variations in their behavior. The two servos must be operated at in uni-some. If we wish to have the desired performance we must apply the respective values to each servo to obtain the necessary behavior. The signicance of measurement error must no be under-estimated and the error must be take in context of the application at hand. The percentage error for this specic application is tolerable, but %0.1 error in the trajectory of an airplane or a missile, will not necessarily be negligible and my have devastating consequences. Understanding statistics about the error is vital, but this values must be seen in the scope of the specic application. Tolerances and condence limits must be dened based on the application and the demand for accuracy. Also there is much importance in the idea of variations across products and their specications. The specications of a device typically should include the mean value and the variance from the central value that is present in the population of the devices. This is of signicance when the specication of an application exceed the specication of the device that is being used. In such a situation the error produced will not be bound at the desired value and can never be meet unless device specications are made more strict. It is the task of the engineer to determine the acceptable error for an application and decide on a design that will guarantee operation within the maximum error limits. It is the task of the engineer to be aware of the presence of error in any process and have knowledge of its distribution and be able to control it. Also in this experiment, the importance of user friendly design and ease of operation are emphasized. The user interface device is the largest and most important aspect of any design. Engineers and technologists are familiar with the many tools accessible to solve problems, even in the solution requires some work and eort to obtain. However it is vital that the information obtained be presented in a clear and straight forward manor to the user. There are numerous devices that perform identical task. However some achieve commercial success and acceptance,

10

while others fail to produce any prot. In a commercial setting it is important to make the user interface as simple and intuitive as possible. The importance of good user interfacing is not only vital in the commercial sector, but also in industry. Equipment that is dicult to use or not well designed for easy operation may lead to accidents and error. User interface is just as important as the functionality the device performs itself.

Scientific Data

Despite the accuracy and precision that the Arduino microcontroller provides there is still some error associated with its performance that must be considered and included in any experimental design. The main focus of this lab is the analog to digital conversion. The device takes a analog signal and performs the conversion by sampling and quantizing the signal. The sampling of the waveform is high enough as to proven aliasing of the waveform of interest. However the quantization of the signal amplitude is subject to error. This is the main constraint that is placed on the accuracy of the device.

Results

The results of this experiment provide a better understanding of the operation of the servo motors. In this experiment we will begin by studying the behaviour of the servo motor and how it operates under varying input signals. The input line to the servo is a variable number (between 0 and 180). In theory, 0 corresponds to full forward, 90 causes no movement, and 180 sets the motor to full reverse. However, in practical situations this may not be the case and we must map the various values and determine the relationship between then input value and the rotational speed of the motor. This will be done by creating an experimental conguration that will allow us to easily vary the input signal and at the same time measure the rotational speed of the servo.

Figure 4: Plot of left servo data The measured circumference of the wheel was 22.5 com. Thus the fastest possible speed that could be developed as a result of the fastest rotation, 48.2 rpm, is 11

Figure 5: Time to tranverse 30 cm 48.2 22.5cm = 1084.4cmperminute = 18.1cm/s This is the maximum theoretical speed that the robot can achieve. The robot was programmed to move in full speed forward and the time was collected in the following table Table 2: Add caption seconds 1.850 1.800 1.900
cm cm The average speed obtained from the above table is 30 1.85s = 16.2 s The discrepency between the theoretical maximum speed and the experimentally measured max speed can be attributted to the fact that the robot has added weight that increases friction and air resistance. Also, torque from the motor is used upon start o to move the robot and get it moving, which requires energy and time. This dierence between the ideal case and the realistic case is expected and can be considered reasonable considering the realistic contraints of the situation. In this experiment we will begin by studying the behaviour of the servo motor and how it operates under varying input signals. The input line to the servo is a variable number (between 0 and 180). In theory, 0 corresponds to full forward, 90 causes no movement, and 180 sets the motor to full reverse. However, in practical situations this may not be the case and we must map the various values and determine the relationship between then input value and the rotational speed of the motor. This will be done by creating an experimental conguration that will allow us to easily vary the input signal and at the same time measure the rotational speed of the servo. From the experimental data that was collected that behavior of the servo motor has been understood and the following table has been compiled that contains all the important and critical

12

values for typical directions of motion of the robot Table 3: Important Combination of Motion left forward backward right turn left turn gradual right gradual left slow forward slow backward 0 180 0 93 0 84 84 98 right 0 180 93 0 84 0 84 98

Discussion

The behavior of the servos was measured and modelled in a way that will allow for further improvement of the design . Despite being very accurate and precise there is still room for improvements and modications to the design to provide greater exibility and operability. The accuracy of the device could be extended to provide more signicant digits and reduce the round o error. The data collected during this experiment will be useful in the future and will provide necessary insight when using the servo motors to operate the robot and navigating it. The knowledge obtained from this experiment will also be useful in debugging future experiments and determining errors and problems with the behavior of the motors. Nonetheless this experiment was important in providing a brief and concise overview of the important of user interfacing. The presentation of data to the user is of equal importance as the accurate acquisition and processing of data. Through the use of the LCD display we were required to develop such a user interface to display the results of the voltmeter. The importance of user friendly design and ease of operation are emphasized. The user interface device is the largest and most important aspect of any design. Engineers and technologists are familiar with the many tools accessible to solve problems, even in the solution requires some work and eort to obtain. However it is vital that the information obtained be presented in a clear and straight forward manor to the user. There are numerous devices that perform identical task. However some achieve commercial success and acceptance, while others fail to produce any prot. In a commercial setting it is important to make the user interface as simple and intuitive as possible. The importance of good user interfacing is not only vital in the commercial sector, but also in industry. Equipment that is dicult to use or not well designed for easy operation may lead to accidents and error. User interface is just as important as the functionality the device performs itself.

5.1

Ethical Implications

The ethical considerations associated with this particular experiment are concerned with the accuracy of measurements and the importance of error in calculations. The theoretical error in our measurements for this experiment is approximately %0.1, which in itself is not important. Considering the value range that we will be looking at, -5V to +5V, such a discrepancy is of no signicance

13

and only be noticeable if subjected to very precise measurements. However this is only the theoretical error that has been previously discussed. The actual error may vary, and greatly depending on the quality and specications of the equipment used. The mean error for all Arduino ADC should be approximately %0.1, but there is some variance associated with all measurements and the specications of devices. In order to ensure that our predictions fall align with the theoretical predictions we must test the equipment and compare results with an actual, calibrated digital multimeter. This experiment focuses on the relationship between the input signal value and the rotational speed of a servo motor. This is a very important relationship to gain an understanding of before the implementation of a servo motor in an embedded system. Variations and uctuations in this relationship should be well documented and understood a priori otherwise this can lead to undesirable behaviour and dangerous istuations. The issues associated with this particular experiment are concerned with the accuracy of measurements and the importance of error in calculations. The theoretical behavior of all servo motors is that there are three states of operation, forward, no motion and backwards. However, this is completely unrealistic and impossible to occurs. Thus the transition between these three states must be determined and studied to understand the behavior of the servo in these regions. Also, the othe assumption is that all servo motors are identical and thus has the same maximum rotational speed. The input line to the servo is a variable number (between 0 and 180). In theory, 0 corresponds to full forward, 90 causes no movement, and 180 sets the motor to full reverse. The reality of the situation is that there does not exist a discontinuous transition between theses three states, but a steep and rapid transition that bridges the gap between any two states.Also, the assumption that the value of 90 provides a full stop is also under speculation since the servo requires calibration and adjustments to make sure that it does not move when there is no value applied to it. The other issue that occurs is that since the speed is under speculation is is reasonable to consider whether the rotational speed of the forward direction and the reverse direction are equal. Essentially if the two speeds are equal. This lab requires the use of two servos. Given that not all servos has identical behavior and that the there are variations in their behavior. The two servos must be operated at in uni-some. If we wish to have the desired performance we must apply the respective values to each servo to obtain the necessary behavior. The signicance of measurement error must no be under-estimated and the error must be take in context of the application at hand. The percentage error for this specic application is tolerable, but %0.1 error in the trajectory of an airplane or a missile, will not necessarily be negligible and my have devastating consequences. Understanding statistics about the error is vital, but this values must be seen in the scope of the specic application. Tolerances and condence limits must be dened based on the application and the demand for accuracy. Also there is much importance in the idea of variations across products and their specications. The specications of a device typically should include the mean value and the variance from the central value that is present in the population of the devices. This is of signicance when the specication of an application exceed the specication of the device that is being used. In such a situation the error produced will not be bound at the desired value and can never be meet unless device specications are made more strict. It is the task of the engineer to determine the acceptable error for an application and decide on a design that will guarantee operation within the maximum error limits. It is the task of the engineer to be aware of the presence of error in any process and have knowledge of its distribution and be able to control it. Also in this experiment, the importance of user friendly design and ease of operation are 14

emphasized. The user interface device is the largest and most important aspect of any design. Engineers and technologists are familiar with the many tools accessible to solve problems, even in the solution requires some work and eort to obtain. However it is vital that the information obtained be presented in a clear and straight forward manor to the user. There are numerous devices that perform identical task. However some achieve commercial success and acceptance, while others fail to produce any prot. In a commercial setting it is important to make the user interface as simple and intuitive as possible. The importance of good user interfacing is not only vital in the commercial sector, but also in industry. Equipment that is dicult to use or not well designed for easy operation may lead to accidents and error. User interface is just as important as the functionality the device performs itself.

5.2

Lifelong Learning

The technology of embedded systems and specically Arduino is fairly recent and had not been available in previous years and was certainly more limited in its capabilities. Lifelong learning is crucial and important in the digital world. The technology drastically changes and improves over shorts period of time and formal education can only cover the fundamental concepts of operation and cannot be expected to provide all knowledge of available technology and future trends. In this context it is the engineers responsibility to stay up-to-date with upcoming technology. The importance of user friendly design and ease of operation are emphasized. The user interface device is the largest and most important aspect of any design. Engineers and technologists are familiar with the many tools accessible to solve problems, even in the solution requires some work and eort to obtain. However it is vital that the information obtained be presented in a clear and straight forward manor to the user. There are numerous devices that perform identical task. However some achieve commercial success and acceptance, while others fail to produce any prot. In a commercial setting it is important to make the user interface as simple and intuitive as possible. The importance of good user interfacing is not only vital in the commercial sector, but also in industry. Equipment that is dicult to use or not well designed for easy operation may lead to accidents and error. User interface is just as important as the functionality the device performs itself.

5.3

Knowledge/Skills from Earlier Courses

This lab was in introduction to the Arduino using basic knowledge from previous courses found in the ECE curriculum. Programming is the basis of the lab, so many concepts from computer science classes are use. Specically, the microcontroller course provides a good introduction and background in the general theory and principles of operation of embedded systems. Of course the knowledge from the circuits course is brought up in the lab. The general knowledge of electrical and computer engineering form previous courses was culminated in this lab to produce and overall examination of prior education. Detached from the theoretical approach of many courses this lab sought after the practical side and critical thinking of the student. This helps draw on knowledge and skills from previous courses and binds them together through experience and interaction with the deivice.

5.4

Educational Benefits

This lab provided an necessary introduction into the world of Arduino. The simple character of the circuit interfaced with the microcontroller the students is allowed to study the Arduino and its idiosyncrasies in programming. Nonetheless the educational benets are limited past exposing 15

the student to the microcontroller. The experiment acted as a catalyst of thought for the potential issues and possibilities that arise from very elementary and basic congurations sych as the once presented in the lab. Studying the simple circuit congurations provides insight into the most basic and fundamnetal issues that may arise in electronics and proper knowledge and training are necessary to design correct circuits.

5.5

Individual Student Contribution

This lab project was completed with the contribution of all three students, George Micros, Lance Berlin and Eric Littley. The components of the project were developed by the group as a whole and the experiment was too small to divide into smallr components.

Conclusion

The behavior of the servos was measured and modelled in a way that will allow for further improvement of the design . Despite being very accurate and precise there is still room for improvements and modications to the design to provide greater exibility and operability. The accuracy of the device could be extended to provide more signicant digits and reduce the round o error. The data collected during this experiment will be useful in the future and will provide necessary insight when using the servo motors to operate the robot and navigating it. The knowledge obtained from this experiment will also be useful in debugging future experiments and determining errors and problems with the behavior of the motors.

7
7.1

Source Code Appendix


Part I Code

# include < Servo .h > Servo myservo ; // create servo object to control a servo

int potpin = 0; // analog pin used to connect the potentiometer int val ; // variable to read the value from the analog pin void setup () { Serial . begin (9600) ; delay (1000) ; backlightOn () ; clearLCD () ; cursorOff () ; selectLineOne () ; Serial . print ( " Servo " ) ; selectLineTwo () ; Serial . print ( " Thing " ) ; delay (2000) ;

16

myservo . attach (9) ; }

// attaches the servo on pin 9 to the servo object

void loop () { val = analogRead ( potpin ) ; val = map ( val , 0 , 1023 , 0 , 179) ; myservo . write ( val ) ; delay (15) ;

// reads the value of the potentiometer // ( value between 0 and 1023) // scale it to use it with the servo // ( value between 0 and 180) // sets the servo position according // to the scaled value // waits for the servo to get there

clearLCD () ; selectLineOne () ; Serial . print ( val ) ; Serial . print () ; selectLineOne () ;

// place cursor at beginning of line one void selectLineOne () { // puts the cursor at line 0 char 0. Serial . write (0 xFE ) ; // command flag Serial . write (128) ; // position delay (10) ; } // place cursor at beginning of line two void selectLineTwo () { // puts the cursor at line 0 char 0. Serial . write (0 xFE ) ; // command flag Serial . write (192) ; // position delay (10) ; } // place cursor at position void goTo ( int position ) { // position = line 1: 0 -15 , line 2: 16 -31 , 31+ defaults back to 0 if ( position <16) { Serial . write (0 xFE ) ; // command flag Serial . write (( position +128) ) ; // position } else if ( position <32) { Serial . write (0 xFE ) ; // command flag Serial . write (( position +48+128) ) ; // position } else { goTo (0) ; } delay (10) ; } void clearLCD () { Serial . write (0 xFE ) ; // command flag Serial . write (0 x01 ) ; // clear command . delay (10) ; } void backlightOn () { // turns on the backlight Serial . write (0 x7C ) ; // command flag for backlight stuff Serial . write (157) ; // light level . delay (10) ;

17

} void backlightOff () { // turns off the backlight Serial . write (0 x7C ) ; // command flag for backlight stuff Serial . write (140) ; // light level for off . delay (10) ; } void cursorOff () { Serial . write (0 xFE ) ; Serial . write (0 x0C ) ; } void serCommand () { // a general function to call the command flag for issuing all other commands Serial . write (0 xFE ) ; }

7.2

Part II Code

# include < Servo .h > Servo myservoRight ; // create servo object to control a servo Servo myservoLeft ; // create servo object to control a servo int potpin = 0; // analog pin used to connect the potentiometer int val ; // variable to read the value from the analog pin void setup () {

myservoLeft . attach (8) ; // attaches the servo on pin 8 to the servo object myservoRight . attach (9) ; // attaches the servo on pin 9 to the servo object } void loop () { val = analogRead ( potpin ) ; // reads the value of the potentiometer ( value between 0 and 1023) val = map ( val , 0 , 1023 , 0 , 179) ; // scale it to use it with the servo ( value between 0 and 180) myservoLeft . write (50) ; // sets the servo position according to the scaled value myservoRight . write (105) ; delay (15) ; // waits for the servo to get there }

// place cursor at beginning of line one void selectLineOne () { // puts the cursor at line 0 char 0. Serial . write (0 xFE ) ; // command flag

18

Serial . write (128) ; delay (10) ;

// position

} // place cursor at beginning of line two void selectLineTwo () { // puts the cursor at line 0 char 0. Serial . write (0 xFE ) ; // command flag Serial . write (192) ; // position delay (10) ; }

References
A [1] Leslie Lamport, L TEX: A Document Preparation System. Addison Wesley, Massachusetts, 2nd Edition, 1994.

[2] Creative Commons, Arduino Uno. http://arduino.cc/en/Main/arduinoBoardUno Accessed; September 23, 2013 [3] Garrett, Ben, Help - How do I run DOS programs on a modern computer?, 2013. [Online]. Available: http://www.defacto2.net/help/how-to-run-dos. [Accessed 23 September 2013].

19

Вам также может понравиться