IRC - dot matrix printer - Page 1
Forum section: electronics / projects

author: williefleete
author_rank: Regular Contributor
timestamp: July 23, 2015, 02:24:02 pm
content: 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 andI have the manual for the thing, including escape codes andBASIClistings. 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,theoreticallythat 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, networkanddriving 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

author: mark03
author_rank: Frequent Contributor
timestamp: July 23, 2015, 04:48:33 pm
content: What is an IRC?

author: williefleete
author_rank: Regular Contributor
timestamp: July 23, 2015, 07:17:49 pm
content: Quote from: mark03 on July 23, 2015, 04:48:33 pmSeriously!?.It stands for Internet relay chat. I was wanting to set it up to do the geek group's IRC channel

author: nali
author_rank: Frequent Contributor
timestamp: July 23, 2015, 07:39:20 pm
content: 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)

author: williefleete
author_rank: Regular Contributor
timestamp: July 23, 2015, 08:15:32 pm
content: Quote from: nali on July 23, 2015, 07:39:20 pmI foundonethat 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 rightEither that or they were passive / pin re-arrangers

author: nali
author_rank: Frequent Contributor
timestamp: July 23, 2015, 08:29:20 pm
content: 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

author: williefleete
author_rank: Regular Contributor
timestamp: July 23, 2015, 08:44:07 pm
content: Quote from: nali on July 23, 2015, 08:29:20 pmThought so, the adapter should let you change the baud rate and run off a plug pack etcThis is the one I found 261974617603

author: daveatol
author_rank: Regular Contributor
timestamp: July 24, 2015, 02:22:45 am
content: 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-lineConverting 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 herehttps://www.star-m.jp/eng/service/usermanual/nx1000um.pdfwhich includes escape/control codes and other goodies for a DIYer

author: williefleete
author_rank: Regular Contributor
timestamp: July 24, 2015, 02:39:52 am
content: Quote from: daveatol on July 24, 2015, 02:22:45 amThanks 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?

author: daveatol
author_rank: Regular Contributor
timestamp: July 24, 2015, 02:46:20 am
content: 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.

author: williefleete
author_rank: Regular Contributor
timestamp: July 24, 2015, 02:47:58 am
content: Quote from: daveatol on July 24, 2015, 02:46:20 ameBay auction: #http://www.ebay.com/itm/Centronics-RS-232C-SP-200-Serial-to-Parallel-Converter-/261974617603?pt=LH_DefaultDomain_0&hash=item3cfee76e03

author: miguelvp
author_rank: Super Contributor
timestamp: July 24, 2015, 03:03:05 am
content: 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.

author: williefleete
author_rank: Regular Contributor
timestamp: July 24, 2015, 03:15:11 am
content: Quote from: miguelvp on July 24, 2015, 03:03:05 amI 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

author: miguelvp
author_rank: Super Contributor
timestamp: July 24, 2015, 03:32:06 am
content: So like:Copy COM1: LPT1:or however it was done in DOS?Or the linux/unix equivalent: cp /dev/ttyS0 /dev/lp0But maybe that's not geeky enoughMany 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.

author: williefleete
author_rank: Regular Contributor
timestamp: July 24, 2015, 04:29:08 am
content: Quote from: miguelvp on July 24, 2015, 03:32:06 amIIRC 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 wellThat 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

author: williefleete
author_rank: Regular Contributor
timestamp: July 27, 2015, 07:48:41 pm
content: 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

author: daveatol
author_rank: Regular Contributor
timestamp: July 27, 2015, 11:56:03 pm
content: Quote from: williefleete on July 27, 2015, 07:48:41 pmYeah, 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

author: williefleete
author_rank: Regular Contributor
timestamp: July 28, 2015, 12:16:55 am
content: 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

author: daveatol
author_rank: Regular Contributor
timestamp: July 28, 2015, 12:51:30 am
content: Quote from: williefleete on July 28, 2015, 12:16:55 amSorry, 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 tohttp://www.shellcheck.net/)Code:#!/bin/bashwhile IFS= read -s -r -d '' -n1 chardovalue=$( printf "%d" "'${char}" )value_copy=$value# send inactive /STROBEprintf "\xFE"for bit in 128 64 32 16 8 4 2 1doif [[ $value -ge $bit ]]; thenprintf "\xFE"value=$((value - bit))elseprintf "\xFF"fidone# latch dataprintf "\xF8"value=$value_copy# send active /STROBEprintf "\xFF"for bit in 128 64 32 16 8 4 2 1doif [[ $value -ge $bit ]]; thenprintf "\xFE"value=$((value - bit))elseprintf "\xFF"fidone# latch dataprintf "\xF8"done

author: daveatol
author_rank: Regular Contributor
timestamp: July 28, 2015, 02:35:02 am
content: Quote from: williefleete on July 28, 2015, 12:16:55 amIf 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.

author: williefleete
author_rank: Regular Contributor
timestamp: July 28, 2015, 03:05:43 am
content: Quote from: daveatol on July 28, 2015, 02:35:02 amTrouble 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

author: daveatol
author_rank: Regular Contributor
timestamp: July 28, 2015, 03:20:04 am
content: Quote from: williefleete on July 28, 2015, 03:05:43 amOh, 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?

author: williefleete
author_rank: Regular Contributor
timestamp: July 28, 2015, 03:34:30 am
content: Quote from: daveatol on July 28, 2015, 03:20:04 amNothing. 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.

author: codeboy2k
author_rank: Super Contributor
timestamp: July 28, 2015, 04:11:04 am
content: 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.

