Author Topic: Interfacing microprocessor serial port with USB printer  (Read 1285 times)

0 Members and 1 Guest are viewing this topic.

Offline birdTopic starter

  • Newbie
  • Posts: 4
  • Country: au
Interfacing microprocessor serial port with USB printer
« on: August 22, 2020, 09:23:34 pm »
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.
 

Offline greenpossum

  • Frequent Contributor
  • **
  • Posts: 408
  • Country: au
Re: Interfacing microprocessor serial port with USB printer
« Reply #1 on: August 22, 2020, 09:33:01 pm »
That won't work. USB levels and protocols are nothing like serial port levels and protocols. You'll need a converter chip.
 

Offline birdTopic starter

  • Newbie
  • Posts: 4
  • Country: au
Re: Interfacing microprocessor serial port with USB printer
« Reply #2 on: August 22, 2020, 09:48:14 pm »
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.
« Last Edit: August 22, 2020, 09:54:40 pm by bird »
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3116
  • Country: us
Re: Interfacing microprocessor serial port with USB printer
« Reply #3 on: August 23, 2020, 02:19:30 am »
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.
 

Offline MosherIV

  • Super Contributor
  • ***
  • Posts: 1530
  • Country: gb
Re: Interfacing microprocessor serial port with USB printer
« Reply #4 on: August 23, 2020, 09:45:53 am »
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 lines
USB is 0V/5V on differential pair (D+ and D-) with 0V

Then 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.
 

Offline Dabbot

  • Regular Contributor
  • *
  • Posts: 192
  • Country: au
Re: Interfacing microprocessor serial port with USB printer
« Reply #5 on: August 23, 2020, 10:20:58 am »
Why not grab yourself a thermal printer with a serial port?

For example: https://www.adafruit.com/product/597
 

Offline wraper

  • Supporter
  • ****
  • Posts: 17333
  • Country: lv
Re: Interfacing microprocessor serial port with USB printer
« Reply #6 on: August 23, 2020, 10:43:47 am »
Drop using COMM port, many microcontrollers now have USB peripheral devices to interface to usb.
It must be with USB host capability. Not simply USB peripheral. End even then good luck writing code to make it work.
 

Offline birdTopic starter

  • Newbie
  • Posts: 4
  • Country: au
Re: Interfacing microprocessor serial port with USB printer
« Reply #7 on: August 23, 2020, 07:37:49 pm »
Re levels on COM ports,

"First, the electrical interfaces are different and not compatible:
COMM (Serial) is +/-12V with Tx, Rx and 0V lines
USB 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...
 

Offline wraper

  • Supporter
  • ****
  • Posts: 17333
  • Country: lv
Re: Interfacing microprocessor serial port with USB printer
« Reply #8 on: August 23, 2020, 07:41:14 pm »
Re levels on COM ports,

"First, the electrical interfaces are different and not compatible:
COMM (Serial) is +/-12V with Tx, Rx and 0V lines
USB 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...
Then 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.
 

Offline birdTopic starter

  • Newbie
  • Posts: 4
  • Country: au
Re: Interfacing microprocessor serial port with USB printer
« Reply #9 on: August 23, 2020, 07:47:48 pm »
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...'
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3116
  • Country: us
Re: Interfacing microprocessor serial port with USB printer
« Reply #10 on: August 23, 2020, 10:09:40 pm »
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

 

Offline wraper

  • Supporter
  • ****
  • Posts: 17333
  • Country: lv
Re: Interfacing microprocessor serial port with USB printer
« Reply #11 on: August 23, 2020, 10:20:21 pm »
And then, there's this product selling for $95:

https://microcontrollershop.com/product_info.php?products_id=5031
Should be be noted that it won't work with low cost printers. Printer must support PostScript or PCL for it to work.
 

Offline Renate

  • Super Contributor
  • ***
  • Posts: 1460
  • Country: us
Re: Interfacing microprocessor serial port with USB printer
« Reply #12 on: August 24, 2020, 01:49:44 am »
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.)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf