Author Topic: IRC - dot matrix printer  (Read 10729 times)

0 Members and 1 Guest are viewing this topic.

Offline williefleeteTopic starter

  • Regular Contributor
  • *
  • Posts: 109
  • Country: nz
IRC - dot matrix printer
« on: July 23, 2015, 02:24:02 pm »
I have a crazy idea that involves trying to get a parallel dot matrix printer onto an IRC. Similar to how they get teleprinters to work with an IRC. I have a star NX1000 mono dot matrix and a boatload of fanfold paper, it still works and I have the manual for the thing, including escape codes and BASIC listings. I have a vague idea of how to do it, eg a Unix box connected to the IRC (need to figure that out too) using the teletype output on a serial port or direct to parallel if it supports it (I have plenty of old machines floating around with com/lpt ports) and converting the serial to the printer, theoretically that is how I would expect it to work however I am a complete nub at Linux /Unix, I need to figure out what to do for the serial/RS232 to centronics parallel (micro that takes serial, sticks it in a fifo and prints on the parallel port) or rPi for Linux, network and driving the printer on the same board)

I was thinking Arduino to do serial to parallel, like I said it's crazy, possibly out of my league but that printer was pretty easy to interface, I got an 8 pin PICAXE with a shift register and a serial input to print serial data (slowly/typing speed) it's getting it to do it at a reasonable rate and from a Linux terminal based IRC client that can send to a TTY output
 

Offline mark03

  • Frequent Contributor
  • **
  • Posts: 711
  • Country: us
Re: IRC - dot matrix printer
« Reply #1 on: July 23, 2015, 04:48:33 pm »
What is an IRC?
 

Offline williefleeteTopic starter

  • Regular Contributor
  • *
  • Posts: 109
  • Country: nz
Re: IRC - dot matrix printer
« Reply #2 on: July 23, 2015, 07:17:49 pm »
What is an IRC?

Seriously!? :palm:.

It stands for Internet relay chat. I was wanting to set it up to do the geek group's IRC channel
 

Online nali

  • Frequent Contributor
  • **
  • Posts: 657
  • Country: gb
Re: IRC - dot matrix printer
« Reply #3 on: July 23, 2015, 07:39:20 pm »
You can get serial-Centronics adapters off eBay for next to bugger all... so unless you're doing it for the technical exercise I wouldn't bother.

The printer should just print out the plain ASCII from the IRC channel so there shouldn't be any need for ESC codes (also you can normally set font & pitch on the front panel)
 

Offline williefleeteTopic starter

  • Regular Contributor
  • *
  • Posts: 109
  • Country: nz
Re: IRC - dot matrix printer
« Reply #4 on: July 23, 2015, 08:15:32 pm »
You can get serial-Centronics adapters off eBay for next to bugger all... so unless you're doing it for the technical exercise I wouldn't bother.

The printer should just print out the plain ASCII from the IRC channel so there shouldn't be any need for ESC codes (also you can normally set font & pitch on the front panel)

I found one that was a reasonable price but it was an auction, unless you call 45+ with near that again for shipping cheap you're mental, unless I'm not looking on eBay right

Either that or they were passive / pin re-arrangers
 

Online nali

  • Frequent Contributor
  • **
  • Posts: 657
  • Country: gb
Re: IRC - dot matrix printer
« Reply #5 on: July 23, 2015, 08:29:20 pm »
I'll admit it was a quick look. Item #161763865629 was the one I looked at originally...

That and a few others however look like they are just 9-25 way adapters, so not sure if I'd trust them, although this listing specifically says "Use your old parallel printer with a newer computer, using this adapter. Allows you to use a serial port connection"

There are also a couple of USB parallel devices I saw, which depending on the chipset may just appear as a tty port something like /dev/ttyUSB0
 

Offline williefleeteTopic starter

  • Regular Contributor
  • *
  • Posts: 109
  • Country: nz
