Multi-Sensor Integration and Fusion using PSoC

Similar documents
Tarocco Closed Loop Motor Controller

YDLIDAR G4 DATASHEET. Doc#: 文档编码 :

School of Surveying & Spatial Information Systems, UNSW, Sydney, Australia

BRB900 GPS Telemetry System August 2013 Version 0.06

Interfacing Sensors & Modules to Microcontrollers

ECE 477 Digital Systems Senior Design Project Rev 8/09. Homework 5: Theory of Operation and Hardware Design Narrative

Modern Robotics Inc. Sensor Documentation

YDLIDAR F4PRO DATASHEET

Cost efficient design Operates in full sunlight Low power consumption Wide field of view Small footprint Simple serial connectivity Long Range

ADVANCED EMBEDDED MONITORING SYSTEM FOR ELECTROMAGNETIC RADIATION

Project Final Report: Directional Remote Control

Training Schedule. Robotic System Design using Arduino Platform

UNIVERSITY OF NORTH CAROLINA AT CHARLOTTE

Cost efficient design Operates in full sunlight Low power consumption Wide field of view Small footprint Simple serial connectivity Long Range

66-Channel GPS Module GP-3711

CMPS09 - Tilt Compensated Compass Module

GPS Engine Board FGPMMOSL3

SNIOT702 Specification. Version number:v 1.0.1

I 2 C RedBot & DC Motor Servo Motor Control

EVDP610 IXDP610 Digital PWM Controller IC Evaluation Board

Master Thesis Presentation Future Electric Vehicle on Lego By Karan Savant. Guide: Dr. Kai Huang

SMARTALPHA RF TRANSCEIVER

CMPS11 - Tilt Compensated Compass Module

L76-L GNSS Module Presentation

GPS-Aided INS Datasheet Rev. 2.3

Part Number Weblink for the part Description Unit Price. Hardware interfacing to the Freescale 9S12C32 MCU on board the CSM-12C32 module

HAND GESTURE CONTROLLED ROBOT USING ARDUINO

SKYTRAQ. GPS Module MG-ST1315S. UUser s Manual Ver 1.01

Serial Communication AS5132 Rotary Magnetic Position Sensor

32-channel GPS Engine Board SmartAntenna

Carbon Dioxide (Tiny CO2) Gas Sensor. Rev TG400 User Manual

RPLIDAR A2. Introduction and Datasheet. Low Cost 360 Degree Laser Range Scanner. Model: A2M5 A2M6 OPTMAG. Shanghai Slamtec.Co.,Ltd rev.1.

Citrus Circuits Fall Workshop Series. Roborio and Sensors. Paul Ngo and Ellie Hass

EL6483: Sensors and Actuators

GPS System Design and Control Modeling. Chua Shyan Jin, Ronald. Assoc. Prof Gerard Leng. Aeronautical Engineering Group, NUS

GPS-Aided INS Datasheet Rev. 2.6

G3P-R232. User Manual. Release. 2.06

OS3D-FG MINIATURE ATTITUDE & HEADING REFERENCE SYSTEM MINIATURE 3D ORIENTATION SENSOR OS3D-P. Datasheet Rev OS3D-FG Datasheet rev. 2.

FLCS V2.1. AHRS, Autopilot, Gyro Stabilized Gimbals Control, Ground Control Station

Interfacing to External Devices

RPLIDAR A1. Introduction and Datasheet. Low Cost 360 Degree Laser Range Scanner. Model: A1M8. Shanghai Slamtec.Co.,Ltd rev.1.

CONDOR C1919 GPS RECEIVER MODULE technical notes GENERAL OVERVIEW

TX CONTROLLER Model EM-IP Quick Start Guide

RPLIDAR A2. Introduction and Datasheet. Model: A2M3 A2M4 OPTMAG. Shanghai Slamtec.Co.,Ltd rev.1.0 Low Cost 360 Degree Laser Range Scanner

RB-Dev-03 Devantech CMPS03 Magnetic Compass Module

Brian Hanna Meteor IP 2007 Microcontroller

B Robo Claw 2 Channel 25A Motor Controller Data Sheet

RPLIDAR A3. Introduction and Datasheet. Low Cost 360 Degree Laser Range Scanner. Model: A3M1. Shanghai Slamtec.Co.,Ltd rev.1.

DASL 120 Introduction to Microcontrollers

Key Modules For Your Success SKYTRAQ. GPS Module MG-ST1315. UUser s Manual Ver 展得國際有限公司

Applications. Operating Modes. Description. Part Number Description Package. Many to one. One to one Broadcast One to many

Debugging a Boundary-Scan I 2 C Script Test with the BusPro - I and I2C Exerciser Software: A Case Study

X3M. Multi-Axis Absolute MEMS Inclinometer Page 1 of 13. Description. Software. Mechanical Drawing. Features

Accident Sensor with Google Map Locator

RPLIDAR A1. Introduction and Datasheet. Low Cost 360 Degree Laser Range Scanner rev.2.1. Model: A1M8. Shanghai Slamtec.Co.

APN-0046: Configure CAN for SPAN

In this lecture, we will look at how different electronic modules communicate with each other. We will consider the following topics:

GNSS 5 click PID: MIKROE-2670

IMU: Get started with Arduino and the MPU 6050 Sensor!

3D ULTRASONIC STICK FOR BLIND

ATB200. Datasheet. ATB200 GPRS / GPS based Fleet Management Terminal. 1

Hardware in the Loop Simulation for Unmanned Aerial Vehicles

Critical Design Review: M.A.D. Dog. Nicholas Maddy Timothy Dayley Kevin Liou

GPS/GNSS Receiver Module

USB4. Encoder Data Acquisition USB Device Page 1 of 8. Description. Features

Prototype Realization

GPS Receiver. UT-41R (DB9 and PS2 cable) Fast Acquisition Enhanced Sensitivity 12 Channel GPS Sensor Receiver. Features

Project Name Here CSEE 4840 Project Design Document. Thomas Chau Ben Sack Peter Tsonev

GPS-41EBR GPS-41EBF. GPS Receiver Module GPS-41EB. Fast Acquisition Enhanced Sensitivity 12 Channel GPS Sensor Module FEATURES. Ordering Information

LOCOSYS Technology Inc.

Trademarks & Copyright

B RoboClaw 2 Channel 30A Motor Controller Data Sheet

EN: This Datasheet is presented by the m anufacturer. Please v isit our website for pricing and availability at ore.hu.

Serial Servo Controller

era, eric, era-lora, eric-lora & eric-sigfox Evaluation Board with GNSS

Remote Switching. Remote Gates. Paging.

Autonomous Following RObot Critical Design Review

Marine Debris Cleaner Phase 1 Navigation

Designing with STM32F3x

EE 314 Spring 2003 Microprocessor Systems

Application Note. Communication between arduino and IMU Software capturing the data

Users guide ECS 1/2/3 COMPASS / GPS Sensor

Servo click. PID: MIKROE 3133 Weight: 32 g

BV4112. Serial Micro stepping Motor Controller. Product specification. Dec V0.a. ByVac Page 1 of 18

Remote Switching. Remote Gates. Paging.

RF RECEIVER DECODER RDF1. Features Complete FM Receiver and Decoder. Applications

LV-Link 3.0 Software Interface for LabVIEW

Asset Tracking and Accident Detecting Using NI MyRIO

isma-b-w0202 Modbus User Manual GC5 Sp. z o.o. Poland, Warsaw

TFmini Infrared Module Specification

MTY (81)

GPS-Aided INS Datasheet Rev. 3.0

SV613 USB Interface Wireless Module SV613

PalmGauss SC PGSC-5G. Instruction Manual

Emergency Assisting Autonomous Robot Using GPS

GPS Engine Board USB Interface

Catalog

CONDOR C1722 GPS RECEIVER MODULE technical notes

GNSS 5 click PID: MIKROE Weight: 30 g

AN Low Frequency RFID Card Reader. Application Note Abstract. Introduction. Working Principle of LF RFID Reader

Transcription:

Multi-Sensor Integration and Fusion using PSoC M.S. FINAL PROJECT REPORT Submitted by Student Name Master of Science in Electrical and Computer Engineering The Ohio State University, Columbus Under the Guidance of Dr. Lisa Fiorentini Assistant Professor, Clinical Department of Electrical and Computer Engineering The Ohio State University, Columbus i

TABLE OF CONTENTS ABSTRACT... 1 INTRODUCTION... 2 PROGRAMMABLE SYSTEM-ON-CHIP (PSoC)... 2 MULTI-SENSOR SYSTEM ARCHITECTURE... 5 ENCODERS... 7 TEMPERATURE SENSOR... 8 ACCELEROMETER... 10 MAGNETOMETER... 11 GPS... 13 REAL TIME CLOCK (RTC)... 14 DATA LOGGING IN F-RAM... 15 COMMUNICATION WITH RASPBERRY PI... 17 LIDAR... 21 REFERENCES... 23 ii

LIST OF TABLES Table 1: List of Hardware Components Used... 5 Table 2: Encoder Color Code Description... 6 Table 3: PSoC 4200M Pin Connections... 6 Table 4: Sensor Characters, Table 5: Special Characters... 18 LIST OF FIGURES Figure 1: High Level Block Diagram of PSoC 4200M... 3 Figure 2: CY8CKIT-044 PSoC 4 M-Series Pioneer Kit... 3 Figure 3: TopDesign Schematics of PSoC Creator Project... 4 Figure 4: Design Wide Resources of PSoC Creator Project... 5 Figure 5: A and B Channel Encoder Output Waveforms... 7 Figure 6: Quadrature Decoder Component Configuration... 7 Figure 7: TMP102 Internal Register Structure... 8 Figure 8: I2C Component Configuration... 9 Figure 9: I2C Timing Diagram to Read data from TMP102... 9 Figure 10: I2C Timing Diagram for ADXL345... 10 Figure 11: Internal Schematic diagram of HMC5883L... 12 Figure 12: Raw NMEA Sentences transmitted by the GPS... 14 Figure 13: RTC Component Configuration... 15 Figure 14: Timing Diagram to write data into F-RAM... 15 Figure 15: Timing Diagram to read data from F-RAM... 16 Figure 16: Bridge Control Panel to read data from F-RAM... 16 Figure 17: UART Component Configuration... 17 Figure 18: Example communication packets between Raspberry Pi and PSoC... 19 Figure 19: PSoC Firmware Flowchart for communication and unparsing... 20 Figure 20: LIDAR Lite Block Diagram... 21 Figure 21: PSoC 4 I2C Component Configuration for LIDAR... 22 iii

ABSTRACT Multi-Sensor Integration and Fusion subsystem is a part of the multidisciplinary research project Unmanned Ground Vehicle (UGV) and Aerial (UAV) Vehicle Swarms. In order for autonomous navigation, path planning and target identification of the autonomous vehicles, various sensors measurements are required. A PSoC 4 (Programmable System-on-Chip) from Cypress Semiconductors was used to interface various sensors. The PSoC 4 is based on ARM Cortex M0 architecture along with the integration of programmable analog and digital blocks. The PSoC 4 acts as a coprocessor collecting all the sensor data in real time and communicating it to Raspberry Pi which performs high level controls based on the sensor measurements. The sensor data is also logged in an external memory, a 256 K byte F-RAM available on the PSoC 4 Development Kit. A specific communication scheme was also developed on top of UART protocol between the PSoC 4 and Raspberry Pi to transfer specific sensor readings requested by Raspberry Pi. Multiple sensors like Motor Encoders, IMU, GPS, Temperature Sensor and LIDAR were successfully interfaced with PSoC 4. The Motor Encoders consists of hall effect sensors which produces a pulse every time the motor rotates, the counters in PSoC 4 are used to count these pulses to determine the rpm of the motor and hence the wheel. The IMU consists of a combination of Accelerometer and Magnetometer to measure the linear acceleration and orientation of the robot with respect to the Earth s Magnetic field essentially a compass pointing towards the north direction. The temperature sensor is used to measure the ambient temperature. GPS gives the position of the robot in terms of longitude and latitude. In addition to the position, the speed of the robot can also be measured and the UTC time from the GPS is used to lock the RTC time of PSoC 4 for the time stamp of the sensor readings. LIDAR is used to detect obstacles in front of the robot. 1

INTRODUCTION Multi-Sensor integration refers to the process of using of multiple sensors to obtain more accurate and reliable information regarding the system and its environment. Multi-Sensor fusion refers to the process of combining the information from various sensors and representing it in a common format understandable to the main processor which will take decisions based on the sensor data. The acquisition of sensor data must be done in real-time in order to make the decisions at the right time. The time at which the each sensor data is acquired must also be included in the data format to be sent to the main processor. In addition to sending the sensor data to the main processor, it must also be logged in an external memory. In this project, the main processor is a Raspberry Pi 2 and a PSoC 4200M performs the multisensor integration and fusion in real-time and sends the fused sensor data to Raspberry Pi. The sensors currently integrated with the PSoC 4200M are, 1. Motor Encoders 2. Temperature Sensor 3. Accelerometer 4. Magnetometer 5. GPS 6. LIDAR PROGRAMMABLE SYSTEM-ON-CHIP (PSoC) The PSoC 4200M device from Cypress Semiconductors is a mixed signal system on chip based on 32-bit Arm Cortex M0 architecture with programmable analog and digital blocks as depicted in the high level block diagram in Figure 1. Multiple sensors, both analog as well as digital sensors can be interfaced with PSoC 4200M to acquire sensor data in real-time. The programmable analog and digital blocks operate independently along with the CPU of the PSoC [1]. This enables acquisition of data from multiple sensors, formatting of sensor data and communication with the main processor in parallel. The PSoC 4200M device also contains a Real Time Clock (RTC) which is used to time stamp the sensor data. 2

PSoC 4200M Sensor Inputs Programmable Digital Blocks ARM Cortex M0 Sensor Data to Raspberry Pi Programmable Analog Blocks RTC Figure 1: High Level Block Diagram of PSoC 4200M CY8CKIT-044 PSoC 4 M-Series Pioneer Kit shown in Figure 2 features a PSoC 4200M device which is used in this project to interface with the various sensors and the Raspberry Pi. This development kit also contains an on-board programmer and debugger and therefore no additional hardware is required to program and debug the PSoC 4200M device [2]. Figure 2: CY8CKIT-044 PSoC 4 M-Series Pioneer Kit 3

The firmware for the PSoC 4200M device was developed using the PSoC Creator IDE (Version 3.2 SP1). The PSoC Creator contain PSoC components which are virtual ICs which users can drag and drop into a design and configure them to meet the application requirements. Every PSoC component comes with its own set of API libraries [3]. PSoC Creator is free to use and can be downloaded from the following link, www.cypress.com/psoccreator. Figure 3 shows the top design schematics of the PSoC Creator developed for Multi-Sensor Integration and Fusion project. Figure 3: TopDesign Schematics of PSoC Creator Project Figure 4 shows the design wide resources of the PSoC Creator developed for Multi-Sensor Integration and Fusion project. 4

Figure 4: Design Wide Resources of PSoC Creator Project MULTI-SENSOR SYSTEM ARCHITECTURE The Multi-Sensor system architecture with the interconnections between the multiple sensors and PSoC 4200M development kit is shown in figure 5. The Temperature sensor and the Accelerometer both use I2C interface and are connected in the same I2C bus with the PSoC 4200M. The PSoC 4200M identifies the respective sensor with its unique I2C address. Table 1 lists all the hardware components used in the Multi-Sensor system architecture along with their web links. The TMP102, ADXL345 and HMC5883L sensor breakout boards from SparkFun are used in this project. Table 1: List of Hardware Components Used Component Description Web link CY8CKIT-044 PSoC 4200M Development Kit www.cypress.com/cy8ckit-044 Raspberry Pi 2 Main Processor www.raspberrypi.org Encoders 48 CPR Quadrature Encoder www.pololu.com/product/2275 TMP102 Digital Temperature Sensor www.sparkfun.com/products/11931 ADXL345 3-Axis Accelerometer www.sparkfun.com/products/9836 HMC5883L 3-Axis Magnetometer www.sparkfun.com/products/10530 GPS Ultimate GPS module www.adafruit.com/products/746 LIDAR LIDAR Lite www.sparkfun.com/products/retired/13167 5

Table 2 describes the color code functionality of connecting wires in the encoder which is obtained from Pololu Robots and Electronics. Table 3 gives the pin connection details between the different components and PSoC 4200M in the Multi-Sensor system architecture. Table 2: Encoder Color Code Description Color Red Black Green Function Motor power (connects to one motor terminal) Motor power (connects to the other motor terminal) Encoder GND Blue Encoder VCC (3.5 20 V) Yellow White Encoder A Output Encoder B Output Table 3: PSoC 4200M Pin Connections Component Pin PSoC 4200M Pin Encoder 1 Encoder 2 Temperature Sensor Accelerometer Magnetometer GPS LIDAR Raspberry Pi 2 Encoder A Output P2.0 Encoder B Output P2.1 Encoder A Output P2.2 Encoder B Output P2.3 SDA P4.1 SCL P4.0 SDA P4.1 SCL P4.0 SDA P4.1 SCL P4.0 UART TX UART RX P1.1 (UART RX) P1.0 (UART TX) SDA P6.1 SCL P6.0 GPIO 14 (UART TX) GPIO 15 (UART RX) P3.0 (UART RX) P3.1 (UART TX) 6

ENCODERS An encoder is an electromechanical device used to measure the position and speed of a motor shaft. The motors used in the robot contain a two-channel Hall-effect sensor encoder which outputs square waves corresponding to the rpm (rotations per minute) of the motor shaft [5]. The outputs of the two channels are 90 degrees out of phase which refers to a quadrature encoder as shown in Figure 5. Figure 5: A and B Channel Encoder Output Waveforms PSoC Creator offers a quadrature decoder component as shown in Figure 6 which is used to acquire data from the two channel encoders. The encoding mode in the component is set to 4x which offers highest resolution by counting both the rising and falling edges of both the square waves to provide the count value output [4a]. Figure 6: Quadrature Decoder Component Configuration 7

The Counter_X_ReadCounter() API is used to read the current counter value from the quadrature encoder. The difference between the encoder values is computed by reading the encoder values at two different times with a given time interval which is then formatted and sent to the Raspberry Pi. TEMPERATURE SENSOR The temperature sensor used in this project is TMP102, which is a digital temperature sensor with I2C interface. The TMP102 has a resolution of 0.0625 C, and accuracy of 0.5 C over the temperature range of -25 C to +85 C [6]. Figure 7 shows the internal register configuration of the temperature sensor. To read the current temperature from the sensor, the pointer register must first be initialized to point to the address of the temperature register. After pointing to the temperature register, data can be read from the temperature register. Two bytes of data must be read from the temperature register which corresponds to the MSB and LSB of the temperature reading. Figure 7: TMP102 Internal Register Structure The PSoC 4200M communicates with the TMP102 sensor via I2C interface. The PSoC 4200M is configured as an I2C master with 100 Kbps data rate as shown in Figure 8. To communicate with the slave I2C sensor, the master should know the I2C address of the slave. For TMP102 sensor, the 7-bit I2C address is 0x48 which is provided in the datasheet of the sensor. The I2C timing diagram to read data from TMP102 is shown in Figure 9. 8

Figure 8: I2C Component Configuration Figure 9: I2C Timing Diagram to Read data from TMP102 9

Following is the sequence of steps followed in the firmware to get the temperature reading: 1. Initialize the 8-bit pointer register to 00 to point to the temperature register using the API, I2C_I2CMasterWriteBuf 2. Read two bytes of data from temperature register using the API, I2C_I2CMasterReadBuf [4b] 3. Combine the MSB and LSB of the temperature reading 4. Shift left the combined data by 4 bits and multiply by 0.0625 to get the current temperature 5. Compute the difference between two temperature readings in a given time interval which is then formatted and sent to the Raspberry Pi ACCELEROMETER The accelerometer used in this project is ADXL345, which is a 3-axis MEMS accelerometer with 13-bit resolution and measurement at up to +/-16 g. Digital output data is formatted as 16-bit twos complement and is accessible through either a SPI (3- or 4-wire) or I2C digital interface. The ADXL345 automatically modulates its power consumption in proportion to its output data rate which can be configured. Registers 0x32 to 0x37 inside the ADXL345 holds the output data for each axis. Two 8-bit registers hold the data for one axis. Register 0x32 and Register 0x33 hold the output data for the x-axis, Register 0x34 and Register 0x35 hold the output data for the y-axis, and Register 0x36 and Register 0x37 hold the output data for the z-axis [7]. The PSoC 4200M communicates with the ADXL345 sensor via I2C interface. The accelerometer is connected to the same I2C bus as the temperature sensor. For ADXL345 sensor, the 7-bit I2C address is 0x53 which is provided in the datasheet of the sensor. The I2C timing diagram for ADXL345 is shown in Figure 10. Figure 10: I2C Timing Diagram for ADXL345 Following is the sequence of steps followed in the firmware to get the accelerometer reading: 1. Initialize the accelerometer by first going into standby mode 10

2. Configure the accelerometer in full resolution, 100 Hz data rate, stream mode and measurement mode 3. Read data from two registers corresponding to each axis 4. Combine the data from the two registers for each axis to get the current reading for the respective axis 5. Compute the difference between two accelerometer readings in a given time interval which is then formatted and sent to the Raspberry Pi MAGNETOMETER The magnetometer used in this project is HMC5883L, which is a 3-axis magnetometer from Honeywell. The HMC5883L contains a high-resolution HMC118X series magneto-resistive sensors plus an integrated application specific processor for amplification, automatic degaussing strap drivers, offset cancellation, and a 12-bit ADC that enables 1 to 2 compass heading accuracy. Digital output data is formatted as 16-bit twos complement and is accessible through e I2C digital interface. Registers 0x03 to 0x08 inside the HMC5883L holds the output data for each axis. Two 8-bit registers hold the data for one axis. Register 0x03 and Register 0x04 hold the output data for the x-axis, Register 0x07 and Register 0x08 hold the output data for the y-axis, and Register 0x05 and Register 0x06 hold the output data for the z-axis. The PSoC 4200M communicates with the HMC5883L sensor via I2C interface. The magnetometer is connected to the same I2C bus as the temperature sensor and the accelerometer. For HMC5883L sensor, the 7-bit I2C address is 0x1E which is provided in the datasheet of the sensor [8]. Figure 11 shows the internal schematics of the HMC5883L magnetometer sensor along with the example connection with the I2C Master which in this case is a PSoC 4200M. 11

Figure 11: Internal Schematic diagram of HMC5883L Following is the sequence of steps followed in the firmware to get the magnetometer reading: 1. Initialize the magnetometer by first going into standby mode 2. Configure the magnetometer in full resolution, 100 Hz data rate and continuous measurement mode 3. Read data from two registers corresponding to each axis 4. Combine the data from the two registers for each axis to get the current reading for the respective axis 5. Compute the difference between two magnetometer readings in a given time interval which is then formatted and sent to the Raspberry Pi The magnetometer readings are not tilt compensated, however since the accelerometer reading is also available to the main processor which is a Raspberry Pi, it can perform tilt compensation using both the magnetometer and accelerometer reading to perform tilt compensation and calculate the true reading when the magnetometer is not lying flat which is usually the case in off terrain environment. 12

GPS The GPS module used in the project is the Ultimate GPS module from Adafruit which is a breakout board with the MTK3339 chipset, which is a high-quality GPS module that can track up to 22 satellites on 66 channels, has an excellent high-sensitivity receiver (-165 db), and a built in antenna. The GPS module also has built in data logging ability and can be powered using a CR1220 coin cell to keep the RTC running. The GPS module also contains an LED which blinks at about 1Hz while it's searching for satellites and blinks once every 15 seconds when a fix is found to conserve power [9]. The GPS module transmits the received messaged through UART interface. The default baud rate of the GPS module is 9600 bps. GPS modules start transmitting data as soon as they are powered on and try to get a 'fix' (location verification). The data transmitted by them is the raw GPS "NMEA sentence" output which contains multiple different kinds of NMEA sentences [10]. The two NMEA sentences used in this project are the $GPRMC (Global Positioning Recommended Minimum Coordinates) and the $GPGGA sentences. These two provide the time, date, latitude, longitude, altitude, estimated land speed, and fix type. Fix type indicates whether the GPS has locked onto the satellite data and received enough data to determine the location (2D fix) or location + altitude (3D fix). The PSoC 4200M communicates with the GPS module via UART interface which is configured at 9600 baud rate [4c]. The PSoC firmware contains a function called GetGPSMessage() which extracts the required information such as longitude, latitude, altitude, speed an UTC time. The UTC time can also be used to initialize the RTC of PSoC 4200M since RTC resets the time every time power is turned off to the PSoC. Figure 12 shows an example of the raw GPS NMEA sentences transmitted by the GPS module. 13

