Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 02:09 20 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Printing to 'lineprinter' ie hard copy

     Page 1 of 2    
Author Message
Herry

Senior Member

Joined: 31/05/2014
Location: Australia
Posts: 261
Posted: 08:19pm 08 Aug 2020
Copy link to clipboard 
Print this post

While breathlessly waiting for my CMM2 kit, I am now looking (via VB6) at very old 1999 code under BASIC (QB before compiling). Is one of the inconsistencies LPRINT?  What is the MMB version of print to a hard copy?
Senior?!  Whatever it says, I'm a complete and utter beginner...
 
Sasquatch

Senior Member

Joined: 08/05/2020
Location: United States
Posts: 296
Posted: 08:29pm 08 Aug 2020
Copy link to clipboard 
Print this post

There is no dedicated printer interface on the CMM2.  You could print to a file or to a device (possibly a printer) on one of the serial ports.

See the manual for:

OPEN fname$ FOR mode AS[#]fnbr
OPEN comspec$ AS [#]fnbr
Print #nbr
CLOSE [#]nbr [,[#]nbr]

Also see the section on "Sequential File Access"
-Carl
 
Herry

Senior Member

Joined: 31/05/2014
Location: Australia
Posts: 261
Posted: 08:44pm 08 Aug 2020
Copy link to clipboard 
Print this post

Thanks Carl. That's a shame. I used BASIC to run an entire service office many years ago (rather than just games) and it would have been good to emulate that. I'll have a try with your suggestion. I imagine the printer will be connected via the console USB  socket, and for ease of programming, the necessary code be encapsulated in a  subroutine (perhaps called LPRINT!)?
Senior?!  Whatever it says, I'm a complete and utter beginner...
 
Sasquatch

Senior Member

Joined: 08/05/2020
Location: United States
Posts: 296
Posted: 08:58pm 08 Aug 2020
Copy link to clipboard 
Print this post

Well, NO,  You can't connect a printer to the USB socket.  You would need a printer with a serial port (most of the old line printers had serial and/or centronics parallel)  or you could print to a file on the SD card and then print to hard copy from a PC.

You could make a subroutine for LPRINT and that might make converting your old files easier.  You could also search/replace for "LPRINT" and replace with "PRINT #1,"

Then depending on where you have file #1 opened to (i.e. file or serial port) the printed data will go there.
-Carl
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1085
Posted: 09:12pm 08 Aug 2020
Copy link to clipboard 
Print this post

There are enough pins in the I/O connector to cobble together your own parallel port.

8 data bits, a strobe, a few others, some status inputs...
Just watch the voltages or buffer the signals.

Consider:
Dot-matrix printer interface for the MM
Printermite
Visit Vegipete's *Mite Library for cool programs.
 
Sasquatch

Senior Member

Joined: 08/05/2020
Location: United States
Posts: 296
Posted: 09:41pm 08 Aug 2020
Copy link to clipboard 
Print this post

I don't have a Laser Printer with a serial or parallel port at this time.  My recollection is that when I had an HP-4L with a parallel port, you could send it plain text and it would pretend to be a line-printer.  It would print plain text with a default 12pt font and 80 columns width etc. no special formatting or embedded codes needed.
-Carl
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 1995
Posted: 11:13pm 08 Aug 2020
Copy link to clipboard 
Print this post

it all depends what you want. Printed output isn't hard whatever.

Serial is *really* easy to do, Centronics (parallel) is more involved but still very doable method.

You could do a serial printer using a serial port and then LPrint is just a wrapper for the strings you want to output...

Aimed at MicroMites (you don't have CSubs easily on CMM2), but see http://www.fruitoftheshed.com/MMBasic.LPrint-for-attached-serial-printer-legacy-BASIC-statement.ashx

Should give you some idea of how easy it is to do.

LList presents some difficulties, but you could always open the basic source from a prog and jut spool it to the printer of your choice.

Serial printer could be one of those little thermal panel jobbies in that wiki or an Epson FX80 with the serial to parallel converter. You might have difficulty finding that precise combo (and for not many $$$) but again, it should get the creative juices flowing.
Edited 2020-08-09 09:16 by CaptainBoing
 
Herry

Senior Member

Joined: 31/05/2014
Location: Australia
Posts: 261
Posted: 08:48pm 22 Aug 2020
Copy link to clipboard 
Print this post

Working from the post by Sasquatch, I am thinking now on the lines of interfacing say the COM2 pin (precaution as 5v tolerant) with a USB connection to printer. Most of the serial to USB adaptors I've seen are for full serial connection using various lines(for synchronous operation?). I'll look further because it must be technically possible to interface COM2 and ground with the USB data lines. Thoughts?

The subroutine would then be trivial, say

SUB LPRINT XP$
  OPEN “COM2:4800” AS #5
  PRINT #5, XP$
  Data$ = INPUT$(20, #5) 'up to 20 chars, if more send in slices. May not need
  CLOSE #5
END SUB

Call by LPRINT "Testing" (exact same syntax as old QBASIC!)
Edited 2020-08-23 06:50 by Herry
Senior?!  Whatever it says, I'm a complete and utter beginner...
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5923
Posted: 09:35pm 22 Aug 2020
Copy link to clipboard 
Print this post

  Herry said  Working from the post by Sasquatch, I am thinking now on the lines of interfacing say the COM2 pin (precaution as 5v tolerant) with a USB connection to printer. Most of the serial to USB adaptors I've seen are for full serial connection using various lines(for synchronous operation?). I'll look further because it must be technically possible to interface COM2 and ground with the USB data lines. Thoughts?


USB to serial adapters are for plugging into a USB host such as a computer. They do NOT allow you to plug a USB device into a serial port.
TO use a USB printer, you will need a processor that is acting as a USB host and then you will need it to have the right drivers for your printer.

If you have a printer with a Centronics printer port and uses something like HP PCL to communicate, you could make a parallel interface relatively easily. (Not easy at all but doable)

Much easier to save your file to a PC and print from there.

Jim
VK7JH
MMedit   MMBasic Help
 
zeitfest
Guru

Joined: 31/07/2019
Location: Australia
Posts: 396
Posted: 10:43pm 22 Aug 2020
Copy link to clipboard 
Print this post

Maybe try something like this  adapter...I have no idea if it works or not though (or cost or supply), let me know any results, it would be quite useful
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5923
Posted: 11:04pm 22 Aug 2020
Copy link to clipboard 
Print this post

  zeitfest said  Maybe try something like this  adapter...I have no idea if it works or not though (or cost or supply), let me know any results, it would be quite useful

In theory it should work.
You will probably need  some TTL to RS232 conversion  and then code to convert the text (or graphics) to the correct printer language.

At $95US it's way too expensive for me to even think about playing with.

Jim
VK7JH
MMedit   MMBasic Help
 
Herry

Senior Member

Joined: 31/05/2014
Location: Australia
Posts: 261
Posted: 11:21pm 22 Aug 2020
Copy link to clipboard 
Print this post

Thanks all. Still thinking around this. Isn't it just matter of changing levels. There must be a chip to do that. I have feeling it's all possible. I am an optimist..
Senior?!  Whatever it says, I'm a complete and utter beginner...
 
Herry

Senior Member

Joined: 31/05/2014
Location: Australia
Posts: 261
Posted: 12:16am 23 Aug 2020
Copy link to clipboard 
Print this post

  TassyJim said  
  zeitfest said  Maybe try something like this  adapter...I have no idea if it works or not though (or cost or supply), let me know any results, it would be quite useful

In theory it should work.
You will probably need  some TTL to RS232 conversion  and then code to convert the text (or graphics) to the correct printer language.

At $95US it's way too expensive for me to even think about playing with.

Jim


...it would be OK if results were certain but at $95 it is also too much for me if purely an experiment. It would be interesting to see what a scope or logic analyser makes of the COM pin outputs when they are being printed to....
Senior?!  Whatever it says, I'm a complete and utter beginner...
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5923
Posted: 02:32am 23 Aug 2020
Copy link to clipboard 
Print this post

Doing the TTL to RS232 levels is the easy part.

Start with your printer capabilities.
Does it do PCL or equivalent?

My networked laser description is
  Quote  HP Color LaserJet Pro M252 PCL 6

I know it will understand PCL which makes sending text relatively easy.
Laser printers print page at a time so it would need formfeed commands sent at the appropriate time.

I do have an older laser printer that is PCL 5 and it does have a parallel port.
I probably have a serial to centronics adapter somewhere in the collection but I have no desire to spend time playing.

Most new domestic printers are GDI so rely on the PC to do all the work.
They would not be suitable.

In the last shed cleanup, I disposed of a couple of dot matrix printers but kept one.
I even have a box of tractor feed paper if you really want retro.

Start with your printer capabilities.

Jim
VK7JH
MMedit   MMBasic Help
 
zeitfest
Guru

Joined: 31/07/2019
Location: Australia
Posts: 396
Posted: 03:03am 23 Aug 2020
Copy link to clipboard 
Print this post

Yeah $95 is out of reach ... there's not exactly a Lambo in the garage !
Pity but.  The HP and Brother lasers usually have PCL though.
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2294
Posted: 06:54am 23 Aug 2020
Copy link to clipboard 
Print this post

you could always roll-your-own using a RPi zero and a short (python) script on the RPi that takes data from the serial port and sends to the driver for an attached USB printer. it might not be quite as small as the unit shown, but a whole lot cheaper.

there probably smaller boards similar to the RPi zero that could also do much the same thing. basically anything running linux would do.


cheers,
rob   :-)
 
Herry

Senior Member

Joined: 31/05/2014
Location: Australia
Posts: 261
Posted: 06:54am 23 Aug 2020
Copy link to clipboard 
Print this post

PCL? I was separately coming to the conclusion that the problem was not one of hardware (surely there's any easy way to change levels) but of software protocols, given that there's no question of a driver interceding. Probably no normal Windows type printer responds to pure ASCII as a simple stream? I have Brother MFC-7362N, HL 1210 and HL 3045 CN...
Senior?!  Whatever it says, I'm a complete and utter beginner...
 
Herry

Senior Member

Joined: 31/05/2014
Location: Australia
Posts: 261
Posted: 07:43am 23 Aug 2020
Copy link to clipboard 
Print this post

  robert.rozee said  you could always roll-your-own using a RPi zero and a short (python) script on the RPi that takes data from the serial port and sends to the driver for an attached USB printer. it might not be quite as small as the unit shown, but a whole lot cheaper.

there probably smaller boards similar to the RPi zero that could also do much the same thing. basically anything running linux would do.


cheers,
rob   :-)


Thanks Robert!  I'll consider this further. Means coding in another lingo though... (have to take my blinkers off)
Senior?!  Whatever it says, I'm a complete and utter beginner...
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9083
Posted: 09:19am 23 Aug 2020
Copy link to clipboard 
Print this post

Printing to a LPT(parallel port) dot-matrix printer is really quite easy, using some pins and the PORT command(as hinted at above by vegipete), and I have developed dedicated dot-matrix printer controller things as linked to by vegipete, but at the end of the day, THESE days, you are better of using a thermal printer.

They take standard thermal printer receipt paper rolls, and print out on the paper just like any receipt you get these days from pretty much any shop.

They are quite easy to drive, as most of them only need a serial COM port, and generally speaking, you can ignore the printer TXD(out) line, and only need the printer RXD(in) and ground for the serial link - done.

Most of the thermal printers I have played with, seem to operate at 19k2 baud - easily within the capabilities of the CMM2 COM port pins.

Thermal printers DO SUCK QUITE A LOT OF CURRENT though, so you WILL(absolutely) need an external regulated power supply for the printer, capable of at least 2-amps or so.

HERE is a link to the printers I was playing with at the time, and they are still my go-to printer today.
Smoke makes things work. When the smoke gets out, it stops!
 
zeitfest
Guru

Joined: 31/07/2019
Location: Australia
Posts: 396
Posted: 09:59am 23 Aug 2020
Copy link to clipboard 
Print this post

From memory (and a long time ago)  many lasers using PCL, Postscript etc had a default start-up config ...if ascii text was sent to the printer, it would be in memory and a formfeed would then eject a page with the text printed in the basic default font etc. A very useful thing ! PCL itself was easy enough, a bit fiddly but OK.

Edit - Unfortunately it looks like your printers are the Windows GDI type.  
Edited 2020-08-23 20:07 by zeitfest
 
     Page 1 of 2    
Print this page
© JAQ Software 2024