Shop OBEX P1 Docs P2 Docs Learn Events
Some general question — Parallax Forums

Some general question

jimgoldenjimgolden Posts: 4
edited 2012-04-30 20:47 in Propeller 1
Hello, I was wonding if I might be able to get some help with some qestions.

First, I have some experiance with programing these little black bugs that I have crawling all over my bread boards, and they are arduinos, chipkits, picaxe. But this spin is a little new to me. I am not sure how, but with some major luck, I was able to write to a sd card that I soldered some pins to and shoved in my bread board! That was lots of fun. So here are some questions about writing to the sd card

1. I do like being able to write to .csv files, I have some projects that will need this. So, Excel like the CSV, but when I put it in a string like
(string
sdfat.pputs(string( "123,234,345,56,4567,5,678,79,56,456,345,345,34,5,35,34,3,45,35" 13, 10  )]
it puts every thing in row one. Will I need to place the 13, 10 part in between all the number like this to get it to work or will some other way work?
sdfat.pputs(string( "123" 13 "234" 13, 10  )
2. How do I put something like a variable. IE..... I am monitoring the level of something and I want it to log that level that is being measured?
With the arduino, If I were to print it or save it to the eeprom, I would just do something like "move levelmes to eeprom" I tried writing a var to the sd card but it said" String Char must range from 1 to 255" What do I use instead of string?

Comments

  • Cluso99Cluso99 Posts: 18,069
    edited 2012-04-30 19:34
    I am not sure if the error below is just a typo, but it should be...
    sdfat.pputs(string( "123,234,345,56,4567,5,678,79,56,456,345,345,34,5,35,34,3,45,35" 13, 10  )]
    should be...
    sdfat.pputs(string( "123,234,345,56,4567,5,678,79,56,456,345,345,34,5,35,34,3,45,35", 13, 10  ))
    

    For using variables, I suggest you look at the FullDuplexSerial object (in the OBEX but downloaded with PropTool). This works the same way and you have various conversions in spin to get variables into strings for sending serially. There is DEC, HEX, etc conversions. Now, Kye (the writer of the SDFAT object I believe you are using) has a string manipulation object and IIRC that comes with the FAT driver, and there are some demos for using it.

    Once you get the variable into a string it is a simple matter to use sdfat.puts(strvar) where strvar is the variable in string format.

    I hope this helps. If not, then please re-ask here for more help.
    [code]
    strx:=
    sdfat.pputs(strx)
  • AribaAriba Posts: 2,690
    edited 2012-04-30 20:14
    You can define constant strings also in a DAT section. This gives you more control than a string(" ") pseudo function.
    DAT
    mystring  byte "123",13,10,"987",13,10 ,0
    cr        byte 13,10 ,0
    
    The strings must end with a zero byte to terminate the string, and to use the string in a methode call, you need to pass the address of the string (a pointer to the string) with a @ before the name (@mystring, @cr).

    To write variables in form of decimal strings, you can use the "Simple_Numbers" object:
    OBJ
     num : "simple_numbers"
    
    PUB ...
      ...
      sd.puts(@mystring)
      sd.puts(num.dec(myvar))
      sd.puts(@cr)
    

    Andy
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-04-30 20:47
    I just wrote a little demo program to show how to store variables as ASCII characters on a SD card.

    It's written for the PropBOE but you can just change the pin numbers to match your setup.
Sign In or Register to comment.