how to use usb without knowing usb

Upload: nqdinh

Post on 30-May-2018

233 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/14/2019 How to Use USB Without Knowing USB

    1/14

    2006 John Hyde, USB Design By Example Page 1

    Windows Kernel

    Function/Class Driver

    Device Driver

    Port Driver

    Win32api

    Applications

    Plug

    And

    PlayManager

    User

    System

    Windows Kernel

    Function/Class Driver

    Device Driver

    Port Driver

    Win32api

    Applications

    Plug

    And

    PlayManager

    User

    System

    PC

    COM1 COM2 USB1 USB2

    FlashDriveBar CodeReader

    InternetPhone

    Modem

    PC

    COM1 COM2 USB1 USB2

    FlashDriveBar CodeReader

    InternetPhone

    Modem

    How to use USB withoutknowing USBJohn Hyde, USB Design By Example

    USB is now a mature technology yet many people are not using it since they perceiveit as too complicated. To date, all USB books and most USB technical articleshave presented USB as a technical wonder and the reader is flooded with detailssuch as packet types and descriptor parsing. Not surprisingly, many people whocould take advantage of USB are holding back. This paper treats USB as a tool thatcan be used to solve real world problems in embedded systems design.

    This paper works through a range of examples, starting with a single button and ending with anembedded USB host controller. There are three distinct sections; this introduction coversessential USB terminology but explained relative to RS232 which you already know; I then builda range of embedded devices that attach to a USB host such as a PC, Mac, Linux, or any USB-aware OS; I then add a mass storage device to an existing embedded product. You will discoverthat all of the low-level USB issues have been already solved and you can use these buildingblocks to solve your unique embedded system design challenges. These examples aredownloadable from www.USB-By-Example.com.

    Lets first compare and contrast a USB solution with an RS232 solution. Figure 1 shows a PCwith four connected devices, two serial and two USB devices. A serial connection has twosignal wires and a ground while a USB connection has two signal wires, a power and a ground.A USB connection has one extra wire but otherwise the hardware looks similar.

    The operating system running on the PC (Windows, MacOS, Linux, or other OS) has built-insupport for both types of devices and the layered structure of the software on this PC is alsoshown in Figure 1. I use Windows names in the figure but the layered architecture for MacOS,Linux and others is the same, they just change the names to keep us hardware folks on our toes!

    Figure 1: Hardware and software view of device connections.

  • 8/14/2019 How to Use USB Without Knowing USB

    2/14

    Windows has pre-declared names for the serial ports. You can open the first withHandle = CreateFile (com1,)

    Windows does a lot of work as a result of this Win32api call - it has to determine if com1 is avalid symbolic name then it has to attach to the correct low-level driver. But once you have a

    Handle you can ReadFile, WriteFile, or send IOCTLs until you call CloseHandle.

    Note that I have a scanner attached to com1 and a modem attached to com2. The application

    programmer needs to know this and the baud rate of each of these devices (read the manual) andalso needs to know the data exchange protocol for each device (study the manual in detail). Thisis all quite straight forward and programs have been written like this for a long time.

    But now look what happens if I swap the connections of com1 and com2. The scannerapplication will be connected to the modem and the modem application will be connected to thescanner. Both devices will be initialized incorrectly, the data exchange will be garbled and bothapplications will fail. This is the price we pay for allowing the user to bind the applicationprogram with the hardware connection.

    Now lets look at the two USB devices. Many users want to do a

    Handle = CreateFile (USB1,)

    but this is NOT how it works. We wanted to remove the user from the hardware binding processand let the OS do this work. When a USB device is attached to a PC the OS enumerates thedevice - it sends a series of commands to the USB device that discover what the device is. TheUSB device responds with fixed-format data structures, called descriptors that identify itcompletely. The OS uses this descriptor information to load the supporting device driver. It thenplaces this information into the OSs PlugAndPlay tables.

    Figure 2 shows the descriptors of my two devices (100% Flash Drive, 70% Internet Phone).

    Figure 2: Self-contained descriptors describe a USB device completely.

    2006 John Hyde, USB Design By Example Page 2

  • 8/14/2019 How to Use USB Without Knowing USB

    3/14

    Note that each has a unique VID_PID combination and they belong to a different class. All USBdevices are assigned to a class - examples are HumanInterfaceDevice (HID), MassStorageDevice(MSC), Audio, StillImage, Video, Hub, VendorDefined, etc. - depending upon theirfunctionality. When you read that USB devices are self-identifying this interrogation by theOS and discovery of the devices capabilities is the process that is being described.

    Now lets turn our attention back to the applications programmer who wants to open one of theseUSB devices. The initial problem is that the programmer doesnt know the name of the device touse in the CreateFile API call. But the programmer knows the TYPE of device that they need toconnect to, so they ask the PlugAndPlay manager do you have any MassStorageClass devicesattached. The PnP manager responds with a list and we use some algorithm to isolate ourchosen device - in this example we would select the removable device. Similarly the audioapplication would search for, and open, an AudioClass device.

    So with USB devices we have an extra step to identify our device since it doesnt have a pre-declared name such as COM1 or LPT4. The benefit is that the user could swap the USB cablesand both applications would still work. Additionally there was no need to read the manual ofeither device to discover their characteristics - these were read by the OS during the enumeration

    process and are available to the applications programmer

    Bottom Line: a USB device contains descriptors that the OS reads so that it can load the

    correct device driver. The PlugAndPlay manager makes this information available to the

    applications programmer so that it can be initialized or changed.

    Ok. Enough theory. Lets look at some examples.

    A USB Button

    But all I want is a simple button. This used to be easy with a parallel port and I dont have time

    to learn USB. What other options do I have?

    I get questions like this almost every week at my website and people are surprised when Iexplain that you dont have to be a USB guru to solve this kind of problem. They tell me howthey have hacked a USB mouse or keyboard to get a simple button but have then fallen into thesystem input device trap of Windows.

    I am going to solve some typical USB interfacing problems and you wont have to buy any newdevelopment tools over what you already have for serial and parallel port interfacing. I shall usereadily available commercial products to implement these solutions so that you should have noproblems adapting them for your particular application.

    My first example is a simple push button and matching LED to show that the button has beenpressed. This button press will be recognized by a PC, and the PC can also independently lightthe LED. To solve this interfacing problem I am going to use a special USB-to-Serial cablemanufactured by FTDI note that this TTL232R cable does not use RS232 levels, it uses TTLlevels to enable it to interface directly with microcontrollers and other TTL circuitry. Myapplication is not what this product is specifically designed for but it is fully tested andwarranted - it is also quite cheap! This cable is shown in Figure 3.

    2006 John Hyde, USB Design By Example Page 3

  • 8/14/2019 How to Use USB Without Knowing USB

    4/14

    2006 John Hyde, USB Design By Example Page 4

    Active

    Green

    Yellow

    Orange

    Red

    Brown

    Black

    Vbus

    Gnd

    Insert

    or

    Active

    Green

    Yellow

    Orange

    Red

    Brown

    Black

    Vbus

    Gnd

    Insert

    or

    Figure 3: The FTDI cable contains a USB-to-Serial converter in the plug.

    The cable in Figure 3 looks like an innocent USB cable except for the fact that it has 6 wiresinstead of the standard 4 wires. Figure 3 also shows the detail of the electronics embedded into

    the USB plug - it contains an FT232 USB-to-Serial component plus the support circuitrymounted on a tiny PCB. The 6 wires are Vbus, TX, RX, RTS, CTS and Gnd but we wont beusing them in this mode until example 3. My first two examples configure the cable intoBitBang mode and this provides 4 independent IO lines that I can read and write.

    Figure 4 shows the passive components attached to the end of my FTDI cable for my firstexample. I will demonstrate two example programs on my Windows PC, one in Visual C++ andthe other in Visual Basic. I have the same example also available for the MacOS and for Linux.The program first asks the OS if there are any FTDI cables attached and when it finds one itopens it and reads/writes to it every 100 msec. Button presses are shown on the PC screen andPC commands can independently turn on the LED.

    Figure 4: USB device with up to 4 bits of IO.

    Notice that you didnt see any descriptors or had to deal with any USB-ness at all. The OSrecognized the FTDI cable and loaded the FTDI driver (FTDI supply certified drivers for all

    major OSs). I first configured the cable to support BitBang mode then used standard ReadFile

    and WriteFile commands in a timer/sleep loop. Pretty easy.

  • 8/14/2019 How to Use USB Without Knowing USB

    5/14

    2006 John Hyde, USB Design By Example Page 5

    1K0

    VCC

    TXD.0

    RTS.2RXD.1

    CTS.3

    GND

    SCL

    SDA

    INT

    10K

    10K

    10K

    330

    330

    330

    330

    330

    330

    330

    330

    PCA9554

    AddressSelect

    1K0

    VCC

    TXD.0

    RTS.2RXD.1

    CTS.3

    GND

    SCL

    SDA

    INT

    10K

    10K

    10K

    330

    330

    330

    330

    330

    330

    330

    330

    PCA9554

    AddressSelect

    If you dont like the gauge or the length of the cable you can just purchase the plug +electronics and add your own cable and case. The electronics supports 4 IO lines and these canbe any combination of buttons and LEDs.

    Inputting and Outputting Bytes.

    The first example used the four available signals of the FTDI cable as simple IO lines. Thissecond example uses these lines as an I2C bus and the example program adds an I2C protocol.From the software perspective this just means that I write and read a buffer of bytes rather thansingle bytes - a small extension to the example software. Most of the software effort wasdesigning and implementing the human interface. From the hardware perspective I add up to 8I2C IO expanders as shown in Figure 5.

    Figure 5: USB device with up to 8 bytes of IO.

    So, with this cable and a few standard components I can simply access 64 bits of IO - enough formany control panels, system configuration, or even a distributed data gathering system. I havethis up and running and I didnt have to even open the USB spec! All the USB-ness is handledby the device, and the device driver, allowing me to concentrate on my application.

    Now is a good time to discuss USB power considerations. Power can be drawn from the Vbusline but you must understand the rules. A USB host port is required to supply up to 100mA at5.0 Volts for any device - mice and keyboards can run off this power. If your device requiresmore power you are allowed to request up to 500mA once your device is configured. A PC or apowered hub will have no problems supplying this power but an un-powered hub (which Irecommend you do not use!) will not be able to do this and this creates user confusion. If your

    device needs more than 500mA then it should contain its own power source - the USB spec callsthis a self-powered device but this is still allowed to request up to 500mA from the bus.

    At the other end of the scale a device must not consume more that 0.5mA when it is suspended.As a PC is powering down it stops sending signals on USB and devices must interpret no USBactivity for 3msec to mean suspend yourself. There is no point having a peripheral devicepowered on if the PC is powered off. A powered down device can have the ability to send aWakeUp signal to the PC to bring it back to its powered-on state.

  • 8/14/2019 How to Use USB Without Knowing USB

    6/14

    Converting a serial device to USB

    In this third example I use the FTDI cable in the mode that it was designed for. Figure 6 shows atypical serial device connected to a PC. It has an internal microprocessor or microcontroller thatdrives an RS232 voltage converter for PC communications and drives custom IO specific to theembedded application.

    In the center diagram of Figure 6 I have replaced the serial cable with the FTDI cable. Thiscable drives TTL levels so there is no need for the RS232 voltage converters. We have aproblem with the connector however since the industry expects RS232 voltage levels on the 9pin (or 25 pin) serial connector; I shall deal with this issue in a moment.

    What impact does changing the cable have on the PC and the application software? The OS willnow enumerate a USB device instead of a COM device and will load the FTDI drivers again.These drivers include a Virtual Comport driver - which means that a device called COMxx willbe added by the PlugAndPlay manager. So, the application program now opens, say, COM8rather than COM1 - there are no other changes needed.

    Now look at the third diagram in Figure 6 - I have moved the FT232 part from the PC end of

    the cable to the device end of the cable. This FT232 part replaces the RS232 voltage converterand I replace the serial port connector with a USB B connector (standard size or mini-B). Thismeans that I use a standard USB cable to connect me new device to the PC.

    RS232

    Buffers uCIO

    IOPC

    COM1

    uCIO

    IOPC

    USB1

    uCIO

    IOPC

    USB1

    FT232USB-B

    ???

    9-Pin DRS232

    Buffers uCIO

    IOPC

    COM1

    uCIO

    IOPC

    USB1

    uCIO

    IOPC

    USB1

    FT232USB-B

    ???

    9-Pin D

    Figure 6: Migrating a serial connection to USB.

    2006 John Hyde, USB Design By Example Page 6

  • 8/14/2019 How to Use USB Without Knowing USB

    7/14

    2006 John Hyde, USB Design By Example Page 7

    USB

    TX

    RX

    FT2232

    BA

    RS232 Buffers

    USB

    TX

    RX

    RS232Buffers

    RS232Buffers

    FT2232

    BA

    USB

    RX

    TX

    FT2232

    BA

    RS232 Buffers

    USB

    TX

    RX

    RS232Buffers

    RS232Buffers

    FT2232

    BA

    Total conversion effort is less than a day. We migrated a serial device into a USB device. Butwhat else did we gain besides a product that is likely to sell better?

    If needed, we could increase the baud rate to the device. Standard serial cables can easilysupport 56K baud and some can do 192Kbaud. The FT232 can run at 3,000K baud due to thehigher data transfer rate of USB. If your device moves a lot of data then this upgrade would beworth implementing.

    A USB cable can also supply up to 500mA at 5Volts. If your device can operate at this powerlevel then you could eliminate the power source from your device and thus reduce itsmanufacturing cost. And since you will charge more for a USB version then you get a doublecost benefit as well as a simpler product. This is also low hanging fruit and is easy toimplement.

    Converting a parallel device to USB

    FTDI have a trio of USB converters that can be used in this type of application. So far wehave been using the FT232 that has a serial interface. A companion part, the FT245 replaces this

    serial interface with a parallel bi-directional FIFO interface for higher data throughput rates.Converting a parallel interface device to a USB device follows the methodology as the serialdevice. From an applications software perspective you CreateFile(com12,..) rather thanCreateFile(LPT2,) but otherwise the software is un-changed. You can also reap the higherspeed, and USB-provided power, benefits of the serial port conversion example. A dual-channelpart, the FT2232, is also available: the two channels can be individually programmed to operateas an FT232 or an FT245 or they can be combined to produce higher capability interface.

    Inputting and Outputting protocols and data blocks

    The simplest application of an FT2232 is a serial spy cable shown in Figure 7. The passive

    version just monitors the bi-directional communications whereas the intelligent version caninject traffic in either direction.

    Figure 7: An FT2232 can be used for a passive or active serial spy cable.

  • 8/14/2019 How to Use USB Without Knowing USB

    8/14

    2006 John Hyde, USB Design By Example Page 8

    FT2232USBRD

    TX

    TLC7528

    A

    B

    TLC272

    WRFT2232USB

    RD

    TX

    TLC7528

    A

    B

    TLC272

    WR

    The sound player example in Figure 8 sets up FT2232 channel A as a parallel FIFO and channelB as a serial device. The PC writes blocks of data to the parallel interface and an equal numberof 0xff characters to the serial interface. The TX line is used to clock data out of the FIFO at aprogrammed rate - I chose 16KHz. The parallel bytes feed an 8-bit DAC whose output isbuffered and sent to a speaker. Thus the PC can send sounds to be played by the device - notethat this is NOT an MP3 player, it is intended for audio cues and warnings. It is an example thatshows how easy it is to send blocks of information from a PC to a device. Block input couldeasily be added.

    Figure 8: USB device supporting blocks of data.

    The FT2232 has direct support for I2C and SPI serial protocols. Another interesting applicationof the FT2232 is as a fully programmable device as shown in Figure 9. Here the personality of

    the device is downloaded from the PC into an FPGA. A complete development kit, calledMorph, is available from FTDI. During run-time the FPGA has a parallel data path into and outof the PC. Good examples of the use of this technology are the high performance oscilloscopes,data loggers and other USB instrumentation from EasySync.

    Figure 9: A soft-loadable USB device designed around an FPGA.

  • 8/14/2019 How to Use USB Without Knowing USB

    9/14

  • 8/14/2019 How to Use USB Without Knowing USB

    10/14

    Figure 11: Using our trusty USB-to-Serial cable with a VMusic demo board.

    The board will sign on and offer a D: > prompt. Now, in HyperTerminal, enter DIR and, HeyPresto, the contents of the drive are displayed. Now enter the following commands:

    OPW test1IPAWRF 12Hello World!CLF test1

    These commands first opens a file called test1 for write, then tells Vinculum that 12 bytes ofdata are coming. Hello World! is the data that is written, and CLF closes the data file.

    Now remove the flash drive and connect it to your PC, Mac or Linux system and open test1.Notice that the data written by the Vinculum is present. Now edit test1 to add a message Hellofrom my PC, Mac or Linux

    Now reattach the flash drive to the Vinculum board and enter RD test1. Voila, the text isdisplayed!

    Now stop and think what we have accomplished.

    We have written, read and exchanged data files between a PC, Mac or Linux system and anembedded system using a flash drive. We did not have to learn USB, the Mass Storage Classspecification or even the FAT file system. It was as easy as entering DOS-like commands on aserial connection.

    Pretty amazing.

    The Vinculum powers up in Extended Command mode where all the commands and data areASCII; some of these commands are summarized in Figure 12. It can be switched into ShortCommand mode where binary commands and data can be exchanged. The VMusic board onlyprovides access to the UART connection but this will be enough for my first set of examples.The Vinculum is also available in an OEM 24 pin DIP and this additionally provides access tothe SPI port, the parallel port FIFO and the other USB port.

    2006 John Hyde, USB Design By Example Page 10

  • 8/14/2019 How to Use USB Without Knowing USB

    11/14

    Directory Operations

    DIR Lists the current directory

    MKD Creates a new directory in the current directory

    DLD Deletes the directory from the current directory

    CD The current directory is changed to the new directory

    CD .. Move up one directory level

    File operationsRD Read file . This will return the entire file

    OPR Opens file for reading with RDF

    RDF Reads bytes of data from the current file

    OPW Opens file for writing with WRF

    WRF Writes bytes of data to the end of the current open file

    CLF Closes file for writing

    DLF This will delete the file from the current directory and free up diskspace

    VPF Play an MP3 file. Sends file to SPI interface then returns

    REN Rename a file or directoryManagement Commands

    SCS Switch to the short command set

    ECS Switch to the extended command set

    IPA Input data values in ASCII

    IPH Input data values in Hex

    SUD Suspend the disk when not in use to conserve power. The disk willbe woken up automatically when a disk command is sent to it.

    WKD Wake Disk and do not put it into suspend when not in use

    SUM Suspend Monitor and stop clocks

    FWV Get Firmware Versions

    FS Returns free space in bytes on disk

    Figure 12: This table shows some of the monitors DOS-like commands.

    There are two types of project suitable for a Vinculum data distribution and data collection andI have examples of each category. Typically, data to be distributed is created on a PC usingspecialist tools and then copied onto a flash drive; an embedded system then accesses thisinformation and presents it to a user or a machine. My example is a small JPEG viewer and MP3player something that we would take on a business trip and that plays back images and soundsof our family, or our favorite music. If I had used a larger display I would have called this an

    active photo frame (it is on my TODO list!). My data collection example is a portable datalogger that collects field data for later analysis by a PC. In both cases an applicationmicrocontroller is used to drive the Vinculum (it is a peripheral device) and other circuitry. I amconfident that you can dream up many more applications for this easy-to-use part.

    2006 John Hyde, USB Design By Example Page 11

  • 8/14/2019 How to Use USB Without Knowing USB

    12/14

    JPEG viewer and MPEG player

    I chose a Cypress PSoC for the target microcontroller since it has firmware-configurablehardware that allows me to solve a wide range of problems with a single device. I develop anddebug using a high-end PSoC device that has ample analog and digital resources then, nearproject completion, I can select a lower cost device within the same family. For the firstexample I shall use the Cypress PSoC Evaluation board and this is shown in Figure 13 with theVMusic board and a 1.5 x 1.5 Micro-LCD display already attached to the breadboard area.

    Figure 13: This example was developed anddebugged using a PSoC development system.

    In summary I have a PSoC that reads imagefiles off a flash drive using commands sent tothe Vinculum monitor, the PSoC then displaysthis image. If a matching MP3 file is alsopresent on the flash drive then I command theVinculum to play it this could be music or aperson talking. A PC is used to create theimage and MP3 files and these are copied ontothe flash drive. The PSoC/Vinculum-basedplayer then runs the show. A JPEG viewer

    and MPEG player is the base example but aninteractive display that could be used in stores,museums, product demonstrations, artgalleries, etc. is a straightforward designextension. A series of flash drives in English,Spanish, Japanese, etc. could be used to createa more universal solution.

    Another beneficial aspect of a PSoC-baseddesign is that Cypress has over a hundredapplications notes that describe building

    blocks that can be used within your owndesign. The PSoC could scan buttons, whichwould use CapSense technology, and theapplication program would use these buttoninputs to navigate through images / MP3 files.

    Additionally the PSoC could support a touch screen using a few of its configurable analog anddigital blocks. This could be a simple resistive screen overlay or a more reliable CapSenseimplementation.

    The size of the graphical display determines the complexity and choice of the PSoC. Since thisis a paper about embedded flash drive applications I chose the simplest display to implement

    here and I will cover interfacing to a larger display in a future article. I found a serial-interface,micro-LCD at www.dontronics-shop.com and was very impressed with ease of use of these128x128 color displays. These 1.5 x 1.5 displays are not expensive you should get some andexperiment with them. I am sure that you will soon find many uses for them, just as I did. Ipersonally found the OLED displays much better to look at when compared with the LCDdisplays but the firmware to drive the both displays is identical. The micro-LCD module is avery capable subsystem that supports graphics rending and several fonts. My example usesabout 5% of its capability as I just download images to it. These images are 128x128 by 16-bit

    2006 John Hyde, USB Design By Example Page 12

  • 8/14/2019 How to Use USB Without Knowing USB

    13/14

    color and Graphics_Composer is a PC application that converts JPEG, BMP, and GIF imagesinto this format (this is included in the download package). In this example these images will becopied to a flash drive and called nnn.img (nnn = 000 to 999). MP3 files are also created foreach image and they will be called nnn.MP3 (these could be your favorite songs renamed).

    From an application software perspective we have a PSoC interfacing two serial connections,the Vinculum and a micro-LCD connection. The application starts by looking for 001.img andcopies it to the display. If it finds 001.MP3 then it will play it, else it will wait for 60 seconds(easy to modify) before moving onto 002.img. The application keeps incrementing throughfilenames until one is not found then it starts at 001.img again. To change the photos and/ormusic you just swap the flash drive. The complete PSoC project is downloadable from mywebsite and, as you will see, it supports the basic function. It is easy to expand this design to addfunctions I plan to add a feature-rich alarm clock once I get some spare time. It would be easyto make this battery powered however displays tend to consume a lot of power so I would alsoadd a battery charger in this case. A battery charger uses a few analog and digital resources of aPSoC, a few FETs, an inductor and Rs and Cs. This design extension is covered in detail inCypresss application note collection.

    Portable data logger

    I was persuaded to create an example based on the PIC microcontroller. I personally didnt likethis part due to its weird instruction set. However, my colleague Don Powrie of DLP Designintroduced me to the CCS toolset and these make PIC designs actually pleasant to do! I used tobe a staunch advocate of only using assembler code for microcontrollers I argued that acompiler would always generate larger object code than my tuned assembler code. But nowthese microcontrollers are available with 16KB, 32KB and beyond of flash memory! So what isthe point of saving a few hundred bytes when you still have over half of the flash space asunused? C code is also much easier to write and debug when compared with assembler code.

    The CCS compiler was specifically designed to create optimized code for the PIC family ofmicrocontrollers. As well as all of the standard features that you would expect from a quality Ccompiler it includes built-in functions to support the on-chip features of a PIC microcontroller.A good example is the #use RS232 directive; here you specify that you need to use a serial portand you give the compiler details such as baud rate and the IO pins that will be used for TX andRX. If the chosen PIC device has a hardware UART then the compiler will use this for printfand scanf functions, else it will include subroutines to manage the low-level bit manipulationsfor you. Your main program uses printf statements as before. The CCS compiler also containsbuilt-in functions to drive the on-chip ADC and the real time clock. This way you can focusupon WHAT your program is doing and not the lower level HOW.

    Don designed the battery powered data logger shown in Figure 11 to demonstrate the capabilitiesof the Vinculum. The example program uses RS232 to control the Vinculum, which writes datato the flash drive. Better still, the hardware connection is a standard 4-wire serial port using TX,RX, RTS and CTS.

    The PIC runs an application program that has access to a flash drive using the Vinculum, a realtime clock, a temperature and humidity sensor and two analog input channels. A connector forFTDIs TTL-232R-3V3 cable is included, as it a connector for a PIC debugger such as CCSsICD-U40 unit.

    2006 John Hyde, USB Design By Example Page 13

  • 8/14/2019 How to Use USB Without Knowing USB

    14/14

    Figure 14: The DLP-VLOG is designed to showcase Vinculums capabilities.

    The application program first checks to see if a flash drive is present if one is not found then

    the PIC goes back to sleep since there is no point collecting data if there is no where to store it.Once a flash drive is found the PIC starts a data collection cycle: it first reads the real time fromthe Dallas/Maxim DS1302, then the two analog signals and the battery voltage, then thetemperature and humidity. This data is then written to the flash drive and the system goes back tosleep to save battery power. This cycle repeats while a flash drive is present and the battery ischarged. The flash drive may be removed at any time and the collected data may then beanalyzed using a PC.

    The source code for the application is available with the Development Kit so that you cancustomize the data collected and the time interval between samples. Don designed the board asan evaluation tool for Vinculum designs but I can see many applications where this battery-

    operated, portable data logger would be a great fit as is.

    Embedded flash drive designs now enabled

    I hope that I have shown you that projects built around a flash drive are now easy. TheVinculum ASIC encapsulates all of the required industry standard specifications and presents asimple DOS-like command line interface that is accessed via a serial port (or SPI or parallelFIFO). You add your favorite microcontroller with an application program to control theVinculum. I presented a few projects to fuel your imagination. My examples used a CypressPSoC and a MicroChip PIC but the code is readily ported to a different microcontrollerarchitecture. Your project can collect data that is later analyzed on a PC or it can be used to

    redistribute data that was created on a PC via lower cost platforms. Project data may be updatedby simply swapping flash drives.

    If you can read and write to a serial port then, with Vinculum, you can read and write data fileson flash drives. I would be interested to hear about projects in which you have creatively used aVinculum and a flash drive.

    Happy developing!

    2006 John Hyde, USB Design By Example Page 14