Menu
After interfacing the PIC16F887 microcontroller with NEO-6M GPS module, now I’m going to show how to build a GPS clock with local time where time and date are displayed on 20×4 LCD screen.
In this project the microcontroller receives time and date data from the GPS module (the GPS module receives data from satellites) and print it on the 20×4 LCD. The compiler used in this project is mikroElektronika mikroC PRO for PIC. — GPS: Global Positioning System --
In this project the microcontroller receives time and date data from the GPS module (the GPS module receives data from satellites) and print it on the 20×4 LCD. The compiler used in this project is mikroElektronika mikroC PRO for PIC. — GPS: Global Positioning System --
Related Projects:
Last PIC16F887 project, I made a simple interfacing of this microcontroller with NEO-6M GPS module in order to get position, altitude, time (UTC), date, speed, number of satellites and course, project page link is below. — UTC: Universal Time Coordinated --
Interfacing PIC microcontroller with GPS module | mikroC Projects
Last PIC16F887 project, I made a simple interfacing of this microcontroller with NEO-6M GPS module in order to get position, altitude, time (UTC), date, speed, number of satellites and course, project page link is below. — UTC: Universal Time Coordinated --
Interfacing PIC microcontroller with GPS module | mikroC Projects
MikroC PRO for AVR is an ANSI C compiler for Atmel AVR microcontrollers. You get features such as LCD Custom Character Tool, GLCD Bitmap Editor, Seven Segment Editor, UART Terminal, UDP Terminal, and HID Terminal, which improve the speed of program development. Mikroc pro,free download mikroc, PIC Microcontroller Programming Tutorial for Beginners with step by step picture. Here each tutorial and every task described as good as possible.
MikroC PRO for PIC + crack. 6/10/2017 14 Comments mikroC PRO for PIC is a full-featured ANSI C compiler for PIC devices from Microchip®. It is the best solution for developing code for PIC devices. It features intuitive IDE, powerful compiler with advanced optimizations, lots of hardware and software libraries, and additional tools that will. MikroC PRO for PIC 7.2.0 can be downloaded from our website for free. The program lies within Development Tools, more precisely IDE. The mikroC PRO for PIC installer is commonly called mikroC PRO PIC.exe, mikroC Pro PIC32.exe or mikroC.exe etc. This program is a product of MikroElektronika. Our antivirus check shows that this download is safe. 8b9facfde6 Mikroc tutorial for beginners pic pdf - wizard-like tool Additional menus allow viewing of individual stories, themselves. Mikroc tutorial for beginners pic pdf you. Mikroc pro for pic.pdf - mikroC PRO for. Creating First Project in mikroC for PIC In this simple tutorial,. Download our mikroc pic programming eBooks for free.
Hardware Required:
To build this project, the following components are required.
To build this project, the following components are required.
- PIC16F887 microcontroller
- NEO-6M GPS module
- 20×4 LCD screen
- 10k ohm variable resistor (or potentiometer)
- 330 ohm resistor
- 5V source
- Breadboard
- Jumper wires
Mikroc Pro For Pic Library
GPS Clock using PIC16F887 and NEO-6M module circuit:
The following image shows the circuit schematic of the project.
The following image shows the circuit schematic of the project.
(All grounded terminal are connected together)
The NEO-6M GPS module board has 4 pins connected as follows:
GND (Ground) pin connected to circuit GND
TX pin goes to PIC16F887 RX (RC7) pin (pin #26)
RX pin is not connected (there is no need to send data from the microcontroller to the GPS module)
VCC pin goes to circuit +5V pin.
GND (Ground) pin connected to circuit GND
TX pin goes to PIC16F887 RX (RC7) pin (pin #26)
RX pin is not connected (there is no need to send data from the microcontroller to the GPS module)
VCC pin goes to circuit +5V pin.
The 20×4 LCD screen is used to display the real time clock time and date where:
RS —> RD0 pin
E —> RD1 pin
D4 —> RD2 pin
D5 —> RD3 pin
D6 —> RD4 pin
D7 —> RD5 pin
VSS, RW, D0, D1, D2, D3 and K are connected to circuit GND (ground)
VEE to the variable resistor (or potentiometer) output pin
VDD to +5V and A to +5V through 330 ohm resistor
RS —> RD0 pin
E —> RD1 pin
D4 —> RD2 pin
D5 —> RD3 pin
D6 —> RD4 pin
D7 —> RD5 pin
VSS, RW, D0, D1, D2, D3 and K are connected to circuit GND (ground)
VEE to the variable resistor (or potentiometer) output pin
VDD to +5V and A to +5V through 330 ohm resistor
VEE pin is used to control the contrast of the LCD. A (anode) and K (cathode) are the back light LED pins.
In this project the PIC16F887 microcontroller runs with its internal oscillator @ 8 MHz, MCLR pin is configured as an input pin.
GPS Clock using PIC16F887 and NEO-6M module C code:
The following C code is for mikroC PRO for PIC compiler.
The following C code is for mikroC PRO for PIC compiler.
In this project I used a small GPS library for mikroC compiler, this library decodes NMEA sentence that the microcontroller receive from the GPS module, therefore getting time and date is more easier.
GPS Library for CCS C compiler downloaded link is the one below, library full name is “GPS_mikroc.c“:
mikroC GPS Library download
GPS Library for CCS C compiler downloaded link is the one below, library full name is “GPS_mikroc.c“:
mikroC GPS Library download
after the download, add the library file (GPS_mikroc.c) to project folder.
As known, the GPS module always gives UTC time and date which may need to be converted to our time zone (for example UTC + 1). To do the conversion of time we can use mikroC PRO for PIC time library (built-in library). But we’ve to add the library header to the project folder, the library header named timelib.h, it is located in examples folder of mikroC installation folder (for example, C:Program Files (x86)MikroElektronikamikroC PRO for PICExamplesOtherTime).
Or you can download it from the following link:
timelib.h
Or you can download it from the following link:
timelib.h
To be able to convert the UTC standard time into our time zone (local time), first we’ve to convert the UTC time into UNIX time (also known UNIX Epoch time or POSIX time ) which is the number of seconds that have elapsed since 00:00:00 UTC, 1 January 1970.
After we get the UNIX Epoch time we add our time offset to it (plus or minus), for example for UTC + 1 time zone we add 3600 seconds, for UTC – 5 we add -18000 seconds and so on.
After that we converter the ‘new’ UNIX time into our zone time and date.
Functions used in the code:
Brink pc download. UART1_Data_Ready(): returns 1 if a character has been received by the MCU.
Brink pc download. UART1_Data_Ready(): returns 1 if a character has been received by the MCU.
GPS library functions:
GPSRead(): returns 1 if the GPS data (NMEA sentences) have been received and parsed with successful.
GPSHour(): returns hours from the decoded GPS data (0 – 23)
GPSMinute(): returns minutes (0 – 59)
GPSSecond(): returns seconds (0 – 59)
GPSDay(): returns day of month (1 – 31)
GPSMonth(): returns month (1 – 12)
GPSYear(): returns year with 2 digits (0 – 99)
GPSRead(): returns 1 if the GPS data (NMEA sentences) have been received and parsed with successful.
GPSHour(): returns hours from the decoded GPS data (0 – 23)
GPSMinute(): returns minutes (0 – 59)
GPSSecond(): returns seconds (0 – 59)
GPSDay(): returns day of month (1 – 31)
GPSMonth(): returns month (1 – 12)
GPSYear(): returns year with 2 digits (0 – 99)
mikroC Time library functions:
First we need to save the UTC time and date (in order to convert it to UNIX time) to a variable of type TimeStruct (structure type), I named this variable: utc_time. This variable is a collection of 7 variables, 6 of them are required (the 7th variable is utc_time.wd which is day of the week, not needed here):
utc_time.hh, utc_time.mn, utc_time.ss, utc_time.md, utc_time.mo and utc_time.yy .
utc_time.mn has to be between 1 and 12. utc_time.yy is 4-digit year (2018, 2019, 2020 …).
First we need to save the UTC time and date (in order to convert it to UNIX time) to a variable of type TimeStruct (structure type), I named this variable: utc_time. This variable is a collection of 7 variables, 6 of them are required (the 7th variable is utc_time.wd which is day of the week, not needed here):
utc_time.hh, utc_time.mn, utc_time.ss, utc_time.md, utc_time.mo and utc_time.yy .
utc_time.mn has to be between 1 and 12. utc_time.yy is 4-digit year (2018, 2019, 2020 …).
Now we can convert the UTC time to UNIX time with the following function where the converted UNIX time is saved to unix_time variable of type long (4 byte signed number):
unix_time = Time_dateToEpoch(&utc_time) ;
unix_time = Time_dateToEpoch(&utc_time) ;
Returning from the UNIX time to our zone time and date is also simple, here an other variable of type TimeStruct is used, I used a variable named: my_time. This variable is also a collection of 7 variables:
my_time.hh, my_time.mn, my_time.ss, my_time.md, my_time.mo, my_time.yy and my_time.wd.
The last variable is day of the week between 0 and 6 (0 for Monday).
my_time.md is day of month (1-31)
my_time.mo is the month (1-12)
my_time.hh, my_time.mn, my_time.ss, my_time.md, my_time.mo, my_time.yy and my_time.wd.
The last variable is day of the week between 0 and 6 (0 for Monday).
my_time.md is day of month (1-31)
my_time.mo is the month (1-12)
Webroot AntiVirus is the smarter cybersecurity way to combat today's threats. Webroot secureanywhere key code free.
Our zone time and date are stored to the variable my_time using the function:
Time_epochToDate(unix_time, &my_time) ;
Time_epochToDate(unix_time, &my_time) ;
2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 122 124 126 128 130 132 | /************************************************************************************** GPS Clock with local time using PIC16F887 microcontroller and NEO-6M GPS module Internal oscillator used @ 8MHz CONFIG2 = 0x0700 http://simple-circuit.com/ ***************************************************************************************/ // LCD module connections sbit LCD_EN at RD1_bit; sbit LCD_D5 at RD3_bit; sbit LCD_D7 at RD5_bit; sbit LCD_EN_Direction at TRISD1_bit; sbit LCD_D5_Direction at TRISD3_bit; sbit LCD_D7_Direction at TRISD5_bit; #define time_offset 3600 // define a clock offset of 3600 seconds (1 hour) > UTC + 1 // include GPS mikroC library // include mikroC time library // mikroC time library variables TimeStruct utc_time,my_time; // other variables { chari; returntext_; { { case0:lcd_out(2,6,codetxt_to_ramtxt(' MONDAY '));break; case1:lcd_out(2,6,codetxt_to_ramtxt(' TUESDAY '));break; case2:lcd_out(2,6,codetxt_to_ramtxt('WEDNESDAY'));break; case3:lcd_out(2,6,codetxt_to_ramtxt('THURSDAY '));break; case4:lcd_out(2,6,codetxt_to_ramtxt(' FRIDAY '));break; case5:lcd_out(2,6,codetxt_to_ramtxt('SATURDAY '));break; default:lcd_out(2,6,codetxt_to_ramtxt(' SUNDAY ')); voidbyte_to_str(unsignedshortnub,char*str) str[0]=nub/10+'0'; str[2]='0'; voidmain() OSCCON=0X70;// set internal oscillator to 8MHz Lcd_Cmd(_LCD_CURSOR_OFF);// cursor off lcd_out(1,2,codetxt_to_ramtxt('GPS CLOCK (UTC+1)')); lcd_out(4,3,codetxt_to_ramtxt('DATE: - -20')); UART1_Init(9600); while(1) if(UART1_Data_Ready()1) { // read UTC time and date and save them to utc_time structure utc_time.mn=GPSMinute();// minutes 0-59 utc_time.mo=GPSMonth();// month 1-12 utc_time.yy=GPSYear()+2000;// four digits year (2018, 2019 ..) // get unix time unix_time+=time_offset; // get the local time print_wday(my_time.wd); byte_to_str(my_time.hh,txt); byte_to_str(my_time.mn,txt); byte_to_str(my_time.ss,txt); // print date lcd_out(4,9,txt); lcd_out(4,12,txt); lcd_out(4,17,txt); } } } |
The result of this project should be as shown in the following video where PIC16F877A is used: