Shop OBEX P1 Docs P2 Docs Learn Events
USB Memory Stick Datalogger (#27937) Issues [RESOLVED] — Parallax Forums

USB Memory Stick Datalogger (#27937) Issues [RESOLVED]

Parallel UniverseParallel Universe Posts: 46
edited 2010-01-16 01:11 in Propeller 1
Hello. I am working on a robotics·project involving the Parallax Datalogger module. I have been·working off the PropRPM board at 80 MHz, and everything else is working fine, but the datalogger is behaving erraticly. The test program for the SPI driver in the Object Exchange works fine 97% of the time, but I can't seem to get my own code to work. I am attempting to write a file to the disk, with varying degrees of success. Sometimes the datalogger reports all commands as errors and leaves the disk blank. Other times it reports an error in opening a file, but still porduces a file with the correct content, but with an odd filename.

Here's my test code:
pub main
  debug.start(9600)
  usb.dataloggerspi(20, 21, 23, 22)  
  usb.receivepromptorerror(3000)
  
  if not usb.diskpresent
    debugline(string("Disk not found. Waiting for disk..."))
    repeat until usb.diskpresent    
  debugline(string("Disk found."))
  
  if usb.changedirectory(string("\"))
    debugline(string("Accessed root directory."))
  else
    debugline(string("Unable to access root directory."))
    
  if usb.openfileforwrite(string("LOG_0001.TXT"), 0)
    debugline(string("Created file 'LOG_0001.TXT'."))
  else
    debugline(string("Unable to create file 'LOG_0001.TXT'."))
 
  if usb.writetofile(string("Hello, World!", 14, 0)
    debugline(string("Data written."))
  else
    debugline(string("Unable to write data."))
    
  if usb.closefile(string("LOG_0001.TXT"))
    debugline(string("File saved."))
  else
    debugline(string("Unable to save file."))    
  


Any ideas about what I might be doing wrong?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://forums.parallaxinc.com/paralleluniverse
New Game: Vector

Post Edited (Parallel Universe) : 1/16/2010 1:14:26 AM GMT

Comments

  • SRLMSRLM Posts: 5,045
    edited 2010-01-14 21:29
    We can't help without the "usb" object. If you post the full code (archived via proptool) then you may get some more help...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Powered by enthusiasm
  • Parallel UniverseParallel Universe Posts: 46
    edited 2010-01-15 02:16
    Doh! Thanks for pointing that out. Normally I'm not quite that dumb.
    I'm using DataloggerSPI from the object exchange. Its included test program works fine, but I get either no or unexpected results when I try my little test program above. Mainly I was wondering if anyone else had encountered similar issues with the Vinculum or this particular driver object. Maybe there's a more robust object out there?
    All my project needs to do is output text to a file, so it shouldn't be hard to modify DataloggerSPI's test program to ouput a single file--which is essentially what I have done--but for some reason it doesn't work.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    http://forums.parallaxinc.com/paralleluniverse
    New Game: Vector
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2010-01-15 07:23
    The accompanied test program of the DataloggerSPI object
    has a 250 msec wait after starting DataloggerSPI.

    · waitcnt(clkfreq / 4 + cnt)····· ' Wait for 250ms initialization (80MHz clock)

    This delay seems not present in your code.

    regards peter
  • Parallel UniverseParallel Universe Posts: 46
    edited 2010-01-15 13:27
    Thanks. I'll give it a try with that.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    http://forums.parallaxinc.com/paralleluniverse
    New Game: Vector
  • Parallel UniverseParallel Universe Posts: 46
    edited 2010-01-15 23:17
    The 250 ms pause helped: I got more mangled data than I did no data. But I did notice that there was no RecievePromptOrError inside my wait for disk loop. So I made the following modifications and now it works:
      usb.dataloggerspi(20, 21, 23, 22)
      waitcnt(clkfreq / 4 + cnt)                             repeat
        usb.receivepromptorerror(2000)
        if usb.diskpresent
          quit 
        debugline(string("Searching for disk."))
        waitcnt(clkfreq + cnt)    
      debugline(string("Disk found."))
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    http://forums.parallaxinc.com/paralleluniverse
    New Game: Vector

    Post Edited (Parallel Universe) : 1/15/2010 11:25:36 PM GMT
  • Parallel UniverseParallel Universe Posts: 46
    edited 2010-01-16 01:11
    As it turned out, modifying the SPI driver fixed the problem for a few runs, but then it resurfaced.
    I then realized the pinout on the datalogger allowed me to also use it in UART mode, so I decided to try the UART Driver in the object exchange, and it seems to work fine with the following debug program:
    obj
      usb : "USBDrive"
      bug : "SimpleDebug"
    
    pub main                       
      bug.start(9600)
      
      case usb.Start(22,20,21,23)
        0:
          bug.str(string("Initialization succeded.", $d)) 
        -6:
          bug.str(string("Initialization failed: No disk.", $d))
        -5:
          bug.str(string("Initialization failed: No Carrage return.", $d))
        -4:
          bug.str(string("Initialization failed: Did not echo 'e'.", $d))
        -3:
          bug.str(string("Initialization failed: Did not echo 'E'.", $d))
        -1:
          bug.str(string("Initialization failed: All cogs in use.", $d))   
        other: 
          bug.str(string("Initialization failed: Unknown error.", $d))
                                                        
      if usb.OpenForWrite(string("LOG_0001.TXT"))
        bug.str(string("Opened file for write.", $d))
      else
        bug.str(string("Unable to open file for write.", $d))
        
      if usb.WriteLine(string("Hello, World!"))
        bug.str(string("Wrote line to file.", $d))
      else
        bug.str(string("Unable to write line to file.", $d))
        
      if usb.Close(string("LOG_0001.TXT"))
        bug.str(string("Saved file.", $d))
      else
        bug.str(string("Unable to save file.", $d))
    
    



    Thanks for your help!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    http://forums.parallaxinc.com/paralleluniverse
    New Game: Vector
Sign In or Register to comment.