Figure 12: Raw NMEA Sentences transmitted by the GPS Following is the sequence of steps followed in the firmware to get the GPS readings: 1. Start the UART component which is configured at 9600 baud rate 2. Store the raw NMEA sentences in a buffer using UART_G_GetChar() API until one complete set of NMEA sentences are received 3. Check whether a fix is obtained from the received NMEA sentences 4. If a fix is obtained, call the GetGPSMessage() function 5. The GetGPSMessage() function first extracts the $GPRMC and the $GPGGA sentences from the raw NMEA sentences 6. The GetGPSMessage() function then extracts the longitude, latitude, altitude, speed and UTC time from $GPRMC and $GPGGA sentences REAL TIME CLOCK (RTC) The data acquired from all the sensors is formatted into a common format along with a time stamp at which the sensor data was acquired. The RTC component in PSoC Creator as shown in Figure 13 is used obtain the current time. The RTC_GetHours, RTC_GetMinutes, RTC_GetSecond APIs are used to get the hours, minutes and seconds respectively from the time value passed from the RTC_GetTime() API [4d]. The time in hours: minutes: seconds is then added to the sensor data which is then sent to the Raspberry Pi. 14

Figure 13: RTC Component Configuration DATA LOGGING IN F-RAM The CY8CKIT-044 also provides onboard memory storage via Cypress s non-volatile F-RAM device of 1 Mb capacity [11]. The F-RAM is connected to the I2C interface of the PSoC 4200M device with a 7-bit I2C address of 0x50. It is used for data logging in this project. The combined sensor data from all the sensors along with the timestamp is stored in the F-RAM. Figures 14 and 15 show the timing diagram for write and read operations using F-RAM. Figure 14: Timing Diagram to write data into F-RAM 15

Figure 15: Timing Diagram to read data from F-RAM The data stored in the F-RAM can later be read using the Bridge Control Panel software available along with the installation of PSoC Creator [2]. Connect the Kit to PC using USB cable and in the Bridge Control Panel, select KitProg and once it connects read data from the F-RAM using the command, w 50 00 00 r 50 x x x x x x x x x x x x x x x p as shown in Figure 16. The above command reads 15 bytes of data starting from the memory location with address 00. To read data from a different memory location, specify the two byte address after w 50 followed by the rest of the command. Figure 16: Bridge Control Panel to read data from F-RAM 16

COMMUNICATION WITH RASPBERRY PI The PSoC 4200M communicates with the Raspberry Pi via UART interface. The UART component in PSoC 4200M is configured at 115200 baud rate as shown in Figure 17. Customized handshake control is implemented while communicating with the Raspberry Pi. Figure 17: UART Component Configuration All the sensor data and timestamp information are in hexadecimal representation which are converted to ASCII characters using sprintf function to send the data over UART. Note that the acquisition of sensor data, formatting and data logging continues irrespective of the handshake control status i.e., the PSoC 4200M will not be idle until it receives a start from the Raspberry Pi. It will continue to perform other functions in parallel. Once the Raspberry Pi receives the sensor data, it decodes the data format and makes decisions based on the individual sensor data. 17

The following tables give the characters chosen for different sensors and also for additional details like timestamp and sensor data logged for a given time duration, Table 4: Sensor Characters # Sensor Sensor Reading Character Example data 1 Encoders Left Encoder EL 2489 Right Encoder ER -1672 2 Accelerometer X-Axis AX 212 Y-Axis AY -163 Z-Axis AZ 12 3 Magnetometer X-Axis MX 253 Y-Axis MY 26 Z-Axis MZ -45 4 GPS Latitude GX 4000.175N Longitude GY 08234.134W Altitude GZ 545.4 Speed GS 022.4 Time GT 12:35:19 5 Temperature Sensor Temperature TE 23.24 6 Time Stamp - TS 00:01:30 Table 5: Special Characters # Additional Readings Character 1 Timestamp TS 2 All Sensors AL 3 Previous Sensor Data PR XX 05* 4 End Character!! * XX Respective Sensor Character followed by the time duration in seconds 18

Example: Raspberry Pi sends the command ELERGXGY!! to request the Encoder and GPS data from the PSoC and the PSoC responds with the respective sensor data along with timestamp as shown in Figure 18. EL ER GX GY!! Raspberry Pi EL 1234 ER 1234 GX 4000.175N GY 08234.134W TS 00:01:30!! PSoC Figure 18: Example communication packets between Raspberry Pi and PSoC UART Settings for communication between Raspberry Pi and PSoC: Baud rate: 115200 bps (bits per second) Data bits: 8 bits Parity: None Stop bits: 1 Following is the representation of each of the sensor reading: Encoder Data: ± Number of ticks in 100ms (example: 2489, -1672) Accelerometer (units in G-forces (g)) and Magnetometer (units in micro Tesla): ±Reading for each axis (example: 212, -163) GPS Example Readings Latitude: 4000.175N (Latitude 40 degrees 00.175 minutes North) Longitude: 08234.134W (Longitude 082 degrees 34.134 minutes East) Altitude: 545.4 (Meters, above mean sea level) Speed: 022.4 (Speed over the ground in knots) Time: 12:35:19 (UTC time) Temperature: ± reading in degree Celsius (example: 23.24, -2.58) Time Stamp: Hours:Minutes:Seconds (example: 00:01:30) 19

Figure 19 shows the flowchart for the communication and unparsing firmware functions. Figure 19: PSoC Firmware Flowchart for communication and unparsing 20

LIDAR LIDAR is an optical distance measurement technology that uses laser to determine the distance from targets. LIDAR is useful because of its high accuracy over long ranges. The module used in this project is the LIDAR Lite sensor from PulsedLight [12]. It is a compact, low cost, and low power proximity sensor with a range of up to 40 meters with an accuracy of ±2.5cm. It can be interfaced with a microcontroller through either the I2C or PWM interfaces. I2C is used in this project as the internally processed distance measurements can be read directly from registers in the LIDAR lite module, and this reduces the work of the microcontroller. In principle, the LIDAR lite measures distance based on the precise measurement of the time delay between the transmission of a laser signal and its reception. The high accuracy is achieved by the digitization and averaging of two signals a reference signal emitted by the transmitter before distance measurement, and a received signal reflected from the target. The time delay between these signals is estimated through an accurate correlation algorithm. This time delay is then translated to a distance measurement based in the known speed of light. All signal processing is dine internally on the Signal Processing Core, and the measured distance values on internal registers which can be accessed through the I2C interface as shown in Figure 20. The default slave address for the LIDAR lite is 0x62. Figure 20: LIDAR Lite Block Diagram 21

Figure 21 shows the I2C PSoC Creator component configuration for interfacing with LIDAR. Figure 21: PSoC 4 I2C Component Configuration for LIDAR Following is the sequence of steps followed in the firmware to get the distance reading: 1. Write the value 0x04 to register 0x00 to initiate a DC stabilization cycle, signal acquisition and data processing. 2. Wait until an ACK is received. The unit responds with a NACK to read or write commands with a NACK when it is busy processing. 3. Initiate a 2 byte read starting at register 0x8f and store the received bytes separately. These are the upper and lower bytes of the distance in centimeters. 4. Combine the upper and lower bytes to get the measured distance. Future work: The LIDAR lite module does not include a motor that can allow the sensor to scan a wide area. Hence, it will be useful to mount the LIDAR lite on a rotating platform attached to a servo motor to enable the sensor to scan either a 180º forward view or an entire 360º view to create a 2D map of all the obstacles around the vehicle based on its current position. This data can be further utilized to perform Simultaneous Localization and Mapping. 22

REFERENCES 1. PSoC 4200M Datasheet www.cypress.com/file/139956/download 2. User Guide of CY8CKIT-044 www.cypress.com/file/157906/download 3. PSoC Creator Quick Start Guide www.cypress.com/file/195271/download 4. PSoC Creator Component Datasheets a. Quadrature Decoder b. I2C c. UART d. RTC 5. Encoder Specifications www.pololu.com/product/2275 6. TMP102 Datasheet www.sparkfun.com/datasheets/sensors/temperature/tmp102.pdf 7. ADXL345 Datasheet www.sparkfun.com/datasheets/sensors/accelerometer/adxl345.pdf 8. HMC5883L Datasheet cdn.sparkfun.com/datasheets/sensors/magneto/hmc5883l-fds.pdf 9. Adafruit Ultimate GPS learn.adafruit.com/adafruit-ultimate-gps/overview 10. GPS - NMEA sentence information aprs.gids.nl/nmea/ 11. F-RAM Datasheet www.cypress.com/file/41666/download 12. LIDAR lite v1 Operating Manual github.com/pulsedlight3d/lidar-lite-documentation/blob/master/docs/lidar-lite-v1- docs.pdf 23