AN_106_Interfacing_USB_Printer_using_Vinculum_Host_Controller_FT_000064.pdf

(882 KB) Pobierz
Microsoft Word - AN_106_Interfacing_USB_Printer_using_Vinculum_Host_Controller_FT_000064_
Future Technology Devices International Ltd.
Application Note AN_106
Interfacing to a USB Printer using Vinculum
VNC1L Host Controller
Document Reference No.: FT_000064
Version 1.0
Issue Date: 2008-11-24
This application note describes how to add printing capability to an embedded design via a USB
interface using FTDIÓs Vinculum Host controller VNC1L. VNC1L implements USB Printer Class and
gives a command monitor port interface for controlling USB printers using standard PCL ASCII
commands. Details of how a battery operated portable printer HP-DeskJet 460 printer was
interfaced with FreescaleÓs 16-bit micro-controller HC12 using VNC1L on SPI monitor port are
presented.
This design can be applied to a variety of real-life embedded applications including medical
portable devices, field tester devices, logistics, point of sales, rentals, queuing systems, ticketing
system, gas receipts, etc. that require a printer interface. We highlight a product in the market
Quantifit from OHD that uses VNC1L to provide USB printer capability to a field fitness testing
device using the design in this application note.
Future Technology Devices International Limited
Unit 1, 2 Seaward Place, Centurion Business Park, Glasgow G41 1HH United Kingdom
Tel.: +44 (0) 141 429 2777 Fax: + 44 (0) 141 429 2758
E-Mail (Support): vinculum.support@ftdichip.com Web: http://www.ftdichip.com
Copyright ¨ 2008 Future Technology Devices International Limited
721518274.019.png
Document Reference No.: FT_000064
Using Vinculum USB Host Controller Printer Interface Application Note AN_106
Version 1.0
Clearance No.: FTDI# 68
Table of Contents
1 Introduction............................................................................................ 2
2 Project framework ................................................................................. 3
2.1 Project Installation ..............................................................................................3
2.2 Project Structure .................................................................................................3
3 Software Theory and Command Structure .......................................... 4
3.1 Block Diagram: VNC1L Printer Interface Design ..............................................4
3.2 USB Printer Class Details ...................................................................................4
3.3 VNC1L Printer Interface Commands..................................................................5
3.4 Printer PCL Commands ......................................................................................7
3.5 HC12 Firmware Details........................................................................................8
3.5.1 Theory of Operation ................................................................................................................. 8
3.5.2 Firmware Routines................................................................................................................... 9
4 Hardware Connections and Running the Demo ................................ 10
4.1 Jumper Settings ................................................................................................10
4.2 LED Usage..........................................................................................................12
4.3 Printer Output ....................................................................................................12
5 Summary .............................................................................................. 13
6 Contact Information............................................................................. 14
Appendix A Î Acknowledgements ........................................................... 15
Appendix B - References .......................................................................... 16
Appendix C Î HC12 Firmware Source Code ............................................ 17
Appendix D Î Revision History................................................................. 25
Copyright ¨ 2008 Future Technology Devices International Limited
1
721518274.020.png 721518274.021.png 721518274.022.png
Document Reference No.: FT_000064
Using Vinculum USB Host Controller Printer Interface Application Note AN_106
Version 1.0
Clearance No.: FTDI# 68
1 Introduction
In the printer marketplace, USB is the defacto interconnect standard for personal printers. The Universal
Serial Bus (USB) has several advantages over previous generation of connection methods such as parallel
ports. A USB port is much faster than a parallel port (can handle 12Mbps) and a single port can handle
different devices e.g. a USB port can handle USB Flash disks, mouse and keyboard whereas the parallel
port was dedicated for the printer connection. The USB enumeration process that occurs when a device is
connected to the USB host handles the device requirements using standard USB descriptors supplied by
the device. This is completely transparent to user. Users just plug in the printer and see it is ready for
use.
USB 2.0 specification defines a specific device class for printing devices. VNC1L USB Host controller
implements and supports USB print class device, configuration, and interface and endpoint descriptors as
per USB printer device specification. It also supports USB printer class specific request and response
structure used by basic Printer Command language (PCL) interface. Note: The VNC1L Host does not
provide drivers for printers.
Most modern printers support built-in fonts and as such they can print text, using basic printer control
codes, directly from the Vinculum Monitor. Other printers will require embedded fonts or graphics to be
sent as part of a print job. Most modern printers support a PCL language as the protocol for an operating
system driver to communicate with the printer. If the printer supports PCL language it can be controlled
by the VNC1L using the methods outlined in this application note.
Copyright ¨ 2008 Future Technology Devices International Limited
2
721518274.001.png 721518274.002.png 721518274.003.png
Document Reference No.: FT_000064
Using Vinculum USB Host Controller Printer Interface Application Note AN_106
Version 1.0
Clearance No.: FTDI# 68
2 Project framework
2.1 Project Installation
The VPD.msi is the installation file for the project. When this file is run, the installer will install the project
files into C:\Program Files\Vinculum Printer Demo folder (the installer will give an option for selecting the
target folder). After successful installation the target folder is created and all source code files will be
present as per the file structure shown in Figure 1 below.
2.2 Project Structure
Project Folder: ÐC:\Program Files\Vinculum Printer DemoÑ contains a project repository of all the files
needed to implement the project. These include source code, PCB GerberÓs, output files, readme files and
tools used for implementing the demo. The structure of the project folder is shown in Figure 1.
Figure 1 Directory Structure
Output: This folder contains following files
Vdem7.sx
Distributable source code. It can be used to flash into microcontroller but doesnÓt
contain source listing when loaded into debugger.
Vdem7.mrk
Assembler output file, used for debugging.
Vdem7.bbt
Assembler Output file, probably used for debugging.
Vdem7.dbg
Debugger File
Vdem7.abs
File to be loaded into debugger (hiwave.exe)
PCB: This folder contains all the Gerber, Solder Mask, Silk Screen and Drill files for designing the Printer
daughter board.
Readmes: This folder contains readme files with more details on firmware files, version etc.
Source: This folder contains the assembly source code and list files for memory maps
Vdem7.asm
Assembly source code (text file)
Vdem7.lst Listing file, provides memory locations for program code (text file).
Tools: For developing this demo application we have used the FTDI V-Eval utility V-Eval.exe. This
provides the user with a terminal application that acts as a debug tool to intercept the messages on the
VNC1L monitor port. This application is provided in the tools folder, along with the links to the IDE used
for writing the Freescale assembly code.
Copyright ¨ 2008 Future Technology Devices International Limited
3
721518274.004.png 721518274.005.png 721518274.006.png 721518274.007.png 721518274.008.png 721518274.009.png 721518274.010.png 721518274.011.png 721518274.012.png 721518274.013.png
Document Reference No.: FT_000064
Using Vinculum USB Host Controller Printer Interface Application Note AN_106
Version 1.0
Clearance No.: FTDI# 68
3 Software Theory and Command Structure
3.1 Block Diagram: VNC1L Printer Interface Design
SW1
M
o
n
i
t
o
r
USB-2
Freescale
HC12
Micro-
controller
SPI
Vinculum VNC1L
USB-1
HP DeskJet 460
Daughter
board
V-Eval Board
Figure 2 Block Diagram of VNC1L USB Printer Interface
Figure 2 shows the connections between the various devices used in this application note. An FTDI V-
Eval board is used as the base development platform. This includes the VNC1L device, prototyping area,
external connectors and two USB Host ports. An external microcontroller is required to control the
VNC1L. In this application note, a Freescale micro-controller on a daughter board is connected to the V-
Eval on the SPI bus.
The VNC1L monitor port is selected on V-Eval board through jumper settings (see Section 4.1). Three
interface options are possible Î UART, SPI and FIFO. In this set-up the monitor port SPI interface was
used. The Freescale micro-controller is then connected to the V-Eval SPI header.
When a printer is attached to Type A USB port of the V-Eval board, it is enumerated and a status
message is sent to the monitor port. This status message is captured by the HC12 micro-controller. The
VNC1L has two modes of commands - text based command and binary commands. To reduce the
bandwidth on the SPI bus, the binary command set (also called the Short Command Set) is used.
In the micro-controller unit firmware, pressing switch SW1 on the V-Eval board generates a set of PCL
commands which are sent to the VNC1L on the V-Eval board via the SPI interface. VNC1L sends the
corresponding data on the USB to the printer. The printer takes the data, parses it using PCL and prints
the data to the paper. LED7 and LED8 on V-Eval board are used to indicate the status of printer (see
details in Section 4.2).
The same concept can be implemented in Windows Mobile devices (based on Win CE) that interface with
Vinculum VNC1L chip on monitor port. Applications can be written to send PCL commands to the printer.
3.2 USB Printer Class Details
USB Printer Class specification defines three class-specific requests Î GET_DEVICE_ID,
GET_PORT_STATUS and SOFT_RESET.
GET_DEVICE_ID (bRequest = 0)
This class-specific request returns a device ID string that is compatible with IEEE 1284. See IEEE 1284
for syntax and formatting information. A printer with multiple configurations, interfaces, or alternate
settings may contain multiple IEEE 1284 device ID strings. The wValue field is used to specify a zero-
Copyright ¨ 2008 Future Technology Devices International Limited
4
721518274.014.png 721518274.015.png 721518274.016.png 721518274.017.png 721518274.018.png
Zgłoś jeśli naruszono regulamin