Go Down

Topic: SD card read/write with Arduino (Read 117087 times) previous topic - next topic

nnnn

hi friends i am doing an data logger project i'am using the below code... when i interact with harware i could'nt inizilaise the card this is ma error could any one help me out....

#include <Spi.h>
#include <sd-reader_config.h>
#include <sd_raw.h>
#include <sd_raw_config.h>

int print_disk_info();
int sample();
int readDisk();

byte incomingByte;
void printWelcome();
long int address;
byte tempBytes[2];


void setup()
{

 Serial.begin(115200);
 delay(1000);

 printWelcome();
 if(!sd_raw_init())
 {
    Serial.println("MMC/SD initialization failed");
 }
print_disk_info();
//sd_raw_init();
}



void loop()
{
   int i;

   if(Serial.available()>0)
   {
        incomingByte=Serial.read();

      switch(incomingByte)
      {
          case 114:
                    readDisk();
                    break;
          case 115:
                    sample();
                    break;
          default:
                    break;
      }
   }
}

int sample()
{
   int i,j;
   int temp;
   byte low;
   byte high;
   byte inByte;

   Serial.println();
   Serial.println();
   Serial.println("Sampling..");
   for(i=0;i<20;i=i+2)
   {
       if(Serial.available()>0)
       {
           inByte=Serial.read();
           if(inByte==113) return 0;
       }
       temp=analogRead(0);
       Serial.print(temp,DEC);
       Serial.print(" ");

       //Convert int to 2 bytes
       low=temp&0xFF;
       high=temp>>8;
      // Serial.print(temp,DEC);
       //Serial.print(low,DEC);
       //Serial.print(high,DEC);

       tempBytes[0]=low;
       tempBytes[1]=high;

       if(!sd_raw_write(i,tempBytes,2))
       {
         Serial.print("Write error");
       }
       //sd_raw_sync();
       delay(1000);

 Serial.println();

   }

   return 1;
}


int readDisk()
{
   byte low;
   byte high;
   byte info[2];
   int i;
   int  result;
   Serial.println();
   for(i=0;i<50;i=i+2)
   {
       sd_raw_read(i,info,2);

       //Serial.print(info[0],DEC);
       //Serial.print(" ");
       //Serial.print(info[1],DEC);
       low=info[0];
       high=info[1];
       result=high<<8;
       //result<<8;
       Serial.print(" ");
       Serial.print(result+low,DEC);
       Serial.print(" ");
   }

}

void printWelcome()
{
   Serial.println("------------------------");
   Serial.println("Data sampling system");
   Serial.println("send r to read disk");
   Serial.println("send s to start sampling");
   Serial.println("send q to stop sampling");
   Serial.println("Ready.....");
   Serial.println("-------------------------");
}


int print_disk_info()
{


   struct sd_raw_info disk_info;
   if(!sd_raw_get_info(&disk_info))
   {
       return 0;
   }


   Serial.println();
   Serial.print("rev:    ");
   Serial.print(disk_info.revision,HEX);
   Serial.println();
   Serial.print("serial: 0x");
   Serial.print(disk_info.serial,HEX);
   Serial.println();
   Serial.print("date:   ");
   Serial.print(disk_info.manufacturing_month,DEC);
   Serial.println();
   Serial.print(disk_info.manufacturing_year,DEC);
   Serial.println();
   Serial.print("size:   ");
   Serial.print(disk_info.capacity,DEC);
   Serial.println();
   Serial.print("copy:   ");
   Serial.print(disk_info.flag_copy,DEC);
   Serial.println();
   Serial.print("wr.pr.: ");
   Serial.print(disk_info.flag_write_protect_temp,DEC);
   Serial.print('/');
   Serial.print(disk_info.flag_write_protect,DEC);
   Serial.println();
   Serial.print("format: ");
   Serial.print(disk_info.format,DEC);
   Serial.println();
   Serial.print("free:   ");

   return 1;
}



b0zz

Hi all, I was tryning without success to install a Libelium Sd Module on a Arduino Mega (ATMEGA1280) :'(. I've searched on the net for some information; everyone say that this module doesn't work with Arduino Mega and nobody has a solution :o.
So anyone tried to use this circuit and this library with Arduino Mega?
Thank you for help.

cadrogui

#152
Mar 27, 2010, 01:14 am Last Edit: Mar 27, 2010, 01:36 am by cadrogui Reason: 1
anyone make the pcb of this???

tnks

cadrogui

if anyone want the PCB file, send me a PM, its make on eagle software

;)

jonnyboy323

Hello All!
I'm am new to the Sd card phase. My question is which of the libraries and setups do you recommend for logging gps data strings to an sd card. Yes I know about Ladyadas shield and code but I am overwhelmed. I bought the sparkfun arduino sd shield without realizing it was a failed product. Through the forums I found how to wire it up and got the sparkfun code working but I'm still having small issues. So i'm coming here to find out where i should start.

Jon

SirPoonga

I am looking for a library that solves my needs or information on how to do it.  I have a project that will use asynclab's wishield and a microsd card.  All I need to do is read files from an SD card.  There can be any number of files on the SD card so I think uFAT is out.  I can do what I want with sdlaftlib after I make my own read function.  I need to be able to read a byte at a specific position in a file.  The files will be created on a PC.

When I include both the wishield and sdfatlib they don't leave much memory left for the program.  In fact, right now my program is 1.3k over the limit of a 368 arduino.  I went through the sdfatlib and took out everything that deals with writing to files as I don't need that.  I also went through my code and made sure I didn't allocate memory when I didn't need to.  I got it down to 1k over the limit.

Since I just need to read from a microsd I was wondering if there is a library that takes up a smaller footprint that will do that.

J4R6im

I was not sucessfull in write/read SD Card using this schematics and library. Could someone give a help? I'm using an Kingston 1GB SD Card, and an Freeduino v1.0.  I had connected the SD Card like this picture, but I was not sucessful.


cadrogui

someone might use it? (the circuit and the lib)

tnks

paddywwoof

Just to say thanks. I got a seeeduino a couple of days ago, tried using a card holder hacked from a broken camera and couldn't get the DevicePrintDemo to work (mmc::initialize() returned 3). All the connections tested ok with a multimeter on beep but I noticed a (2k) short on one of the connections. So I took the advice elsewhere in this or parallel thread and soldered wires directly to a micro-adapter, set the + to 3v3 and it just worked - no resistors needed!!

The adapter seemed to have pin 3 connected to pin 6 internally so that saved one of the connections.

alecjcook

Hi,
  as soon as I try and run this example I receive the following error:
My Documents\arduino-0018\libraries\SDcard\arduino sd card example.cpp:161: error: 'DEC' was not declared in this scope

This makes no sense to me as "DEC" seems to be used in the correct way throughout the example. Can anyone help?

Many thanks!

NOTE: I'm using Arduino_0018 and the "libraries" folder is not within the "hardware" folder, does this matter?

Nnk

Hi to all,

This is N.Nandhakumar again. After a lot of struggle I have purchased the EM-406a GPS module, Adafruit GPS shield V1.1, Freeduino ATMega328 for my project.
I soldered the GPS shield , interfaced it with the Arduino and the GPS logged data successfully into the SD card.
Now, I have a problem. I want to read back the logged data from the log file stored in SD card for doing some processing, comparison with the data. I made use of SdFat library's SdFatRead example code and I was able to read back the file contents .

Code: [Select]
/*
* This sketch reads and prints the file
* PRINT00.TXT created by SdFatPrint.pde or
* WRITE00.TXT created by SdFatWrite.pde
*/
#include <SdFat.h>
#include <SdFatUtil.h>

Sd2Card card;
SdVolume volume;
SdFile root;
SdFile file;

