5/6/2023 0 Comments Work clock out pic![]() With small changes in the code, you can use this on a different PIC. In this article, I've shown you one way to get the time and date from a GPS module using a PIC microcontroller. Jc_pic16f628a-gpsclock-v2.c.zip Conclusion You can download the c-source code below. The time displayed is often called GPS ZULU time. When the program is near the end of the main while-loop, it displays the time and date on the LCD. In this example it reads time, date, latitude and longitude, but only time and date are displayed on the LCD. Now follows a lot of for-loops, to read and place the right values in the right places. If it is equal, then I know two things: one, I have a sentence and two, I have the right sentence. This array is then compared to a predefined array. Then it reads the next six bytes and puts them in an array. If it is a dollar sign, I know now that I'm at the beginning of an NMEA sentence, but I don't know which one. The variable is compared to see if it's the dollar sign, $. In the main while-loop, each byte received on RX is placed in a variable. Then it initialize the LCD port and the uart port. The main program starts off with some instructions: turning off comparators, setting the right directions to the ports, and set all port s to low. After that comes the uart functions and two functions to display a message when the received time and date is not valid. To get the LCD display to work properly, you'll have to follow a certain recipe. Then I have the functions to drive the LCD display. The software is commented, but I'll walk through it in general here.įirst are the includes libraries, configuration bits, variable declaration, and prototyping of the functions. The following is an edited list from the BOM ulp in EagleCAD. This is not the case here since the circuit is breadboarded. It is good practice to ground unused pins like this, however unused pins on a PIC mounted on a PCB I like to route to a pad for easy access if I'm adding some more features to the project. This happens to be PGC and PGD, the programming pins. I'm not going to read from the LCD, so I ground the RW pin. D6 and D7 are connected to the PICs pins 12 and 13. The following schematic is built on a breadboard. The software will search for the right one and use the information from that. The GPRMC sentence and others are sent each second. To read out the time, I'm going to use the GPRMC sentence. This sentence looks like this: The baud rate is 9600, so I have to configure the uart port to match this. In this article I'm using a different GPS module than I did in the previous articles. For a brief introduction to GPS and navigation, read the article in the first link. In the previous articles Make a GPS Clock With Arduino and Make a GPS Clock With PICAXE, I've made GPS clocks with both an Arduino and a PICAXE. Breadboard and jumperwires, LCD and a 5K pot.A GPS module, that sends NMEA sentences.PICKIT 3.5 or equivalent PIC programmer.Computer with MPLAB X, and the XC8 compiler.Use a PIC microcontroller to get time and date from a GPS module.
0 Comments
Leave a Reply. |