Shop OBEX P1 Docs P2 Docs Learn Events
logging data — Parallax Forums

logging data

FreakTheMightyFreakTheMighty Posts: 5
edited 2007-10-17 22:58 in General Discussion
I'm looking for an efficient way to save data to a txt file. I am reading it off of an AtoD chip. I think the data will be recorded as bits and I will do all my other programming when I am not concerned with speed.

-Thanks for your help.

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-10-17 22:58
    If you use the IDE beta, you can log the message window output.
    The attached file shows a template file that prints 16 values per line.

    import stamp.core.*;
    import stamp.util.text.*;

    public class AdcLogging_test {

    · //prototype function for ADC
    · static int readAdc() {
    ··· return 0;
    · }

    · static void main() {
    ··· int i,value;
    ··· while (true) {
    ····· for (i=0; i<16; i++) {
    ······· value = readAdc();
    ······· Format.printf("%04x ",value); //print value as hexadecimal value
    ····· }
    ····· Format.printf("\r\n"); //CR,LF at line end
    ··· }
    · }
    }

    You can also print unsigned decimal values
    Format.printf("%5u ",value); //print value as unsigned decimal value
    or Comma Seperated Values (CSV file)
    Format.printf("%5u, ",value); //print value as comma seperated unsigned decimal·value

    To log the message window output, rightclick in the main message window
    and select Log. You will be prompted for a file name.

    regards peter


    Post Edited (Peter Verkaik) : 10/18/2007 4:13:56 AM GMT
Sign In or Register to comment.