Re: IRC - dot matrix printer
« Reply #6 on: July 23, 2015, 08:44:07 pm »
I'll admit it was a quick look. Item #161763865629 was the one I looked at originally...

That and a few others however look like they are just 9-25 way adapters, so not sure if I'd trust them, although this listing specifically says "Use your old parallel printer with a newer computer, using this adapter. Allows you to use a serial port connection"

There are also a couple of USB parallel devices I saw, which depending on the chipset may just appear as a tty port something like /dev/ttyUSB0

Thought so, the adapter should let you change the baud rate and run off a plug pack etc

This is the one I found 261974617603
 

Offline daveatol

  • Regular Contributor
  • *
  • Posts: 136
  • Country: au
Re: IRC - dot matrix printer
« Reply #7 on: July 24, 2015, 02:22:45 am »
In linux, you should be able to send serial data by writing to the device /dev/tty1 (or whichever device your serial port is). Details are here: http://stackoverflow.com/questions/8877269/writing-to-serial-port-from-linux-command-line

Converting from serial to parallel can be done using a couple of shift registers and some resistors & capacitors (no microcontroller is required - I can provide diagram if you want). Level conversion may be required for RS232 levels. If you use an RPi, no level conversion is required.

You said you already know how to write to the printer (set the 8 bit data, pulse the strobe line), so you shouldn't have any problems.

For reference, the datasheet is here https://www.star-m.jp/eng/service/usermanual/nx1000um.pdf which includes escape/control codes and other goodies for a DIYer
 

Offline williefleeteTopic starter

  • Regular Contributor
  • *
  • Posts: 109
  • Country: nz
Re: IRC - dot matrix printer
« Reply #8 on: July 24, 2015, 02:39:52 am »
In linux, you should be able to send serial data by writing to the device /dev/tty1 (or whichever device your serial port is). Details are here: http://stackoverflow.com/questions/8877269/writing-to-serial-port-from-linux-command-line

Converting from serial to parallel can be done using a couple of shift registers and some resistors & capacitors (no microcontroller is required - I can provide diagram if you want). Level conversion may be required for RS232 levels. If you use an RPi, no level conversion is required.

You said you already know how to write to the printer (set the 8 bit data, pulse the strobe line), so you shouldn't have any problems.

For reference, the datasheet is here https://www.star-m.jp/eng/service/usermanual/nx1000um.pdf which includes escape/control codes and other goodies for a DIYer

Thanks for the info. I have a hard copy of the printer's manual already :). If you can show the schematic for the ser - parallel converter that would be ok, I've bidded on an active ser-parallel adapter on eBay (see my previous reply with the listing I found) if it falls through I will experiment with the shift register type adapter. Does Linux etc have the ability to connect to an IRC through the terminal or a telnet session etc and do the > /dev/tty** output redirect or does it need an external program?
 

Offline daveatol

  • Regular Contributor
  • *
  • Posts: 136
  • Country: au
Re: IRC - dot matrix printer
« Reply #9 on: July 24, 2015, 02:46:20 am »
Which serial-parallel converter did you get?

Sure, I'll post a schematic after work.

I'm guessing there should be an IRC client that can be asked (or scripted) to spit out the conversations to STDOUT, in which case you can format them as needed and forward them on to the serial port via pipes on the command line.
 

Offline williefleeteTopic starter

  • Regular Contributor
  • *
  • Posts: 109
  • Country: nz
Re: IRC - dot matrix printer
« Reply #10 on: July 24, 2015, 02:47:58 am »
Which serial-parallel converter did you get?

Sure, I'll post a schematic after work.

I'm guessing there should be an IRC client that can be asked (or scripted) to spit out the conversations to STDOUT, in which case you can format them as needed and forward them on to the serial port via pipes on the command line.

eBay auction: #http://www.ebay.com/itm/Centronics-RS-232C-SP-200-Serial-to-Parallel-Converter-/261974617603?pt=LH_DefaultDomain_0&hash=item3cfee76e03
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5550
  • Country: us
