Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] SD card implementation in GPS device with mikroc

Gerelectronic

Newbie
Joined
May 14, 2021
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
12
Hello everybody.
I am working on my personal electronics project.
I want to create a program that is able to communicate the pic18f452 with an LCD display, an SD card and a GPS module.

I would like the program to succeed in the following operations:
- 1) Read the information from the GPS via Uart and send it to the LCD display.
- 2) When it has sent the first string coming from the GPS module to the LCD display, the pic sends this information to the SD card so that if it is connected to a computer, the data coming from the GPS in text format (FAT 16) can be read .
- 3) The cycle starts again.

I managed to accomplish point number 1 but when I try to initialize the SD card the pic stops receiving information from the gps module.

Could someone help me to carry out point 2?

The program that I have managed to carry out so far is the following:
C:
//Memory Card Chip Select Connection
sfr sbit Mmc_Chip_Select at RC2_bit;
sfr sbit Mmc_Chip_Select_Direction at TRISC2_bit;
 
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;

sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections

char txt5[] = "GPS with PIC877A";
char txt6[] = "F.M.S.";
            //  "$xxxxx,xxxxxxxxx,xxxx.xxx,x,xxxxx.xxx,x,x,xx,x.x,xxx.x,x,xx.x,x,,*xx"; GPGGA
int i = 0;
int received = 0;
char DataType[] = "GPXXX";
char NMEA[] = "$xxxxx,xxxxxx.xx,x,xxxx.xx,x,xxxxx,x,x.x,x.x,xxxxxx,x.x,x*xx";
char receive;

unsigned char filename[] = "Temp.TXT";
unsigned char error;

void main()
{
while(1)
{
 TRISD = 0x00;
 Lcd_Init();                        // Initialize LCD
 Lcd_Cmd(_LCD_CURSOR_OFF);          // Cursor off
 Lcd_Out(1,1,txt5);                 // Write text in first row
 Lcd_Out(2,6,txt6);                 //displays txt5
 Delay_ms(1000);                    //displays txt6
 Lcd_Cmd(_LCD_CLEAR);               // Clear display
 Delay_ms(250);

 UART1_Init(9600);         // Initialize UART for GPS board connectivity
 SPI1_Init();
 SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV64, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
 Delay_us(10);

 Delay_mS(100);
 Lcd_Cmd(_LCD_CLEAR);
 
 while(1)
 {
  if (UART1_Data_Ready() == 1)
  {
   receive = UART1_Read();
   if (receive == '$')  // Check if sentence begins.
   {
    received = 0;
    do
    {
     if (UART1_Data_Ready() == 1)
     {
      UART1_Read_Text(DataType, ",", 10);  // Capture GPXXX word
      received = 1;
     }
    }
    while(received == 0);
    // If it is GPRMC Data, then acquire it.
    if ((DataType[2] == 'R') && (DataType[3] == 'M') && (DataType[4] == 'C'))
    {
     received = 0;
     do
     {
      if (UART1_Data_Ready() == 1)
      {
       UART1_Read_Text(NMEA, "*", 100);   // Stop at *XX checksum data
       received = 1;
      }
     }
     while(received == 0);

     Lcd_Cmd(_LCD_CLEAR);
     // Latitude
     LCD_Out(1,1, "La:");
     LCD_Chr(1, 5, NMEA[13]);
     LCD_Chr(1, 6, NMEA[14]);
     LCD_Chr(1, 7, 223);
     LCD_Chr(1, 8, NMEA[15]);
     LCD_Chr(1, 9, NMEA[16]);
     LCD_Chr(1, 10, NMEA[17]);
     LCD_Chr(1, 11, NMEA[18]);
     LCD_Chr(1, 12, NMEA[19]);
     LCD_Chr(1, 13, NMEA[20]);
     LCD_Chr(1, 14, NMEA[21]);
     LCD_Chr(1, 16, NMEA[23]);

     // Longitude
     LCD_Out(2,1, "Lo:");
     LCD_Chr(2, 5, NMEA[25]);
     LCD_Chr(2, 6, NMEA[26]);
     LCD_Chr(2, 7, 223);
     LCD_Chr(2, 8, NMEA[27]);
     LCD_Chr(2, 9, NMEA[28]);
     LCD_Chr(2, 10, NMEA[29]);
     LCD_Chr(2, 11, NMEA[30]);
     LCD_Chr(2, 12, NMEA[31]);
     LCD_Chr(2, 13, NMEA[32]);
     LCD_Chr(2, 14, NMEA[33]);
     LCD_Chr(2, 15, NMEA[34]);
     LCD_Chr(2, 16, NMEA[36]);

     Delay_Ms(1000);
     Lcd_Cmd(_LCD_CLEAR);

     //DATA
     Lcd_Out(1,1,"Data:");
     LCD_Chr(1, 7, NMEA[50]);
     LCD_Chr(1, 8, NMEA[51]);
     LCD_Chr(1, 9, '/');
     LCD_Chr(1, 10, NMEA[52]);
     LCD_Chr(1, 11, NMEA[53]);
     LCD_Chr(1, 12, '/');
     LCD_Chr(1, 13, NMEA[54]);
     LCD_Chr(1, 14, NMEA[55]);

     //ORA
     Lcd_Out(2,1,"Ora:");
     LCD_Chr(2, 6, NMEA[0]);
     LCD_Chr(2, 7, NMEA[1]);
     LCD_Chr(2, 8, ':');
     LCD_Chr(2, 9, NMEA[2]);
     LCD_Chr(2, 10, NMEA[3]);
     LCD_Chr(2, 11, ':');
     LCD_Chr(2, 12, NMEA[4]);
     LCD_Chr(2, 13, NMEA[5]);

     Delay_Ms(1000);
     Lcd_Cmd(_LCD_CLEAR);
    }
    receive = "x";
    }
   }
  }
 }
}


If you find it useful, I also attach the photo of the circuit on Proteus.
Thanks a lot to everyone.
Sorry for the bad English.
Long live electronics!
 

Attachments

  • circuit_forum.png
    circuit_forum.png
    32.7 KB · Views: 17

LaTeX Commands Quick-Menu:

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top