Design of LPT-USB printer driver based on CH375

Publisher:电子科技爱好者Latest update time:2006-08-28 Source: 国外电子元器件 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1 Introduction

  This topic comes from Beijing Puji General Company. Since the company's existing stand-alone spectroscopic instruments (such as 1810 and T6, etc.) use parallel port printing technology, and with the gradual popularization of USB printer technology, there are fewer and fewer parallel port printers. Some users' original printers are just The USB interface is not a parallel port, so the printer support of existing instruments cannot meet user needs. In order to connect the company's parallel port instruments directly to the USB printer, the author designed a LPT-USB printer driver to realize the connection between the parallel port instrument and the USB printer.

  The author uses microcontroller and USB bus interface device to realize the design of LPT-USB printer driver. This design will enable the direct printing of parallel port data on a USB printer, overcoming the disadvantage that some parallel port instruments must be connected to a parallel port printer in order to print, and greatly facilitate the use of users.

2 Characteristics and working principle of CH375

2.1 Characteristics of CH375


  CH375 is a USB bus universal interface circuit that supports HOST host mode and SLAVE device mode. CH375 internally integrates PLL frequency multiplier, master-slave USB interface SIE, data buffer, passive parallel interface, asynchronous serial interface, command interpreter, protocol processor to control transmission, general firmware program, etc. On the local side, CH375 has an 8-bit data bus and read, write, chip select control lines and interrupt outputs, which can be easily connected to the system bus of controllers such as microcontrollers, DSPs, and MCUs. The USB host mode of CH375 supports various commonly used USB full-speed devices. External microcontrollers, DSPs, and MCUs can communicate with USB devices through CH375 according to the corresponding USB protocol. The characteristics of CH375 are as follows:

(1) The full-speed USB-HOST host interface complies with USB1.1 and supports dynamic switching of host and device modes. The peripheral components only require 1 crystal and 2 capacitors;

(2) Host endpoint input and output buffers Each has 64 bytes and supports commonly used 12Mb/s full-speed USB devices;

(3) Supports control transmission, batch transmission, and interrupt transmission of USB devices;

(4) Automatically detects the connection and disconnection of USB devices, and provides device connection and disconnection Notification of opening;

(5) Built-in protocol processor for control transmission, simplifying commonly used control transmission;

(6) Parallel interface includes 8-bit data bus, 4-wire control: read strobe, write strobe, chip select input and interrupt output ;

(7) The serial interface includes serial input, serial output and interrupt output, and supports dynamic adjustment of communication baud rate.

(8) Supports 5V power supply voltage and 3.3V power supply voltage.

2.2 Working principle of CH375

  As shown in Figure 1, CH375 can be easily connected to the system bus of various 8-bit microcontrollers, DSPs, and MCUs through passive parallel interface circuits, and can coexist with multiple peripheral devices. The parallel port signal lines include 8-bit bidirectional data bus D7-DO, read strobe input RD, write strobe input WR, chip select input CS, interrupt output INT and address input line AO. RD and WR of CH375 can be connected to the read strobe output pin and write strobe output pin of the microcontroller respectively. INT can be connected to the interrupt input pin of the microcontroller, and the interrupt request is active low. When CS, RD and AO are all low level, the data in CH375 is output through D7-DO; when CS, WR and AO are all low level, the data on D7-DO is written to CH375; when CS and WR are both When A1 is low level and A1 is high level, the data on D7-DO is written to CH375 as a command code.

3 Hardware circuit design

  Figure 2 shows the hardware circuit of the microcontroller controlling the USB printer through CH375. CH375 is connected to the system bus of the 8-bit microcontroller through a passive parallel interface circuit. The TXD pin of CH375 is grounded, so that CH375 works in parallel port mode. The 8-bit bidirectional data bus D7-DO of CH375 is directly connected to the PO data port of the microcontroller. RD and WR are connected to the read strobe output pin and write strobe output pin of the microcontroller respectively. The chip select signal CS is connected to the P2.6 pin of the microcontroller. When this pin is low level, CH375 is gated. INT can be connected to the interrupt input INTO pin of the microcontroller, and the interrupt request is active low. The address input line AO ​​is connected to the P2.5 pin of the microcontroller. When the AO pin is high level, the command port is selected and commands can be written. When the AO pin is low level, the data interface is selected and data can be read and written.

  The 74HC245 three-state bidirectional bus driver is used as the interface for the printer port to transmit parallel port data to the microcontroller. Its chip select signal is connected to P2.7 of the microcontroller, and the direction control bit DIR is connected to P3.4 of the microcontroller. When DIR is high level, Data is transmitted from port A to port B. At this time, the microcontroller can obtain the parallel port data by reading the 74HC245 data port. The printer status signal BUSY is connected to the P1.5 pin of the microcontroller, and the parallel port data acquisition control signal CTRL is directly connected to INT1 of the microcontroller. Interrupt pin, when INT1 generates an interrupt, the microcontroller reads data from the parallel port and then sends it to the printer for printing.

4 Software Design

4.1 Software Process


  The software process is shown in Figure 3. The software is programmed in C language, and the communication process mainly includes initialization and parallel port data collection.

  Parallel port data collection is carried out through interrupts. The control signal CTRL for collecting data is connected to the interrupt INT1 pin of the microcontroller, and the parallel port data is collected by continuously detecting the status of INT1. When the printer is not busy (BUSY=0), if an INT1 interrupt is generated, the parallel port data is read from the data interface of the 74HC245, and the printer busy flag BUSY is set to 1 (indicating that the printer is busy). When the data has been sent to the printer for printing, Then set the printer busy flag BUSY to 0. Then repeat the above steps to collect and print parallel port data.

  The initialization process is divided into microcontroller initialization and printer enumeration initialization. The initialization process of the microcontroller is to directly write the initialization value to the corresponding I/0 port and set the watchdog. The watchdog_init() function can be called to set the watchdog.

  The enumeration initialization process of the printer is very important. To print the collected parallel port data, the printer must first be successfully enumerated and initialized. The initialization USB printer function init_print() mainly uses the following main functions:

4.2 Main program source code

The main program code is as follows:

5 Conclusion

  This article introduces in detail the design and C language implementation of the LPT-USB printer driver based on the 80C51 microcontroller and the CH375 USB bus universal interface circuit. The test results show that this design can be used to print parallel port instrument data directly through a USB printer, and the printing results are correct. This design is now used on parallel port instruments. Parallel port instruments can use this driver to directly connect to a USB printer and print. This overcomes the disadvantage that some parallel port instruments must be connected to a parallel port printer to print, making it convenient for users.

Reference address:Design of LPT-USB printer driver based on CH375

Previous article:Hydrographic cableway testing system constructed using AT89 microcontroller
Next article:Design of LPT-USB printer driver based on CH375

Recommended ReadingLatest update time:2024-11-16 16:22

Fun low-power data acquisition system based on M-BUS
Introduction   With the rapid development of society, smart communities have gradually entered people's lives, and the automatic meter reading system is one of the important functions of smart communities. In terms of water, electricity, and gas management, the use of automatic meter reading technology can not only s
[Microcontroller]
STM8 BUS OFF fast and slow recovery strategy
Preface: An error on the CAN bus will cause the CAN controller to enter the BUS OFF state. For details, please refer to the CAN specification. The CAN controller provides automatic recovery and manual recovery functions. 1. Automatic recovery Automatic recovery is relatively simple, turn on the automatic recov
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号