Re: IRC - dot matrix printer
« Reply #11 on: July 24, 2015, 03:03:05 am »
Some motherboards have parallel port connectors. Just not brought to the back of your PC, same as serial ports.

What motherboard do you have? and have you checked if it does have a parallel port on the device manager already?
It will show under "Ports (COM & LPT) in Windoze.
 

Offline williefleeteTopic starter

  • Regular Contributor
  • *
  • Posts: 109
  • Country: nz
Re: IRC - dot matrix printer
« Reply #12 on: July 24, 2015, 03:15:11 am »
Some motherboards have parallel port connectors. Just not brought to the back of your PC, same as serial ports.

What motherboard do you have? and have you checked if it does have a parallel port on the device manager already?
It will show under "Ports (COM & LPT) in Windoze.

I have a few older motherboards that have a parallel port and serial port that is no problem, I was wanting to turn the dot matrix printer I have into something like a teleprinter and printing a line at a time as it receives, like a serial terminal with paper
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5550
  • Country: us
Re: IRC - dot matrix printer
« Reply #13 on: July 24, 2015, 03:32:06 am »
So like:

Copy COM1: LPT1:

or however it was done in DOS?

Or the linux/unix equivalent: cp /dev/ttyS0 /dev/lp0

But maybe that's not geeky enough :)

Many MCUs will be able to do what you need though.

Have not dealt with dot matrix for a long time but it was pretty simple to drive.I once did a CGA/Hercules print screen in assembly to print into Epson printers in graphics mode, as I recall printing just ASCII was easy, but this was over 20 years ago.
 

Offline williefleeteTopic starter

  • Regular Contributor
  • *
  • Posts: 109
  • Country: nz
Re: IRC - dot matrix printer
« Reply #14 on: July 24, 2015, 04:29:08 am »
So like:

Copy COM1: LPT1:

or however it was done in DOS?

Or the linux/unix equivalent: cp /dev/ttyS0 /dev/lp0

But maybe that's not geeky enough :)

Many MCUs will be able to do what you need though.

Have not dealt with dot matrix for a long time but it was pretty simple to drive.I once did a CGA/Hercules print screen in assembly to print into Epson printers in graphics mode, as I recall printing just ASCII was easy, but this was over 20 years ago.

IIRC control P or (control) print screen in MSDOS  turned on "teletype" mode eg it would print the text out to the printer when you hit enter, eg for file lists. I don't know if the output redirect (the >) after the program name (text based ones especially) would have worked with printers as well

That printer was dead easy to talk to, I wrote a program for an 8 pin PICAXE to buffer characters from hyper term and when full (or I think a CR) run it to a shift register and strobe the printer. I think the printer needed either a full buffer or taken off line to actually print the stuff I sent to it (probably needed to send another line low too) . I could actually send it some of the control codes for different sized text and control the fonts etc using alt 0027 (I didnt know if the ctrl+[ would work in hyperterm) for the escape char and the code letter/number etc
 

Offline williefleeteTopic starter

  • Regular Contributor
  • *
  • Posts: 109
  • Country: nz
Re: IRC - dot matrix printer
« Reply #15 on: July 27, 2015, 07:48:41 pm »
I missed out on the eBay auction, I believe someone was going to post a schematic of an RS232 to parallel converter using shift registers
 

Offline daveatol

  • Regular Contributor
  • *
  • Posts: 136
  • Country: au
Re: IRC - dot matrix printer
« Reply #16 on: July 27, 2015, 11:56:03 pm »
I missed out on the eBay auction, I believe someone was going to post a schematic of an RS232 to parallel converter using shift registers
Yeah, I believe that was me. Sorry, I forgot. The schematic for a simple converter is attached. Each bit of your parallel data is loaded into the shift register by sending a byte of serial data. To load a 0, you send the 0xFF character. To load a 1, send 0xFE. To latch the data that has been shifted in, send the 0xF8 character value. The value of the components can be calculated from the equations on the schematic, but here are some that should work if sending at 115200 baud: R1 = 12k, R2 = 24k (or 27k is fine also), C1 = C2 = 1nF.

The schematic is for TTL level serial (e.g. from the raspberry pi async. serial headers, or a TTL USB-serial converter). If you want to convert RS232 levels (i.e. inverted), then you can put the RS232 signal through a 10K resistor into an additional inverter: the signal will be converted to TTL levels.

If wired as drawn in the schematic, you'd first send the STROBE value, then the D7, D6, ..., D0 bits, and then the LATCH command. You can write a simple script to convert from the character you want to send and the sequence of characters required by the script, and then pipe the data through your script. e.g. if your IRC streaming program is called "irc_stream" and your convert script is called "sp_convert", then you might use:
./irc_stream | sp_convert > /dev/ttyS0

« Last Edit: July 28, 2015, 03:42:56 am by daveatol »
 

Offline williefleeteTopic starter

  • Regular Contributor
  • *
  • Posts: 109
  • Country: nz
Re: IRC - dot matrix printer
« Reply #17 on: July 28, 2015, 12:16:55 am »
What kind of baud rate does that talk properly at with those values?
I'm guessing the formula outputs just the R value and pretty much just use a 1nF.

I think I have some 595's left so I might whip it up and give it a test.

I have some BASIC code from the PICAXE that can probably be adapted to convert ASCII to the FFh, FEh and F8h pulses
 

Offline daveatol

  • Regular Contributor
  • *
  • Posts: 136
  • Country: au
Re: IRC - dot matrix printer
« Reply #18 on: July 28, 2015, 12:51:30 am »
What kind of baud rate does that talk properly at with those values?
I'm guessing the formula outputs just the R value and pretty much just use a 1nF.

I think I have some 595's left so I might whip it up and give it a test.

I have some BASIC code from the PICAXE that can probably be adapted to convert ASCII to the FFh, FEh and F8h pulses
Sorry, I forgot to mention that those values are for sending at 115200 baud.

Here's a BASH script that should convert from characters to the sequence of codes as described above. I haven't written bash scripts in over 10 years, so I'm a bit rusty. Hopefully someone else can check it (syntax is ok according to http://www.shellcheck.net/)
Code: [Select]
#!/bin/bash

while IFS= read -s -r -d '' -n1 char
do
value=$( printf "%d" "'${char}" )
value_copy=$value

# send inactive /STROBE
printf "\xFE"

for bit in 128 64 32 16 8 4 2 1
do
if [[ $value -ge $bit ]]; then
printf "\xFE"
value=$((value - bit))
else
printf "\xFF"
fi
done

# latch data
printf "\xF8"

value=$value_copy

# send active /STROBE
printf "\xFF"

for bit in 128 64 32 16 8 4 2 1
do
if [[ $value -ge $bit ]]; then
printf "\xFE"
value=$((value - bit))
else
printf "\xFF"
fi
done

# latch data
printf "\xF8"

done
« Last Edit: July 28, 2015, 03:17:06 am by daveatol »
 

Offline daveatol

  • Regular Contributor
  • *
  • Posts: 136
  • Country: au
Re: IRC - dot matrix printer
« Reply #19 on: July 28, 2015, 02:35:02 am »
I think I have some 595's left so I might whip it up and give it a test.

I have some BASIC code from the PICAXE that can probably be adapted to convert ASCII to the FFh, FEh and F8h pulses
If you have a PICAXE and a single '595, that should be all you need... If the PICAXE has a serial input and four outputs, use one output for the /STROBE, and the other three outputs to shift and latch the data into the '595. You don't need any of the other components I showed if you're using a PICAXE.
 

Offline williefleeteTopic starter

  • Regular Contributor
  • *
  • Posts: 109
  • Country: nz
Re: IRC - dot matrix printer
« Reply #20 on: July 28, 2015, 03:05:43 am »
If you have a PICAXE and a single '595, that should be all you need... If the PICAXE has a serial input and four outputs, use one output for the /STROBE, and the other three outputs to shift and latch the data into the '595. You don't need any of the other components I showed if you're using a PICAXE.

Trouble is I'm not sure if it could handle the serial stream, I suppose depending on the line lengths, I can get it to buffer (when I tried before it was typing speed on a serial terminal, I'm not sure how long it takes to write to and prepares to read again, maybe at a slow baud rate) it could buffer ~170 bytes in the EEPROM space left which, carriage return terminated eg it would burst when it gets a carriage return character and adds a line feed carriage return to the parallel output. From previous experiments on another project that uses a PICAXE and shift registers (8digit display "clock" line on the scope) it will take about 16mS per character maybe 18mS for the additional strobe for the printer (~2mS per clock pulse period) that is running the PICAXE 08m at 8Mhz
 

