USB Memory Stick Datalogger (#27937) Issues [RESOLVED]
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:
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
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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Powered by enthusiasm
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
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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://forums.parallaxinc.com/paralleluniverse
New Game: Vector
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
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