Modern thermal printer to emulate 82240B
02-25-2018, 01:24 AM (This post was last modified: 02-25-2018 12:14 PM by tcab.)
Post: #1
 tcab Member Posts: 183 Joined: Dec 2017
Modern thermal printer to emulate 82240B
I'm looking for advice on how to print to a modern day thermal printer from my PC/Mac using the HP calculator codepage Modified_HP_Roman-8 in order to emulate a HP 82240B thermal printer. I happen to have a Epson TM-T20 thermal printer which uses the ESCPOS language.

Note that I'm not trying to print from a calculator to this printer (that's hard, needs infra red electronics etc). I'm just trying to print Free42 virtual printer output to this modern (and fast!) thermal printer.

The TM-T20 has a custom codepage feature but I don't know how to build that codepage and use it? There is some heavy duty Epson documentation - perhaps I need to send some custom bytes to the printer to define the custom code table and then select it that codepage before I print to the printer. Not at all sure how to define this codepage to match the 82240. Does anyone have any thoughts, advice or resources I could draw upon? Some 'code' in some programming language that defines the relevant codepage would be great.

There is a related thread on the HP codepage used in the 82240 printer.
02-25-2018, 03:17 AM
Post: #2
 Thomas Okken Senior Member Posts: 1,280 Joined: Feb 2014
RE: Modern thermal printer to emulate 82240B
If you can send graphics to the printer, you might be better off translating the bitmap part of the shell_print() calls to graphics escape sequences and sending only those. That way you'd get the actual HP-42S character shapes, no worrying about code pages, and as a bonus, PRLCD would also work.
02-25-2018, 11:41 AM (This post was last modified: 02-25-2018 11:43 AM by martinot.)
Post: #3
 martinot Junior Member Posts: 40 Joined: Aug 2017
RE: Modern thermal printer to emulate 82240B
Now you already have a printer, but if you ever get a new one there are several POS printers that support the full Unicode UTF-8 character set, which should be trivial to set up a convert map of HP Roman 8 charters to.

