Difference between revisions of "F13: Obstacle Avoidance Robot"

From Embedded Systems Learning Academy
Jump to: navigation, search
 
(36 intermediate revisions by 2 users not shown)
Line 1: Line 1:
=== Grading Criteria ===
 
<font color="green">
 
*  How well is Software & Hardware Design described?
 
*  How well can this report be used to reproduce this project?
 
*  Code Quality
 
*  Overall Report Quality:
 
**  Software Block Diagrams
 
**  Hardware Block Diagrams
 
**:  Schematic Quality
 
**  Quality of technical challenges and solutions adopted.
 
</font>
 
 
 
= Object Sensing and Avoidance Robot =
 
= Object Sensing and Avoidance Robot =
  
Line 17: Line 5:
  
 
== Objectives & Introduction ==
 
== Objectives & Introduction ==
''Show list of your objectives.  This section includes the high level details of your project.  You can write about the various sensors or peripherals you used to get your project completed.''
 
  
 
=== Team Members & Responsibilities ===
 
=== Team Members & Responsibilities ===
Line 26: Line 13:
  
 
== Schedule ==
 
== Schedule ==
''Show a simple table or figures that show your scheduled as planned before you started working on the project.  Then in another table column, write down the actual schedule so that readers can see the planned vs. actual goals.  The point of the schedule is for readers to assess how to pace themselves if they are doing a similar project.''
 
  
 
{| class="wikitable"
 
{| class="wikitable"
Line 73: Line 59:
 
| 11/26
 
| 11/26
 
| Work documentation
 
| Work documentation
|
+
| Worked algorithm and schematic documentation. Took videos for final presentation.
 
|-
 
|-
 
! scope="row"| 9
 
! scope="row"| 9
 
| 12/3
 
| 12/3
 
| Project due
 
| Project due
|
+
| Complete. Presentation shown during class.
 
|}
 
|}
  
 
== Parts List & Cost ==
 
== Parts List & Cost ==
*  Pololu 5" Robot Chassis - $7.95
 
*  Pololu 42x19mm Wheel & Encoder - $39.95
 
*  Toshiba TB6612FNG Motor Driver - $4.95
 
*  50:1 Micro Metal Gearmotor - $15.95
 
*  Sensor, IR, Compound Eye - $9.95
 
