Data Logger

5 Comments

After many trials, finally I was able to complete this small project which had been in my mind for a long time.

A data logger that store information on SD card. Using PIC18F4550, and one SD card socket I was able finally to complete this project. One Analogue input was added to the board where any analogue sensor can be placed over there. (As of now I am using a temperature sensor (NTC).

The PIC program was made using MikroC. (This made programming PIC much simpler, and saved a lot of time with its gerat libraries)

Below the final circuit picture.

My plan now is to write a small application that would get the logged data, and based on scaling information entered to the software; correct values would be calculated and plotted.

Please let me know if you were trying to build a similar project, and I’ll help you as much as possible.

Code:

// MMC module connections
sbit Mmc_Chip_Select           at LATA5_bit;  // for writing to output pin always use latch (PIC18 family)
sbit Mmc_Chip_Select_Direction at TRISA5_bit;
// eof MMC module connections
long int temp_res;
const LINE_LEN = 16;         ///012345678901234
char file_contents[LINE_LEN] = "XX,XXXXXXXXXXXX";
int temp;
char           filename[] = "TempLogF.TXT";
int i;
unsigned short loop, loop2;


char txt[12];

void M_Create_New_File() {

  Mmc_Fat_Set_File_Date(2010, 4, 19, 9, 0, 0); // Set file date & time info
  Mmc_Fat_Assign(&filename, 0xA0);          // Find existing file or create a new one
  Mmc_Fat_Rewrite();       
  PORTD=0xFF;                 // To clear file and start with new data
  for(loop = 1; loop <= 9999; loop++) {
   PORTD=0b10100000;
  Delay_1sec();
    Delay_1sec();
    Delay_1sec();

     PORTD=0b01000000;



    file_contents[0] = loop / 10 + 48;
    file_contents[1] = loop % 10 + 48;
    
    temp_res = ADC_Read(2);
    LongIntToStrWithZeros(temp_res, txt);
    file_contents[3] = (temp_res / 1000) + 48;

    for(i=4;i<=14;i++)
    file_contents[i] = txt[i-4];

    Mmc_Fat_Write(file_contents, LINE_LEN-1);   // write data to the assigned file
    Mmc_Fat_Write("\r\n", 2);   // write data to the assigned file
   // Mmc_Fat_Write('\n', 1);   // write data to the assigned file
    Delay_1sec();
    Delay_1sec();

  }
}



// Main. 

void main() {
  ADCON1 = 12;                  // Configure AN pins as digital
  CMCON  |= 7;                     // Turn off comparators
  TRISD=0x00;
  TRISA=0b00001111;
   
   PORTD=0b10100000;
   Delay_1sec();
   Delay_1sec();
   PORTD=0b01100000;
   Delay_1sec();
   Delay_1sec();



  // Initialize SPI1 module
  SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV64, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
   Delay_ms(10);

   if (Mmc_Fat_Init() == 0)    // reinitialize spi at higher speed
  {
  PORTD=0b11100000;
    SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV4, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
    M_Create_New_File();

    PORTD=0b11100000;
   
    while(1)
    {
         PORTD=0b11100000;
         Delay_1sec();
         Delay_1sec();
         PORTD=0x0;
         Delay_1sec();
         Delay_1sec();
     }
  }
  else {
        PORTD=0b01000000;


  }

}

Download Hex File (Finally!!)

5 thoughts on “Data Logger”

  1. Hola admin. I must tell you I’m impressed with your work and it has been of great help to me. I tried running the code but received several error messages like * undeclared Identifier* where the SPI is initialised and operator *is not applicable to this operand* (line 74 reinitialize spi at higher speed) wish you could help me out.
    I’m working on a similar project where multi sensors (4) are connected to ucontroller, data from sensors are stored in an SD card and later read on the pc through the serial port. please help me if you can

    my regards

    Karstro

  2. Our porn purlieus offers to elation in watching the brightest and most tantalizing porn videos of the a- porn studios. We are purport to satisfy mouldy our viewers most overpowering joyfulness that pattern choice and testament entrancement to any aficionado of porn with any preference. Here you can brains inoperative of evil’s road the video with mortifying plots that created not later than well-founded porn teams’ studios which are pleased as punch their users with its high-quality contented regularly. We comprise numerous variants of sprung porn in behalf of viewers with distinguishable preferences, there are videos from the most inventive teams such as: Digital Playground, Truth Kings, Mofos, Brazzers, Wicked. Each of these sections has a nationwide thousand of clips, so each visitant with extraordinary preferences obey be positively pleased as punch with them. Each Studio has its own shooting features, choices on conceive and the cast. Here, all users could scan an special high-quality video of these porn
    plat:
    https://house.porn/studios and xpuretaboo.com/

  3. Ohh, ohh Mentirosa, no me importa que de amor te mueras x2.Gather your crew and seek out new life and new civilizations.For reasons that are still debated, Lewis decided to leave the Vapors at about 2 30 a.According to a report in Manchester Evening News, Jaime was jailed for two years and eight months in 2016 after being found guilty of arson.Todas tus canciones favoritas de Reik Ft Nicky Jam Ya Me Entere las encuentras en la mejor web para bajar musica NiX.

    http://deicalxipolsoressterdarkbakoheami.co/40/szunnyad-a-boemb-amorf-rdoegoek-a-zuevexem-golyszr-file-album.php

  4. Can I simply say what a relief to find somebody who genuinely knows what they’re discussing over the internet. You definitely understand how to bring an issue to light and make it important. More people ought to read this and understand this side of the story. It’s surprising you are not more popular since you definitely have the gift.
    https://arbargains.com

  5. Рћ Billboard 200, 210 000.Where do you live.Bad Moon Rising 7.MAJOR CIVIL WAR BATTLES FOUGHT IN TEXAS.No voy a llorar. https://monlongkomalplira.lophovolmucotlaisubviecukosasag.co Primary Handbook For Snare Drum Book CD – Learn the proper methods of playing the snare drum with this internationally acclaimed book.I hope most projects succeed as I have been investing full force in many of them, as well.Maluma Jajaja Carlos Vives Shakira Maluma Colombia.Als Zigeuner werden seit dem 15.Rock Roll Hall Of Fame.

Leave a Reply

Your email address will not be published. Required fields are marked *