Shop OBEX P1 Docs P2 Docs Learn Events
Write from SX memory to USB drive — Parallax Forums

Write from SX memory to USB drive

astro70astro70 Posts: 8
edited 2008-05-08 23:32 in General Discussion
I am building a system to count revolutions of a rotating shaft then writing to SX memory.· Once I fill a few banks in the SX I am writing this information to a USB drive using the Parallax Datalogger.·

Counting and writing to SX memory works great.· Communicating to the datalogger works great (thanks to Bean!).· I can't get the data transferred to the USB drive now.· I can get it to increment through the memory locations, but can't get the actual data to write to the USB drive.· I can write text, but not data.·

Any ideas would be appreciated, the code is attached.· The one called Try2 works great and writes the word "TEST" 16 times.· Try3 I'm trying to write actual data, file is blank.· I'm probably overlooking something.

Thanks,

Comments

  • BeanBean Posts: 8,129
    edited 2008-04-29 17:45
    You need to change the "10" to how many characters you are sending (1 or 2 if you count the CR).

    SendStr "WRF "
    SendChar 0
    SendChar 0
    SendChar 0
    SendChar 10 ' <- Change this value to number of characters being sent.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Did you know that 111,111,111 multiplied by 111,111,111 equals 12345678987654321 ?

    www.iElectronicDesigns.com

    ·
  • astro70astro70 Posts: 8
    edited 2008-04-29 20:41
    Now that I've spent some quality time with the Datalogger and SX·I need help understanding why I cannot write from a memory location.· I have attached 2 different programs.· One will write the letters "aa" 15 times, just like it should.· If I write those same 2 letters to a memory location then point to that location for sending to the·memory stick I get a blank file.·

    I DON'T UNDERSTAND!! Both programs shoud do the same thing??

    Below in Blue is the Piece of code that works

    RevData = $30
    DO
    ····· ' Write to file "TEST.TXT"


    ····· SendStr "WRF "
    ····· SendChar 0
    ····· SendChar 0
    ····· SendChar 0
    ····· SendChar 3
    ····· SendChar CR
    ····· SendStr "aa"·····'write the ASCII directly to the·SUB parameter
    ····· SendChar CR
    ····· RecvStr
    INC RevData
    LOOP UNTIL revdata = $3F


    Below in red is the same piece of code modified to pull from RAM and it doesn't work

    Revdata=$30
    DO
    __RAM (Revdata)="BB"


    Getdata=__RAM (RevData)

    ····· ' Write to file "TEST.TXT"
    ····· SendStr "WRF "
    ····· SendChar 0
    ····· SendChar 0
    ····· SendChar 0
    ····· SendChar 3
    ····· SendChar CR
    ····· SendStr· Getdata
    ····· SendChar CR
    ····· RecvStr


    INC Revdata
    LOOP UNTIL revdata = $3F




    Post Edited (astro70) : 5/3/2008 4:49:16 AM GMT
  • astro70astro70 Posts: 8
    edited 2008-05-03 04:48
    Bump
  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2008-05-08 23:32
    Astro,

    There are some incompatible concepts that you are unsuccessfully trying to make work together.

    1.) I do not think the __RAM(address) alias knows how to formally handle strings. The __RAM(address) alias allows you to access a single byte of RAM. I think you would need to assign each character independently being certain to increment the RAM address each time. Also, most strings are terminated with a character value of zero to signify the end of the string. So you would probably need to add a terminating value as well.

    However...

    2.) The __READ(address) command used in your SendStr subroutine reads data from program memory not RAM. So you can not use the __READ(address) command to retrieve data stored in RAM.


    I think that if you use SendChar __RAM(address) to send out data that is stored in RAM one byte at a time you can achieve the results desired. If not, write back with what you tried and what happened.


    - Sparks

    Post Edited (Sparks-R-Fun) : 5/8/2008 11:37:18 PM GMT
Sign In or Register to comment.