sd.write problem

Coding and general discussion relating to user created compiler modules

Moderators: David Barker, Jerry Messina

Post Reply
Roshan
Registered User
Registered User
Posts: 42
Joined: Tue Mar 03, 2009 3:08 pm
Location: India

sd.write problem

Post by Roshan » Sun Nov 15, 2009 8:17 am

Hi All !

Need help in sd.write command.

When 1st time i create new file then make some fields but program does not create field. Here is my code & result.

Here is the code

Code: Select all


//check file existance if not found then
// create new file & close file.
//now open file & write some data & close file
        If SD.FileExists(FileName) = false Then             
           If SD.NewFile(FileName) = errOK Then

                  SD.Write("TIME")'T
                  SD.Write(#58)

                  SD.Write("DATE")'D
                  SD.Write(#58)

                  SD.Write("B-VOLT")
                  SD.Write(#58)

                  SD.Write("S-VOLT")
                  SD.Write(#58)

                  SD.Write("AMP")
                  SD.Write(58)
                  
                  SD.Write(#13,#10)
                  SD.CloseFile()
                  EndIf
                  EndIf


Here is the result

Code: Select all


:::::



it will never print as i write code like this.

TIME:DATE:B_VOLT:S_VOLT:AMP


Can some one guide me whre is the problem.

After this write another code which will log data in file. That is working perfect below is example.


Code: Select all

:::::
133539:20091115:00.6V:00.3V:00.5A
133548:20091115:00.7V:00.3V:00.5A
133556:20091115:00.8V:00.3V:00.5A
133604:20091115:00.7V:00.3V:00.6A
133612:20091115:00.7V:00.2V:00.5A
133620:20091115:00.7V:00.3V:00.5A
133628:20091115:00.7V:00.2V:00.5A


but 1st time when i create file, headings are missing.

Regards
ROSHAN

Roshan
Registered User
Registered User
Posts: 42
Joined: Tue Mar 03, 2009 3:08 pm
Location: India

Post by Roshan » Wed Nov 18, 2009 6:33 am

still not replied by any one.
ROSHAN

Francis
Registered User
Registered User
Posts: 314
Joined: Sun Mar 25, 2007 9:40 am
Location: Devon

Post by Francis » Wed Nov 18, 2009 9:11 am

I don't know the answer, but does it make any difference if you write your headings e.g. "TIME" as a defined string array as opposed to in between "quotes" ?

Why use # as in #58?

gramo
Registered User
Registered User
Posts: 200
Joined: Tue Mar 20, 2007 6:55 am
Location: Australia
Contact:

Post by gramo » Thu Nov 19, 2009 6:21 am

Francis wrote:Why use # as in #58?
Although not required, it is a prefix for decimal numbers. The only info I can find on it is in the Swordfish - Variable help topic;
An alternative way to assign a single character to a string element or char variable is by using the # notation. For example, the underscore character ("_") can be represented by the ASCII number 95 decimal. We could therefore write StrResult = #95. This technique is particularly useful when dealing with non white space characters, such as carriage returns and line feeds.
Though it is not listed in the section that discusses prefixes (Swordfish - Constants);
Constants, unlike program variables, do not use RAM to store their values. If a constant is used in a program expression, code memory is used instead. When declaring numeric constants, or when using numeric literals in your program, you can use different number representations, as shown below

Representation
Prefix
Example
Value


Decimal
none
100
100 decimal

Binary
%
%100
4 decimal

Hexadecimal
$
$100
256 decimal
The table formatting was lost in the copy/paste, though its understandable..

I've tried running a variation of the above program though it was with an 18F2620 which require the software SPI library to run the SD Card library. It worked perfectly with the software SPI library, though I will program a compatible PIC with a hardware variant of the program when some spare time pops up
digital-diy.com - Hobby microcontroller projects and tutorials. Assembly, PICBasic and C examples.

Australian distributor for the Swordfish Compiler

Post Reply