You are on page 1of 15

FINAL PROJECT REPORT Mechanical Engineering 224 Professor Espinosa June 9, 2005 Kendra Armstrong Nick Eccles Cary

Maguire Alex Taam Paul Williams2 Table of Contents I. Introduction II. Boe-Bot Assembly III. Servo Calibration IV. Gyroscope Calibration V. Analog-to-Digital Converter VI. Programming and Debugging VII. Results and Conclusions VIII. Improvements and Future Considerations IX. Appendix A: Servo Calibration Program X. Appendix B: LabView Program for Gyroscope Calibration XI. Appendix C: Turn Test Program XII. Appendix D: Final Path Program3 I. Introduction The objective of this project is to use our knowledge acquired in Mechanical Engineering 224 to control a Boe-Bot along a specified path, Figure 1 Robot Path using gyroscope sensing in a closed-loop feedback system (see figure 1). The Boe-Bot robot is

mainly composed of two servo motors to operate the wheels and a Board of Education carrier board, which is controlled by a program called BASIC Stamp. Specifically, we will create a BASIC Stamp program that will use a specified voltage, which corresponds to a certain angular velocity, to control the direction of travel of the Boe-Bot. Then, using closed-loop feedback from a gyroscope and ADC (Analog-to-Digital Converter), the Boe-Bot will correct itself to travel in a completely straight line.4 II. Boe-Bot Assembly Figure 2Boe Bot Our Boe-Bot was brand new, therefore unassembled. First, we attached the four standoffs to the four corners of the chassis. The standoffs support the Board of Education from which the Boe-Bot runs. After centering the Parallax Continuous Rotation servos, we attached the servos to the chassis using Philips screws and nuts. We then attached our power source, the battery pack, to the underside of the chassis. After that, we attached the tail wheel ball and high quality rubber band tires. Lastly, we connected the Board of Education onto the four standoffs, with the breadboard closest to the drive wheels. And the Boe-Bot was born! (See figure 2 for a photo of an assembled Boe-Bot).5 III. Servo Calibration Figure 3 Boe Bot Servo Before assembling the Boe-Bot, we had to calibrate the servo motors (see figure 3). We used a program (see Appendix A) that sends the servos a signal, telling them to stay still. Because the servos are not pre-adjusted at the manufacturing facility from which they came, they will actually start spinning. We then had to use a screwdriver and adjust the servos until they were still. This calibration is called centering the servos. When the program input is PULSOUT 12, 750, it is centering the right (designated by 12) servo to stay still (750 designates no movement in either direction). When the program input is PULSOUT 13, 750, it is centering the left (designated by 13) servo to stay still. When the input 750 is increased, the servo will travel in one direction, and when it is decreased, the servo will travel in the opposite direction.6

IV. Gyroscope Calibration The main programming softwares we used in this project were LabView and BASIC Stamp. While we were capable of programming the Boe-Bot to travel in straight lines and make various turns with BASIC Stamp, we did not know the actual angles the Boe-Bot turned during its test trials. In order to be more accurate with our Boe-Bot following its respective path, we integrated the response of a gyroscope in a closed feedback loop, which will allow us to program the robot to make turns at specified angles and will adjust the Boe-Bot so it does not deviate from its straight path. In this project, we used an ADXRSS150EB gyroscope from Analog Devices. It operates on a 5 Volt power supply and is capable of sensing up to 150 degrees in angular motion. This gyroscope contains two polysilicon sensing structures which have capacitive pickoff structures that are capable of detecting motion caused by a Coriolis force. This Coriolis force is produced when the Boe-Bot rotates. After the Boe-Bot rotates, the Coriolis force causes the two polysilicon sensing structures to be displaced orthogonal to the vibrating motion of the Boe-Bot. The capacitive pickoff structures on the polysilicon sensors then pick up the Coriolis motion and a rate signal output is produced. This rate signal is the feedback we need in order to ensure that our Boe-Bot turns at specified angles and follows a straight path. Before we wrote our final program, we needed to calibrate the gyroscope and determine the relationship between its angular velocities and their respective output signals. We first created a LabView program (see Appendix B) that plotted our gyroscope output signals versus time:7 Figure 4 Gyroscope Response This allowed us to see how the gyroscope output signals varied as the Boe-Bot spun in a clockwise (from t = 5 s to t = 17 s) and then counterclockwise (t = 17 s to t = 26 s) motion (see figure 4). The next step was to determine the relationship between the gyroscopes angular velocities and their respective output signals. In order to find this relationship we created a