// store error strings in flash to save RAM
#define error(s) error_P(PSTR(s))
void error_P(const char *str)
{
 PgmPrint("error: ");
 SerialPrintln_P(str);
 if (card.errorCode()) {
   PgmPrint("SD error: ");
   Serial.print(card.errorCode(), HEX);
   Serial.print(',');
   Serial.println(card.errorData(), HEX);
 }
 while(1);
}
void setup(void)
{
 Serial.begin(9600);
 Serial.println();
 Serial.println("type any character to start");
 while (!Serial.available());
 Serial.println();
 
 // initialize the SD card
 if (!card.init()) error("card.init");
 
 // initialize a FAT volume
 if (!volume.init(card)) error("volume.init");
 
 // open the root directory
 if (!root.openRoot(volume)) error("openRoot");
 
 // open a file
 if (file.open(root, "PRINT00.TXT", O_READ)) {
   Serial.println("Opened PRINT00.TXT");
 }
 else if (file.open(root, "WRITE00.TXT", O_READ)) {
   Serial.println("Opened WRITE00.TXT");    
 }
 else{
   error("file.open");
 }
 Serial.println();
 
 // copy file to serial port
 int16_t n;
 uint8_t buf[7];// nothing special about 7, just a lucky number.
 while ((n = file.read(buf, sizeof(buf))) > 0) {
   for (uint8_t i = 0; i < n; i++) Serial.print(buf[i]);
 }
 /* easier way
 int16_t c;
 while ((c = file.read()) > 0) Serial.print((char)c);
 */
 Serial.println("\nDone");
}

void loop(void) {}


The problem is that the file contents are read in raw format using uint8_t [ I googled about this datatype . But I am not clear with this datatype and how it works  :( ] . It will be more useful If I could read the data from the file in char or string format .

I searched for a better way to convert the uint8_t data to char datatype. But I get only junk characters.

I need the forum's help to solve this issue. Please give your suggestions on this.
Please help me out. Waiting for your valuable suggestions.

My works on the project at : http://walkingwithtux.wordpress.com/2010/05/02/tran-duino-under-progress/

Regards

N.Nandhakumar  :)

cemath

Hi,

Do you think you could post here what is the content of the file you are reading and what you are seeing in the serial window? I'm not sure if I can help you out, but I think that information would be helpful.

Good luck!



Nnk

Hi cemath,

Thanks for the reply. THe code which I edited in the SdFatRead Example is

Code: [Select]
 int16_t n;
 char msg;
 uint8_t buf[7];// nothing special about 7, just a lucky number.
 while ((n = file.read(buf, sizeof(buf))) > 0)
 {
   for(uint8_t i=0;i < n;i++)
      msg = (char)buf[i];
      Serial.print(msg);
 }
 Serial.println("\nDone");


I am trying to read the file contents , convert them to char type from uint8_t type.

The file which I am trying to read from SD card is the GPSLOG00.TXT . the file contains GPS sentences logged into a text file from GPS.
The contents are

Code: [Select]

$GPRMC,112209.290,A,1307.3214,N,08013.3322,E,,,030510,,*0D
$GPRMC,112210.290,A,1307.3089,N,08013.3367,E,,,030510,,*02
$GPRMC,112211.290,A,1307.3299,N,08013.3306,E,,,030510,,*07
$GPRMC,112212.290,A,1307.3512,N,08013.3207,E,,,030510,,*00
$GPRMC,112213.290,A,1307.3630,N,08013.3141,E,,,030510,,*03
$GPRMC,112214.290,A,1307.3468,N,08013.3262,E,,,030510,,*09
$GPRMC,112215.290,A,1307.3531,N,08013.3234,E,,,030510,,*06
$GPRMC,112216.290,A,1307.3595,N,08013.3207,E,,,030510,,*0B
$GPRMC,112217.290,A,1307.3534,N,08013.3249,E,,,030510,,*0B
$GPRMC,112218.290,A,1307.3502,N,08013.3273,E,,,030510,,*08
$GPRMC,112219.290,A,1307.3489,N,08013.3282,E,,,030510,,*05
$GPRMC,112220.290,A,1307.3705,N,08013.3196,E,,,030510,,*0E
$GPRMC,112221.290,A,1307.3383,N,08013.3295,E,,,030510,,*05
$GPRMC,112222.290,A,1307.3405,N,08013.3251,E,,,030510,,*07
$GPRMC,112223.290,A,1307.3420,N,08013.3292,E,,,030510,,*0E
$GPRMC,112224.290,A,1307.3526,N,08013.3229,E,,,030510,,*0E
$GPRMC,112225.290,A,1307.3553,N,08013.3228,E,,,030510,,*0C
$GPRMC,112226.290,A,1307.3535,N,08013.3259,E,,,030510,,*09
$GPRMC,112227.290,A,1307.3417,N,08013.3269,E,1.42,312.24,030510,,*0B
$GPRMC,112228.000,A,1307.3425,N,08013.3270,E,0.33,308.80,030510,,*04
$GPRMC,112229.000,A,1307.3422,N,08013.3278,E,0.04,240.51,030510,,*0F
$GPRMC,112230.000,A,1307.3417,N,08013.3283,E,0.23,173.43,030510,,*00
$GPRMC,112231.000,A,1307.3416,N,08013.3285,E,0.34,164.87,030510,,*0E
$GPRMC,112232.000,A,1307.3413,N,08013.3285,E,0.53,166.36,030510,,*01
$GPRMC,112233.000,A,1307.3410,N,08013.3286,E,0.63,159.12,030510,,*09
$GPRMC,112234.000,A,1307.3406,N,08013.3288,E,0.72,157.94,030510,,*07
$GPRMC,112235.000,A,1307.3404,N,08013.3290,E,0.78,157.79,030510,,*04
$GPRMC,112236.000,A,1307.3400,N,08013.3295,E,1.01,158.20,030510,,*0A
$GPRMC,112237.000,A,1307.3394,N,08013.3298,E,0.58,151.13,030510,,*08
$GPRMC,112238.000,A,1307.3391,N,08013.3302,E,0.23,124.27,030510,,*09
$GPRMC,112239.000,A,1307.3392,N,08013.3305,E,0.23,144.30,030510,,*0C
$GPRMC,112240.000,A,1307.3393,N,08013.3306,E,0.19,0.60,030510,,*0D
$GPRMC,112241.000,A,1307.3391,N,08013.3308,E,0.55,344.99,030510,,*0D
$GPRMC,112242.000,A,1307.3393,N,08013.3309,E,0.65,346.12,030510,,*0F
$GPRMC,112243.000,A,1307.3391,N,08013.3311,E,0.58,327.75,030510,,*0D
$GPRMC,112244.000,A,1307.3392,N,08013.3312,E,0.31,315.15,030510,,*02
$GPRMC,112245.000,A,1307.3390,N,08013.3311,E,0.43,334.94,030510,,*0D
$GPRMC,112246.000,A,1307.3393,N,08013.3305,E,0.45,322.00,030510,,*04
$GPRMC,112247.000,A,1307.3396,N,08013.3301,E,0.76,330.60,030510,,*01
$GPRMC,112248.000,A,1307.3397,N,08013.3297,E,0.27,314.78,030510,,*0A
$GPRMC,112249.000,A,1307.3400,N,08013.3295,E,0.36,20.55,030510,,*3B
$GPRMC,112250.000,A,1307.3400,N,08013.3290,E,0.29,263.99,030510,,*0D
$GPRMC,112251.000,A,1307.3397,N,08013.3288,E,0.48,229.59,030510,,*09
$GPRMC,112252.000,A,1307.3398,N,08013.3284,E,0.41,316.03,030510,,*02
$GPRMC,112253.000,A,1307.3398,N,08013.3280,E,0.80,313.98,030510,,*0D
$GPRMC,112254.000,A,1307.3401,N,08013.3277,E,1.11,318.17,030510,,*00
$GPRMC,112255.000,A,1307.3403,N,08013.3274,E,1.02,322.50,030510,,*08
$GPRMC,112256.000,A,1307.3406,N,08013.3268,E,0.51,310.56,030510,,*03
$GPRMC,112257.000,A,1307.3405,N,08013.3265,E,0.20,172.19,030510,,*07
$GPRMC,112258.000,A,1307.3405,N,08013.3265,E,0.25,131.33,030510,,*02
$GPRMC,112259.000,A,1307.3405,N,08013.3263,E,0.50,286.05,030510,,*0D
$GPRMC,112300.000,A,1307.3405,N,08013.3263,E,0.43,318.18,030510,,*08
$GPRMC,112301.000,A,1307.3406,N,08013.3262,E,0.14,166.60,030510,,*0D
$GPRMC,112302.000,A,1307.3403,N,08013.3263,E,0.23,93.57,030510,,*31
$GPRMC,112303.000,A,1307.3400,N,08013.3267,E,0.58,150.75,030510,,*05
$GPRMC,112304.000,A,1307.3396,N,08013.3268,E,0.73,157.31,030510,,*0B
$GPRMC,112305.000,A,1307.3395,N,08013.3270,E,0.23,144.14,030510,,*00
$GPRMC,112306.000,A,1307.3395,N,08013.3272,E,0.21,139.18,030510,,*05
$GPRMC,112307.000,A,1307.3393,N,08013.3272,E,0.28,356.23,030510,,*08
$GPRMC,112308.000,A,1307.3391,N,08013.3272,E,0.12,3.89,030510,,*0F
$GPRMC,112309.000,A,1307.3390,N,08013.3273,E,0.15,342.02,030510,,*0C
$GPRMC,112310.000,A,1307.3388,N,08013.3272,E,0.03,14.17,030510,,*3F
$GPRMC,112311.000,A,1307.3388,N,08013.3272,E,0.51,352.24,030510,,*08
$GPRMC,112312.000,A,1307.3389,N,08013.3272,E,0.43,339.14,030510,,*07
$GPRMC,112313.000,A,1307.3389,N,08013.3272,E,0.11,290.20,030510,,*04
$GPRMC,112314.000,A,1307.3388,N,08013.3270,E,0.21,235.81,030510,,*07
$GPRMC,112315.000,A,1307.3388,N,08013.3270,E,0.17,241.13,030510,,*0B
$GPRMC,112316.000,A,1307.3386,N,08013.3272,E,0.18,122.90,030510,,*06
$GPRMC,112317.000,A,1307.3385,N,08013.3275,E,0.25,29.10,030510,,*3F
$GPRMC,112318.000,A,1307.3385,N,08013.3277,E,0.07,201.14,030510,,*0E
$GPRMC,112319.000,A,1307.3385,N,08013.3278,E,0.48,0.37,030510,,*09
$GPRMC,112320.000,A,1307.3385,N,08013.3281,E,0.40,346.95,030510,,*04
$GPRMC,112321.000,A,1307.3387,N,08013.3281,E,0.78,340.65,030510,,*05
$GPRMC,112322.000,A,1307.3388,N,08013.3282,E,0.23,328.18,030510,,*00
$GPRMC,112323.000,A,1307.3388,N,08013.3283,E,0.79,341.04,030510,,*0D
$GPRMC,112324.000,A,1307.3389,N,08013.3282,E,0.48,321.94,030510,,*07
$GPRMC,112325.000,A,1307.3390,N,08013.3280,E,0.11,297.44,030510,,*01
$GPRMC,112326.000,A,1307.3390,N,08013.3275,E,0.27,211.88,030510,,*03
$GPRMC,112327.000,A,1307.3389,N,08013.3270,E,0.43,291.88,030510,,*05
$GPRMC,112328.000,A,1307.3388,N,08013.3266,E,0.57,203.58,030510,,*0F
$GPRMC,112329.000,A,1307.3386,N,08013.3265,E,0.12,265.01,030510,,*0E
$GPRMC,112330.000,A,1307.3389,N,08013.3261,E,0.10,192.25,030510,,*02
$GPRMC,112331.000,A,1307.3391,N,08013.3259,E,0.37,338.75,030510,,*03
$GPRMC,112332.000,A,1307.3392,N,08013.3257,E,0.36,345.45,030510,,*05
$GPRMC,112333.000,A,1307.3392,N,08013.3256,E,0.19,286.73,030510,,*03
$GPRMC,112334.000,A,1307.3395,N,08013.3254,E,0.52,327.34,030510,,*07
$GPRMC,112335.000,A,1307.3395,N,08013.3253,E,0.21,248.92,030510,,*01
$GPRMC,112336.000,A,1307.3395,N,08013.3252,E,0.21,301.84,030510,,*08
$GPRMC,112337.000,A,1307.3395,N,08013.3252,E,0.09,264.22,030510,,*0D
$GPRMC,112338.000,A,1307.3396,N,08013.3252,E,0.16,346.95,030510,,*02
$GPRMC,112339.000,A,1307.3397,N,08013.3252,E,0.11,277.62,030510,,*0E
$GPRMC,112340.000,A,1307.3396,N,08013.3252,E,0.31,346.83,030510,,*0F
$GPRMC,112341.000,A,1307.3394,N,08013.3253,E,0.23,330.10,030510,,*05
$GPRMC,112342.000,A,1307.3394,N,08013.3254,E,0.20,327.85,030510,,*08
$GPRMC,112343.000,A,1307.3392,N,08013.3255,E,0.12,193.25,030510,,*08
$GPRMC,112344.000,A,1307.3391,N,08013.3256,E,0.29,347.05,030510,,*0E
$GPRMC,112345.000,A,1307.3389,N,08013.3257,E,0.40,340.46,030510,,*08
$GPRMC,112346.000,A,1307.3388,N,08013.3258,E,0.20,327.57,030510,,*02
$GPRMC,112347.000,A,1307.3388,N,08013.3258,E,0.35,339.64,030510,,*08
$GPRMC,112348.000,A,1307.3389,N,08013.3259,E,0.13,322.44,030510,,*0B
$GPRMC,112349.000,A,1307.3389,N,08013.3260,E,0.08,272.78,030510,,*01
$GPRMC,112350.000,A,1307.3388,N,08013.3260,E,0.12,204.95,030510,,*01
$GPRMC,112351.000,A,1307.3387,N,08013.3261,E,0.05,209.98,030510,,*08


When I uploaded the code , The serial monitor contents are,
Code: [Select]


Opened GPSLOG00.TXT



,.11023*R2,.,3,0$12391,00M1A302,,G190,3E53C4,4860,P207N.,1
,.19073*R2,.,3,0$12321,00M1A302,,G190,3E5EC1,3890,P207N.,1
,.12023*R2,.,3,0$12331,00M2A302,,G190,3E30,P207N.,03*R2,.,30000M3A302..50C1,488381
,.1105360$10301,,,,G100,3E10,P207N.,53*R2,.,31800M3A302..58C8,380221
,.1905300$10331,,3*R2,.,30400M4A303..5FC3,381571
,.1902150$10301,,,,G100,3E30,P207N.,33*R2,.,30400M4A302.51
,.1000990$10371,,,,G100,3E30,P207N.,13*R2,.,31800M5A302..58C6,486551
,.1005090$10351,,,,G100,3E20,P207N.,13*R3,.,30600M0A302.51
,.1007850$10361,,,,G100,3E10,P207N.,33*R3,.,30600M0A302.90$10301,,,,G100,3E13*R3,.,30200M1A302..57C3,387121
,.1800110$10381,,,,G100,3E10,P207N.,903M1A302..5EC9,3874,,G100,3E30,P207N.,43*R3,.,30800M2A302..5DC4,388491
,.1900140$10301,,,,G100,3E20,P207N.,03*R3,.,30500M3A302..52C1,385371
,.1907650$10321,,,,G100,3E30,P207N.,43*R3,.,30100M3A302..5DC8,385191
,.1902120$10361,,,,G100,3E30,P207N.,23*R3,.,30300M4A302..5EC5,385441
,.1808070$10381,,,,G100,3E30,P207N.,73*R3,.,30400M5A302..58C2,386241
,.1807940$10311,,0,P207N.,.5FC6,387180$10381,,3*R3,.,30.5FC9,388160$10371,,,,G100,3E10,P207N.,63*R4,.,30700M0A302..5BC5,389131
,.1603360$10311,,,,G100,3E10,P207N.,903M1A303..58C1,380401
,.1604860$10301,,0,P207N.,53*R4,.,30.52C6,380430$10331,,0,P207N.,73*R4,.,30.5FC0,380121
,.1601750$10311,,,,G100,3E10,P207N.,33*R4,.,30800M2A303.71
,.15093,,G100,3E10,

Done



The contents in the serial monitor are of different format [ I think its of HEX type]
and the full contents are also not fully converted and displayed in the serial monitor. Please help me out and tell me where I made wrong in the code. I also need to convert the full contents into char, since the log file is very huge.

Thanks in advance
N.Nandhakumar

cemath

Hi Nnk,

I found a pattern while comparing the data in your file and the data that is displayed in the monitor window. If you break the file data in blocks of 7 characters (the last caracter of a line, break line, counts as a caracter), and you keep only the last caracter of each block, then you can reconstruct what you are seeing in the monitor window. The problem must be in the example code you use to display the caracters, but I do not see it. I suspect that by reading a single byte at a time (using uint8_t buf[1] instead of uint8_t buf[7]) it should correct the problem, but that doesnt not explain it.

I suggest that you debug the code step by step by displaying the value of 'n' and other variables to verify that the program is doing what it should.

Also, I think that going throught the 'char' intermediate step is not necessary, because the formats 'uint8_t' and 'char' are very similar. I think uint8_t is equivalent to the format 'byte', which is 8 bits unsigned, and char is 8 bits signed. But since the caracters in ASCII are encoded on a range from 0 to 127, signed or unsigned bytes make no difference.

I hope that you find the solution to your problem quickly!

Good luck,

cemath

novamax

#164
May 19, 2010, 03:59 am Last Edit: May 19, 2010, 04:13 am by max88poon Reason: 1
Hi guys

i am in a serious situation, i can't graduate if i don't get done with the datalogging...
so please, help , i very appreciate it
here is the case:
i am having a project that display a speed and record it
the former part is done, however, the later part is very difficult to me
i am trying to save the speed into the SDcard, don't need to read or copy, just write.
here is the code for the former part:
Code: [Select]
#define FREQ_PIN 3
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup() {
 pinMode(FREQ_PIN, INPUT);
lcd.begin(16, 2);
}

void loop()
{

unsigned long t1 = pulseIn(FREQ_PIN, HIGH);// Time how long it takes to go HIGH again
unsigned long t2 = pulseIn(FREQ_PIN, LOW); // and how long it takes to go low again.
double t = t1 + t2;
        double f = 1000000.0/t;
          double w = 2 * 3.14 * f;
          double v = w * 0.05;
      lcd.setCursor(0,0);
        lcd.println(v);
        delay(2000);
}    


Help please, I very very appreciate it.

i have the exactly the same circuit with this post, but i don't know how to write, thanks a lot

The code above is created by members, they are Pauls, Groove, AWOL and mem, i couldn't do this without their help, thanks a lot  :)

Go Up