Offline daveatol

  • Regular Contributor
  • *
  • Posts: 136
  • Country: au
Re: IRC - dot matrix printer
« Reply #21 on: July 28, 2015, 03:20:04 am »
it will take about 16mS per character maybe 18mS for the additional strobe for the printer (~2mS per clock pulse period) that is running the PICAXE 08m at 8Mhz
Oh, I didn't realise PICAXEs were so inefficient.

So what is the actual setup you're using at the moment? Are you using a Windows PC? A Raspberry PI? Something else?
 

Offline williefleeteTopic starter

  • Regular Contributor
  • *
  • Posts: 109
  • Country: nz
Re: IRC - dot matrix printer
« Reply #22 on: July 28, 2015, 03:34:30 am »
it will take about 16mS per character maybe 18mS for the additional strobe for the printer (~2mS per clock pulse period) that is running the PICAXE 08m at 8Mhz
Oh, I didn't realise PICAXEs were so inefficient.

So what is the actual setup you're using at the moment? Are you using a Windows PC? A Raspberry PI? Something else?


Nothing. At the moment it's not doing much except attached to a winXP based printer server and getting the rare print job. I was wanting to make use of one of the older motherboards/computers in my possession to hook into an IRC (the geekgroup) and have the dot matrix as the "terminal" output, I wasn't sure how to go about it too much hence the post, I believe Unix/Linux can route their shell/prompt to the com port (hence tty) either from not having a video card or in some setting somewhere, and I'm not 100% sure if it works on parallel, And also whether I could get a shell based IRC client.
 

Offline codeboy2k

  • Super Contributor
  • ***
  • Posts: 1836
  • Country: ca
Re: IRC - dot matrix printer
« Reply #23 on: July 28, 2015, 04:11:04 am »
Basic IRC is a really simple protocol, if all you want to do is join a channel and get the text.

At one time in the past I've used telnet from the shell and hand crafted IRC commands to join a channel and post into the channel. Receiving was just as easy, although I don't remember the commands anymore. An IRC server is just listening for ASCII commands to it, and it responds with text back.

You can do it very easily with a Python script on Linux that just gets new text from the channel and copies it out to the serial port, or equally the parallel port.  On Linux, the parallel port driver is a character based driver, just like the serial port driver, and is actually easier to use since you don't have to set 7/8 bits, start/stop bits, or the bit rate for the port.

If your printer is a parallel printer, try to use the motherboards parallel port.  It can be done with the serial port and a micro for serial to parallel conversion, but why bother if your motherboard already has a parallel port on it?

There are also USB to parallel converters that I have used in the past and these work well enough for printing.
 

Offline williefleeteTopic starter

  • Regular Contributor
  • *
  • Posts: 109
  • Country: nz
Re: IRC - dot matrix printer
« Reply #24 on: July 28, 2015, 04:43:39 am »
Ok, I was wondering if you could use telnet to use IRC. And I have several older motherboards including the PC the printer is on that have parallel ports. Could it be done with telnet on windows (98?, dos based telnet with an output redirect?)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf