Shop OBEX P1 Docs P2 Docs Learn Events
data logger creating multi files — Parallax Forums

data logger creating multi files

ftechftech Posts: 8
edited 2009-09-25 01:49 in BASIC Stamp
Hi all
I have a need to do one of two things with the data logger and its driving me nuts. speed is not a huge issue but want seconds not minute to execute.. if it is at all possible.
·
I want to either open three files on the memory stick and write to them at different times over a day period... i.e.
File one ... pin 1·goes high it writes data in EPROM to file one
File two...· pin 2 goes high it writes different date string
File three.... this can either be continuous write data if neither above action or set to a pin reference.
·
OR
·
With above mention pin actions open a new file each time without erasing previous...
·
I guess what I am asking for simply is can I have a variable/counter/name change in a file command string
·
·SEROUT TX\CTS, Baud, [noparse][[/noparse]$09, $20, "datafile.txt", CR]···
·
i.e.
·
file one.............................. datafile1
file two...............................datafile2
file three..............................datafile3
·
or
datafile ,1,2,3,4,5,6,7,8,9,10, 11...etc

Just to add extra degree of difficulty if possible and really prefered but can maybe get around it if have to....Is to·have it not delete any file on restart or if data stick left in at end of day... ie never overwrite a file... using date and time maybe as file name to prevent over writing is what i thought of... hence asking how I can create a gosub or get in the file name string..

hope not asking toooo much... place to start would be great not asking anyone to write program for me
·
thanks for any help or clues cheers

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-09-23 00:35
    You can open different files, but only one at a time. You have to close one before you can open another.

    The file name is just an output string like any other. You can construct the file name portion from pieces just like you'd display something like:

    SEROUT TX\CTS, Baud, [noparse][[/noparse]$09, $20, "datafile", DEC number, ".txt", CR]

    "number" would be a variable or expression, whatever you need.

    The datalogger doesn't delete files unless you command it to do so, but it will overwrite an existing file. You could use subdirectories and make the subdirectory name out of the date (like 2009-09-22). Alternatively, you could have a file called "datafile.txt" that only contains the number of the last file written and always read that file at the beginning of a day (when the day is entered).
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2009-09-23 01:46
    Hi , providing that you don't delete a file then the VDAP instruction "WRF" will append data each time you open and write to a file.

    Jeff T.
  • ftechftech Posts: 8
    edited 2009-09-23 01:58
    Ha cheers guys that helps! figured it was simple thats why couldnt think it or find it...I couldnt see the·forest for the trees

    think I can get it sorted now just have to try a few methods.... like the folder idea didnt even think of that one and I look into the "wrf" to



    thanks so much cheers
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-09-24 16:07
    One thing you will have to be aware of is that the filename must be in 8.3 format, so you couldn't use datafile as the root for the name since it is already 8 characters long. You could use the word FILE and then a number though. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Parallax Engineering
    50 72 6F 6A 65 63 74 20 53 69 74 65
    ·
  • ftechftech Posts: 8
    edited 2009-09-25 01:49
    ha!!!

    I had that problem but didnt realize it... accidently skipped around it.. that explaines now why one file work and the other didnt...one was to large!

    Cheers thanks for that Chris and others!
Sign In or Register to comment.