LCD_Write("CSE 211 | Introduction to Embedded Systems");
LCD_Set_Cursor(1, 0);
LCD_Write("Final Project");
In this project, we used Tiva™ C Series TM4C123G LaunchPad in order to develop a GPS tracking system that is able to calculate the distance between two points1 depending on the starting point and the end point.
in the first step, our goal was only to display a sequence of ASCII characters on the LCD, with the full control of it's position.
In LCD_Functions.c we started by initializing the used pins from PORT A and PORT B
we have known that the LCD functions will be used a lot in the project, so we needed to make the code reuseable and readable. so we followed the functional programming paradigm, so our code became nothing more than a set of functions that call each other2, we can summarize as following
LCD_init calls the initializing functions, clears the LCD and sets the cursor
LCD_Cmd_init initializes the Command ports
LCD_Data_init initializes the Data ports
LCD_Write Taking an array of characters that contains the word to be displayed in the LCD
LCD_Set_Cursor taking the row and the column, and sets the cursor in the selected position
LCD_Clear_Block clears a certain block
LCD_Clear_Blocks clears a group of blocks
LCD_Clear Clears the LCD
LCD_Home sets the cursor to the beginning
LCD_Move_Right Moves the cursor right
LCD_Move_Left Moves the cursor left
LCD_Cursor_On leaves the cursor bar on
LCD_Cursor_Off turns off the cursor bar
LCD_8Bit makes the LCD mode 8 bits
LCD_Cursor_Blink turns on LCD blinking after typing
LCD_Shift_Right shifts current displayed characters right
LCD_Shift_Left shifts current displayed characters left
Instead of using meaningless delay such as looping in an empty loop, we have used the systick timer, giving us the choice from choosing between 3 modes in counting us for microseconds, ms for milliseconds, and sec for seconds, and of course the number of counts in the selected mode.
we have chosen to use the UART protocol in order to take the GPS data, so our work has divided into two major parts:
in this process we created to functions
void UART1_Init which initializes the UART and the pins to be used in PORT C
UART1_receiver This is the core function of the program, in this function we start receiving the data from the GPS module, and starting passing it as a parameters to different functions.
we also write in the LCD in this function3, to synchronize between the receiving process and the displaying process.
The main Parsing process was implemented in GPRMC_Data_Parser function in which we searched until we find the GPRMC Data and start storing it after checking its availability
we have also created two functions String_To_Float and StrDeg_To_FloatDec which converts the received data into a float, and from degree into decimal respectively.
in this function 4, we take the starting point and the end point, calculating the distance between them and returning it's value to the UART1_receiver function.
after calculation and returning the value into the UART1_receiver, we tried the system many times, and the margin of error was comparably high, so we suggested that multiplying the result with a correction factor will solve this problem. The correction factor was calculated after many tries, so the error was quite predictable.
1 The calculated distance is not completely correct due to inaccuracy in the GPS module itself, we've tried our code with real coordinates, our LCD has shown 259.5m while google maps has shown 260m. ↩
2 The implementation of many functions is nothing more than just calling another functions. ↩
3 In terms of design, we'd better to implement this in a separate function, and call this function from the UART1_receiver function. ↩
4 We have no idea about how to calculate the distance between two points given their coordinates which is known as Haversine Formula, we heavily depended on this Stack Overflow answer↩