Shop OBEX P1 Docs P2 Docs Learn Events
help with USB datalogger 27937 — Parallax Forums

help with USB datalogger 27937

matthew2matthew2 Posts: 5
edited 2009-05-01 02:15 in Propeller 1
I'm trying to set up an application that can log data locally when it wants to using the Parallax Memory Datalogger #27937. Currently I am using the code which is available on the Parallax Object Exchange, USBdrive and FullDuplexSerial (I am trying to take advantage of the UART communication mode in order to later combine it with the other UARTs I already have running).

However, I'm at a standstill and am not sure what is going wrong. I currently have the setup as follows:

27937 pin list

Pin 1 Vss
GND
Pin 2 RTS#
1K pulldown to GND and Pin 18
Pin 3 Vdd
Vcc, 5V
Pin 4 RXD
Pin 20
Pin 5 TXD
Pin 21
Pin 6 CTS
1K pulldown to GND and Pin 19
Pin 7 NC floating
Pin 8 RI floating

The problem is that the start function in USBdrive.spin doesn't pass the BigE (transmitting a serial E and reading it back, which is in the USBdrive file) test. I can't figure out what I'm doing wrong, does anyone have any suggestions?

Comments

  • T ChapT Chap Posts: 4,223
    edited 2009-04-08 15:05
    Possibles issues may be your USB driver. Do you see activity lights when you plug a USB driveinto the device itself?
  • TJHJTJHJ Posts: 243
    edited 2009-04-08 16:03
    Pin 5 should have a 1k resistor in line with it and the prop. If I am reading that right. The Tx from the datalogger to the prop. 5v Device interfacing. I dont know why sometimes this makes such a big difference. Maybe give it a shot.

    I think its 2gig limit on the drive. Fat 16 is 2 gigs right? If its to big the drive will simpily·not respond. Also it doesnt work·with the dumb scan·disk ones from radio shack, becasue they have the weird 2 drive mount thing. It mounts the wrong·one. That annoying install this software one....

    TJ


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I owe everyone here a bunch, So thanks again for answering my dumb questions.
    Projects. RG500 ECU system. PropCopter. Prop CanSat. Prop Paste Gun.
    Suzuki RG500 in a RGV 250 frame.
    Bimota V-Due (Running on the fuel injection system)
    Aprilia RS250
  • matthew2matthew2 Posts: 5
    edited 2009-04-08 18:50
    Thanks for all the help so far, here is an update:

    I've got the Datalogger recognizing the USB and giving me the ok-to-go red light. Now, I'm trying to open a file "Test.txt" and writing "Hello world" to it.

    The functions that I use to do this; open, write, and close, all return TRUE but there is no data to be found on the USB when I plug it into my computer.

    The red led does flash when I run the code, signifying there is data transfer from the propeller to the datalogger.

    Is it possibly the formatting of the USB? It's a 2GB kingston drive that I have formatted to Fat32

    Post Edited (matthew2) : 4/8/2009 7:36:13 PM GMT
  • KenBashKenBash Posts: 68
    edited 2009-04-08 19:30
    I experienced odd results myself not long ago trying to get a flash drive interfaced with the prop using the memorystick datalogger. The prop WAS writing data to the drive because I could open up the drive afterward and see that it had wiped out everything that was there before and left a series of file folders on the drive. However, there was no data in any of these folders.

    I didn't have time to dig into it any further but if you get a program running that WILL let you read and write data to a flash drive and also allow you to open it on the PC... Please post the code. If I get back on the project and get it working, I'll do the same.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    " Anything worth doing... is worth overdoing. "

    ··············································· ( R.A.H. )
    ····································
  • T ChapT Chap Posts: 4,223
    edited 2009-04-08 20:09
    I recently out of curiosity tried to connect a USB/Firewire hard drive to the Vinculum, there was activity lights but nothing got written, so just because you see activity doesn't always mean there will be a result.

    Try some other tests like creating a file. I also suggest that you go to Vinculums site and download the manual for the firmware you are using.

    I thought that Green meant ready on the Vmusic2, maybe your device is different.

    Do post the code you are using.

    Oh, you definitely have to make sure you are using the correct modes, i.e. hex, ascii, Extended, Short, etc. I forget the default input modes but I think it is Extended on boot. If you are sending it commands in one mode and it is in another, there will be problems.

    What is provided in the code to monitor the Vinculum 'monitor'? You need a TV or LCD at a minimum.

    Here is code I use on the Vmusic2, very similar to the Vdap. The code is for the 4 port so the "2" is for port 2, ignore that.

    PUB eSync | y
        cls
        repeat until y == $45
         ser.str(2, string("E")) 'send an "E"   and it should soon return E $45
         ser.tx(2, $0D)    
         y := ser.rx(2)
         'ser.hex(3, y, 2)      'display if using LCD
         waitcnt(1_000_000 + cnt)
        repeat until y == $65    'send e, it should return e
         ser.str(2, string("e")) 'returns $65
         ser.tx(2, $0D)
         y := ser.rx(2)
         'ser.hex(3, y, 2)    'display if using LCD
         waitcnt(1_000_000 + cnt)
    




    Code that works to open a file:

    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)
    

    Post Edited (TChapman) : 4/8/2009 8:25:15 PM GMT
  • MGreimMGreim Posts: 114
    edited 2009-04-10 16:42
    I spent two week with the Vinculum and the PROPELLER. I was using the SPI mode (some said worse then the UART mode) .
    My result is that FAT 32 doesn't work!
    Same code same stick (i tested Kingston 1 GByte and Imation 512MByte)
    Formated as FAT16 (workings so la'la) FAT 32 not working. There is some comunication between the stick and the
    Vinculum, i can read data, bit i am not able to write a file on FAT32!
    I am now waiting (or hoping) for a new better firmware for the Vinculum, bit i am not very optimistic.


    Regards

    Markus Greim
    Germany
  • T ChapT Chap Posts: 4,223
    edited 2009-04-10 16:49
    I am not sure what your issue is with FAT16 or FAT32. I use the Vinculum and a USB drive daily for writing, reading, etc, it works very well once you learn how to talk to it. I don't think you need a new firmware just to work with a thumbdrive. If you post code you can get better results here rather than leaving it up in the air as to what you are actually doing.
  • MGreimMGreim Posts: 114
    edited 2009-04-11 16:24
    Hello,

    i am using the

    Datalogger SPI mode

    object from
    /* December 24, 2007 v1.0: Initial release.
    * @author Peter Verkaik (verkaik6@zonnet.nl)
    */
    from the PObject Exchange.

    My own code is

    /********************************************************************************/

    PUB usbschreiben

    logger.DataloggerSPI(SPI_CS,SPI_CLK,SPI_SDI,SPI_SDO)
    waitcnt(clkfreq / 4 + cnt) ' Wait for 250ms initialization
    logger.receivePromptOrError(2000) ' get unsollicited message from datalogger
    if logger.diskPresent
    if logger.changeDirectory(string("\"))
    ''text.str(string("creating testdir and testfile.txt ..."))


    if logger.changeDirectory(string("SCHLUS"))

    if logger.openFileForWrite(string("TESTFILE.TXT"),0)

    if logger.writeToFile(@demobuf,strsize(@demobuf),0)
    psaver := 0
    if logger.closeFile(string("TESTFILE.TXT"))

    return 1
    else
    text.out(home)
    text.str(string("file write error"))
    else
    text.out(home)
    text.str(string("file not op. f. write"))
    else
    text.out(home)
    ''text.str(string("not moved to dir"))

    else
    logger.makeDirectory(string("SCHLUS"),0)
    text.out(home)
    text.str(string("directory created"))


    return 0


    /*************************************************************/

    This works as written with FAT16 but not with FAT32.

    Any ideas why???


    Regards

    Markus
  • Sabre00Sabre00 Posts: 30
    edited 2009-04-29 17:49
    Hello everyone,

    I have been trying for over two weeks now to communicate with the 27937 memory stick datalogger from Parallax. I bought three of the modules and all three modules I have had no success. I do not however believe it is a problem with the modules themselves.

    I tried the code from the object exchange (only the UART versions as I would have this as my preferred means of communication) and I have had no success.

    I have purchased two of the memory cards that are on the list of suggested memoty stick to use and still nothing.

    I have tried many of the suggestions in the forum ie 1K pull down resistors on the handshaking lines and inline 1K resistor with the loggers TX pin, still nothing.

    I then decided to write my own code that will "talk" to the memory stick data logger and record all the information that comes back from the logger and it still has not solved my problem. I used the capture text feature in Hyperterminal to record the data in a text file.

    I have attached the text file that I have received in the hyperterminal windown from the logger and also the code I used to "generate" the responses. I know that there is a distinct lack of "handshaking" between the propeller chip and the datalogger.

    Any help, comments questions, queries would be greatly appreciated.
  • T ChapT Chap Posts: 4,223
    edited 2009-04-29 18:41
    Someday I will get around to an object for what I have that works. This device is picky in my opinion, but when you get the magic formula it is great. There has been a lot of confusion on the Vinculum, so you are not alone. One day we need to create a complete document including schematic and settings so that there is less run around just trying to get to square one.

    I don't know about the Parallax version you bought, but the Vinculum must be programmed with firmware if not buying it preloaded. Maybe Parallax preloaded the part you have. If not, it will need the latest FW off their site, I use Vmusic firmware, forget the actual name but it operates basically the same as VDAP awith more commands related to music.

    I think you are having problems confusing how to send hex and strings to talk to it, but that's just my guess at first glance. Try using .tx whyen using a hex value, and using .str when using "x" ascii values. It should boot on ECS and IPH. Leave it on IPH (hex) as default, I think I had problems until I started using ECS and IPH. Forget ASCII mode IMO! Just reboot the device with no need to send it any setup, and it will default to ECS and IPH. Communicate as in my code and test it out. .TX for hex values, .STR for ascii values, yes you cvan send ascii values for commands even though you are in hex(IPH), but you need to send hex values for information like data, values etc.

    I will post code below that definitely works in ECS and IPH. After detecting the drive with a D:/ response, you should easily be able to test the drive with a write to file, specify the size of data to be written, specify with SEK where to write it or it will append the data. Maybe do a test and write to file some values, then put the drive in a computer to see if it got written. Then start trying to read from file(set the length to read). Skip making dir for now until you can work in the main dir, if you can read and write the main dir then you don't need top try to tackle making and changing directories. Ignore the number 2 in my code, it just specifies a serial port on a 4 port serial, just a 4 port version of full duplex which requires you to state the port. Your code will drop the #2.

    Various USB code:

    
    
    PUB eSync | y
        cls
        repeat until y == $45
         ser.str(2, string("E")) 'returns $45
         ser.tx(2, $0D)
         y := ser.rx(2)
         'ser.hex(3, y, 2)   port '3 = lcd use
         waitcnt(1_000_000 + cnt)
        repeat until y == $65
         ser.str(2, string("e")) 'returns $65
         ser.tx(2, $0D)
         y := ser.rx(2)
         'ser.hex(3, y, 2)   
         waitcnt(1_000_000 + cnt)    
    
    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, @MonitorUSBbuffer)
         CloseFile(filename)
         eSync
    
    
    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, @MonitorUSBbuffer, size)     'always store to EEPROM2?
         CloseFile(filename) 
    
    
    
    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
         check := 0
         'MonitorUSBbuffer[noparse][[/noparse]0] := ser.rx(z)  'wait here for first byte
         m := 0
         Repeat until t == size          
           v :=  ser.rxtime(2, 200) '   (z, 100)   'read more, port 0, wait 2 ms if no byte
           If v == -1
             Return  -1
           MonitorUSBbuffer[noparse][[/noparse]m] := v
           m++
           t++
           if check < 20
            if  MonitorUSBbuffer[noparse][[/noparse]m - 3] == $5C   'checking for done 
             if  MonitorUSBbuffer[noparse][[/noparse]m - 2] == $3E  'checking for done 
               if  MonitorUSBbuffer[noparse][[/noparse]m - 1] == $0D  'checking for done 
                 m := 0
                 t := 0
                 bytecount -= 5
           bytecount++
           check++                           
    
    PUB GetFirmwareSet
         go(0,0)   'lcd pos
         ser.str(2, string("FWV") )
         ser.tx(2, cr)
         readusb(16)
         'display the read now
                        
    
    
    
    




    Below is an actual method that reads from the drive, I took out other unimportant parts:


    
    PUB SWupdateSet        'update software from usb drive
        spk.beep(19, 2500, 200)
        eepromwriteindex := $00
        OpenFile(string("rev20"))    'opens file  rev20
        cls      ' clear lcd
        sekindex := 0
        sekval := 0
        ReadSize := $00000040
        repeat
         ReadSetupKeys   ' read button states
         go(0,0)
         ser.str(3, string("Update Software?"))
         if setupkeys == yesbut
          cls
          repeat 512   '448    '6fff = 4096 x 7  == 28,672 / 64 = 448
           ReadFile(readsize)  'read the file
           ReadUSB(readsize)    'read once to write buffer  to eeprom
           WritePage(eeprom1, eepromwriteindex, @MonitorUSBbuffer, 64)     'write the value from USB to EEPROM
           eepromwriteindex += 64
           sekval :=  eepromwriteindex
    
    
    

    Post Edited (TChapman) : 4/29/2009 7:02:26 PM GMT
  • Sabre00Sabre00 Posts: 30
    edited 2009-04-30 15:54
    Hey TChapman,

    Thanks for the info. it was very useful.

    I am now faced with a new problem (just my luck eh) I am trying to write a simple file and I keep getting "DISK FULL". I think that is better than a "Command Failed" error at least.

    So I change the code to make it like a DOS prompt interface and I checked the IDD command result and I noticed two things;

    1) there is no information for the "FAT" formart coming back from the logger

    and

    2) both the Capacity and the Free space are "$00000000 Bytes"
    (as per data sheet for the Vinculum VNC1L datasheet verion 1.07 table 4.3 pg 14)

    I tried formating the memory sticks in FAT32 and FAT format ( the only other option I get through Windows XP) and I got the same result. Obviously I check the disk on my laptop and it is blank. I do a properties check from the "My Computer" location and I see that is has bytes free. I also tried the "chkdsk x: /f" in the command prompt and still nothing.

    I am at a lost as to how I can resolve this issue.

    here is the result I get from the IDD command.

    for my transcend stick
    IDD

    USB VID = $058F
    USB PID = $6387
    Vendor Id = JetFlash
    Product Id = Transcend 2GB
    Revision Level = 8.07
    I/F = SCSI

    Bytes/Sector = $0200
    Bytes/Cluster = $000000
    Capacity = $00000000 Bytes
    Free Space = $00000000 Bytes
    D:\>

    for my Kingston stick

    IDD

    USB VID = $0951
    USB PID = $1625
    Vendor Id = Kingston
    Product Id = DT 101 II
    Revision Level = 1.00
    I/F = SCSI

    Bytes/Sector = $0200
    Bytes/Cluster = $000000
    Capacity = $00000000 Bytes
    Free Space = $00000000 Bytes
    D:\>


    Can anyone help?

    Sabre00...
  • T ChapT Chap Posts: 4,223
    edited 2009-04-30 19:19
    Post all the complete code of what you are doing to get the disk full error as an attachment.

    Are you getting a sync with E and e?

    Can you get a response with CR?

    Have you powered up the device with the new code you are sending?

    If you can get a response D:/ from a command CR, then try creating a small .eeprom file from any spin file Proptools where you can read in the info area what the first 16 bytes are. rename the file as anyhing you want, 'test' is fine, put the file onto the USB drive. Then do a Open File, then read 16 bytes of the the file into an array that can be displayed on LCD or terminal. Find out if you can even read from the device and compare that to the eeprom file first 16 bytes, then move towards writing the drive.

    Post Edited (TChapman) : 4/30/2009 7:35:58 PM GMT
  • Sabre00Sabre00 Posts: 30
    edited 2009-04-30 23:47
    Thanks once again for the swift reply,

    I am getting the E and e syncs.

    After I have gone through the synchronization when I press enter (CR) I do get the D:> prompt. It can be seen from the information I sent above that the prompt is also received after the information for the IDD commands were sent.

    I am just using the Hyperterminal program to enter the commands directly into the datalogger. The code does not have any software echoes, that is done by echoing the characters locally within Hyperterminal. So there is no code that does the "IDD<CR>" command automatically. When I enter "OPW test.txt <CR>", I get the "DISK FULL" comment. I kept trying other commands and that is when I saw the strange Capacity 0 and available bytes 0.

    I will attach the code anyway to show you what I did.

    Sabre00...

    <CR> stands for carriage return or simply enter
  • T ChapT Chap Posts: 4,223
    edited 2009-05-01 02:15
    I am not able to offer any suggestions with using hyperterminal It took me weeks to arrive at what I wrote above to get things working, trying every possible combination of protocol. I'd say you might want to configure your code in a manner as I have shown above, see what happens. I suggest ECS, IPH modes, which are default on boot so no need to set. In these cases, you can't use hyperterminal properly I would assume.

    From what you are describing since I can't see what is actually taking place on the terminal, it looks like you are not specifying the size to write after OPR. I never bother with CTS, RTS etc.

    Here is some code I was testing to read and write to the drive. Put some data in the array MonitorUSBbuffer[noparse][[/noparse]64], first few slots is fine just to be able to look at the drive manually later if needed from a PC to check it. In the case below, if you are testing using startaddr always as '0', the data will continue to write and read at the same location. If using -1 it will append.

    I suggest using objects for display like TV, LCD, or other means to read the results other than hyperterminal.
    
    VAR
         byte MonitorUSBbuffer[noparse][[/noparse]64] 
    
    PUB TestUSBReadWRite
         WriteFileToUSB(16, 0, string("7"))       'size, startaddr,filename    test file named 7
         waitcnt(40_000_000 + cnt)
         ReadFileFromUSB(16, 0, string("7"))     'size, startaddr, filename
    
    
    PUB WriteFileToUSB(size, startaddr, filename)    'open and write a file  ...  was testbyte changed to MonitorUSBbuffer to save ram
         cls  'lcd clear
         gotoxy(0,0)   'lcd
         ser.str(3, string("Writing USB"))   'lcd
         OpenFileToWrite(filename)  'open or create a file
         if startaddr > -1    'if the location to write to was specified, then seek to that location. else ignore seek
            seek(startaddr)
         WriteFileSize(size)   'hex size we are going to send
         WriteData(size, @MonitorUSBbuffer)     'write data stored in byte -  MonitorUSBbuffer   0 - 15
         CloseFile(filename)
         eSync   'not really needed, just waits till i gets an e
    
    
    PUB ReadFileFromUSB(size, startaddr, filename)  
         'if size sent is greater than current file size, it pads with FE
         ser.str(3, filename)  'lcd use
         OpenFile(filename) 
         if startaddr > -1
            seek(startaddr)
         ReadFile(size)  'read the file  at start, using readsize
         readusb(size)
         WritePage(eeprom2, eepromwriteindex, @MonitorUSBbuffer, size)     ' store to EEPROM2 after read
         CloseFile(filename)     'not needed really on reads
    
    

    Post Edited (TChapman) : 5/1/2009 2:31:44 AM GMT
Sign In or Register to comment.