(One example of such POS printer: http://www8.hp.com/h20195/v2/GetDocument...pt-printer)

HP 35s, HP 50g, HP Elite X3, SwissMicros DM42
02-25-2018, 12:42 PM
Post: #4
 tcab Member Posts: 183 Joined: Dec 2017
RE: Modern thermal printer to emulate 82240B
(02-25-2018 03:17 AM)Thomas Okken Wrote:  If you can send graphics to the printer, you might be better off translating the bitmap part of the shell_print() calls to graphics escape sequences and sending only those. That way you'd get the actual HP-42S character shapes, no worrying about code pages, and as a bonus, PRLCD would also work.

I presume this would mean a custom build of Free42, adding some code to its shell_print() function. This would indeed be a powerful approach, with the downside of having to recompile Free42. Perhaps Free42 could have an option to generate another kind of file, a 'raw virtual out' which has all the information needed to print both text and graphics, which would mean custom builds of Free42 would not be necessary.

My current lazy approach has been to watch the text file generated by the 'Print to textfile' feature of Free42 - detect and read any new text output and print it to the TM-T20 thermal printer, using ESCPOS commands. This works, except for the rendering of special characters. And yes, I don't get graphics.
02-25-2018, 11:12 PM
Post: #5
 Thomas Okken Senior Member Posts: 1,280 Joined: Feb 2014
RE: Modern thermal printer to emulate 82240B
(02-25-2018 12:42 PM)tcab Wrote:
(02-25-2018 03:17 AM)Thomas Okken Wrote:  If you can send graphics to the printer, you might be better off translating the bitmap part of the shell_print() calls to graphics escape sequences and sending only those. That way you'd get the actual HP-42S character shapes, no worrying about code pages, and as a bonus, PRLCD would also work.

I presume this would mean a custom build of Free42, adding some code to its shell_print() function. This would indeed be a powerful approach, with the downside of having to recompile Free42. Perhaps Free42 could have an option to generate another kind of file, a 'raw virtual out' which has all the information needed to print both text and graphics, which would mean custom builds of Free42 would not be necessary.

In other words, you don't want to do it, and would prefer if I did it?
Sorry, but no.

(02-25-2018 12:42 PM)tcab Wrote:  My current lazy approach has been to watch the text file generated by the 'Print to textfile' feature of Free42 - detect and read any new text output and print it to the TM-T20 thermal printer, using ESCPOS commands. This works, except for the rendering of special characters. And yes, I don't get graphics.

That's not a bad approach, but as far as the special characters are concerned, bear in mind that the text file output from Free42 is UTF-8 encoded, not HP Roman.

You could even get graphics this way, using the "print to gif" feature.
02-26-2018, 02:08 AM
Post: #6
 mfleming Senior Member Posts: 706 Joined: Jul 2015
RE: Modern thermal printer to emulate 82240B
(02-25-2018 03:17 AM)Thomas Okken Wrote:  If you can send graphics to the printer, you might be better off translating the bitmap part of the shell_print() calls to graphics escape sequences and sending only those. That way you'd get the actual HP-42S character shapes, no worrying about code pages, and as a bonus, PRLCD would also work.

Here's a link to an interesting project in which the author was trying to build an HP82240B replacement using a low cost Chinese POS printer from TAS. He took the bitmap approach so you can learn something from his experience doing so.

My conclusion from his travails with two low cost units is that POS has an alternative scatological meaning
~Mark

Remember kids, "In a democracy, you get the government you deserve."
02-26-2018, 06:12 PM (This post was last modified: 02-26-2018 06:13 PM by martinot.)
Post: #7
 martinot Junior Member Posts: 40 Joined: Aug 2017
RE: Modern thermal printer to emulate 82240B
(02-25-2018 11:12 PM)Thomas Okken Wrote:  That's not a bad approach, but as far as the special characters are concerned, bear in mind that the text file output from Free42 is UTF-8 encoded, not HP Roman.

Great! When it is very easy if you just get a modern POS printer which supports Unicode UTF-8 (like the HP I linked to above).

Not applicable for the original poster (unless he sells his current and get a new), but generally a very good thing for us other users.

HP 35s, HP 50g, HP Elite X3, SwissMicros DM42
02-28-2018, 05:37 AM (This post was last modified: 07-07-2018 02:13 PM by tcab.)
Post: #8
 tcab Member Posts: 183 Joined: Dec 2017
RE: Modern thermal printer to emulate 82240B
(02-25-2018 11:12 PM)Thomas Okken Wrote:  You could even get graphics this way, using the "print to gif" feature.

I've been playing with this approach today and got something working. The Free42 "print to gif" feature generates sequentially numbered GIF files. Specifying out.gif in Free42 preferences creates the following sequence of files:

Code:
 out.0000.gif out.0001.gif out.0002.gif ...

My algorithm looks for new files being generated and prints them to the thermal printer. New files are generated once 'Maximum GIF height (pixels)' has been filled (see Free42 preferences). Depending on how the user sets this value, new files can be emitted rarely or very frequently. I want new GIF files as frequently as possible because my goal is to have the thermal printer respond and track Free42 virtual tape output exactly.

It turns out that I cannot print a GIF file until it has been fully flushed and closed by Free42 - till then the file sits at 0 bytes and thus has no content, as far as my external program/script can see. Ideally I need to set the maximum gif height to 10.667 which seems to correspond to exactly one line of Free42 text output. My algorithm:
• Each Free42 text line that gets emitted to virtual tape is output to a new GIF file
• That new GIF file containing that line is flushed and closed
• My program/script sees the new, non zero byte GIF file and prints it to the thermal printer immediately

Nice plan - except Free42 won't let me enter 10.667 into the dialog box, 32 is the minimum value. This means that there is a 'buffer' of 3 lines before you see anything on my epson tm-t20 escpos thermal printer. You may be lucky and your Free42 output happens to correspond with a filling up and closing of the most recent gif file- or you may not be so lucky. I can work around this by manually sending a few paper ADV commands in Free42 to 'flush' things out.

So close to a nice solution! At least I didn't have to modify Free42 and compile it etc :-) This approach works with standard Free42 builds available to everyone. The proliferation of GIF files is a nuisance but my script could potentially delete them as it prints them. And the GIF files seem to mesh perfectly on the thermal printer output - one wouldn't know the output was comprised of separate files.

02-28-2018, 09:05 PM
Post: #9
 Marcus von Cube Senior Member Posts: 760 Joined: Dec 2013
RE: Modern thermal printer to emulate 82240B
There is another way: Connect the emulated calculator and the (emulated) printer with a local socket. Here is some code from WP-34s (print.c):
Code:
/*  *  Send printer output to emulated HP 82440B by Christoph Gieselink  */ #undef State #undef Alpha #define shutdown shutdown_socket #include <winsock.h> #define UDPPORT 5025 #define UDPHOST "127.0.0.1" int put_ir( int c ) {     int s;     WSADATA ws;     struct sockaddr_in sa;     set_IO_annunciator();     WSAStartup( 0x0101, &ws );     sa.sin_family = AF_INET;     sa.sin_port = htons( UDPPORT );     sa.sin_addr.s_addr = inet_addr( UDPHOST );     s = socket( AF_INET, SOCK_DGRAM, 0 );     sendto( s, (const char *) &c, 1, 0, (struct sockaddr *) &sa, sizeof( struct sockaddr_in ) );     closesocket( s );     return 0; }
The output goes typically to Christoph Gieselink's HP 82440B emulator or its equivalent which is part of the WP-34s project. Only the latter would need to be adapted to send output to a physical printer instead of the screen.

I'm not proficient enough with Free42 to tell if the application can do the same, i. e. sent its IR output to a socket.

Marcus von Cube
Wehrheim, Germany
http://www.mvcsys.de
http://wp34s.sf.net
http://mvcsys.de/doc/basic-compare.html
03-01-2018, 01:50 AM
Post: #10
 Thomas Okken Senior Member Posts: 1,280 Joined: Feb 2014
RE: Modern thermal printer to emulate 82240B
(02-28-2018 09:05 PM)Marcus von Cube Wrote:  I'm not proficient enough with Free42 to tell if the application can do the same, i. e. sent its IR output to a socket.

Free42 generates its simulated printer output directly, by painting on the screen, generating GIF files, or generating UTF-8 encoded text. There is no 82240 emulation, and no output to infrared or to a socket.

Of course it is possible to hack Free42 to make it drive an actual printer, and that is what SwisdMicros have done in the DM42. But vanilla Free42 does not have that functionality.
07-04-2018, 11:14 PM (This post was last modified: 07-06-2018 01:11 PM by tcab.)
Post: #11
 tcab Member Posts: 183 Joined: Dec 2017
RE: Modern thermal printer to emulate 82240B
I’ve developed a piece of software called Print42 to echo Free42's virtual tape to a real thermal printer. Bring back the old days of having a line by line printer tape for your calculator, but with modern fast, supported thermal printer hardware.

Supports both Free42’s text and GIF image virtual tapes modes, meaning you can plot HP42S graphs etc.

It runs on Mac and Windows 10 and has been a serious multi month, full time development effort. All the needed extra HP characters have been handcrafted and programmed for an Epson thermal printer etc. As such the premium version of the software will need to be purchased, however the free version does have its uses too, as a general log tailer with search feature, line by line annotations etc. Here is an example of tailing a regular (non Free42) log file, for example.

I have openings for a few beta testers, who will get the full software for free. They will need to already have a thermal printer or be prepared to buy an Epson thermal printer for their Mac or PC. There are links to buy the appropriate hardware on the print42 website. Please PM if you are interested in participating. For example an Epson TM-T20II should cost around USD $127 which is arguably cheaper than a second hand 82240B (I bought a second hand 82240B and it burned out on me soon after! See this thread This melted vintage printhead experience was one of the main inspirations for this Print42 project, actually). PS. Thomas Okken will also get a free license, should he ever request one. 07-06-2018, 10:54 AM Post: #12  Thomas Okken Senior Member Posts: 1,280 Joined: Feb 2014 RE: Modern thermal printer to emulate 82240B I don't own a printer so it wouldn't be of much use to me, but I do appreciate the offer! Which printers does this support? Can end users customize it to work with printers that aren't supported by default? 07-06-2018, 01:59 PM (This post was last modified: 07-06-2018 02:09 PM by StephenG1CMZ.) Post: #13  StephenG1CMZ Senior Member Posts: 902 Joined: May 2015 RE: Modern thermal printer to emulate 82240B Tcab, I was curious about your reference to your beta testers needing a thermal printer - I couldn't help wondering if a non-thermal printer would suffice. Obviously, this might not be the case if you are needing support for specifixlc fonts. But I imagine the printer is receiving commands like PRINT "tcab" PRINT Red "." In whatever postscript/alternative is used....Not Print t at 60C Print.Red "," at 70F Stephen Lewkowicz (G1CMZ) 07-07-2018, 04:52 AM (This post was last modified: 07-07-2018 02:12 PM by tcab.) Post: #14  tcab Member Posts: 183 Joined: Dec 2017 RE: Modern thermal printer to emulate 82240B (07-06-2018 10:54 AM)Thomas Okken Wrote: Which printers does this support? Can end users customize it to work with printers that aren't supported by default? Print42 theoretically supports numerous thermal printers (other than the recommended Epson TM-T20 which I own) because it uses a Python library called python-escpos to do the low level printing, which in turn uses the open source ESC/POS printer database which is a community-maintained database of thermal receipt printer capabilities. For a list of supported printers visit here. There is a slight complication however in that the virtual printer file that Free42’s generates is unicode (nice) yet most affordable thermal printers do not support unicode. You can of course buy a nice unicode thermal printer but such printers cost much more than traditional thermal printers. We want to print the full range of Free42 unicode characters on affordable printers. Luckily these traditional thermal printers have multiple codepages, and most of the characters we need can be found. Print42 dynamically switches codepages to emit the needed character. However more obscure HP-42S characters like ▸←↑↓→≠∫∡ are typically not available on any typical thermal printer codepage. The way I solved this is was to create a custom codepage and load it with custom characters - but this currently only works for Epson printers - since programming such codepages involves vendor specific magic escape codes and custom fonts etc. This kind of custom font programming could potentially be open sourced and made part of python-escpos and the open source ESC/POS printer database - but that would be a major project in itself, and require the consent of those existing projects. Alternatively I could somehow make a plug in architecture to allow users of Print42 to program their non Epson printers with custom HP-42S fonts. Happy to look at doing this if Print42 gets some usage and there is demand. To summarise, look at the open source ESC/POS printer database: • Unicode thermal printers - ok • Epson thermal printers - ok • Non Epson printers - 98% ok but probably no ▸←↑↓→≠∫∡ chars, unless they happen to have those characters in one of their codepages, in which case it will be found automatically and you will be ok. Now for a competently different way of looking at things… Print42 has a graphics mode where it looks for Free42’s GIF virtual tape files. This mode is compatible with any thermal printer in the aforementioned ESC/POS printer database, as there are no fonts/characters involved - just pure graphics. This mode exactly replicates Free42 output and thus is suitable for graphs etc. Graphics mode doesn't have quite all the same features as text mode e.g. no search. Final recommendation: I have only tested with the Epson TM-T20. I can’t buy lots of different thermal printers and test with them all, so will need to rely on others to provide feedback over time. If you are buying a new thermal printer I simply suggest buying an Epson, as it is the only brand with Mac, Windows and Linux drivers, and you can also use it as a normal system printer from all your other apps (e.g. Word, Excel, Notepad, Pages, terminal etc.) -Andy 07-07-2018, 12:57 PM (This post was last modified: 07-07-2018 12:58 PM by rprosperi.) Post: #15  rprosperi Senior Member Posts: 4,851 Joined: Dec 2013 RE: Modern thermal printer to emulate 82240B Do you mean Epson TM-T20 ? There seem to be lots of TM-T20 models around, but virtually no TM-TS20 models. Is the S20 model something special? --Bob Prosperi 07-07-2018, 02:11 PM (This post was last modified: 07-07-2018 02:15 PM by tcab.) Post: #16  tcab Member Posts: 183 Joined: Dec 2017 RE: Modern thermal printer to emulate 82240B (07-07-2018 12:57 PM)rprosperi Wrote: Do you mean Epson TM-T20 ? There seem to be lots of TM-T20 models around, but virtually no TM-TS20 models. Is the S20 model something special? You are right it’s actually the TM-T20. Sorry for the typo (now corrected). TM-T20$160 USD

TM-T20II $127 USD The faster TM-88V$270 USD should also be compatible, but I’m already blown away at the TM-T20 series speeds so can’t see the need for the more expensive models - unless you print hundreds of supermarket receipts per hour. The speed of these modern thermal printers is actually astonishing, and they are completely silent when idle - so I keep one next to me on my desk for small print tasks like screen captures, notes, chunks of code that I want to analyse with a pen etc. They use no ink and thermal paper refills are cheap. All these Epson printers take 80mm wide thermal paper which is significantly wider and more useful than the HP 82240B paper width, though they can accommodate the narrower width paper too.
07-07-2018, 03:22 PM
Post: #17
 rprosperi Senior Member Posts: 4,851 Joined: Dec 2013
RE: Modern thermal printer to emulate 82240B
(07-07-2018 02:11 PM)tcab Wrote:  You are right it’s actually the TM-T20. Sorry for the typo (now corrected).

Thanks for clarifying, and for the links.

--Bob Prosperi
07-08-2018, 12:10 AM
Post: #18
 tcab Member Posts: 183 Joined: Dec 2017
RE: Modern thermal printer to emulate 82240B
(07-06-2018 01:59 PM)StephenG1CMZ Wrote:  I couldn't help wondering if a non-thermal printer would suffice.

What makes thermal printers unique is their ability to print a single line at a time vs. a normal Windows/Mac/Linux desktop printer which always prints a page at a time.

Thus I don't think printing from Print42 to a non-thermal desktop printer would achieve what people expect of a "calculator printer tape" experience, which is that "line by line" behaviour. For example if you execute the PRX command on the Free42 calculator which emits one line to the virtual tape file, what would you expect to be printed to the regular desktop printer - a single page with a single line at the top? Or would you expect nothing to be printed till the page filled up - whenever that might be? You see the problem. With thermal printers you can emit that single line immediately and even tear it off if you want, for study.

You can always copy selections of Free42 print output from Print42, paste into some other software like Wordpad/Textedit then print that to a regular printer. Or I could make it easier and add a "print selection to desktop printer" feature, if that would be useful to people. There already is a "print selection" to thermal printer.

Hope this all makes sense?
Andy
07-08-2018, 07:46 PM
Post: #19
 StephenG1CMZ Senior Member Posts: 902 Joined: May 2015
RE: Modern thermal printer to emulate 82240B
Thank you for making that clear - so it is not anything to do with the paper actually being thermal or, perhaps, portable.

One conceivable solution for non-thermal printers: Many come with a small LCD - one could imagine that displaying the page being received before it is printed. But I don't know if any can actually do that. Mine just shows number of copies/zoom menus but no image.

Stephen Lewkowicz (G1CMZ)
08-14-2018, 12:37 AM
Post: #20
 tcab Member Posts: 183 Joined: Dec 2017
RE: Modern thermal printer to emulate 82240B
As some users have expressed interest in being able to use Print42 with a regular (non thermal) printer, I've added the ability to print a selection from the tape to any normal desktop printer (windows or mac).

Print42 allows the pasting of graphics (e.g. from screen grabs of web pages, other calculator emulator screens etc.) onto the tape, so I've also made sure that these areas of the tape can be selected and printed to any normal desktop printer too. In the above example you can see a screengrab of a HP Prime session that has been pasted into Print42's tape.

Print42 was initially inspired to mirror Free42's virtual tape files and echo them to a thermal printer, but has evolved to be a general purpose log file tailer/viewer, and also accepts arbitrary screen grabs and typed text onto the tape.

Beta places are still available, so if you didn't have a thermal printer and want to try out Print42 with your regular printer instead, please PM me!
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)