Shop OBEX P1 Docs P2 Docs Learn Events
Need help reading file from VMusic2 — Parallax Forums

Need help reading file from VMusic2

VadooVadoo Posts: 92
edited 2011-07-23 01:03 in Propeller 1
I just brushed a couple years of dust off this project, so I have some memory refreshing to do. So lets start small. :)

FullDuplexSerialplus.getstr(@TempBuff[0],512)

I know this isn't right but I think it will help show what I am trying to do.
I want to read a file 512 bytes at a time, and store it in a buffer for use in other parts of the program. I have looked at a couple other objects, but don't know what I need exactly. I have found plenty of SPI objects that would work, but I'm using the UART interface...

Thanks!
«134

Comments

  • StefanL38StefanL38 Posts: 2,292
    edited 2011-06-20 21:51
    as far as I have understood what you want to know
    CON
      RxPin = 31
      TxPin = 30
      Mode  = 0
      Baud  = 115200
    
    OBJ
      Serial : "FullDuplexSerialPlus"
    
    
    VAR
      byte TempBuff [512]
    
    
    PUB ReadInFile
      Serial.Start(RXPin,TxPin,Mode,Baud)
    
      Serial.GetStr(@TempBuff)
    

    if this doesn't hit what you want to know. Please give a more specific description of it

    keep the questions coming
    best regards

    Stefan
  • VadooVadoo Posts: 92
    edited 2011-06-21 06:52
    StefanL38 wrote: »
    as far as I have understood what you want to know
    CON
      RxPin = 31
      TxPin = 30
      Mode  = 0
      Baud  = 115200
    
    OBJ
      Serial : "FullDuplexSerialPlus"
    
    
    VAR
      byte TempBuff [512]
    
    
    PUB ReadInFile
      Serial.Start(RXPin,TxPin,Mode,Baud)
    
      Serial.GetStr(@TempBuff)
    

    if this doesn't hit what you want to know. Please give a more specific description of it

    keep the questions coming
    best regards

    Stefan

    Yes. But I want to read 512 bytes at a time, store it, use it, and then reload the buffer with the next 512 bytes. The file is not a zero terminating file. Its just a long line of shift register commands.
  • StefanL38StefanL38 Posts: 2,292
    edited 2011-06-21 07:05
    please provide a datasheet and manual of the VMusic2 how this device sends the data to the propeller.

    keep the questions coming
    best regards

    Stefan
  • VadooVadoo Posts: 92
    edited 2011-06-21 09:31
    StefanL38 wrote: »
    please provide a datasheet and manual of the VMusic2 how this device sends the data to the propeller.

    keep the questions coming
    best regards

    Stefan

    www.ftdichip.com/Support/Documents/DataSheets/.../DS_VMUSIC2.pdf

    I think this will help.
  • StefanL38StefanL38 Posts: 2,292
    edited 2011-06-21 10:18
    no it did not help link broken.

    all I could find was
    http://www.ftdichip.com/Support/Documents/DataSheets/Modules/DS_VMUSIC2.pdf

    but in this document only the spi-interface is described.

    so I searched for VMusic2 source code and came up with this BASCOM-AVR basic code
    http://www.surplusgizmos.com/assets/images/vmusic2/Vmusic2_demo.bas

    So until now I haven't found any useful information about how to communicate via UART with the VMUSIC2 device

    I guess you have already some code running
    Please attach this code to a posting. I like to help but only if the starter of the thread does his "homework"

    So keep the CONCRETE questions coming

    best regards

    Stefan
  • VadooVadoo Posts: 92
    edited 2011-06-21 10:38
    StefanL38 wrote: »
    no it did not help link broken.

    all I could find was
    http://www.ftdichip.com/Support/Documents/DataSheets/Modules/DS_VMUSIC2.pdf

    but in this document only the spi-interface is described.

    so I searched for VMusic2 source code and came up with this BASCOM-AVR basic code
    http://www.surplusgizmos.com/assets/images/vmusic2/Vmusic2_demo.bas

    So until now I haven't found any useful information about how to communicate via UART with the VMUSIC2 device

    I guess you have already some code running
    Please attach this code to a posting. I like to help but only if the starter of the thread does his "homework"

    So keep the CONCRETE questions coming

    best regards

    Stefan

    Here is something I was using at one point to play with this problem.

    CON
    _xinfreq = 5_000_000
    _clkmode = xtal1 + pll16x

    RX=25
    TX=24

    VAR
    byte temp1[256]
    long index
    long temp2
    long temp3
    long numbyte

    OBJ
    VMusic2: "FullDuplexSerialplus"

    PUB SYNC
    numbyte := 24
    VMusic2.Start(25, 24, 0, 9600)

    VMusic2.str(string("OPR Data.HLX", 13))



    VMusic2.str(string("RDF 24", 13))



    VMusic2.getstr(@temp1, numbyte)

    waitcnt(clkfreq * 4 + cnt)
    VMusic2.Start(31, 30, 0, 9600)

    repeat until temp1[index] == 0
    VMusic2.tx(temp1[index])
    waitcnt(clkfreq/10 + cnt)
    index++


    I have a data sheet somewhere with all of the commands for the VMusic. I'm currently searching a couple TB worth of hard drives to find it!
    But all I really need for this part is the OPR command to open the file, and RDF to read the file. Then you tell it how much of the file you want to read I believe. Like I said, I'm still trying to refresh my memory :(
    I think the problem I was running into was I could only get so much data at one time using the FullDuplexSerialplus Object.
    I'm going to look over old notes and play with this a bit more and see if I can be more specific.
  • StefanL38StefanL38 Posts: 2,292
    edited 2011-06-21 10:53
    If I remember right the FDX+-driver has a receivebuffer of only 16 bytes. So even receiving 24 bytes is a problem.

    Go try to receive only 10 bytes and look if this is working properly.
    If yes go try receiving 16 bytes.
    Then 17 bytes and check if this is still working

    There are modifications of the fds-driver with a larger receive-buffer. If the buffer is changed to HUB-RAM you can increase the buffer up to kilobytes.
    But I don't have the modified driver handy. I remember a modified version in the obex called serial mirror which uses hub-ram. There you can increase
    the receivebuffer-size and test if this solves the problem.

    minimum what you should do about code is using the "[ code ] [ /code ] commands to make code look like in the propellertool with indention.
    If you just cut and paste the indention gets lost and it makes the coe hard to read.

    To say it very clear. You load more work than nescessary onto us (the forum-members)
    If you keep this "I keep the work very short for me (and long for you)"-style I will refise to help any more.

    So in the next posting I expect from you to attach your complete code to a posting using the Go advanced Button and the Attachement-Manager
    And including an example of what your serial terminal-software is receiving from
    repeat until temp1[index] == 0 
      VMusic2.tx(temp1[index])
      waitcnt(clkfreq/10 + cnt)
      index++    
    
    and supporting what is originally stored on the usb-drive so that it will be easy for us to compare stored and received data

    keep the DETAILS coming
    best regards

    Stefan
  • VadooVadoo Posts: 92
    edited 2011-06-24 14:16
    I found it! Here is the manual for the VMusics's Vinculum firmware. Thats all I have right now. Ill have more information to answer your questions a little later. Gotta play around some and see where Im at.
    Thanks!
  • VadooVadoo Posts: 92
    edited 2011-06-24 17:45
    Ok so heres where I'm at. I now have a working watered down shift register driver object for easy testing. All I have to do is call the object and send it a variable with the stored data.
    So now I'm back on trying to read the data from a thumb drive using the VMusic2 and storing it to a variable. I'm going to try using the FDSP object and see if I can read its maximum allowed bytes (which I think we decided was 16?), then I'll have to figure out how to scale it up so I can get 512 at a time to work with the full version of my program.
  • VadooVadoo Posts: 92
    edited 2011-06-24 20:44
    If you have:

    cogon := (cog := cognew(SHIFTout (10, 12, 11, temp) ,@stack)) >0


    and:

    PUB SHIFTout (Clock_pin, Latch_pin, Strobe_pin, DATA)

    How can you pass on temp if temp is:

    VAR
    long temp[2]

    I seem to be getting temp[0] only but when I try to use temp[1] from the PUB SHIFTout its empty though I know it has data stored to it. I know I'm not doing it right but I cant find the correct way to pass on temp[2] so far.

    Sorry I still cant figure out the correct way to post code here. How do you use the "[ code ] [ /code ] commands?

    Thanks!
  • Mike GreenMike Green Posts: 23,101
    edited 2011-06-24 20:51
    What's the rest of SHIFTout? Is it written to run as a separate cog? If not, what you're doing won't work.

    attachment.php?attachmentid=78421&d=1297987572
  • VadooVadoo Posts: 92
    edited 2011-06-24 21:06
    Its a little ugly looking right now. Iv'e been changing a lot of things testing it out. I'm working on setting this up so when I figure out how to get my VMusic to read a file, I can send it to this object and use at least a couple longs worth of data at a time.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-06-24 21:15
    Yep. You're trying to pass an array as the last parameter of SHIFTout and that just doesn't work. You need to pass the address of temp to SHIFTout like this: @temp
    You then need to treat it as an address within SHIFTout. Instead of writing out[index], you need to write byte[out][index]
    Look up BYTE in the Propeller Manual for an explanation.
  • VadooVadoo Posts: 92
    edited 2011-06-24 21:21
    I actually tried both of those and still couldnt get it to work. Ill try to rewrite and post what I was trying earlier real quick....
  • VadooVadoo Posts: 92
    edited 2011-06-24 21:31
    I think this is basically one of my earlier attempts. I am using a custom board which has two 16 bit shift registers. Each output has an led directly on the board. I get half of each shift register (8 outputs each) to turn on, then they turn off (with the programmed in delays). Its like nothing is stored in the [index++].
  • Mike GreenMike Green Posts: 23,101
    edited 2011-06-24 21:48
    If I were you, I'd throw it all out and start with the clocked serial output routine in BS2_Functions (SHIFTOUT) from the Object Exchange. This handles single or multiple byte values as single 8, 16, 24, or 32 bit numbers. You should avoid thinking about additional cogs until you get things working and determine that another cog is necessary, then spend some time understanding how to program with multiple cogs. There are some tutorials for the Propeller Education Kit that might help.
  • VadooVadoo Posts: 92
    edited 2011-06-24 22:06
    The BS2 object looks like it would still have to be modified the same way as what I am using now if I where to use more then 32 bits.
    Ill play around with it tomorrow and see what I can come up with. I already have a much larger working program. Im just trying to modify it to work with a VMusic2. It originally worked with an sd card reader. The main issue I have is finding or making an object that can buffer 512 of a file at a time. The shiftout object is just to test it once its running, in small scale. Any objects out there with a larger buffer that can do this?
  • Mike GreenMike Green Posts: 23,101
    edited 2011-06-25 07:28
    You use the SHIFTOUT or SHIFTIN to handle a byte at a time or a word at a time or a long at a time and do the buffering yourself in a routine that calls SHIFTOUT or SHIFTIN. By not using a separate object and keeping SHIFTOUT or SHIFTIN in your main program, you can reference the buffer globally rather than having to pass its address around.
  • VadooVadoo Posts: 92
    edited 2011-06-25 09:10
    Ok ill try to play with that in a little bit. You gave me a couple different ideas.
  • VadooVadoo Posts: 92
    edited 2011-06-25 11:54
    Iv'e made a working object for testing simple control over my shift register board. :)

    I did work on making this one much easier to read, and made notations.
  • VadooVadoo Posts: 92
    edited 2011-06-25 11:58
    I have also made this which is showing signs of being able to read something from the vmusic2, buffer, and shift it out to the shift registers. Its not working right, but it is accessing the the vmusic2 and it is making things blink on the sr board. I dont think I have my bits and bytes and buffers set right for the object communication with the vmusic2.


    Edit: Wrong file, Ill repost the correct one in a few.....
    Edit: Here it is.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-06-25 16:11
    Vadoo wrote: »
    The main issue I have is finding or making an object that can buffer 512 of a file at a time. . . . Any objects out there with a larger buffer that can do this?

    I have several modified versions of Tim Moore's four port serial object. One of the versions uses a 512 byte rx buffer. I've posted the objects on this thread.

    Duane
  • VadooVadoo Posts: 92
    edited 2011-06-25 17:05
    Duane Degn wrote: »
    I have several modified versions of Tim Moore's four port serial object. One of the versions uses a 512 byte rx buffer. I've posted the objects on this thread.

    Duane

    Thanks Duane! Ill take a look at it in a bit. I'm still fighting to get my object to read correctly. :(
  • VadooVadoo Posts: 92
    edited 2011-06-25 19:40
    I'm stuck...
    This is the best I have been able to do.This object is storing something to my little buffer. But not sure what. Its defiantly not playing what is in the seqnum01 file correctly.
    Attached is the file I'm trying to read. It has data for controlling my 32 bit shift register board.
    Anyone have any ideas?

    seqnum01.spin should be seqnum01.hlx It would not let me upload it without changing the extension...
  • VadooVadoo Posts: 92
    edited 2011-06-25 20:02
    I noticed I was shifting out 16 bits though I had only stored 8. This copy fixes that, though still has not fixed my overall problem of not receiving the correct sequences from the VMusic2.
  • VadooVadoo Posts: 92
    edited 2011-06-26 16:04
    So I almost gave up on UART and started working on creating an SPI object since there seems to be a LOT more support for it. But then I came across this:

    http://forums.parallax.com/showthread.php?90387-Simple-Propeller-Vinculum-Test-Program&p=620161

    Post #7, Jim C posted an object that looks promising. Iv been playing with it for a bit now and so far the communication works fine, but better then that it is set up to show me everything going on through the pc terminal.
    Next I will work on storing the data to an address to use for the shift register board.
  • VadooVadoo Posts: 92
    edited 2011-06-26 21:21
    This is the best I could come up with over the weekend. Still not right. I'm considering again switching from UART to SPI.
    Anyone have any ideas/advice yet?
  • VadooVadoo Posts: 92
    edited 2011-06-28 10:30
    It looks like one problem I'm having is no flow control when reading from the VMusic2. I can get data from it, and even store it. But when I store it, it's a little mixed up and missing things or even has some extra things. Is there something I can do to include some sort of flow control in my object while still using UART?
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2011-06-28 16:49
    Hi Vadoo, every instruction transmitted to the Vmusic has a reply which ends with a prompt followed by $0D. Waiting for this sequence of bytes after each and every instruction and before transmitting the next should keep everything synchronized.

    I have not looked at all the files that you posted but one that I did scan had open file ,read file and close file as three consecutive instructions. In my opinion before the instructions read file and close file there should be a check to see if the prompt and $0D were received from the previous instruction. One it keeps all the instructions flowing in a timely manner and two if the prompt $0D is not received you know something went wrong and can handle the error accordingly.

    Jeff T.
  • VadooVadoo Posts: 92
    edited 2011-06-29 14:12
    Hi Vadoo, every instruction transmitted to the Vmusic has a reply which ends with a prompt followed by $0D. Waiting for this sequence of bytes after each and every instruction and before transmitting the next should keep everything synchronized.

    I have not looked at all the files that you posted but one that I did scan had open file ,read file and close file as three consecutive instructions. In my opinion before the instructions read file and close file there should be a check to see if the prompt and $0D were received from the previous instruction. One it keeps all the instructions flowing in a timely manner and two if the prompt $0D is not received you know something went wrong and can handle the error accordingly.

    Jeff T.

    What about receiving data from it? How can I best store the data? It seems the way I was doing it had to many steps, and I would miss little bits of the data because I was doing too much at once in my code. I then just set it up to directly store what UARTdebug.spin saw coming from the VMusic2, to a datptr, but that gave me slightly mixed up data. It was general correct but it would have mixed up parts in it.
Sign In or Register to comment.