How to drive the Vinculum VDIP1 in UART mode


Closed Thread
Results 1 to 40 of 42

Hybrid View

  1. #1

    Default How to drive the Vinculum VDIP1 in UART mode

    The FTDI Vinculum VDIP1 module appears to be a simple way of adding USB memory cards and other devices to PIC projects. Their documentation is appalling and there are several traps to waste many hours with. There are also huge timing differences between brands and sizes of memory sticks that need to be catered for.

    WARNING - Regardless of when and where you bought your VDIP1 modules, get the latest code first (ver 3.61 as at 11 December 2007). I had ZERO success until I flashed the latest code into the VDIP1 module. I first tried to flash the code in using a slow Rundisk 2 GB card. That killed the bootloader in the VDIP1 and rendered the module useless. I had success with a faster Verbatim 512 MB card and was able to reflash the VDIP1 with version 3.61 code.

    Schematic details.
    Data TO the VDIP1 destined for the USB stick is sent into pin 8 called RXD.
    Data FROM the VDIP1 is ignored.
    VDIP1 pin 9 called RTS is monitored by the PIC. Data is only sent while RTS is LOW.
    VDIP1 pin 10 called CTS is pulled low by the PIC and left low throughout.
    The VDIP1 RESET line, pin 22, needs to float normally but every now and then a manual reset is required. This could either be by code or an external pushbutton.
    +5 volts is applied to VDIP1 pin 1. VDIP pins 7 and 18 are tied to ground. All other pins are floating.

    Setup for simplest UART mode.
    a/ The interface defaults to 9600 bps, 8N1 TTL where steady mark/idle is +v and a space bit is zero volts. Use SEROUT 'driven true' mode.

    b/ Set the jumpers to be both 1-2 or both 2-3 for UART mode.

    c/ You can permanently ground the VDIP1 pin 10 called CTS. This pin must be low before the VDIP1 will work.

    d/ You MUST monitor the VDIP1 pin 9, called RTS. Do NOT tie RTS to CTS as shown in the Circuit Cellar article - that only sometimes works. RTS is low when ready to accept data and when RTS goes high you must stop sending data to the VDIP1. If you continue to send data, the VDIP1 will frequently lock up and need a manual reset or power cycling before it comes good. Any active file on the USB stick will be left open and appear empty when viewed with a PC.

    e/ RTS going high apparently indicates there are only 32 character positions left in the buffer. RTS ALSO goes high immediately after issuing some commands. Which commands seems to vary with brand of card. The WRF 26 <cr> in my code below causes pin 9 RTS to go high with a Rundisk 2 GB memory stick but RTS does NOT go high with a Verbatim 512 MB stick.

    f/ Every command must be terminated with a carriage return. No line feed is necessary.

    g/ You must count your characters very carefully. The WRF nn <cr> command tells the VDIP1 that nn characters are to be written to the memory stick. If you send more than nn the VDIP1 module will harmlessly truncate the data but the file will be readable minus those overflow characters. If you don't send enough characters however, the VDIP1 will hang waiting for the balance. Subsequent commands to close the file will be lost and the file will remain open and be unreadable or empty.

    h/ The following code creates a new directory called TESTFILE (8 character limit) and creates a file in that directory called Test1.txt. It then opens Test1.txt, writes a short header block and closes the file. It then opens the file a second time and appends 10,330 bytes to Test1.txt and closes the file. Finally it opens it, appends a trailer and closes Test1.txt. Only 8.3 format file and directory names are allowed. All file names are changed to capitals by the VDIP1.

    i/ I have put a flow control test after every command. This is probably overkill but I don't know what are the fast and what are the slow commands. These appear to vary between brands and memory sizes so I have left them in.

    '************************************************* ***************
    '* Name : Vinculum01.pbp *
    '* Author : Brian Taylor *
    '* Notice : Copyright (c) 2007 Brian Taylor *
    '* : All Rights Reserved *
    '* Date : 4/12/2007 *
    '* Version : 1.0 *
    '* Notes : USB memory stick interface for PIC 18F4620 *
    '* : *
    '************************************************* ***************

    data @0, 0

    VinTxD var portb.0 'data from Vinculum VDIP1 pin 6
    VinRxD var portb.1 'data TO VDIP1 pin 8 for writing to USB stick
    FlowIn var portb.2 'Flow control FROM VDIP1 pin 9
    FlowOut var portb.3 'Flow control TO VDIP1 pin 10
    RstVDIP1 var portb.4 'active LOW reset line to VDIP1
    LED var portb.5
    SpareB6 var portb.6
    SpareB7 var portb.7
    TRISB = %11001101 'bits 2 & 3 temporarily inputs

    TxD var portc.6 'MCS+ bootloader
    RxD var portc.7

    A var byte
    B var byte
    C var byte
    W var word

    Start:
    define osc 4
    define loader_used 1

    Define LCD_DREG PORTD
    Define LCD_DBIT 0
    Define LCD_RSREG PORTD
    Define LCD_RSBIT 5
    Define LCD_EREG PORTD
    Define LCD_EBIT 4


    high rstvdip1 'active LOW so not reset.
    low flowout 'pull VDIP1 pin 10 CTS low
    input flowin 'from VDIP1 pin 9 RTS

    Loop:
    read 0,a
    lcdout $FE, $01, "A = ", #a
    pause 1000
    if a = 0 then
    write 0,1
    lcdout $FE, $01, "Press Reset to", $FE, $C0, "start logging."
    end
    endif

    StartWriteBlock:
    high vinrxd 'condition serout pin to mark state
    pause 5
    serout vinrxd , 2, ["ECS", 13] 'Select Extended Command Set
    high vinrxd
    Pauseus 10
    serout vinrxd, 2, ["IPA", 13] 'Input in ASCII
    high vinrxd
    pause 10
    serout vinrxd , 2, ["MKD TestFile", 13] 'Make Directory called TestFile
    Pauseus 10
    Wait11:
    if flowin = 1 then wait11
    lcdout $FE, $01, "Make directory", $FE, $C0, "TestFile"
    serout vinrxd, 2, ["CD TestFile", 13] 'Change Directory
    Pauseus 10
    Wait12:
    if flowin = 1 then wait12
    WriteHeader:
    high vinrxd 'condition serial data line state
    pause 5
    serout vinrxd , 2, ["OPW Test1.txt", 13] 'Open file test1.txt for Writing
    Pauseus 10
    Wait13:if flowin = 1 then wait13
    serout vinrxd, 2, ["WRF 26",13] 'Write 26 characters to the open file
    Pauseus 10
    Wait1:
    if flowin = 1 then wait1
    serout vinrxd, 2, [13, 10, "Start 10,330 byte test "] 'these are the 26.
    Pauseus 100
    Wait2:
    if flowin = 1 then wait2
    serout vinrxd, 2, ["CLF Test1.txt", 13]
    Pauseus 100
    Wait3:
    if flowin = 1 then wait3
    WriteDataBlock:
    high vinrxd
    pause 5
    serout vinrxd , 2, ["OPW Test1.txt", 13]
    high vinrxd
    Pauseus 10
    wait4:
    if flowin = 1 then wait4
    serout vinrxd, 2, ["WRF 10330",13]
    lcdout $FE, $01, "Writing data", $FE, $C0, "10,330 characters"
    Pauseus 10
    Wait14:
    if flowin = 1 then wait14
    for c = 0 to 9
    serout vinrxd, 2, [13, 10, #c]
    Pauseus 10
    Wait15:
    if flowin = 1 then wait15
    for a = 0 to 9
    serout vinrxd, 2, [13, 10, #a]
    Pauseus 10
    Wait5:
    if flowin = 1 then wait5
    for w = 0 to 99
    serout vinrxd, 2, [#c]
    Pauseus 10
    Wait6:
    if flowin = 1 then wait6
    next w
    next a
    next c
    Pauseus 10
    serout vinrxd, 2, ["CLF Test1.txt", 13]
    Pauseus 10
    Wait7:
    if flowin = 1 then wait7
    CloseDataBlock:
    lcdout $FE, $01, "Closing file", $FE, $C0, "Test1.txt"
    serout vinrxd , 2, ["OPW Test1.txt", 13] 'Open file for Writing
    Pauseus 10
    Wait8:
    if flowin = 1 then wait8
    serout vinrxd, 2, ["WRF 24",13]
    Pauseus 10
    Wait9:
    if flowin = 1 then wait9
    serout vinrxd, 2, [13, 10, "End 10,330 byte test",13,10]
    Pauseus 10
    Wait10:
    if flowin = 1 then wait10
    serout vinrxd, 2, ["CLF Test1.txt", 13]
    Wait16:
    if flowin = 1 then wait16
    write 0, 0
    pause 1000
    goto loop
    end


    Cheers
    BrianT

  2. #2
    Join Date
    Mar 2004
    Location
    UK-Midlands
    Posts
    84


    Did you find this post helpful? Yes | No

    Default

    Thanks BrianT,

    I have just ordered one of these modules. When I get it will try out your program and see how reliable the module is!

    Thanks for all your work,
    Bob

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Hi Brian,

    I was wandering if, in your search for answers on how to make better use of the VDIP1 based products, you found a reliable way (other than the message on Tx line) that will show if the storage device is present or not.
    I’m thinking more in terms like a pin status change or a sequence in pin status changes.

    I have an application which just transfers data from and to the flash storage device one byte at the time without having the PIC to look at it and I need a way to detect if the device is still connected.

    I just received my first VDIP1 module and my first tests show that, without checking the data content from the module, I receive an answer from the module to my “RDF $01” command (read one byte from an open file) even if the flash device is removed (I guess it is an error message like “no device detected” or “bad command”). I was hopping that RTS might change but it doesn’t.

    To be able to keep the speed on data transfer to a maximum I prefer not to concern the PIC with the data content and I need an alternate way to detect if the flash media is present or not.

    Any idea will be appreciated.
    Thank you in advance.

    Nick

  4. #4


    Did you find this post helpful? Yes | No

    Default USB memory stick detection.

    Hi Nick,

    I don't believe there is any pin that will tell you a card is present or not. If I had to do it in hardware I would use a small resistor in series with the 5 volt line and sense the extra current pulled by the USB card.

    Lots of luck with just sending bytes without a PIC. Data over- and under-runs drive the VDIP1 nuts and you must be careful to write exactly as many characters as you told the VDIP1 you were going to send otherwise the fiile can be left open and will be unreadable to any other device.

    AFAIK, RTS / CTS are driven by the buffer falling below 32 or 64 characters or by some undefined messages sent between the VDIP1 and the USB card which the user never gets to see.

    Email the factory but ask your questions very carefully. They responded quite quickly to me but never once volunteered any help or gave a suggestion outside the very narrowest meaning of my question.

    HTH
    BrianT

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Thank you Brian.
    I will try to E-mail FTDI.
    I'll post the results.
    Thanks again,

    Nick

  6. #6


    Did you find this post helpful? Yes | No

    Default

    Hi all,

    First I would like to clarify the fact that I am using a PIC for my data transfer to and from a USB data storage device and I’m carefully counting my bytes. It is just that there is no need for the PIC to know what they are. In order to get the information of device disconnected you must monitor the data stream for the “No disk” message and I can’t afford to keep the PIC busy with that. So checking a pin status makes it really easy for me.

    After reading the information (Yes, now I agree with the RTFM supporters 100%) on the LEDs behavior one solution to detect USB device disconnect “blinked” to me.
    The LED2 output is supposed to be ON (Low) when the device is inserted and there is no data exchange on USART monitor port. If there is traffic the LED2 blinks. If the USB device is disconnected the LED2 is OFF (High).
    I’m using a loop like:

    Loop:
    Read a string of 50 bytes from a open file on the USB device, via Debugin
    Process and format the string
    Send the string out via Serout2 to an other application (Hyper Terminal)
    Check if USB device is present
    Go to loop

    As you can see it works for me due to the slight pause on activity on the monitor port.
    I did not do a full test to see how fast you can expect the LED2 response but it is fast enough for me.

    Hope this information will help people with similar applications.

    Regards,

    Nick

  7. #7
    ganesh_shelkar's Avatar
    ganesh_shelkar Guest


    Did you find this post helpful? Yes | No

    Unhappy VNC1L SPI mode New data not accepted

    hi all
    i have done interface with VNC1L in SPI mode.I have a problem when write to VNC1L new data rejected according data sheet retry untill data not accepted but its not working i have send the data continuously but not accepted by VNC1L.

  8. #8
    Join Date
    Sep 2011
    Posts
    2


    Did you find this post helpful? Yes | No

    Default Re: VNC1L SPI mode New data not accepted

    Mackrackit, what is the easiest mode in interfacing the VDIP1 Module and PIC microcontroller,,, UART or SPI?

    I have seen in this site(http://www.pic_examples.byethost3.com/VDIP.html) that he used SPI mode in interfacing the PIC and VDIP2 module...
    But, I'm planning to buy VDIP1 because it is more cheaper than VDIP2 module.
    Do you have any circuit diagram just like in that site using UART mode in interfacing the PIC and the VDIP1 module not the PIC and VDIP2 module???

  9. #9
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: VNC1L SPI mode New data not accepted

    Read the first post of this thread. That is all you need to get started.
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. VDIP1 (Vinculum - FTDI) problems
    By BrianT in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 20th August 2013, 13:51
  2. MPASM Path & File Name Length Limtation
    By Brian J Walsh in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 14th June 2008, 15:48
  3. Oscillator stops when touching with a wire
    By Wilbert Ingels in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 25th April 2008, 08:51
  4. USB-FTDI[UM232R] with PIC16f877a
    By bjox in forum USB
    Replies: 1
    Last Post: - 23rd February 2008, 22:40
  5. Replies: 14
    Last Post: - 26th September 2007, 05:41

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts