Shop OBEX P1 Docs P2 Docs Learn Events
Simple Propeller - Vinculum Test Program — Parallax Forums

Simple Propeller - Vinculum Test Program

Mike GreenMike Green Posts: 23,101
edited 2007-12-22 16:38 in Propeller 1
Attached is a simple test program for the Vinculum in SPI mode attached to a Propeller Demo Board with a keyboard and TV monitor. It simply copies anything typed to the Vinculum (while echoing it on the display) and copies any responses from the Vinculum to the TV text display. It does translate any responses with non-displayable characters to hex, so $03 will display as {03}. A return ($0D) character is echoed directly to the display for readability.

Comments

  • parskoparsko Posts: 501
    edited 2006-12-08 19:00
    Mike,

    What kind of rates, in SPI mode, can be thrown at these chips?

    -Parsko
  • Mike GreenMike Green Posts: 23,101
    edited 2006-12-08 19:20
    They say a 10-12MHz clock is the maximum, easy to do in assembly. I'm going to have to add support in assembly for my I2C loader so programs can be directly loaded off a USB drive. There are still some issues around error responses from the Vinculum chip that need to be resolved. It seems to be possible for the controller to insert some unsolicited status messages into the response stream while you're setting up a read command. Also, if there's a problem with the read command ("RD" or "RDF"), it may not be possible to distinguish between the error message and the data (that isn't there).
  • JamesxJamesx Posts: 132
    edited 2006-12-08 19:51
    Mike:

    Thanks for the demo. I'm just at the point of getting the propeller to talk to the V-Flash, using UART and ASCII. With that in hand, I will now try your SPI method.

    Jim C
  • T ChapT Chap Posts: 4,223
    edited 2006-12-08 20:21
    What are the basic possibilities and meaning of the Vinculum new product? It would be great to see an overview in a nutshell of what the Vinculum potential is to get ideas on it's use. For example, with the Vinculum and Propeller with a keyboard and LCD or TV attached, would inputting ascii names for variables be a simple task? Or another example typing in numbers to replace a value in a variable? What I am getting at is does the Propeller become more of a self-contained computer with monitor(LCD), mouse, keyboard etc features?

    Thanks
  • Mike GreenMike Green Posts: 23,101
    edited 2006-12-08 20:51
    There already is a very fast Basic interpreter that comes with the Hydra book and CD. Andre' has mentioned that the author is working on some extensions for graphics, etc. Once we get the Vinculum to work reliably with the Propeller, it would be straightforward to add statements to the Basic interpreter to load and save programs and to read and write text data to files. At that point, you have a self-contained Basic computer.
  • Jim CJim C Posts: 76
    edited 2006-12-09 00:30
    Mike:

    Here is a simple test routine for assessing the V_Drive. It is done differently from yours, in that it uses a terminal program to view the output from the V_Drive. It uses a second Full Duplex in its own cog to send commands and data to the V_Drive, set up in UART mode. I'm sure there are slicker ways, but is was a way for me to visualize what is going on.
    OBJ
      debug : "pc_debug"
      UART:  "UART_Debug"
    
    PUB main | idx
      cognew(Printer, @Stack)     
      debug.start(230400)                     'set up debugging on RealTerm
      UART.start(9600)                        'second full duplex setup for V_Drive       
      debug.str(string(CR, LF,CR, LF, "USB Drive", CR, LF))       ' print string
      UART.str(string("IPA", CR))             'Input numbers as ASCII
      UART.str(string("OPW FILE.3",CR))       'open new file
      UART.str(string("WRF 14",CR,"Hello World!! ")) 'save 14 characters
      UART.str(string("CLF FILE.3",CR))       'close file
      UART.str(string("RD FILE.3", CR))       'read it to confirm
      UART.str(string("DLF FILE.3", CR))      'Delete it so it can be created again next time.
      UART.str(string("E", CR))               'Synchronizing character
    
    PUB Printer
      repeat                             'this keeps printing in the background
        debug.out(UART.in)               'anything that V_Drive sends out goes to RealTerm
    
    



    Jim C
  • Mike GreenMike Green Posts: 23,101
    edited 2006-12-09 00:40
    Both of these do pretty much the same thing. I can type in the commands you've given and they show the same display. The trick is to handle all the error conditions in a reasonable way without human intervention so the Vinculum can function like any other I/O device (like the display, a UART, a keyboard, etc.)
  • GavinGavin Posts: 134
    edited 2006-12-09 04:52
    There has been a few camera interfacing posts, with Vinculum how about a USB camera interface?
    I understand the FTDI chip itself can handle 2 x USB ports, one Thumbdrive and one camera, stereo cameras?
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-12-09 06:24
    If you look on thier website youll see an application where a camera can offload its pictures to a thumbdrive, but this is using the camera as a disk drive. The streaming USB hosting is a little light on details at this point. My understanding is it may be possible if you already know the format and have experience doing that sort of thing, but it is by no means plug and play at this time.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • Mike GreenMike Green Posts: 23,101
    edited 2006-12-10 04:17
    Just for fun, here's a version of the Vinculum test program that uses Chip's 1024x768 tiled VGA driver. It's otherwise the same as the TV one.
    I've included a copy of his driver in the archive.
  • mcstarmcstar Posts: 144
    edited 2007-08-28 17:28
    Mike (and others),
    ·Has anyone been able to determine the fix for the Vinculm error's codes being inserted into read responses?
    Perhaps, the vinculum switches the RTS·or CTS pin states before sending it's extra gibbersih data?· That might be a key to detecting the transmissions.· It may also be that software handshaking is turn on. Table 4.8 shows how to change this.

    I'm expecting a Memory DataLogger this week and look forward to working with it to communicated with other devices via the prop.· I've noticed that the vinculum chip has a number of free io pins. Can these be used to·read from other devices like keyboards and mice?· Has anyone tryed using the vinculum's IO pins?··I see commands to read them (QP1 and QP2) but haven't seen anything on writing to them yet. It seems like a great way to effectively expand the number available pins for use by the prop.· Basically, with the prop using 4 pins to communicate with the vinculum via SPI, you get 20 free vinculum IO pins (pins 11-23 and pins 41-48).· This is enough for a number of perpherials perhaps even an LCD display if there are send commands as well.


    UPDATE :
    There is a new version of the vinculum firmware documentation...
    http://www.vinculum.com/documents/fwspecs/Vinculum%20Firmware%20User%20Manual%20V2.1%20Rev%202.pdf
    assuming it's the same version that the datalogger has (I don't have mine yet), there is a write command for the IO pins (command IOW in section 6.4.2).· It looks like driving a Parallel LCD and other things via SPI from the prop is very doableyeah.gif

    Post Edited (mcstar) : 8/28/2007 5:43:48 PM GMT
  • Goran (Sweden)Goran (Sweden) Posts: 68
    edited 2007-09-05 21:28
    Mike and others,

    I have loaded·Mike's "Test program for Vinculum and Propeller Demo Board "
    I had a hard time to figure ot how to achive the following without using the keyboard

    What I want to achive is·using the spin program to send the following strings instead of using the keyboard to enter the string.

    Hope somebody could help on this.

    I have spent many hours trying but can't figure out how to do.
    I am using the Vinculum USB and it works fine using the keyboard.

    Regards Goran Sweden·confused.gif

    · (string("IPA", CR))············ 'Input numbers as ASCII
    · (string("OPW FILE.3",CR))······ 'open new file
    · (string("WRF 14",CR,"Hello World!! ")) 'save 14 characters
    · (string("CLF FILE.3",CR))······ 'close file
    · (string("RD FILE.3", CR))······ 'read it to confirm
    · (string("DLF FILE.3", CR))····· 'Delete it so it can be created again next time.
    · (string("E", CR))·············· 'Synchronizing character
  • Mike GreenMike Green Posts: 23,101
    edited 2007-09-05 23:00
    Goran,
    Your code "snippets" only show the string, not the outer call. I assume you are going to send these with a serial driver. I've been using the FullDuplexSerial driver with a music playing program. You will need some kind of pause between commands or you will need to check for the prompt (or error message) from the Vinculum chip. You could do something like this sort of framework:
    OBJ ser : "FullDuplexSerial"
    PUB begin
       ser.start(recvPin,xmitPin,%0000,9600)
       repeat 4
          waitcnt(clkfreq + cnt)
       ser.str(string("IPA",CR))
       waitcnt(clkfreq/2 + cnt)
       ser.str(string("OPW FILE.3",CR))
       waitcnt(clkfreq/2 + cnt)
    
    
  • Goran (Sweden)Goran (Sweden) Posts: 68
    edited 2007-09-06 06:05
    Mike,

    Well I did not explain properly.
    What I tried is to instead of the keyboard use a string inside the spin program.
    Code snippet from your "Test program for Vinculum and Propeller Demo Board"

    Any idea
    Regards, Goran

    PUB start | t, s
    · dsp.start(12)·················· ' TV pin block for Demo Board
    · key.start(26,27)··············· ' Keyboard pins for Demo Board
    · dsp.str(string("Vinculum Test Program",EOL))
    · outa[noparse][[/noparse]RESET]~··················· ' Reset device
    · dira[noparse][[/noparse]RESET]~~
    · outa[noparse][[/noparse]SPI_CS]~·················· ' Select normally low
    · dira[noparse][[/noparse]SPI_CS]~~
    · outa[noparse][[/noparse]SPI_CLK]~················· ' Clock normally low
    · dira[noparse][[/noparse]SPI_CLK]~~
    · dira[noparse][[/noparse]SPI_DATA]~················ ' Data initially input
    · outa[noparse][[/noparse]RESET]~~
    · s := 0
    · waitcnt(clkfreq / 4 + cnt)····· ' Wait for 250ms initialization
    · repeat
    ··· if s == 0···················· ' Buffer not full in Vinculum?
    ***********************************************************************************
    Here I want to take a string for example
    "IPA" from a DAT section in the spin program
    and transmit this via SPI to the Vinculum chip

    i.e replace the····· s := key.key··············· ' Look for typed character
    with s:=(@IPA)
    and send a byte at a time.

    ***********************************************************************************
    ··· if s > 0····················· ' Character pending?
    ····· if (transfer(false,false,s) & 1) == 0
    ······· dsp.out(s)··············· ' If transmitted ok, echo to display
    ······· s := 0··················· ' Allow another
    ··· if ((t := transfer(true,false,0)) & 1) == 0
    ····· t := t >> 1 & $FF·········· ' If character read from Vinculum
    ····· if t & $7F => " " or t == EOL
    ······· dsp.out(t)··············· ' Display all displayable characters
    ····· else
    ······· dsp.out("{")············· ' Or display hex code of others
    ······· dsp.hex(t,2)
    ······· dsp.out("}")

    DAT

    IPA· Byte "IPA",0
  • mcstarmcstar Posts: 144
    edited 2007-09-10 15:25
    Mike,
    I'm trying to use your Vinculum test in SPI mode. However I'm confused by the pinouts. In the vinculum docs and the parallax document, the following pins are listed.... SDO, SDI, SCLK, and CS. However, in your code, I see RESET, SPI_CLK, SPI_DATA and SPI_CS. I can assume the following relationships. SPI_CS -> CS and SPI_CLK -> SCLK, but I'm confused by the other pins. Which DATA line is controlled by the SPI_DATA pin (SDI, or SDO)? Also, what is the RESET line? Does it go to one of the data lines? Actually, I'm a bit confused how this works at all. According to the FTDI documentation (VNC1L USB Host Controller Datasheet version 0.97 section 2.5) shows both data lines used to do a read or a write. In Read mode, SDI is shown sending a preamble of 110 before reading SDO for 8 bits. In Write mode SDI sends the preamble 100, then it sends the 8-bits... during this time, the SDO line is meaningless until after the 8th bit, then it recieves a status bit from the controller. I don't see the preambles or status handling in your code. Am I missing something, or maybe I have a different version of the Vinculum?

    Update... OK, now I see the preambles. They are the bits ANDed with the data and shifted into the data variable. Sorry I missed that.· From this I can presume that the SPI_DATA pin is acutally the SDI line.· However, I don't still don't see how you are able to read data from the Vinculum. The Vinculum docs show that is it sends data on the SDO line, a differnt pin than the input data, but I don't see any code reading from a line other than the SPI_DATA line (the same one that is sending the data).· Does your chip read and write from the same data line?

    Post Edited (mcstar) : 9/10/2007 3:36:24 PM GMT
  • ahanktcdahanktcd Posts: 8
    edited 2007-09-10 18:03
    Is it possible to use this sample code to talk to Parallax's Memory Stick Datalogger via SPI? Is there an advantage to using SPI over serial/UART/ASCII? I have found that using the Datalogger with a BS2-px at 9600 baud, the commands process quickly (couple milliseconds), but writing to the USB drive is really slow (500ms). Any ideas if this speed can be improved using SPI and a Propeller?
  • mcstarmcstar Posts: 144
    edited 2007-09-10 19:08
    Yes, the sample code seems to work in principle.· I've rewritten it slightly to work with two data lines SDI(nput) and SDO(utput) and it seems to be working well. I also made it work with propterminal since I don't have the video or keyboard on my robot. As far as speed goes, not sure yet.· I can tell you it works, but not how fast.· The sample code Mike put up here is in spin and clocks the vinculum as fast as the code executes.·· I chose to use SPI because of its low pin count and so that I didn't have to worry about timing when it comes to sending and receiving data.· The FTDI documentation says you can clock the SPI lines at up to 12MHz.· The docs also say the data's buffered, so I'm not sure what would limit the speed (probably how fast the usb thumb drive is).

    ·
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-12-21 09:28
    mcstar,
    Could you post your modified program?
    I don't have a keyboard/tv either and since you appear to have a working
    demo with a terminal, that should save me and others some time.

    Thanks.
    regards peter
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-12-22 08:31
    Mike,
    I adapted your test program for the spin stamp and a terminal output,
    and I have some questions regarding the transfer method.

    First, since your transfer only uses SPI_DATA, I assume the Vinculum SDO connects to
    Vinculum SDI via a (1k) series resistor and that Vinculum SDI connects via 1k resistor
    to the prop pin SDI_DATA. Is that correct?

    Secondly, the first line in transfer
    · data := $800 | $400 & read | $200 & status | data << 1
    and·directly after the repeat
    ··· dira[noparse][[/noparse]SPI_DATA] := i < 4 or i < 12 and not read
    I rewrote the transfer to transfer1·where I put·brackets
    to make the·order more obvious.
    · data := $800 | ($400 & read) | ($200 & status) | (data << 1)
    ··· dira[noparse][[/noparse]SPI_DATA] := (i < 4) or ((i < 12) and (not read)) '1 for i=[noparse][[/noparse]1..3], 0 for i=12, not read for i=[noparse][[/noparse]4..11]
    Is that·correct?

    Third, the line
    ··· dira[noparse][[/noparse]SPI_DATA]~·············· ' Let data line float after hold time
    is that because after the next statement (make clock low)
    the Vinculum SDO output directly outputs a new bit value?

    Finally, I rewrote transfer1 to transfer2 to support seperate data in and data out pins.
    Is the conversion I did correct? I commented out statements I think are no longer required.

    regards peter
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-12-22 10:29
    Success. The attached version works on a spin stamp with seperate in and out pins
    and a terminal program.

    regards peter
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-12-22 11:27
    I attached a mini hub (Trust· HU-4440p) and connected my USB stick
    to the hub. That appears to work. I just wonder what happens
    when I connect 2 usb sticks.
    Anybody tried that out? Is there a command to change drive?
    (I don't have 2 usb sticks. Normally under DOS, one would use E: to change drive
    but since E is an echo command that probably won't work.)

    regards peter
  • Mike GreenMike Green Posts: 23,101
    edited 2007-12-22 16:38
    Peter,
    The Vinculum's SPI timing is such that it never uses the data-in and data-out lines at the same time, so, to save I/O pins, I decided to just connect the two together and write the low level routine so it worked with that. I have done the same routine with the signals separated as you've done it and it does indeed work fine.

    When I was debugging the routines, I used 1K resistors. After I was comfortable with how it all worked, I left them out. The Vinculum is a 3.3V logic / 5V tolerant chip so it doesn't require them and the timing diagrams are very clear about who talks when.
Sign In or Register to comment.