BASIC Stamp program (see Appendix C) that spun the Boe-Bot at various angular velocities. After each run, we recorded the number of rotations, and the respective times for each run, the Boe-Bot completed. This enabled find a relationship between the gyroscopes output signals and their respective angular velocities. (See figure 5). Voltage vs Time 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 0 5 10 15 20 25 30 Time (s) Voltage (V)8 Figure 5 --Gyroscope Calibration Curve Angular Velocity vs Voltage y = 1.3361x - 3.0312 R 2 = 0.9999 -4 -3

-2 -1 0 1 2 3 4 012345 Voltage (V) Angular Velocity (rad/s) Test Data Linear (Test Data)9 V. Analog-to-Digital Converter After mounting and calibrating the gyroscope, we encountered a major problem. The gyroscope was outputting a voltage in the range of about 0.2V to 4.6V. We needed to incorporate the full scope of these values in our control of the Boe-Bot. However, the pins on the Board of Education of the Boe-Bot can only read high or low. To rectify this problem, we decided to look into ADCs, which could then provide us with a range of values instead of just 1 or 0. After researching various options online, we decided to use the TLC0820AIN, produced by Texas Instruments. (Specification sheet can be found at http://www-s.ti.com/sc/ds/tlc0820a.pdf). The converter is an 8-bit analog-to-digital converter that uses the output of the gyroscope (RATEOUT) as its input and then writes the values to pins zero through seven on the Boe-Bot. Thus, we could theoretically acquire a range of values from 0 to 255, instead of the original 0 or 1. The converter uses the 5V power of the Boe-Bot as its VCC, which is the desired value on the specification sheet, thereby eliminating the need for an op-amp circuit to power the converter. When wiring the converter onto the Board of Education, we encountered another problem, namely a shortage of possible connections. The Board only has 17 rows of pins, but the converter

and the gyroscope each need 10 rows. To solve this problem, we purchased another small breadboard from RadioShack and mounted it to the cart of the Boe-Bot, beneath the original circuitry. (See figures 6 and 7). Before starting to write a comprehensive BASIC Stamp program for the robots route, we needed to determine if the converter was working as expected and was compatible with the Board of Education. To do this, we used a variable voltage generator as the input, and BASIC Stamp to read in the values from the pins of the Boe-Bot. Since the maximum voltage the converter could handle was 5V, and the maximum output of the gyroscope was around 4.6V, we found that it worked nicely. We varied the voltage generator from zero to 4.9V, and found that the converter10 was wired correctly and working as expected. We were now ready to incorporate the gyroscope as the input and control the Boe-Bot with BASIC Stamp. Figure 6 Robot with both breadboards VI. Programming and Debugging Because we chose to use only the BASIC Stamp programming language to control our robot, we developed a single program encompassing both the feedback and control of the robot. Development of this program required the integration of the information obtained in the gyroscope and ADC calibration phases with the programs we had created to perform basic robot maneuvers. The calibration we achieved of the gyroscope produced a correlation between angular velocity of the robot and the voltage generated by the gyroscope. The output of the gyroscope is the input to the ADC, which produces an 8-bit binary number that the Board of Education can read. Testing of the ADC gave us a correlation between the digital numbers produced by the ADC and the analog voltages that create them. Figure 8 The team at work The program reads the output of the ADC and converts the binary signal to an integer value, and then converts this integer to the corresponding voltage of the gyroscope output. Using the gyroscope calibration equation, this voltage is then converted to an angular velocity.12 Knowing the angular velocity of the robot and the sampling time, a simple integration can be Figure 7 ADC, Installed11

performed by summing the product of the angular velocity and the time step to produce the total angular displacement of the robot. The program written performs these tasks and instructs the robot to turn until the proper displacement has been reached, regardless of surface conditions or the time required to do so. The initial runs were far from ideal, but with iteration we were able to produce a program that causes the robot to describe a parallelogram path, with 45 and 135 angles and equal length sides. In order to debug the program we tested the small programs that performed portions of the route (traveling straight, turning 45, etc.) individually before integrating them into the final program as subroutines. The proper turn durations were achieved by iteratively modifying the calibration in the calculation routine. Straight line performance was established by first creating a baseline servo setting that produced the straightest possible path without feedback, then running a feedback loop to correct the path if the robot deviated from straight ahead (if the gyroscope detected an angular velocity). (Figure 8 shows the team hard at work). The robots performance is not as consistent as it could be, nor are the measurements as precise as we would like, due to BASIC Stamps inability to handle decimal numbers. (See figure 9 for a sample of the testing procedure). This introduced error as any decimal value is truncated to leave only the integer. This is particularly important during division operations, when any remainder is discarded. Because BASIC Stamp can only handle numbers up to 65535, the scale of numbers becomes an issueit is difficult to maintain accuracy when dealing with numbers of varying magnitudes. An additional problem is that there is a finite, non-zero time step for the summing operation. Ideally, as the time step goes to zero, the sum becomes an integral, but the Board of Education and the BASIC Stamp software require a finite amount of time to run the program each time it loops. These errors multiply over the integration to create less accurate results. The sensitivity of the instruments was another concern. After processing the gyroscopes output (with the aforementioned BASIC Stamp mathematical complications), the13 robots closed loop straight line feedback is not robust enough to detect small path deviations, only large scale errors. This could be corrected with more sensitive components, faster

processing, more precise computations, or a combination thereof. Figure 9 The robot during testing for path accuracy14 VII. Results and Conclusions Our project was successful. The Boe-Bot follows the specified route successfully most of the time. It races smoothly along as it takes into account the feedback it receives from the gyroscope. Although this fulfills the basic requirements of the project, there are many problems with our current system that detract from the accuracy and consistency of our Boe-Bot operation. First, there are multiple problems with the BASIC Stamp program. The largest problem is that BASIC Stamp does not allow the use of decimal points. This means that the numbers we use must be scaled up, and then subsequently scaled back down as we make our calculations that determine the Boe-Bots route. This scaling results in a large loss of precision. Also, variables can only be declared to about 60,000, which makes it difficult to scale numbers to a large enough number to prevent important values from being truncated. Secondly, there are problems with our ADC. While it converts the analog input from the gyro into a digital signal, it has a number of sensitivity issues. In its current configuration, the ADC cant detect small changes in angle. This allows BASIC Stamp to control the Boe-Bot to some degree, but it often produces inaccurate and inconsistent results. Ultimately, the Boe-Bot works, however, there are many improvements that could be implemented.15 VIII. Improvements and Future Considerations As mentioned above, there are numerous improvements that could be employed to improve the Boe-Bots operation. . (Figure 10 shows the robot during testing). The most important improvement involves making the ADC more sensitive. This can be done in various ways. The most logical way is amplifying the signal with an operational amplifier. There is a detriment to this method, however. Amplifying the signal would improve the sensitivity, but it would also reduce the range of values that would be recognized. The Boe-Bot would subsequently have to be operated at lower voltages to ensure that it didnt go out of the narrowed range. In addition, the method of scaling number in BASIC Stamp to account for the lack of

decimal points could be refined. There are other methods that produce higher precision, but the process is more tedious. For our calculations, the more simple method was used. Finally, all of the equations and calculations would benefit from being recalibrated. Many hours were spent in the lab tweaking numbers, and all of the tweaking resulted in better control of the Boe-Bot. With more time, there could be a larger amount of time dedicated to calibrating the Boe-Bot and refining numbers. We had a limited amount of time for the project, and the equations were refined to be as accurate and consistent as possible Figure 10 The robot connected to the computer during testing16 IX. Appendix A: Servo Calibration Program ' {$STAMP BS2} ' {$PBASIC 2.5} counter VAR Word FOR counter = 1 TO 100 PULSOUT 13, 750 next17 X. Appendix B: LabView Program for Gyroscope Calibration18 XI. Appendix C: Turn Test Program ' {$STAMP BS2} ' {$PBASIC 2.5} value VAR Word theta VAR Word sum VAR Word V VAR Word ts VAR Word counter VAR Word dsum VAR Word

pulsecount VAR Word ts = 6 GOSUB Ramp GOSUB Turn45 END Turn1: PULSOUT 13, 770 PULSOUT 12, 770 PAUSE 20 RETURN Ramp: FOR pulseCount = 1 TO 20 PULSOUT 13, 750 + pulseCount PULSOUT 12, 750 + pulseCount PAUSE 20 GOSUB Calc NEXT RETURN Calc: LOW 8 value = (1*IN0) + (2*IN1) + (4*IN2) + (8*IN3) + (16*IN4) + (32*IN5) + (64*IN6) + (128*IN7) HIGH 8 V = (value*420/256+50) theta = (133*V - 30590)/100 dsum = theta*ts/100 sum = sum + dsum

RETURN Turn45: DO WHILE (sum < 1225)19 GOSUB Turn1 GOSUB Calc LOOP RETURN20 XII. Final Path Program ' {$STAMP BS2} ' {$PBASIC 2.5} value VAR Word theta VAR Word sum VAR Word V VAR Word ts VAR Word counter VAR Word dsum VAR Word pulsecount VAR Word value2 VAR Word value3 VAR Word counter2 VAR Word ts = 2 GOSUB Straight PAUSE 500 GOSUB Ramp GOSUB Turn45 PAUSE 500

GOSUB Straight PAUSE 500 GOSUB Zerovar GOSUB Ramp GOSUB Turn135 PAUSE 500 GOSUB Straight PAUSE 500 GOSUB Zerovar GOSUB Ramp GOSUB Turn45 PAUSE 500 GOSUB Straight PAUSE 500 GOSUB Zerovar GOSUB Ramp GOSUB Turn135 END '%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutines %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Zerovar: value = 0 V=0 dsum = 021 theta = 0 sum = 0 RETURN

Turn135: DO WHILE (sum < 270) GOSUB Turn1 GOSUB Calc LOOP RETURN Turn45: DO WHILE (sum < 85) GOSUB Turn1 GOSUB Calc LOOP RETURN Turn1: PULSOUT 13, 780 PULSOUT 12, 780 PAUSE 20 RETURN Straight: FOR counter2 = 1 TO 10 value2 = 0 value3 = 0 FOR counter = 1 TO 10 PULSOUT 13, 807 PULSOUT 12, 650 PAUSE 20 GOSUB Valread value3 = value3 + value2

NEXT IF value3/10 > 120 THEN GOSUB Correctleft ELSEIF value3/10 < 100 THEN GOSUB Correctright ENDIF NEXT RETURN Ramp: FOR pulseCount = 1 TO 2022 PULSOUT 13, 750 + pulseCount PULSOUT 12, 750 + pulseCount PAUSE 20 GOSUB Calc NEXT RETURN Calc: LOW 8 value = (1*IN0) + (2*IN1) + (4*IN2) + (8*IN3) + (16*IN4) + (32*IN5) + (64*IN6) + (128*IN7) HIGH 8 V = (value*420/256+50) theta = (133*V - 30590)/100 dsum = theta*ts/100 sum = sum + dsum RETURN Valread:

LOW 8 value2 = (1*IN0) + (2*IN1) + (4*IN2) + (8*IN3) + (16*IN4) + (32*IN5) + (64*IN6) + (128*IN7) HIGH 8 RETURN Correctright: FOR counter = 1 TO 3 PULSOUT 13, 770 PULSOUT 12, 770 PAUSE 20 NEXT RETURN Correctleft: FOR counter = 1 TO 3 PULSOUT 13, 730 PULSOUT 12, 730 PAUSE 20 NEXT RETURN

You might also like