Difference between revisions of "F17: Alpha"
Proj user1 (talk | contribs) (→Hardware Design) |
Proj user1 (talk | contribs) (→Hardware Design) |
||
Line 344: | Line 344: | ||
The Motor Module consists of 2 motors viz. DC motor and Servo motor controlled by an 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.Along with two motors we have interfaced the RPM sensor with the motor module micro-controller to get the wheel feedback and move our car at a constant speed even if the car is going uphill or downhill. | The Motor Module consists of 2 motors viz. DC motor and Servo motor controlled by an 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.Along with two motors we have interfaced the RPM sensor with the motor module micro-controller to get the wheel feedback and move our car at a constant speed even if the car is going uphill or downhill. | ||
− | [[File:Motor module Block diagram.PNG| | + | [[File:Motor module Block diagram.PNG|600px|thumb|center|Block Diagram for Motor module]] |
=== Hardware Interface === | === Hardware Interface === |
Revision as of 19:21, 18 December 2017
Contents
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
- Motor Controller
- Geographical Controller
- Chhavi Mehta
- Krishna Sai Anirudh Katamreddy
- Sensor Controller
- Sneha Sharma
- Sushma Macha
- Communication Bridge Controller & LCD
- Kathan Patel
- Sushma Macha
- 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 |
|
Completed |
2 | 09/17/2017 | 10/03/2017 |
|
Completed |
3 | 10/04/2017 | 10/10/2017 |
|
Completed |
4 | 10/11/2017 | 10/17/2017 |
|
Completed |
5 | 10/18/2017 | 10/24/2017 |
|
Completed |
6 | 10/25/2017 | 10/31/2017 |
|
Completed |
7 | 11/01/2017 | 11/07/2017 |
|
Completed |
8 | 11/08/2017 | 11/14/2017 |
|
Completed |
9 | 11/15/2017 | 11/21/2017 |
|
Completed |
10 | 11/22/2017 | 11/29/2017 |
|
In Progress |
11 | 11/30/2017 | 12/14/2017 |
|
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 | Bluetooth (HC-05) | HiLetgo | [3] | 1 | 49.0 |
8 | Graphics LCD Display | 4D systems | [4] | 1 | 49.0 |
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.
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
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.
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 the desired speed in Miles per Hour(MPH).
Team Members
Hardware Design
The Motor Module consists of 2 motors viz. DC motor and Servo motor controlled by an 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.Along with two motors we have interfaced the RPM sensor with the motor module micro-controller to get the wheel feedback and move our car at a constant speed even if the car is going uphill or downhill.
Hardware Interface
Servo Motor:
RC car came with a digital servo motor, requiring around 3-5V. The motor is directly controlled by giving a varying PWM signal from the SJOne board. Servo motor is used to convert an electrical signal into a linear motion. As per the PWM pulse received by the servo motor from SJOne board, it will rotate its shaft by a certain degree left or right. Below table gives the PWM values given to the motor for turning the car in the desired direction.
No. | PWM | Direction |
---|---|---|
1 | 10.1 | Full Left |
2 | 13.3 | Slight Left |
3 | 14.7 | Very Slight Left |
4 | 15.4 | Straight |
5 | 16.1 | Very Slight Right |
6 | 17.5 | Slight Right |
7 | 19.8 | Full Right |
DC Motor:
Like servo motor, the DC motor was also embedded in the RC car. The DC motor is used to convert an 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-phase 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.
// Insert a photo here
Software Design
Implementation
The following steps
1.
2.
Testing & Technical Challenges
Following were the problems faced and their resolutions:
Problem 1: DC motor would not work unless initialized with the transmitter (remote) before connecting to SJOne board.
Solution 1: DC motor was initialized in init function by passing the neutral command (PWM of 15.4) and giving a delay of 1 second.
Problem 2: RPM sensor was not able to detect the magnet fixed on the wheel.
Solution 2: We had to stack together 3 magnets instead of one so that it was just millimeters away from the RPM sensor as well as its magnetic strength increased to be detected accurately by the RPM sensor.
Problem 3: Speed was not accurate with one magnet on the wheel.
Solution 3: Five magnets at an equidistant position from each other were used for better accuracy. More the magnets, better is the accuracy of speed calculation.
Problem 4: Downhill...
Solution 4: Give brake at the start...
Problem 5: Reverse functionality was difficult to implement.
Solution 5: .....
Problem 6: The car did not go reverse all of a sudden even with the working code.
Solution 6: When checked with the transmitter/remote, still didn't work. It was found by reading the manual that ESC has 3 modes which can be set by long pressing the power button. And accidentally, ESC was changed to mode 2 where reverse wouldn't work. Car was set back to Mode 1.
Problem 7: Servo and DC motors didn't move even in open surroundings with no obstacles or MIA condition at one instance.
Solution 7: It was found that the Bluetooth start button was disabled from the Android application.
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
Venus638FLPx is used for detecting the location of the car. It returns the NMEA GPS string which needs to be parsed to get the latitude and longitude values from the module. It is a high performance, low cost, single chip GPS receiver that offers very low power consumption, high sensitivity, and best in class signal acquisition and time-to-first-fix performance.
Feature:
20Hz update rate -148dBm cold start sensitivity -165dBm tracking sensitivity 29 second cold start TTFF 1 second hot start 2.5m accuracy 67mW full power navigation Works directly with active or passive antenna
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
UART :
Pin connections for GPS is as follows:
VCC (Pin 1) - +5V
TX (Pin 2) - RX
RX (Pin 3) - TX
GND (Pin 4) - GND
I2C:
Pin connections for compass is as follows:
VCC (Pin 1) - +3.3V
SDA (Pin 2) - SDA
SCL (Pin 3) - SCL
GND (Pin 6) - GND
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.
Master Module
The master module is the driver which is responsible for the smooth navigation of the car. It accepts all the inputs from sensors, the geo controller, the android app and makes a decision to drive the car according to this data received.
Hardware Design
The objective of the master module is to make the car reach the destination location via all the checkpoints given by the android app with the help of geo-controller. On its way to the destination, there may be obstacles in the path of the car which it should avoid at all times. The flow of the CAN messages is as shown below
Hardware Interface and Pin Connections
One SJ One board is used as a master controller. These boards have the following connections:
- CAN receiver and transmitter connections.
- Headlights and Taillights for the car.
- VCC and GND connections.
Pin Number | Connection Details | Description |
---|---|---|
P 1.20 | Front LED | Headlights of the car |
P 1.22 | Rear LED | Taillights of the car |
P 0.1 | CAN TXPin | Connected to pin 7 of MCP2551 |
P 0.0 | CAN RXPin | Connected to pin 6 of MCP2551 |
GND | Connected to common ground | |
3V3 | Connected to incoming supply voltage | All the VCC are commong, coming from 5V battery supply. |
Software Design
The software is made up of 3 main modules.
- Obstacle Avoidance
- Motor Commands Generator
- Indicators Controller
Overview of modules
- Obstacle Avoidance
- Obstacle avoidance algorithm is the essence if the driver module. It takes care of all the obstacles that come in between the path and avoids the car from colliding or hurting someone.
- Some properties of the obstacle avoidance algorithm,
- It uses a total of 3 sensors mounted at the precise angle on the car to detect obstacles that come in the front and 1 sensors for the rear of the car.
- Whenever all the front sensors senses an object in the middle it will keep on taking reverse with a left astern until the front is clear.
- When all the 4 sensors sense an object at the same time, the car will not move as there is no space for it to move.
- The priority for operation between all the modules is highest for obstacle avoidance.
- Obsatcle avoidance doesn't move the car at all when:
- There is a stop signal from the android app forcing the car to stop
- The destination is reached.
- Bluetooth, GPS, and Sensor modules are not on the CAN
- Some properties of the obstacle avoidance algorithm,
- Let's peek more into the working of obstacle avoidance algorithm,
- Obstacle avoidance algorithm is written based on the following state diagram. It keeps on checking the center sensor at the beginning. If the center sensor is sensing an object there is no way we can go further as the car may collide with an obstacle if it detects an obstacle. So, in this case, the car will check whether there is an object in the back or not if the back is also blocked the car will stop at the position. If the rear is not blocked it will take reverse until the front is unblocked. If the center direction is not blocked it will go straight in this case and keep on checking side sensors, if any one of the direction is blocked it will move in the opposite direction. If both the side sensors are blocked then the car will go into reverse condition as it does not have any front direction to go. If the rear is blocked during this operation the car will be stopped at that position, and if not it will take reverse until font direction is clear. If none of the direction is blocked it will always follow the GPS directions sent by GPS module.
- Motor Commands Generator
- This module is responsible for sending all the actions taken by obstacle avoidance to the motor.
- It sends following commands to the motor module at the execution of the obstacle avoidance algorithm.
- Angle at which the car should move
- Driving speed at which the motors should be driven
- Direction in which the car should go(Reverse or Forward)
- It frames this messages into a structure and sends to the motor to take control accordingly.
- Indicator Controller
- This module is responsible for controlling all the lights mounted on the car. The car has 2 head lights and 2 tail lights.
- All the indicators are updated in 100ms periodically
- Opearation of these lights are as following
Head Light Tail Light Car State On Off Going Forward Off On Stopped Off Blinking Going Reverse Blinking Blinking Reached The Destination
Implementation
Testing & Technical Challenges
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 Car: 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 Bluetooth on car is not connected. A connection indicator shows 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.
2. Routing Algorithm: Dijkstra Routing Algorithm is used to calcite shortest path algorithm between source and destination. Check points are taken inside San Jose State University. Latitude and Longitude of each check point is considered as a node of directed graph. The routing path is stored as an array of check points and sent to car using Bluetooth. On map the routing is shown by blue line which connect to all check points. All check point between source location and destination location is shown by violet colored markers, source location is shown by blue marker and destination is shown by red marker in routing path.
3. Start and Stop: Command to start the car and stop the car provided by android aplication. Here, for both command a single button is used as start and stop are alternative activity. Once car is started by pressing on "GO" button on aplication, the button on app will convert in "STOP" button. A voice command indication is provided to Start and to stop.
Implementation
Algorithm:
PREREQ: All possible checkpoints should be previously saved in the app before the routing algorithm is run. This is a one-time activity.
1. Check Bluetooth Status
- a. If Bluetooth is not enabled
- Enable Bluetooth.
2. Fork a child thread for automatic connection to the car’s Bluetooth module.
3. Fork a child thread to read data from the car continuously through the Bluetooth connection.
4. Get the Destination from ‘On click’ method on map.
5. On clicking on Go Button
- a. If Bluetooth connectivity lost
- Error: Car is not connected to Bluetooth
- b. Else If Destination is not selected
- Error: Destination is not selected
- c. Else
- I. Get current location latitude and longitude and save as source.
- II. Calculate routing path using Dijkstra routing algorithm.
- III. Send all check points to car using Bluetooth.
- IV. Send start message to car using Bluetooth.
6. On clicking on Stop Button send stop message to car using Bluetooth.
Algorithm For Automatic Connection Thread:
1. If Connection to car is available go to sleep.
2. Else
- Delete Old socket.
- Create new socket and send connection request to connect.
- Go to sleep.
3. Repeat step 1 and 2 till app is destroyed.
Algorithm For Read data From Bluetooth Continuously:
1. Read data from Bluetooth buffer.
2. Convert data to Current Location and Compass Angle.
3. Display Current Location and Compass Angle on the Display Screen.
4. Repeat Step 1 to Step 4 till app is not destroy.
Flowchart :
Testing & Technical Challenges
1. Automatic connection to bluetooth: In case of bleutooth connectivity lost, while trying to reconnect using same Socket was not conncting to Bluetooth again.
Solution : If connection lost between Android app and bluetooth a new Socket should create and try to connect using newly created socket. As, now old socket is not used delete old socket.
2. Routing Algorithm: There are many shortest path algorithm available whch move from one check point to another check point in the map.(Logically all points in the map cannot b check points.) In the application current checpoint and dstination may not be from the check point which are taken.
Solution : make algorithm to find nearst check point from the source towards the destination and connect source node to this check point. In same manner, Find nearest check point from Destination towards source and connect destination to this check point. Calculate sortest path between these two check point using Disktera's algorithm.
3. Adding Check points: Check point taen by normal view of google map were not accurate.
Solution: All the check points taken using satellite view of google map.
Communication Bridge Controller & LCD
The purpose of Communication Bridge Controller is to establish communication between Andriod app and Car via bluetooth communication protocol. This ECU send the updated checkpoints to Geo Controller at a particular instance when the car reaches at one checkpoint and sends the current location of the car to Android phone so the tracking of the car on-road becomes easy. The Communication Bridge Controller also displays the Current location, Sensor readings, Car Speed on graphics LCD.
Team Members
Kathan Patel Sushma Macha
Hardware Design and Interface
The Communication Bridge Controller is the interface of communication between user and the car. The ECU is interfaced with Bluetooth via UART and with graphics LCD via UART. The Communication Bridge Controller displays the messages on LCD. This section details the designs of the hardware components used for the communication and display. Android app routes the car.
Design
The components used are SJOne board, Bluetooth, CAN transceiver, gen4-uLCD-32PT (graphics LCD), jumper wires.
HC-05 Bluetoooth module
gen4-uLCD graphics LCD
Hardware Interface
Software Design and Implementation
Implementation
Testing & Technical Challenges
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.