Shop OBEX P1 Docs P2 Docs Learn Events
Help with USB memory stick datalogger — Parallax Forums

Help with USB memory stick datalogger

JemartinJemartin Posts: 9
edited 2010-06-06 18:30 in Propeller 1
Hello,

So, I'm trying to get the USB memory stick datalogger(27937) to work with my propeller chip. Where to start...

So far Ive tried·a few different·objects from the obex·to communicate with it. Ive tried both UART and SPI drivers. So far none of them have gotten through to the USB stick.

With the DataloggerSPI_test set the way it looks the pin assignments are supposed to be·I just get the intro·message and the red light on indefinetly. With the In and out pins flipped I get the intro message and "No disk present. Please insert Disk." and the red light on.

With AutoDatalogger_test I always get:
"AutoDatalogger Test ...
Starting Test..."
with the alternating red and green lights.

Basically the same sort of thing from any object I try; it never gets past the initialization parts in the beginning.

I've also tried a few different USB sticks of various sizes from 32MB to 4GB big. Ive tried formatting the drives to both FAT32 or FAT(default) and also the allocation size at the default and also at 512 bytes(which one of the objects suggested).

One thing I am a bit worried about is that I may have tried running it with the pin assignments for·IN and·OUT flipped. It may have also been running with a SPI object and the datalogger's jumper on UART. I dont know if either of these situations (or any?)·can damage the datalogger?

As far as the hardware goes I didnt put it together, but I traced the circuits and I dont think that there are any resistors between the prop and the datalogger. I've read both ways; that it does or doesnt need any resistors. I havent tried to put any in because the circuits have been wired together until the datalogger so there isnt really an easy way to add resistors. Ive checked continuity between the prop and the pins on the datalogger and it all looks fine.

Thats everything I can think of right now. Im new to microcontrollers, so Im lost about what to do. I got it to read in data from adc's and I was hoping that·getting the USB working would go as easily. :\

Any help would be greatly appreciated.

Comments

  • cessnapilotcessnapilot Posts: 182
    edited 2010-06-05 04:33
    Hi Jemartin,

    Try the http://obex.parallax.com/objects/542/·DataLogger_UART object. I use this regularly these days in a {C328 camera / uOLED128 / MLX90614 / Datalogger} project without any problem.·It is practically bulletproof, but not wireing-proof. If it will not work at your site, please post the picture of your circuit, to find the problem.

    Cheers,

    Istvan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Intentionally Left Blank
  • koze85koze85 Posts: 18
    edited 2010-06-05 13:55
    I have the same problem.... The only object that workes perfectly is the one that Istvan says but the problem is that it is too big.. when i add the object to my project i have a lack of 300 longs and when is not i have about 1800 free..... Is there any working driver that doesnt need so much space and has basic data handling and reading in a file ???
  • cessnapilotcessnapilot Posts: 182
    edited 2010-06-05 14:38
    @Jemartin


    Here are the pin assignments from a working Camera/MLX90614/uOLED/DataLogger project

    CON
    {
    ------------------------------Pin assignements----------------------------
    Tx on the Propeller must be connected to Rx on the Datalogger, Rx on the
    Propeller to Tx on the Datalogger, similarly CTS and RTS also must be
    crossed.
    }
     
    '            On Propeller                   On Memory Stick Datalogger
    '-------------------------------------  ----------------------------------
    'Symbol   IOP#          Function        Symbol Pin IO      Function
    '-------------------------------------------------------------------------
    _RNG     = 4 'Out   Ring            -->  RI     8  In   Ring Indicator  
    _RTS     = 5 'Out   Request To Send -->  CTS    6  In   Clear To Send 
    _RX      = 6 ' In   Receive data    <--  TXD    5 Out   Transmit data 
    _TX      = 7 'Out   Transmit data   -->  RXD    4  In   Receive data 
    _CTS     = 8 ' In   Clear To Send   <--  RTS    2 Out   Request To Send
    _RES     = 9 'Out   Reset           -->  Reset  R  In   Reset VNC1L-1A
    

    and you can see the schematics in the 1st attachment. The other attachments show the actual connections.

    @koze85

    Thanks for using the driver. OK. Let's make a lite version. Let me know what are the basic features useful for your application and I can help by making a Lite version of the DatLogger UART object.

    Cheers,

    Istvan



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Intentionally Left Blank
    640 x 480 - 149K
    640 x 480 - 155K
    640 x 480 - 158K
  • T ChapT Chap Posts: 4,223
    edited 2010-06-05 14:43
    Koxe85, what app are you using to compile and program? BST might give you some advantages using the optimization option.
  • koze85koze85 Posts: 18
    edited 2010-06-05 17:47
    Todd : I am using Propeller Tool i know nothing about optimazation option!!!

    cessnapilot : I want to use datalogger with sensirion and a tvgraphics· driver to display daily temperatures and save them to the datalogger (record, time, temperature humidity) and transfer same values from a distant propeller with RF to the same csv file ( temperature2, humidity2)·, so i only need basic csv writing and reading lines. THANK YOU VERY MUCH! (It is a Uni project).
  • T ChapT Chap Posts: 4,223
    edited 2010-06-05 18:40
    www.fnarfbargle.com/bst/Latest/

    Go there and get BST for your platform. It has several options you can check for optimizing the compiled file, very simple to use and will chop off a lot of longs from your program. Use "Generic Safe Optimisations" and "Eliminate Unused Spin Methods"


    You don't really have to use an obj. I use the Vinculum and VMUSIC firmware and it is fairly easy to make up your own read/write methods to accomplish what you want to do. Basically you just open a file to read or write, then write/read the data and close the file. You may be having an issue with which protocol to use for communication. I recommend ECS and HEX which is the default boot up ( at least on VMUSIC it is).

    You can also use a 4port Full Duplex Serial object, which will allow you to use 4 different sets of i/o on one object, this will save you some room also. See the obj xchange for 4port serial. Make sure you are at the right baud.

    I highly recommend you download the Vinculum manual and read it over.

    Some examples you can use without an object:

    
    PUB OpenFile(filename)
        ser.str(2, string("OPR"))
        ser.tx(2, $20)
        ser.str(2, filename)
        ser.tx(2, $0D)
    
    PUB CloseFile(cfname)
        ser.str(2, string("CLF"))
        ser.tx(2, $20)
        ser.str(2, cfname)
        ser.tx(2, $0D)
    
    PUB ReadFile(readlen)
           rd4 := readlen >> 24
           rd3 := readlen >> 16
           rd2 := readlen >> 8
           rd1 := readlen
    
           ser.str(2, string("RDF"))
           ser.tx(2,$20)
           ser.tx(2,rd4)
           ser.tx(2,rd3)
           ser.tx(2,rd2)
           ser.tx(2,rd1)
           ser.tx(2,$0D)
    
    Pub Seek(s)         'seek to a specific location within an already open for read file
          sekval := s     'sekval is long, destination to seek for read start
          go(0,0)
          ser.hex(3, sekval, 4)
          sek4 := sekval >> 24
          sek3 := sekval >> 16
          sek2 := sekval >> 8
          sek1 := sekval
          ser.str(2, string("SEK"))
          ser.tx(2,$20)
          ser.tx(2,sek4)
          ser.tx(2,sek3)
          ser.tx(2,sek2)
          ser.tx(2,sek1)
          ser.tx(2,$0D)
    
    PUB OpenFileToWrite(filename)    'open or create file
        'ser.str(2, string("OPW"))
        ser.tx(2, $4F)  'O
        ser.tx(2, $50)  'P
        ser.tx(2, $57)  'W
        ser.tx(2, $20)
        ser.str(2, filename)
        ser.tx(2, $0D)
    
    PUB WriteFileSize(size)      '4 bytes specifies size of data to follow in WriteData
        wr4 := size >> 24
        wr3 := size >> 16
        wr2 := size >> 8
        wr1 := size
        ser.str(2, string("WRF"))
        ser.tx(2,$20)
        ser.tx(2,wr4)
        ser.tx(2,wr3)
        ser.tx(2,wr2)
        ser.tx(2,wr1)
        ser.tx(2,$0D)
    
    
    PUB WriteData(size, pointer)  | g, o    'send the data part of WriteFile
        g := 0
        repeat size
          'ser.tx(2, testbyte[noparse][[/noparse]g])
          ser.tx(2, byte[noparse][[/noparse]pointer][noparse][[/noparse]g])
          g++
        ser.tx(2,$0D)
    
    
    PUB readusb(size)   |  m, v, t, check
         t := 0
         w(500_000)   'delay required else usb hangs
         m := 0
         Repeat until t == size          '<<<<<warning flag  leave at 64
           v :=  ser.rxtime(2, 200) '   (z, 100)   'read more, port 0, wait 2 ms if no byte
           If v == -1
             Return  -1
           ResponseArray1[noparse][[/noparse]m] := v
           m++
           t++
           if check < 54 'detect/remove previous vinculum response left overs if below first 54 bytes
            if  ResponseArray1[noparse][[/noparse]m - 3] == $5C   'vinc left over info string
             if  ResponseArray1[noparse][[/noparse]m - 2] == $3E   'vinc left over info  string
               if  ResponseArray1[noparse][[/noparse]m - 1] == $0D  'vinc left over info  string
                 m := 0              'reset all if old string rec'd
                 t := 0              'reset all if old string rec'd
                 check := 0          'reset all if old string rec'd
           'w(100000)
           check++
    
    
    PUB eSync | y
        repeat until y == $45
         ser.str(2, string("E")) 'returns $45
         ser.tx(2, $0D)
         y := ser.rx(2)
         waitcnt(500_000 + cnt)
        repeat until y == $65
         ser.str(2, string("e")) 'returns $65
         ser.tx(2, $0D)
         y := ser.rx(2)
         waitcnt(500_000 + cnt)
    
    PUB ReadFileFromUSB(size, startaddr, filename)  'how to set to read if above 64bytes?
         'if size is greater than current file size, device pads FE
         ser.str(3, filename)
         OpenFile(filename)
         if startaddr > -1
            seek(startaddr)
         ReadFile(size)  'read the file  at start, using readsize
         readusb(size)
         WritePage(eeprom2, eepromwriteindex, @ResponseArray1, size)      'for writing to eeprom
         CloseFile(filename)
    
    
    PUB WriteFileToUSB(size, startaddr,filename)    'open and write a file
         'cls
         'go(0,0)
         'ser.str(3, string("Writing USB"))
         OpenFileToWrite(filename)  'open or create file
         if startaddr > -1
            seek(startaddr)
         WriteFileSize(size)   'hex size we are going to send
         WriteData(size, @USBbuffer)
         CloseFile(filename)
         eSync
    
    
    PUB  MakeDir
         ser.str(2, string("MKD CCC"))
         ser.tx(2, CR)
         ReadSerial(2)
    
    
    PUB  DIR
         ser.str(2, string("DIR"))
         ser.tx(2, CR)
         ReadSerial(2)
    
    
    
    PUB  cdup
         ser.str(2, string("CD"))
         ser.tx(2, $20)
         ser.tx(2, $2E)
         ser.tx(2, $2E)
         ser.tx(2, CR)
         ReadSerial(2)
    
    
    
    
    
    
    

    Post Edited (Todd Chapman) : 6/5/2010 6:46:39 PM GMT
  • koze85koze85 Posts: 18
    edited 2010-06-06 18:30
    Superb!! that tool saved me a lot off space but i added a few more options on the optimasation tab. Thank you
Sign In or Register to comment.