author: williefleete
author_rank: Regular Contributor
timestamp: July 28, 2015, 04:43:39 am
content: 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?)

author: williefleete
author_rank: Regular Contributor
timestamp: July 28, 2015, 04:51:44 am
content: Quote from: daveatol on July 28, 2015, 03:20:04 amThat's for converting an 8bit number to shift register clock and data, the display I made using an 08m takes about 256mS to update 64 LEDs (has to update 2 registers per LED display, the address shift reg and a display shift reg, large changes appear as a wave/slow scan) and it needs at least 350+mS between 8byte bursts of data

author: miguelvp
author_rank: Super Contributor
timestamp: July 28, 2015, 04:53:53 am
content: I'm pretty sure you could find information for creating an IRC bot and modifying it to send what is going on the channel to the printer.

author: codeboy2k
author_rank: Super Contributor
timestamp: July 28, 2015, 07:20:03 am
content: I doubt it, because telnet is not scriptable. You would need to script it, so you can detect errors properly and extract the meaningful parts of the server output.Python is still a good choice , even on Windows (because it's available and works).For the geekgroup, you need to first use a regular IRC client to register a nickname and password with the IRC serverThen you can connect to the server (irc.thegeekgroup.org port 6667)send \r\n( you'll get an IDENT check here )send PASS <password> \r\nsend NICK <nickname> \r\nsend USER <nickname> 8 * :dot-matrix-printer \r\nsend JOIN :#thegeekgroup \r\n(you'll get the channel topic and a list of users back in reply )after you've joined, you'll start to receive a rolling list of messages from the server. This will include JOIN, QUIT, MODE, etc... from all other users, as well as channel text. You are only interested in PRIVMSG from other users to the #channel, as this will be the public channel text.for example, in #freenode channel:$telnet chat.freenode.net 6667Trying 130.239.18.119...Connected to chat.freenode.net.Escape character is '^]'.:leguin.freenode.net NOTICE * :*** Looking up your hostname...:leguin.freenode.net NOTICE * :*** Checking Ident:leguin.freenode.net NOTICE * :*** Found your hostname:leguin.freenode.net NOTICE * :*** No Ident responseNICK foobar6666USER foobar6666 8 * :test user:leguin.freenode.net 001 foobar6666 :Welcome to the freenode Internet Relay Chat Network foobar6666[... lots of MOTD stuff here removed ]:leguin.freenode.net 376 foobar6666 :End of /MOTD command.:foobar6666 MODE foobar6666 :+iJOIN :#freenode[ user list is here, I removed it ]:gry!~noone@gryllida.xen.prgmr.com PRIVMSG #freenode :no, I misworded it. I'm sure you /do/ have the potential to handle it properly, and I ask you to unleash that potential, but if you are lazy then just ignoring them is the next best option:AverageJ0e!~joe@ip68-96-52-90.ph.ph.cox.net JOIN #freenode:Tony99-!uid40440@gateway/web/irccloud.com/x-ukdywdylqparggxo QUIT :Quit: Connection closed for inactivity:VD7ux1a!~VD7ux1a@p5B3A5525.dip0.t-ipconnect.de QUIT :Quit: Have a nice day!:CooloutAC!CooloutAC@gateway/shell/panicbnc/x-ypoibjgelivdqkzg PRIVMSG #freenode :lol:sayan!~sayan@fedora/sayan QUIT :Ping timeout: 244 seconds:CooloutAC!CooloutAC@gateway/shell/panicbnc/x-ypoibjgelivdqkzg PRIVMSG #freenode :i don't have ignore in my bloodYou start to receive lots ofPRIVMSG,JOINandQUITmessages above. ThePRIVMSG #channelis the part you care about, where you can extract the author, the message, and you need to add you're own timestamp. Then print that to the printer log.If you look at the above you will realize it's not a simple matter of just using telnet.You can take each line above in a python script and make something useful from it. For example, you can also choose to log channel joins and quits, as well as the channel text if you want to.

author: daveatol
author_rank: Regular Contributor
timestamp: July 28, 2015, 07:39:19 am
content: Perhaps you could script it something like this:?Code:( echo open ${host} ${port}sleep 5echo -n -e "\r\n"sleep 3echo -n -e "PASS ${pass}\r\n"sleep 3echo -n -e "NICK ${nick}\r\n"sleep 3echo -n -e "USER ${user}\r\n"sleep 3echo -n -e "JOIN :#thegeekgroup\r\n") | telnet | grep PRIVMSG | sed -r "s/^:([^!]*)[^:]*:(.*)$/\1 said: \2\r\n/" | ./sp_convert.sh > /dev/ttyS0

author: williefleete
author_rank: Regular Contributor
timestamp: July 28, 2015, 09:34:13 am
content: Quote from: codeboy2k on July 28, 2015, 07:20:03 amQuote from: daveatol on July 28, 2015, 07:39:19 amThanks for the info, if I can play around with it on some of the old motherboards I have, I will give it a go. If I could afford a rPi I could try that I guess.

author: codeboy2k
author_rank: Super Contributor
timestamp: July 28, 2015, 04:41:58 pm
content: Quote from: daveatol on July 28, 2015, 07:39:19 amYeah, that's a good way to use existing tools and the shell to script it. I like your answerIt would work as a most basic telnet receiver. It's going to work 99% of the time, probably.For error checking, you could useexpect(1)scripts then, and that would allow you to script the telnet communication to do something useful on failure.However once you get into scripting it (with expect), you might discover that it becomes more of a hack, and wish you started with Python in the first place