Interfacing microprocessor serial port with USB printer  - Page 1
Forum section: electronics / beginners

author: bird
author_rank: Newbie
timestamp: August 22, 2020, 09:23:34 pm
content: First post. I am trying to work out how to interface a microprocessor COM port (single pin + ground of course) with a USB printer. I am tempted just to connect ground and COM port pins to the USB data lines but suspect this may not work out. The COM port is 5V tolerant. This is not a windows/linux/mac machine so I don't want to use drivers.

author: greenpossum
author_rank: Frequent Contributor
timestamp: August 22, 2020, 09:33:01 pm
content: That won't work. USB levels and protocols are nothing like serial port levels and protocols. You'll need a converter chip.

author: bird
author_rank: Newbie
timestamp: August 22, 2020, 09:48:14 pm
content: Thanks. Can anyone expand on that? My soldering iron is ready! I should add that I would use one of the serial to USB adaptors that are available, but my microprocessor outputs the data stream asynchronously on one wire and earth rather than an RS232 plug.

author: ledtester
author_rank: Super Contributor
timestamp: August 23, 2020, 02:19:30 am
content: The USB protocol and USB printers themselves are rather complicated. I think you're best option is to have your micro communicate with a Raspberry Pi running Linux or Windows which then talks to the printer.

author: MosherIV
author_rank: Super Contributor
timestamp: August 23, 2020, 09:45:53 am
content: As other have said, not easy and that is an understatement!First, the electrical interfaces are different and not compatible:COMM (Serial) is +/-12V with Tx, Rx and 0V linesUSB is 0V/5V on differential pair (D+ and D-) with 0VThen you have the protocol that each talk?Serial is entirely propritery by the application. Only the protocol bit level is configurable (baud rate, no of bits per byte, parity etc)USB has multiple layers. First there is the basic USB control layer, where host and device must first hand shake and then agree what the device type is.There is a device type class for printers. Since printers vary so much, much of the next layer up (actual transfer of image data) is almost propritery to each manufacturer and device.Most manufacturers now use postscript or PCL (HP rival to postscript)However, within these common protocols, there are manufacturer specific sections which the printer will use for parameters which the standard protocol does not cover.I am not saying that it is not possible - just very very very very difficult.Drop using COMM port, many microcontrollers now have USB peripheral devices to interface to usb.

author: Dabbot
author_rank: Regular Contributor
timestamp: August 23, 2020, 10:20:58 am
content: Why not grab yourself a thermal printer with a serial port?For example:https://www.adafruit.com/product/597

author: wraper
author_rank: Unknown
timestamp: August 23, 2020, 10:43:47 am
content: Quote from: MosherIV on August 23, 2020, 09:45:53 amIt must be with USB host capability. Not simply USB peripheral. End even then good luck writing code to make it work.

author: bird
author_rank: Newbie
timestamp: August 23, 2020, 07:37:49 pm
content: Re levels on COM ports,"First, the electrical interfaces are different and not compatible:COMM (Serial) is +/-12V with Tx, Rx and 0V linesUSB is 0V/5V on differential pair (D+ and D-) with 0V"I am trying to work out how t connect the COM post on a Maximite. This runs on 5V so I'm not sure how it would produce a 12v signal...

author: wraper
author_rank: Unknown
timestamp: August 23, 2020, 07:41:14 pm
content: Quote from: bird on August 23, 2020, 07:37:49 pmThen it's UART, not RS232. It will not work regardless since USB is completely different interface. Data lines use 3.3V BTW, not that it matters.

author: bird
author_rank: Newbie
timestamp: August 23, 2020, 07:47:48 pm
content: Thanks for speedy reply. On the Backshed forum it is suggested that a parallel printer might work. In that case presumably 8 of the Maximite I/O ports would be used. Any comments? Are you familiar with the Maximite (uses BASIC, suggested writing to the port, as in PRINT...'

author: ledtester
author_rank: Super Contributor
timestamp: August 23, 2020, 10:09:40 pm
content: There's a bunch of electrical issues you'll want to check before directly connecting up your Maxmite bus to a parallel port. For starters, what voltage does it operate at, 3.3 or 5? How much current can each port pin deliver?There are a bunch of older printers (like from the 90s) that have a serial port -- e.g. the HP Laserjet 4, 5.And then, there's this product selling for $95:https://microcontrollershop.com/product_info.php?products_id=5031

author: wraper
author_rank: Unknown
timestamp: August 23, 2020, 10:20:21 pm
content: Quote from: ledtester on August 23, 2020, 10:09:40 pmShould be be noted that it won't work with low cost printers. Printer must support PostScript or PCL for it to work.

author: Renate
author_rank: Super Contributor
timestamp: August 24, 2020, 01:49:44 am
content: Your basic problem is that a USB UART and a USB printer are both peripherals.You need a host in there (if you want to use USB).If your MCU had host mode USB you could connect to the printer directly.If your MCU had peripheral mode USB you could connect it through a USB host to the printer.If your MCU had WiFi or Bluetooth you could connect to a printer or a printer server (if they had the capability).(In the drawing, the USB host and hub are drawn separately although they could be the same physical unit.)