*  Pan/Tilt Platform w/ 2 Servos - $14.95
 
  
[[File:obstacle_parts.jpg|thumb|none|Parts]]
+
{| class="wikitable"
 +
|-
 +
! scope="col"| Item
 +
! scope="col"| Description
 +
! scope="col"| Qty
 +
! scope="col"| Unit Cost
 +
! scope="col"| Total Cost
 +
|-
 +
! scope="row"| 1
 +
| #713 TB6612FNG Dual Motor Driver Carrier
 +
| 1
 +
| $5.00
 +
| $5.00
 +
|-
 +
! scope="row"| 2
 +
| #2107 Pololu 5V, 600mA Step-Down Voltage Regulator D24V6F5
 +
| 1
 +
| $5.95
 +
| $5.95
 +
|-
 +
! scope="row"| 3
 +
| #965 0.100" (2.54 mm) Breakaway Male Header: 1x40-Pin, Straight
 +
| 4
 +
| $0.99
 +
| $3.96
 +
|-
 +
! scope="row"| 4
 +
| #1134 Pololu Carrier with Sharp GP2Y0D810Z0F Digital Distance Sensor 10cm
 +
| 4
 +
| $6.95
 +
| $27.80
 +
|-
 +
! scope="row"| 5
 +
| #1700 Premium Jumper Wire 50-Piece Rainbow Assortment F-F 6"
 +
| 1
 +
| $12.49
 +
| $12.49
 +
|-
 +
! scope="row"| 6
 +
| #1944 Aluminum Standoff: 1" Length, 2-56 Thread, M-F (4-Pack)
 +
| 2
 +
| $1.59
 +
| $3.18
 +
|-
 +
! scope="row"| 7
 +
| #1940 Aluminum Standoff: 1/4" Length, 2-56 Thread, M-F (4-Pack)
 +
| 2
 +
| $1.29
 +
| $2.58
 +
|-
 +
! scope="row"| 8
 +
| #1067 Machine Hex Nut: #2-56 (25-pack)
 +
| 1
 +
| $0.99
 +
| $0.99
 +
|-
 +
! scope="row"| 9
 +
| #1955 Machine Screw: #2-56, 1/4" Length, Phillips (25-pack)
 +
| 1
 +
| $0.59
 +
| $0.59
 +
|-
 +
! scope="row"| 10
 +
| #1501 Pololu 5" Robot Chassis RRC04A Solid Black
 +
| 1
 +
| $7.95
 +
| $7.95
 +
|-
 +
! scope="row"| 11
 +
| #1218 Pololu 42x19mm Wheel and Encoder Set
 +
| 1
 +
| $39.95
 +
| $39.95
 +
|-
 +
! scope="row"| 12
 +
| #2365 50:1 Micro Metal Gearmotor MP
 +
| 2
 +
| $16.00
 +
| $32.00
 +
|-
 +
! scope="row"| 13
 +
| #925 T Connector Male-Female Pair
 +
| 1
 +
| $1.49
 +
| $1.49
 +
|-
 +
! scope="row"| 14
 +
| #955 Pololu Ball Caster with 3/4" Metal Ball
 +
| 1
 +
| $2.99
 +
| $2.99
 +
|-
 +
! scope="row"| 15
 +
| 2150441 SENSOR, IR COMPOUND EYE, 200mm
 +
| 1
 +
| $9.95
 +
| $9.95
 +
|-
 +
! scope="row"| 16
 +
| 2157870 PAN/TILT, 2-SERVO INCL, 8g
 +
| 1
 +
| $14.95
 +
| $14.95
 +
|-
 +
! scope="row"| 17
 +
| LiPo Battery
 +
| 1
 +
| $7.00
 +
| $7.00
 +
|-
 +
! scope="row"| 18
 +
| SJSU Development Board
 +
| 1
 +
| $75.00
 +
| $75.00
 +
|-
 +
! scope="row"|
 +
|
 +
|
 +
| Total
 +
| $253.82
 +
|}
 +
 
 +
[[File:obstacle_parts.jpg|thumb|none|Figure 1: Parts]]
  
 
== Design & Implementation ==
 
== Design & Implementation ==
''The design section can go over your hardware and software design.  Organize this section using sub-sections that go over your design and implementation.''
 
 
 
The photo below shows the implementation/progress as of 11/10/2013.
 
The photo below shows the implementation/progress as of 11/10/2013.
  
[[File:obstacle_assemb_11_10.jpg|thumb|none|Assembly as of 11/10/2013]]
+
[[File:obstacle_assemb_11_10.jpg|thumb|upright=1.5|none|Figure 2: Assembly as of 11/10/2013]]
  
The photo below shows the implementation/progress as of 11/17/2013.
+
The photo below shows the implementation/progress as of 11/17/2013. The oscilloscope in the background was being used to display the PWM signal for the motor drives.
  
[[File:obstacle_assembly_11_17.jpg|thumb|none|Assembly as of 11/17/2013]]  
+
[[File:obstacle_assembly_11_17.jpg|thumb|upright=1.5|none|Figure 3: Assembly as of 11/17/2013]]  
  
 
=== Hardware Design ===
 
=== Hardware Design ===
''Discuss your hardware design hereShow detailed schematics, and the interface here.''
+
The design is built onto a Pololu 5" round robotic chassis that is designed to accept two independently driven wheelsAs Figure 1 shows, there are two electronic boards stacked onto each other.  The board on top is the SJSU NXP LPC1758 development board.  Below that is a board that contains the motor driver and the 12V to 5V regulator.  This board also worked well for a power distribution board so several headers are located on this board.
 +
 
 +
The design has three main voltages.  The battery pack provides 12V to run the motors and as input power to the 5V switching regulator.  The 5V out from the switching regulator provides power for the SJSU board at the USB interface as well as for the motor driver logic and ultimately the I/R sensor power. The 5V to 3.3V linear regulator on the SJSU development board was utilized to regulate the 5V input to 3.3V.  The 3.3V was then sent off the SJSU board to power the analog and digital I/R sensors. The high level schematic in Figure 4 below shows these details.
 +
 
 +
[[File:obstacle_bot_schem.jpg|frame|none|Figure 4: High Level Schematic]]
  
The design is built onto a Pololu 5" round robotic chassis that is designed to accept two independently driven wheels.  As the picture above shows, there are two electronic boards stacked onto each other.  The board on top is the SJSU NXP LPC1758 development board.  Below that is a board that contains the motor driver and the 12V to 5V regulator.  This board also worked well for a power distribution board.  There are two main voltages.  The battery pack provides 12V to run the motors and as input power to the 5V switching regulator.  The 5V out from the switching regulator provides power for the SJSU board at the USB interface as well as for the motor driver logic and I/R sensor power.
+
[[File:obstacle_bot_schem.pdf|border|none|High Level Schematic]]
  
 
=== Hardware Interface ===
 
=== Hardware Interface ===
''In this section, you can describe how your hardware communicates, such as which BUSes usedYou can discuss your driver implementation here, such that the '''Software Design''' section is isolated to talk about high level workings rather than inner working of your project.''
+
The design uses the SJSU board PWM and GPIO outputs to drive the scan head servo motors and wheel motors.  The GPIO are also utilized for the inputs from the digital sensors.  An A/D input into the board reads voltage from the analog I/R sensor.
 +
 
 +
In order to integrate the I/R sensor with the robot, we need to perform a calibration to determine the characteristics of the sensor. The basic calibration procedure was to read the A/D counts as a white surface was held at a particular distance from the sensor headA snapshot of this procedure is shown below in Figure 5.
  
We are using the SJSU board PWM and GPIO outputs to the motor driver and I/R servo. We are using the A/D inputs to read voltage from the I/R sensor itself.  The motor driver then interfaces directly to the two motors.
+
[[File:obstacle_analog_cal.png|thumb|upright=1.5|none|Figure 5: Analog I/R Sensor Calibration]]
  
[[File:obstacle_Cal_data.jpg|thumb|none|I/R Sensor Calibration]]
+
The chart below shows the calibration data from each of the four sensors on the I/R sensor head.
 +
 
 +
[[File:obstacle_Cal_data.jpg|frame|none|Figure 6: I/R Sensor Calibration]]
 +
 
 +
From this data, we were able to determine that a sensor reading less than 1000 counts meant that an object was far enough away to take no action. However a reading of greater than 1000 counts meant that an object is getting closer than 5 to 6 inches and it is time to stop the robot from going forward and run an algorithm to determine the best direction to move the robot.
  
 
=== Software Design ===
 
=== Software Design ===
''Show your software design.  For example, if you are designing an MP3 Player, show the tasks that you are using, and what they are doing at a high level.  Do not show the details of the code.  For example, do not show exact code, but you may show psuedocode and fragments of code.  Keep in mind that you are showing DESIGN of your software, not the inner workings of it.''
 
  
We have working functions that can drive the motors forwards and backwards and read from the I/R sensor.  The plan is to find a generally clear direction to go from the I/R sensor input.  This function will send a direction to go to the motor drive sectionCurrently, we are investigating the use of interrupts in order to tie all of the pieces together to make it function smoothly.
+
We have working functions that can drive the motors forwards and backwards and turn the robot left and right.  Other functions read the A/D input from the analog I/R sensor.  The status of the digital I/R connected to the GPIO are also read.  The main functionality of the algorithm is to drive forward until an object is sensed.  If one of the digital I/R sensors sensed the object, then the robot backs up for more clearance.  The scan head is then used to find the clearest path and the wheels turn the robot in that direction and begin moving forward again.
 +
 
 +
The code also contains a few housekeeping functions.  For instance, one of the switches is used to enable/disable the motors.  Also, the light sensor is used to adjust the analog I/R sensor threshold.
 +
 
 +
Two different implementations of the algorithm were tried.  One with interrupts and one without interrupts (polling).  Without some sort of masking functionality, interrupts do not work well.  This is discussed further in the "Issues" section.
 +
 
 +
Below are brief descriptions of each of the software functions.
 +
 
 +
====Main Function====
 +
 
 +
The main function declares all the variables and initializing functions. It scans the switch (sw1) on the board, to enable the robotWhen a button press is detected, the main obstacle avoidance function is called.
 +
 
 +
====check_ir_sensor_function====
 +
 
 +
This function is the main algorithm for this robot.  The function works by first adjusting the threshold of the analog Infra-Red sensor as function of the external light.
 +
 
 +
It will then scan the digital IR sensors and the analog IR sensor. If an object was detected on the digital sensor, the robot will reverse a few inches and call the “distance_scan_function”.
 +
 
 +
If an object was detected on the analog sensor and the reading is below the set threshold, it will call the “distance_scan_function”. 
 +
 
 +
When computing the “distance_scan_function”, the results of the scan are sent to the motors object to turn the robot into the clearest path. Once pointed to the clearest path, it will then continue strait.
 +
 
 +
====distance_scan_function====
 +
 
 +
This function is the “head scanning” functionIt scans 5 angles of view in front of the robot, reading the A/D on each angle and storing the read into an array.  When all 5 measurements are complete, it will find the farthest distance and store into the return value.
 +
 
 +
When using the interrupt version, everything remains the same, except the digital sensors are not being polled, rather firing an interrupt when detecting an object.  The interrupts need to be enabled in the main function. The interrupts will then call the ir_irq function.
 +
 
 +
====ir_irq====
 +
 
 +
This function will turn on an LED to indicate the interrupt.  The function will then stop the motors immediately, reverse the robot a few inches and will then call the "distance_scan_function".
 +
 
 +
====Algorithm with Interrupts====
 +
 
 +
[[File:obstacle_SoftwareDiagram.bmp|frame|none|Figure 7: Software Diagram (Interrupts)]]
 +
 
 +
[[File:obstacle_SoftwareDiagram.pdf|border|none|Software Diagram (Interrupts)]]
 +
 
 +
====Algorithm without Interrupts (Polling)====
 +
 
 +
[[File:obstacle_SoftwareDiagram_polling.bmp|frame|none|Figure 8: Software Diagram (Polling)]]
 +
 
 +
[[File:obstacle_SoftwareDiagram_polling.pdf|border|none|Software Diagram (Polling)]]
  
 
=== Implementation ===
 
=== Implementation ===
''This section includes implementation, but again, not the details, just the high level.  For example, you can list the steps it takes to communicate over a sensor, or the steps needed to write a page of memory onto SPI FlashYou can include sub-sections for each of your component implementation.''
+
 
 +
====Infrared (I/R) Sensors====
 +
Two types of I/R sensors were used.  The first was an analog sensor shown in Figure 9 below.  The analog sensor can gauge the approximate distances to objects based on the calibration found above.  The sensor sits on the scanning head of the robot and is used to find the clearest path for the robot to go next.
 +
 
 +
[[File:obstacle_analogir_det.png|thumb|upright=1.5|none|Figure 9: Analog I/R Sensor Detail]]
 +
 
 +
Figure 10 below shows the detailed location of the digital sensors.  These sensors change state when an object is approximately 2 - 10cm in front of them.  The main purpose of the digital sensors is to provide more coverage area for sensing objects.  While the robot is moving forward, the digital sensors are used to find objects lower and to the side compared to what the main scanning head can see.
 +
 
 +
[[File:obstacle_digitalir_det.png|thumb|upright=1.5|none|Figure 10: Digital I/R Sensor Detail]]
 +
 
 +
====Wheels and Motors====
 +
Two independently controlled wheels were used.  A motor controller was considered in the beginning, but ultimately a motor driver was utilized instead.  A motor controller usually contains all of the functions to drive the motors and is typically commanded via I2C or similar communication bus.  A motor driver, on the other hand, basically amplifies a PWM signal that is sent to it and will also contain direction controls.  For this robot, a motor driver was used since the NXP microcontroller already contained PWM and motor controller functionality.  It was thought that this solution would provide the most versatility.  Figure 11 below shows the motor and motor driver being tested on a bread board before being implemented onto the robot platform.
 +
 
 +
[[File:obstacle_testmotor.png|thumb|upright=1.5|none|Figure 11: Motor Breadboard]]
 +
 
 +
As mentioned above, the PWM functionality of the microcontroller was used to run the motors through the motor drivers.  In software, different functions were created for going forward, backwards, turning right and turning left.  The different functions are needed to set the "A" and "B" GPIO correctly as these lines control whether and individual motor will turn forward or backwardFor example to make a right hand turn, the left wheel should move forward while right wheel turns backwards.
  
 
== Testing & Technical Challenges ==
 
== Testing & Technical Challenges ==
''Describe the challenges of your project.  What advise would you give yourself or someone else if your project can be started from scratch again?
 
Make a smooth transition to testing section and described what it took to test your project.
 
  
Include sub-sections that list out a problem and solution, such as:''
+
=== Issue #1 ===
 +
Voltages:  We had an issue with what voltages to use to drive everything.  At first, we thought we might need 12V for the motors, 3.3V for the SJSU board, and 5V for the motor control logic.  We also ran into the bug on the SJSU board when it is powered directly with 3.3V.  When this is the case, the USB to RS232 chip holds the board in reset.
  
=== Issue #1 ===
+
Solution: In the end, we found that the GPIO pins were 5V tolerant and therefore could accept 5V from the motor control driver.  We also found that the best solution to power the SJSU board was with 5V through the USB power to keep the USB to RS232 chip from resetting the NXP chip.
Voltages: We had an issue with what voltages to use to drive everything.  At first, we thought we might need 12V for the motors, 3.3V for the SJSU board, and 5V for the motor control logic.  We also ran into the bug on the SJSU board when it is powered directly with 3.3V.  When this is the case, the USB to RS232 chip holds the board in reset.  In the end, we found that the GPIO pins were 5V tolerant and therefore could accept 5V from the motor control driver.  We also found that the best solution to power the SJSU board was with 5V through the USB power to keep the USB to RS232 chip from resetting the NXP chip.
 
  
 
=== Issue #2 ===
 
=== Issue #2 ===
We discovered another limitation in with this board. It appears only one frequency of PWM can be used at a time. We are looking at different solutions.
+
PWMs: We discovered another limitation in with this board. It appears only one frequency of PWM can be used at a time. The servo of the scan head must be run at 50Hz, while through experimentation, it was found that the wheel motors run the best at 400Hz.
 +
 
 +
Solution: After looking at several options, the simplest solution was to run both of the motors at 50Hz.  The wheel motors are not as smooth and seem to make more noise at this frequency, but they still run fine.  The spec sheet of the motor was reviewed and it appears that this frequency is acceptable.
 +
 
 +
=== Issue #3 ===
 +
Interrupts: Code was written to try and utilize the interrupt capability of the board.  During testing of this code, we found that if several interrupts came in at once, the code would not behave as expected
 +
 
 +
Solution: The short term solution was to use code that polls the sensors instead of waiting for interrupts.  However we believe a better long term solution would be to use masking in conjunction with the interrupt.  The digital I/R sensors would be masked to disable further interrupts until the robot had gone through a direction change routine.
  
 
== Conclusion ==
 
== Conclusion ==
''Conclude your project here.  You can recap your testing and problems.  You should address the "so what" part here to indicate what you ultimately learnt from this project.  How has this project increased your knowledge?''
 
  
=== Project Video ===
+
The Obstacle Avoidance Robot utilized nearly as many hardware skills as it did software skills.  There were many challenges in trying to connect the various pieces of hardware with all of their unique requirement ranges.  Everything from different voltage requirements to varying frequency requirements.  There were also software limitations to overcome as well.  For instance, it would have been nice to be able to have two different PWM frequencies at the same time: one for the motors and another for the servos.  However we found that we were able to make enough compromises to get the hardware and software to work well enough together without needlessly overcomplicating the design.
''Upload a video of your project and post the link here.''
 
  
 +
=== Project Videos ===
 
The video below shows the first autonomous testing of the motor functionality.
 
The video below shows the first autonomous testing of the motor functionality.
  
 
[https://www.youtube.com/watch?v=APlcrEJ8rNI Motor Test Video]
 
[https://www.youtube.com/watch?v=APlcrEJ8rNI Motor Test Video]
  
This video shows the complete functionality of the robot.
+
This video shows the complete functionality of the robot. However more calibration of the motors was required
  
 
[https://www.youtube.com/watch?v=v7FMOW8j8xo Full Functionality Video]
 
[https://www.youtube.com/watch?v=v7FMOW8j8xo Full Functionality Video]
 +
 +
The two videos below show the full capability of the final design.  These videos show the performance of the robot on different surfaces and with different obstacles.
 +
 +
[https://www.youtube.com/watch?v=S5c3NG780J8 Final Video 1]
 +
 +
[https://www.youtube.com/watch?v=mELEAJNcjfg Final Video 2]
  
 
=== Project Source Code ===
 
=== Project Source Code ===
''Send me your zipped source code and I will upload this to SourceForge and link it for you.''
 
  
 
== References ==
 
== References ==
 
=== Acknowledgement ===
 
=== Acknowledgement ===
''Any acknowledgement that you may wish to provide can be included here.''
 
  
 
=== References Used ===
 
=== References Used ===
''List any references used in project.''
 
  
 
=== Appendix ===
 
=== Appendix ===
''You can list the references you used.''
 

Latest revision as of 02:28, 9 December 2013

Object Sensing and Avoidance Robot

Abstract

The purpose of this project is to develop a robotic platform using the class issued NXP LPC1758 development boards. The main operation of the robot will be to sense objects near it using a distance sensor and then use a moveable platform to steer away from the sensed objects.

Objectives & Introduction

Team Members & Responsibilities

  • Joel
    • Sensor Development
  • Dan
    • Motor Drive Development

Schedule

Week# Date Task (Planned) Task (Result)
1 10/8 Project Proposal Complete
2 10/15 Research parts Complete
3 10/22 Order & receive parts Complete. Received parts 10/23. Found that another order was necessary. Only one motor, needed two. Need bracket hardware.
4 10/29 Research motor driver & A/D converter functions Complete. Not as many A/D channels as hoped for I/R sensor. Considered external A/D, decided on reducing A/D inputs to match available channels.
5 11/5 Write & test motor driver & A/D code Complete. One motor drive output seems a little weaker than the other. Viewed outputs on oscilloscope, no issue found.
6 11/12 Write & test combined avoidance robot code Complete. Updated motor driver. Able to achieve autonomous motion. See video.
7 11/19 Write & test combined avoidance robot code. Complete. Calibrated I/R sensor. Integrated all functionality together. See video.
8 11/26 Work documentation Worked algorithm and schematic documentation. Took videos for final presentation.
9 12/3 Project due Complete. Presentation shown during class.

Parts List & Cost

Item Description Qty Unit Cost Total Cost
1 #713 TB6612FNG Dual Motor Driver Carrier 1 $5.00 $5.00
2 #2107 Pololu 5V, 600mA Step-Down Voltage Regulator D24V6F5 1 $5.95 $5.95
3 #965 0.100" (2.54 mm) Breakaway Male Header: 1x40-Pin, Straight 4 $0.99 $3.96
4 #1134 Pololu Carrier with Sharp GP2Y0D810Z0F Digital Distance Sensor 10cm 4 $6.95 $27.80
5 #1700 Premium Jumper Wire 50-Piece Rainbow Assortment F-F 6" 1 $12.49 $12.49
6 #1944 Aluminum Standoff: 1" Length, 2-56 Thread, M-F (4-Pack) 2 $1.59 $3.18
7 #1940 Aluminum Standoff: 1/4" Length, 2-56 Thread, M-F (4-Pack) 2 $1.29 $2.58
8 #1067 Machine Hex Nut: #2-56 (25-pack) 1 $0.99 $0.99
9 #1955 Machine Screw: #2-56, 1/4" Length, Phillips (25-pack) 1 $0.59 $0.59
10 #1501 Pololu 5" Robot Chassis RRC04A Solid Black 1 $7.95 $7.95
11 #1218 Pololu 42x19mm Wheel and Encoder Set 1 $39.95 $39.95
12 #2365 50:1 Micro Metal Gearmotor MP 2 $16.00 $32.00
13 #925 T Connector Male-Female Pair 1 $1.49 $1.49
14 #955 Pololu Ball Caster with 3/4" Metal Ball 1 $2.99 $2.99
15 2150441 SENSOR, IR COMPOUND EYE, 200mm 1 $9.95 $9.95
16 2157870 PAN/TILT, 2-SERVO INCL, 8g 1 $14.95 $14.95
17 LiPo Battery 1 $7.00 $7.00
18 SJSU Development Board 1 $75.00 $75.00
Total $253.82
Figure 1: Parts

Design & Implementation

The photo below shows the implementation/progress as of 11/10/2013.

Figure 2: Assembly as of 11/10/2013

The photo below shows the implementation/progress as of 11/17/2013. The oscilloscope in the background was being used to display the PWM signal for the motor drives.

Figure 3: Assembly as of 11/17/2013

Hardware Design

The design is built onto a Pololu 5" round robotic chassis that is designed to accept two independently driven wheels. As Figure 1 shows, there are two electronic boards stacked onto each other. The board on top is the SJSU NXP LPC1758 development board. Below that is a board that contains the motor driver and the 12V to 5V regulator. This board also worked well for a power distribution board so several headers are located on this board.

The design has three main voltages. The battery pack provides 12V to run the motors and as input power to the 5V switching regulator. The 5V out from the switching regulator provides power for the SJSU board at the USB interface as well as for the motor driver logic and ultimately the I/R sensor power. The 5V to 3.3V linear regulator on the SJSU development board was utilized to regulate the 5V input to 3.3V. The 3.3V was then sent off the SJSU board to power the analog and digital I/R sensors. The high level schematic in Figure 4 below shows these details.

Figure 4: High Level Schematic

File:Obstacle bot schem.pdf

Hardware Interface

The design uses the SJSU board PWM and GPIO outputs to drive the scan head servo motors and wheel motors. The GPIO are also utilized for the inputs from the digital sensors. An A/D input into the board reads voltage from the analog I/R sensor.

In order to integrate the I/R sensor with the robot, we need to perform a calibration to determine the characteristics of the sensor. The basic calibration procedure was to read the A/D counts as a white surface was held at a particular distance from the sensor head. A snapshot of this procedure is shown below in Figure 5.

Figure 5: Analog I/R Sensor Calibration

The chart below shows the calibration data from each of the four sensors on the I/R sensor head.

Figure 6: I/R Sensor Calibration

From this data, we were able to determine that a sensor reading less than 1000 counts meant that an object was far enough away to take no action. However a reading of greater than 1000 counts meant that an object is getting closer than 5 to 6 inches and it is time to stop the robot from going forward and run an algorithm to determine the best direction to move the robot.

Software Design

We have working functions that can drive the motors forwards and backwards and turn the robot left and right. Other functions read the A/D input from the analog I/R sensor. The status of the digital I/R connected to the GPIO are also read. The main functionality of the algorithm is to drive forward until an object is sensed. If one of the digital I/R sensors sensed the object, then the robot backs up for more clearance. The scan head is then used to find the clearest path and the wheels turn the robot in that direction and begin moving forward again.

The code also contains a few housekeeping functions. For instance, one of the switches is used to enable/disable the motors. Also, the light sensor is used to adjust the analog I/R sensor threshold.

Two different implementations of the algorithm were tried. One with interrupts and one without interrupts (polling). Without some sort of masking functionality, interrupts do not work well. This is discussed further in the "Issues" section.

Below are brief descriptions of each of the software functions.

Main Function

The main function declares all the variables and initializing functions. It scans the switch (sw1) on the board, to enable the robot. When a button press is detected, the main obstacle avoidance function is called.

check_ir_sensor_function

This function is the main algorithm for this robot. The function works by first adjusting the threshold of the analog Infra-Red sensor as function of the external light.

It will then scan the digital IR sensors and the analog IR sensor. If an object was detected on the digital sensor, the robot will reverse a few inches and call the “distance_scan_function”.

If an object was detected on the analog sensor and the reading is below the set threshold, it will call the “distance_scan_function”.

When computing the “distance_scan_function”, the results of the scan are sent to the motors object to turn the robot into the clearest path. Once pointed to the clearest path, it will then continue strait.

distance_scan_function

This function is the “head scanning” function. It scans 5 angles of view in front of the robot, reading the A/D on each angle and storing the read into an array. When all 5 measurements are complete, it will find the farthest distance and store into the return value.

When using the interrupt version, everything remains the same, except the digital sensors are not being polled, rather firing an interrupt when detecting an object. The interrupts need to be enabled in the main function. The interrupts will then call the ir_irq function.

ir_irq

This function will turn on an LED to indicate the interrupt. The function will then stop the motors immediately, reverse the robot a few inches and will then call the "distance_scan_function".

Algorithm with Interrupts

Figure 7: Software Diagram (Interrupts)

File:Obstacle SoftwareDiagram.pdf

Algorithm without Interrupts (Polling)

Figure 8: Software Diagram (Polling)

File:Obstacle SoftwareDiagram polling.pdf

Implementation

Infrared (I/R) Sensors

Two types of I/R sensors were used. The first was an analog sensor shown in Figure 9 below. The analog sensor can gauge the approximate distances to objects based on the calibration found above. The sensor sits on the scanning head of the robot and is used to find the clearest path for the robot to go next.

Figure 9: Analog I/R Sensor Detail

Figure 10 below shows the detailed location of the digital sensors. These sensors change state when an object is approximately 2 - 10cm in front of them. The main purpose of the digital sensors is to provide more coverage area for sensing objects. While the robot is moving forward, the digital sensors are used to find objects lower and to the side compared to what the main scanning head can see.

Figure 10: Digital I/R Sensor Detail

Wheels and Motors

Two independently controlled wheels were used. A motor controller was considered in the beginning, but ultimately a motor driver was utilized instead. A motor controller usually contains all of the functions to drive the motors and is typically commanded via I2C or similar communication bus. A motor driver, on the other hand, basically amplifies a PWM signal that is sent to it and will also contain direction controls. For this robot, a motor driver was used since the NXP microcontroller already contained PWM and motor controller functionality. It was thought that this solution would provide the most versatility. Figure 11 below shows the motor and motor driver being tested on a bread board before being implemented onto the robot platform.

Figure 11: Motor Breadboard

As mentioned above, the PWM functionality of the microcontroller was used to run the motors through the motor drivers. In software, different functions were created for going forward, backwards, turning right and turning left. The different functions are needed to set the "A" and "B" GPIO correctly as these lines control whether and individual motor will turn forward or backward. For example to make a right hand turn, the left wheel should move forward while right wheel turns backwards.

Testing & Technical Challenges

Issue #1

Voltages: We had an issue with what voltages to use to drive everything. At first, we thought we might need 12V for the motors, 3.3V for the SJSU board, and 5V for the motor control logic. We also ran into the bug on the SJSU board when it is powered directly with 3.3V. When this is the case, the USB to RS232 chip holds the board in reset.

Solution: In the end, we found that the GPIO pins were 5V tolerant and therefore could accept 5V from the motor control driver. We also found that the best solution to power the SJSU board was with 5V through the USB power to keep the USB to RS232 chip from resetting the NXP chip.

Issue #2

PWMs: We discovered another limitation in with this board. It appears only one frequency of PWM can be used at a time. The servo of the scan head must be run at 50Hz, while through experimentation, it was found that the wheel motors run the best at 400Hz.

Solution: After looking at several options, the simplest solution was to run both of the motors at 50Hz. The wheel motors are not as smooth and seem to make more noise at this frequency, but they still run fine. The spec sheet of the motor was reviewed and it appears that this frequency is acceptable.

Issue #3

Interrupts: Code was written to try and utilize the interrupt capability of the board. During testing of this code, we found that if several interrupts came in at once, the code would not behave as expected

Solution: The short term solution was to use code that polls the sensors instead of waiting for interrupts. However we believe a better long term solution would be to use masking in conjunction with the interrupt. The digital I/R sensors would be masked to disable further interrupts until the robot had gone through a direction change routine.

Conclusion

The Obstacle Avoidance Robot utilized nearly as many hardware skills as it did software skills. There were many challenges in trying to connect the various pieces of hardware with all of their unique requirement ranges. Everything from different voltage requirements to varying frequency requirements. There were also software limitations to overcome as well. For instance, it would have been nice to be able to have two different PWM frequencies at the same time: one for the motors and another for the servos. However we found that we were able to make enough compromises to get the hardware and software to work well enough together without needlessly overcomplicating the design.

Project Videos

The video below shows the first autonomous testing of the motor functionality.

Motor Test Video

This video shows the complete functionality of the robot. However more calibration of the motors was required

Full Functionality Video

The two videos below show the full capability of the final design. These videos show the performance of the robot on different surfaces and with different obstacles.

Final Video 1

Final Video 2

Project Source Code

References

Acknowledgement

References Used

Appendix