Difference between revisions of "F17: Alpha"

From Embedded Systems Learning Academy
Jump to: navigation, search
(Motor Module)
(Motor Module)
Line 340: Line 340:
 
Motor module consists of 2 motors viz. DC motor and Servo motor controlled by a SJOne board by varying the PWM signals, which is nothing but the duty cycle. PWM stands for pulse-width modulation, a type of digital signal and can be used to control the motors.  
 
Motor module consists of 2 motors viz. DC motor and Servo motor controlled by a SJOne board by varying the PWM signals, which is nothing but the duty cycle. PWM stands for pulse-width modulation, a type of digital signal and can be used to control the motors.  
 
 
*Servo Motor:
+
Servo Motor:
RC car came with a digital servo motor, requiring around 3-5V. The motor is controlled by giving a varying PWM signal from the SJOne board. Servo motor is used to convert electrical signal into a linear motion. As per the PWM pulse received by the servo motor from SJOne board, it will rotate it's shaft by a certain degrees left or right.
+
RC car came with a digital servo motor, requiring around 3-5V. The motor is controlled by giving a varying PWM signal from the SJOne board. Servo motor is used to convert electrical signal into a linear motion. As per the PWM pulse received by the servo motor from SJOne board, it will rotate it's shaft by a certain degrees left or right.
 
 
*DC Motor:
+
DC Motor:
Like servo motor, the DC motor was also embedded in the RC car. The DC motor is used to convert electrical signal into mechanical power. DC motor is controlled in the same manner as the servo motor i.e., by varying the PWM signal. The only difference here is that the PWM signal from the SJOne board is given to an Electronic Speed Controller or ESC. The ESC is used to generate three-phased electric power of low voltage in order to vary the speed of the DC motor. In case of no ESC, the DC motor will either not move or will start moving at full throttle. The RC car DC motor required 7.4V of power supply to work. The maximum speed that can be attained by this DC motor is 31mph.
+
Like servo motor, the DC motor was also embedded in the RC car. The DC motor is used to convert electrical signal into mechanical power. DC motor is controlled in the same manner as the servo motor i.e., by varying the PWM signal. The only difference here is that the PWM signal from the SJOne board is given to an Electronic Speed Controller or ESC. The ESC is used to generate three-phased electric power of low voltage in order to vary the speed of the DC motor. In case of no ESC, the DC motor will either not move or will start moving at full throttle. The RC car DC motor required 7.4V of power supply to work. The maximum speed that can be attained by this DC motor is 31mph.
  
 
=== Hardware Interface ===
 
=== Hardware Interface ===

Revision as of 01:28, 15 December 2017

Project Title

Alpha - Self-navigating RC car using CAN communication based on FreeRTOS.

Git Link - ALPHA
Git Users:

  • Anirudh1313
  • chhavi17
  • DoyalPatel
  • jigar29
  • kthnptl
  • rajvisharia
  • ShubhamKulkarni93
  • SnehaSharma
  • SushmaSJSU
  • SuchetaCiyer

Abstract

This section should be a couple lines to describe what your project does.

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

  • Master Controller
    • Jigar Agarwal
    • Sucheta Iyer
  • Geographical Controller
    • Chhavi Mehta
    • Krishna Sai Anirudh Katamreddy
  • Sensor Controller
    • Sneha Sharma
    • Sushma Macha
  • Communication Bridge Controller + LCD
    • Kathan Patel
  • Android Application
    • Doyal Patel
    • Sneha Sharma
  • Testing
    • Doyal Patel
    • Jigar Agarwal
    • Sucheta Iyer

Schedule

Week# Start Date End Date Task Status
1 09/15/2017 09/16/2017
  • Read previous projects, gather information and discuss among the group members.
  • Distribute modules to each team member.
Completed
2 09/17/2017 10/03/2017
  • Set up individual Git accounts and perform individual git commits on a GIT file.
  • Create a project report template on Wiki.
  • Finalize the scope of each individual modules.
  • Study the datasheet and prepare the high-level design.
  • Order an RC Car (appropriate height and suspension), rechargeable batteries, sensors, GPS and compass module.
Completed
3 10/04/2017 10/10/2017
  • Sensor: Interface individual sensor and observe the sensor readings under different conditions. Determine pins and architecture of board for all four sensors.
  • Motor: Test DC and servo motors using RC Transmitter and Receiver.
  • Master: CAN bus test interface with the sensor.
  • Communication Bridge Controller: Refer previous projects and get an overview of ‘Communication Bridge Controller’. Deciding the Bluetooth module and place orders based on the requirements.
  • Geo: Testing GPS and compass modules by checking connections from the datasheet.
  • Android: Android development environment setup and basic Android application development.
Completed
4 10/11/2017 10/17/2017
  • Sensor: Generate a DBC structure and acceptance filter for the sensor, and send the distance of an obstacle if any over the CAN bus. Interface multiple sensors and experiment with the angles of the sensors to have minimum interference.
  • Motor: Get the motors running using SJOne board based on the observation of the PWM waveforms for DC and servo motors on the Oscilloscope.
  • Master: Finalizing the PCB design and general hardware model layout. Brainstorming on CAN message details like ID, priority, etc.
  • Communication Bridge Controller: Understanding the RFCOMM Protocol for Bluetooth communication and Bluetooth hardware. Configure Bluetooth module using Bluetooth terminal.
  • Android: Work towards enabling Bluetooth in the Android environment and create a basic application for controlling a Bluetooth-enabled phone.
Completed
5 10/18/2017 10/24/2017
  • Complete all the Hardware setup for the project and prepare sensor stands of suitable height (positioned at suitable angle on the car).
  • Sensor: Develop an algorithm to trigger all the sensors sequentially i.e., MIDDLE, LEFT, RIGHT, and BACK. Interface sensors with LEDs to indicate the direction to be taken.
  • Motor: Get the motors to move Left, Right, Forward and Reverse through CAN communication from Master module (pressing the switches on Master module).
  • Master: Establish CAN communication between all the modules.
  • Communication Bridge Controller: Interfacing Bluetooth module with SJOne board and test the working of the module.
  • Geo: Interface GPS module to SJOne board using UART and collect the data from GPS and calcualte bearing angle.
  • Android: Establish basic communication between SJOne and mobile application.
Completed
6 10/25/2017 10/31/2017
  • Sensor: Calculate minimum and maximum range of obstacle detection and send the values to Master module. Interface the sensors to RC Car and take real-time readings on a moving car.
  • Motor: Design a robust algorithm to avoid obstacles based on the communication with Master and Sensor modules.
  • Master: Interfacing with the Motor Module and Sensor Module.
  • Communication Bridge Controller & Android: Bi-directional communication between SJOne board and Android application.
  • Geo: Take checkpoints at varios locations on the campus.
Completed
7 11/01/2017 11/07/2017
  • 3D print the sensor stands and place them on the board at proper angle and orientation.
  • Sensor: Test the obstacle detection algorithm with various obstacles like hard flat surfaces, curved surface etc. Stress test the sensors under different temperatures.
  • Motor: Get wheel feedback using RPM sensor values for vehicular movement on the slope.
  • Communication Bridge Controller: Interfacing Bluetooth module with the Master module over the CAN Bus.
  • Geo: Integrate GPS module with the compass and calibrating them with SJOne board as per the values obtained. Send Latitude and Longitude of the current position of the car on CAN Bus.
  • Android: Get important data required for the Android application over CAN Bus with the help of the Bluetooth module.
Completed
8 11/08/2017 11/14/2017
  • Motor: Modify the code to move slight left/right, half left/right, full left/right, straight or stop as per the GPS data sent by the Master module.
  • Master: Develop an algorithm to calculate the servo motor angle as er the data from Geo controller in order to move the car closer to the destination.
  • Geo: Send the heading and bearing angle difference based on the current position and next position to the Master module.
  • Communication Bridge Controller: Interfacing Bluetooth module with GPS module over the CAN bus.
  • Android: Add Google map to the application and get current location of the car. Implement an algorithm to find the shortest path by using different position marker on the Google map.
Completed
9 11/15/2017 11/21/2017
  • Car: Get Destination and Routing Path from the Android app. Develop an algorithm to move the car in the given routing path as well as avoiding the obstacles on its way.
  • Android: Communication between Android application and Master node to pass GPS coordinates and routing details.
Completed
10 11/22/2017 11/29/2017
  • Add additional functionalities and indicators on the car.
  • Integrating RC Car controllers as a single unit. Start with the testing, debugging and optimization process.
  • Make the PCB design for the entire unit. Give extra Vcc and ground pins at the ends for added functionalities like headlights and indicators.
In Progress
11 11/30/2017 12/14/2017
  • Completion of the final Wiki page and the report.
  • Further testing and optimization of the project on campus routes.
In Progress
**************Final Demonstration.*************** To Do

Parts List & Cost

Item# Part Desciption Vendor Datasheet Qty Cost
1 RC Car 1
2 CAN Transceivers MCP2551-I/P Microchip [1] MCP2551-I/P Datasheet 8 Free Samples
3 Sonar Sensor Amazon [2] Maxbotix EZ1 MB 1010 Datasheet 4 $24.95
4 Headlights
5 NiMH Battery From seniors 2
6 Charger for NiMH/NiCd Battery From seniors 1
7 Character LCD Display

Sensor Module

The sensor module refers to the sensors and the embedded board that controls the sensors. In this project we have used four Maxbotix EZ0 ultrasonic sensors. Each of these is mounted in four positions. Three sensors face the front of the car and are positioned in the centre, the left edge and right edge of the car. One sensor is mounted on the back of the car.

The main goal of the sensor module is to detect the distance to an obstacle, from the car and provide this information to the driver module so that it can successfully avoid the obstacle.

Hardware Design

The sensors used are LV-MaxSonar-EZ1 Ultrasonic Range Finder MB1010.

The valid sensors output is a value between 6 and 254. This value is in inches and represents the distance to the obstacle, from the sensor. It is to be noted that if the obstacle is closer than 6 inches from the sensor it will not be detected.

The sensor provides output in three forms; As a pulse on the PW pin, where pulse width represents the distance to obstacle; As an analog voltage on the AN pin; As a digital output on the TX pin, in RS-232 format. We have used the PW pin in this project to receive the input from the sensor.

It is to be noted that if two sensors which are placed so that their beams/detection areas overlap, are ranging at the same time, they cause each other interference and hence incorrect values. Hence we trigger each sensor separately one by one so that at any time, only one sensor is ranging.

<insert image of sensor here. mark all the pins - vcc gnd tx rx pw> <insert image of two sensors placed close by so that their beams are overlapping>

Pin connections - middle sensor

Hardware Interface

Pin connections for each sensor is as follows:

PW (Pin 2) - GPIO Pin configured as interrupt to receive input from sensor

RX (Pin 4) - GPIO Pin configured as output to trigger the sensor

VCC (Pin 6) - +5V

GND (Pin 7) - GND

Pin connections for the middle sensor are displayed.






Software Design

Sensor CAN message

As described in the previous section, the sensors are triggered one by one to prevent corruption of data. In our implementation the sensors are triggered in the following order: middle, right, left and back. The back and left sensors are triggered together since they would not interfere with each other.

Every sensor needs a power up time of 250 ms and some time to calibrate and take the first reading. After this period the sensor can provide a reading every 49 ms. In our implementation, all 4 sensor values are taken every 120 ms and put on the CAN bus. The format of the CAN message is shown in the following snippet taken from the DBC file. It can be observed that the sensor message has a high priority since it is critical to the operation of the car.

Implementation

The following steps are followed to get a valid sensor reading.

1. Initialize the sensors - account for power up and calibration delay.

2. Enable falling edge interrupts and setup callback functions - this is to record the pulse width output of the sensor

3. Trigger each sensor and record the current time. This is the start time.

4. When falling edge interrupt occurs record the time. This is the end time.

5. Calculate pulse width using the start and end time. This pulse width would indicate the distance to the obstacle.

Sensor operation flowchart

Testing & Technical Challenges

There were a few difficulties during implementation and testing of the sensors. Lessons learned include the following:

1. Research different types of sensors, find out the strengths and weaknesses of each before making a decision.

2. Ultrasonic sensors need to be slightly tilted upwards when mounted on the car to prevent them from accidentally detecting ground as an obstacle. This becomes especially necessary when testing on a slope/ramp.

3. Ultrasonic sensors are very sensitive and care needs to be taken while soldering them. Accidental overheating can cause them to be destroyed.

4. The ultrasonic sensors provide more range when +5V is used as supply rather than +3.3V.

5. Testing both indoors and outdoors is necessary to check if the sensor readings are accurate in both conditions.


Motor Module

Motor module is one of the five controllers used in our self-driving car. Motor controller is responsible for driving the car forward and for steering the vehicle. The motor module has two motors viz.DC motor and Servo motor. DC motor makes the car move forward and reverse. Servo motor steers the car either left or right. Along with the two motors we have the rpm speed sensor which is interfaced with our controller to control the speed of DC and move the car at a desired speed in Miles per Hour(MPH).

Team Members

Hardware Design

Motor module consists of 2 motors viz. DC motor and Servo motor controlled by a SJOne board by varying the PWM signals, which is nothing but the duty cycle. PWM stands for pulse-width modulation, a type of digital signal and can be used to control the motors.

Servo Motor: RC car came with a digital servo motor, requiring around 3-5V. The motor is controlled by giving a varying PWM signal from the SJOne board. Servo motor is used to convert electrical signal into a linear motion. As per the PWM pulse received by the servo motor from SJOne board, it will rotate it's shaft by a certain degrees left or right.

DC Motor: Like servo motor, the DC motor was also embedded in the RC car. The DC motor is used to convert electrical signal into mechanical power. DC motor is controlled in the same manner as the servo motor i.e., by varying the PWM signal. The only difference here is that the PWM signal from the SJOne board is given to an Electronic Speed Controller or ESC. The ESC is used to generate three-phased electric power of low voltage in order to vary the speed of the DC motor. In case of no ESC, the DC motor will either not move or will start moving at full throttle. The RC car DC motor required 7.4V of power supply to work. The maximum speed that can be attained by this DC motor is 31mph.

Hardware Interface

Software Design

Implementation

The following steps

1.

2.

Testing & Technical Challenges

There were a few difficulties during implementation and testing of motors

1.

2.

Geographical Controller

The geographical Controller is responsible for navigating the car in the direction of the destination selected by an android user. It uses a compass module for getting the heading angle with respect to the North and a GPS module which returns the current location of the car. After a particular destination has been chosen from the android app, the bridge module generates a number of checkpoints according to the shortest path algorithm. These are then sent to the geographical controller one by one. Using each of them, the bearing angle and the distance between the car and the checkpoint is calculated. Subsequently, the angle that the car should turn is determined and sent to the master module. On reaching the destination, the car is stopped.

Hardware Design

The Geographical controller makes use of the following two modules:

GPS


COMPASS

CMPS11 tilt-compensated compass module is employed for getting a heading angle value between 0-359. It requires a power supply of 3.6-5V. It can be interfaced via both serial(UART) and I2C. We have incorporated the I2C interface in which the 'mode' pin of the compass is left unconnected. It has a 28-byte array of registers and compass bearing can be read from 8-bit register 1.

Calibration of CMPS11 - We are using switch 1 and switch 2 of the SJOne board for entering and exiting the calibration mode respectively. When switch 1 is pressed, a 3-byte sequence of 0xF0, 0xF5 and 0xF6 is sent to the command register 0 and an led on the module starts blinking indicating the calibration mode. Compass is then slowly rotated in all 3 dimensions to get both negative and positive maximums. Only after the led completely extinguishes, switch 2 is pressed and 0xF8 command is sent to exit the calibration mode. More accurate readings can be achieved by performing calibration meticulously.

Hardware Interface

GPS

COMPASS

Software Design

Flowchart

Algorithm

STEP 1:

Implementation

Formulae used:

CAN Communication

Testing & Technical Challenges

Problem 1: GPS usually takes a long time to get the fix.

Solution 1: The GPS module should be operated in hot start mode wherein an external battery(VBAT) of 3V is connected to it.


Problem 2: There was significant delay(5-10 seconds, approximately) in the getting the latitude and longitude values while the car is moving.

Solution 2: The receive queue/buffer size of UART should be kept minimum.


Problem 3: The compass values were inaccurate.

Solution 3: The calibration needs to be done with a lot of patience. Also, it should be positioned as far away from magnets(GPS antenna and RPM sensors) as possible which can easily generate erroneous values from it.

Android Application

A GoogleMap-based Android application was developed to provide the required information to our self-navigating car, Alpha to reach destination. The information includes the routing information between the source and the destination as well as a software-based command to start and to stop the car. This application also displays information regarding the current position and heading angle of Alpha.

Hardware Interface

Interfaced to Bluetooth module (As explained in Bluetooth Module).

Software Design

1. Bluetooth: Bluetooth allows to wirelessly exchange data with another Bluetooth device. Here, we are using Bluetooth to communicate our self-driving car with our Android application.

1.1. Enable Bluetooth: Bluetooth in the phone programmatically enabled using BluetoothAdapter. If Bluetooth in the phone is not enabled, then it can be enabled from the application.
1.2. Connect to Bluetooth on Alpha: A new Socket was created using UUID of Bluetooth device on Alpha. A connection request is sent by calling a connect method created on the socket. Here, "Connect" is the blocking call which will return if the connection request is accepted and the connection is established or an exception will be thrown. To establish an automatic connection between Alpha and the mobile device, a separate thread was created which will continuously check the connection and try to make a connection in case Alpha is not connected. A connection indicator is used to show the current connection status.
1.3. Read from Alpha: Read the data from input-stream and convert it into accurate latitude, longitude, and heading angle. A separate thread is used to continuously read data and update it on the screen.
1.4. Write to Alpha: Write the data in the output stream so that it can be available to Alpha. In this application Start bit, Stop bit and the routing checkpoints are sent to move the car.

Implementation

This section includes implementation, but again, not the details, just the high-level details. 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 the SPI Flash. You can include sub-sections for each of your component implementation.

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.

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

Upload a video of your project and post the link here.

Project Source Code

References

Acknowledgement

Any acknowledgement that you may wish to provide can be included here.

References Used

List any references used in project.

Appendix

You can list the references you used.