Interfacing the printer port

  • Thread starter Thread starter David
  • Start date Start date
D

David

Hi all,

My client has a device that prints to an Epson LX300+II printer. It is not a
computer, but an electronic measuring device.

I need to capture the data coming from the device.

The device output to the printer is using 11 wires, they are D0 to D7, GND,
Busy and Strobe, going into a regular centronics type connector into the
printer.

I have mapped all pins to their identical on the PC. I was initially
thinking a crossover like laplink, but realised that laplink uses 4 data
bits rather than 8, so was not suitable.

I am writing in C# and using inpout32.dll on Windows XP. My port is 0x378

I am having trouble when the device sends, to read it. At the moment, I have
a loop just monitoring what is on 0x378, but it is missing the whole
communication.

I think I need to raise the busy line (re-map it to a output control line)
but then how do I monitor the strobe? I think that needs to be mapped to an
input line... however, I need C# to be able to respond to the strobe as an
event. I have no idea how to do that...

Also, I am assuming that it is ascii data that is sent to the printer (ascii
on the data lines). Am I correct in this assumption?

Any help would be greatly appreciated.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 
Hi all,

My client has a device that prints to an Epson LX300+II printer. It is not a
computer, but an electronic measuring device.

I need to capture the data coming from the device.

The device output to the printer is using 11 wires, they are D0 to D7, GND,
Busy and Strobe, going into a regular centronics type connector into the
printer.

I have mapped all pins to their identical on the PC. I was initially
thinking a crossover like laplink, but realised that laplink uses 4 data
bits rather than 8, so was not suitable.

I am writing in C# and using inpout32.dll on Windows XP. My port is 0x378

I am having trouble when the device sends, to read it. At the moment, I have
a loop just monitoring what is on 0x378, but it is missing the whole
communication.

I think I need to raise the busy line (re-map it to a output control line)
but then how do I monitor the strobe? I think that needs to be mapped to an
input line... however, I need C# to be able to respond to the strobe as an
event. I have no idea how to do that...

Also, I am assuming that it is ascii data that is sent to the printer (ascii
on the data lines). Am I correct in this assumption?

Any help would be greatly appreciated.

Have you looked at the avaiable refes for this printer?
http://www.epson.com/cgi-bin/Store/...e=yes&infoType=Doc&oid=75683&prodoid=63061037
 
My client has a device that prints to an Epson LX300+II printer.
It is not a computer, but an electronic measuring device.
I need to capture the data coming from the device.

This book is essential reading:

http://www.lvr.com/parport.htm
Jan Axelson's "Parallel Port Complete"
Programming, Interfacing, and Using the PC's Parallel Printer Port

It ought to clearly show
- how to use the PC's parallel port in 8 bit input mode,
accessing it via C# or other languages and operating systems
- how the printer normally handshakes
so you can tap the data by monitoring the data & strobe lines.

A "data logger" or logic analyzer may help
since they're external high speed devices that are now USB interfaced.
 
Thanks Jonas,

I had a look at the website and then followed the link to the codeproject
article. The codeproject C# article only demonstrates outputting on the
ports, however, I started reading the comments and one of the comments
linked to
http://moebiusit.com/blog/pabloroma...g-onchange-event-to-listen-the-parallel-port/

I think this may do what I need...

If I move the strobe wire to a status line, I should be able to use the
strobe to "interrupt" the PC to be able to collect the data. It seems the
strobe line is an output line, I need to be able to respond to a strobe
rather than set it. It may not even need the strobe... I may be able to
respond to just the changes on the data lines, but I think that is risky.

Hopefully, my experimentation can be done from another computer set to print
to the same type of printer. The actual equipment is about 75 miles (1.5
hours drive) away and I don't have the internet access that I would use to
help me.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 
Also, I am assuming that it is ascii data that is sent to the printer (ascii
on the data lines). Am I correct in this assumption?

Epson ESC/P language. Google it for PDF refs.
 
Hi Jeff,

I have now come up with another problem here, perhaps you might be able to
enlighten me...

I am programming on a laptop, which does not have an LPT port. I bought an
Express card parallel port and was trying to interface directly to that.
However, it is not working.

I connected the card up to a laserjet to ensure that I had not blown the
card and that came up, but it came up as USB003.

Any idea how I might interact with the parallel port which is via a USB
(Actually, an express card that is showing as USB)?

Any help would be very much appreciated.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 
My client has a device that prints to an Epson LX300+II printer.
I have now come up with another problem here,
perhaps you might be able to enlighten me...
I am programming on a laptop, which does not have an LPT port.
I bought an Express card parallel port ...
Any idea how I might interact with the parallel port which is via a USB

I'm afraid I've not yet programmed USB devices,
so I'm unusure you can guarantee the response time
without using some intelligence at the other end
such as microcontroller.

Perhaps a better approach would be to use a USB "Logic Analyzer"
or "data logger" to capture the data since that's their intended purpose.
A digital oscilloscope is overkill since you're capturing digital data.
This one is open source and rather affordable
and is on my "wish list" (I don't have one, yet)

http://www.sparkfun.com/products/8938

That ought to speed up your progress.
Keep us posted, for it's an interesting project you have on your hands.
 
Hi Jeff,

I have an idea...

The logic analyser you suggest might take too long to get here (UK), plus it
is prob a little too much (overkill) for me.

I have been thinking laterally, I was trying to find things to do with
parallel ports, but coming stuck everywhere. I changed my search to home
automation usb and found a 16 line output, 16 line input device that will do
almost what I want. I spoke to the designer and the main issue would be the
strobe and the length of the pulse. The device can only poll down to about
20ms, where the pulse may only be 100us.

However, I remember from my early days of playing with computer control,
that I can use an octal latch. Feed the pulse straight into the latch and it
latches the data, while I am reading it, I send a busy. Now, that should
work all being well.

In my program, I will read the data in, then handle the data with a thread.
(I think I need to send the data to 2 files, one with the actual ascii text
and one with the numbers generated, where I can't see the actual text, I can
refer to an ascii chart to determine the numbers and control characters)

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 
I have been thinking laterally, I was trying to find things to do with
parallel ports, but coming stuck everywhere. I changed my search to home
automation usb and found a 16 line output, 16 line input device that will do
almost what I want. I spoke to the designer and the main issue would be the
strobe and the length of the pulse. The device can only poll down to about
20ms, where the pulse may only be 100us.

However, I remember from my early days of playing with computer control,
that I can use an octal latch. Feed the pulse straight into the latch and it
latches the data, while I am reading it, I send a busy. Now, that should
work all being well.

That's the kind of thing you're probably going to need. I'd go
further than that: you're probably going to need the BUSY line
asserted in hardware until you de-assert it in software since you'll
never achieve the latency you need otherwise.

A year or two ago I built a serial to parallel converter that with
a couple of wiring changes to the printer port and new software
could be adapted to work in reverse - I'll send you my schematics
and code if you want. However, some commerically available converters
do that as standard, e.g. http://www.bb-europe.com/product.asp?SKU=232SPS2
For £80 I wouldn't think it worth assembling a unit and writing
new code.
 
Thank you. I have sent them an email describing my scenario and asking if
their device will be suitable for my uses.

I had spent ages looking for something like this. I had found one, but it
only seems to be available in USA and Australia. I had found another device
that appears to do what I need, however, it is very expensive.

I went to buy the extra components from Maplin yesterday, they are really
dropping their electronic component lines and appear to be concentrating on
the consumer electronics. No more components for the hobbyist now. :( I used
to use a 74LS373 many years ago. They only have 74HC373, while stocks last
and none in the stores.

A bit bad really.
--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 
I had spent ages looking for something like this. I had found one, but
it only seems to be available in USA and Australia. I had found another
device that appears to do what I need, however, it is very expensive.

If you get up a £50 order (!), Digi-Key are really good and it'll be free
carriage. Order one day, get it second working day after (by UPS from the
USA!)

http://www.digikey.co.uk/
I went to buy the extra components from Maplin yesterday, they are
really dropping their electronic component lines and appear to be
concentrating on the consumer electronics. No more components for the
hobbyist now. :( I used to use a 74LS373 many years ago. They only have
74HC373, while stocks last and none in the stores.

Useless - and expensive.

Try Rapid Electronics too...they aren't too bad for a lot of stuff.

http://www.rapidonline.com/
 
Hi Jeff,

Does windows require any signals coming in to let it know that a printer is
there?

I have connected just 11 lines... namely,
/STROBE
D0 - D7
BUSY
GND

However, when printing from windows, I am getting an initial /strobe and
data, but nothing else. (That is probably actually just the connection when
I connect the cable).

My printer queue (windows 7) just says "Error - Printing".

I am wondering if windows is expecting anything else coming into it, for
example, paper error, select out, slet in (whatever that is...) or any other
lines?

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 
David said:
Does windows require any signals coming in to let it know that a printer is
there?

I have connected just 11 lines... namely,
/STROBE
D0 - D7
BUSY
GND

David-

As I understand it, the computer uses the STROBE line to signal the
printer that data on D0 - D7 is valid. The printer then uses the BUSY
line to keep the computer from sending more data while it is processing
the current data. When the BUSY line is reset, the computer can send
more data as soon as it is ready to do so.

If the BUSY line is never active, the computer might be programmed to
wait for a time-out period in case the printer is not connected.

I don't know the polarity of STROBE or BUSY. Does /STROBE indicate it
is active low?

Fred
 
I sort of have it working, but it is incredibly slow...

I have set up a Generic / Text only printer on my Win7 machine and am
reading the data on my XP machine via a USB input output device.

The /Strobe is normally high, but flicks low to tell the printer that data
is on the bus.

It seems that strobe is held low until a busy (high) is received. However,
as I am polling my I/O device (no other way, as it doesn't have an
interrupt), I appear to be missing the strobe, but I have worked another way
around it. (What I ended up doing is I needed to know I was in the same
character, the only way I could do that was electronically rather than
programmatically, I ended up tying the BUSY (output line on my USB) to a
spare input line (on my USB), so that I know that while I have a high on my
local busy, I don't attempt to poll the next character)

I was getting something like....


TTTTTThhhhiissssss isssssaaaaa eeeest

(This is a test)

However, I am now getting the proper text, but for some reason, it is
incredibly slow. I will look at speeding it up somehow.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 
I sort of have it working, but it is incredibly slow...

I have set up a Generic / Text only printer on my Win7 machine and am
reading the data on my XP machine via a USB input output device.

The /Strobe is normally high, but flicks low to tell the printer that data
is on the bus.

It seems that strobe is held low until a busy (high) is received. However,
as I am polling my I/O device (no other way, as it doesn't have an
interrupt), I appear to be missing the strobe, but I have worked another way
around it. (What I ended up doing is I needed to know I was in the same
character, the only way I could do that was electronically rather than
programmatically, I ended up tying the BUSY (output line on my USB) to a
spare input line (on my USB), so that I know that while I have a high on my
local busy, I don't attempt to poll the next character)

I was getting something like....


TTTTTThhhhiissssss isssssaaaaa eeeest

(This is a test)

However, I am now getting the proper text, but for some reason, it is
incredibly slow. I will look at speeding it up somehow.

I see two reasons for that: firstly you are not acknowledging the
bytes sent - not all host interfaces check them but ISTR the Windows
driver for a standard prallel port is one that does. That means
it has to time out before sending a new byte.

Secondly you don't say what you mean by your "USB" but I assume
you mean a general purpose interface board. That is going to cause
issues in and of itself. USB is not very fast when it comes to
latency - don't expect anything to happen faster than a couple of
milliseconds. If you want to do this via polling the polling
frequency must be fairly fast - 2MHz or greater - and quite simply
USB is not up to the job.

The way I would suggest therefore needs some additional logic to
make up for the deficencies of your interface. For a start I would
drop an octal latch or D flip flop in there so you grab hold of
the data when the strobe is lowered. I would also hook up the
strobe line to an SR flip flop - you can check if it is set to see
if a character has been resceived and then reset it via software.
I'd also use that flip flop output to drive the BUSY line so that
is asserted automatically until you clear it. You may be able to
get away with a software controlled acknowledge line but I'd be
tempted to drop in a monostable triggered by the falling edge of
the BUSY signal - a 555 should be perfectly up to that job.
 
Hi Andrew,
I see two reasons for that: firstly you are not acknowledging the
bytes sent - not all host interfaces check them but ISTR the Windows
driver for a standard prallel port is one that does. That means
it has to time out before sending a new byte.


I am sending an ACK back, I wouldn't have done because the equipment I have
to connect to doesn't require it (no wire), but for testing against Windows,
I had to put it in.

I think what it actually was is the polling and as it used the
System.Threading timer rather than the regular timer, I couldn't pause it as
easily, so it kept polling.

What I have now is an input line connected to my BUSY (ouput) line and am
monitoring that. I have changed my timer and am able to stop the polling
while reading.

I am going to see if I can optimise it programmatically. When I say SLOW, I
mean... It is taking something like 1 second per character. It should NOT be
that slow.
Secondly you don't say what you mean by your "USB" but I assume
you mean a general purpose interface board. That is going to cause
issues in and of itself. USB is not very fast when it comes to
latency - don't expect anything to happen faster than a couple of
milliseconds. If you want to do this via polling the polling
frequency must be fairly fast - 2MHz or greater - and quite simply
USB is not up to the job.


My USB is an input/output interface. I know it is fairly slow, but I didn't
realise it would be THAT slow. The designer told me the fastest I could
probably drive it is about 20ms.

The way I would suggest therefore needs some additional logic to
make up for the deficencies of your interface. For a start I would
drop an octal latch or D flip flop in there so you grab hold of
the data when the strobe is lowered. I would also hook up the
strobe line to an SR flip flop - you can check if it is set to see
if a character has been resceived and then reset it via software.
I'd also use that flip flop output to drive the BUSY line so that
is asserted automatically until you clear it. You may be able to
get away with a software controlled acknowledge line but I'd be
tempted to drop in a monostable triggered by the falling edge of
the BUSY signal - a 555 should be perfectly up to that job.


Yeah, I was trying to buy a 74HC373 from maplin, but they are stopping
stocking it now. I have found another that might work similarly, but not
sure. 74HC573

I don't know what an SR flip flop is.

I think this might be getting a bit too complicated now. Last time I played
to this level (and deeper) of electronics was 20 years ago, though I guess I
am going to have to get my brain into gear and learn it again to solve this
problem.

Thanks to everyone for their advice so far. I will keep you all updated.

Regards,
David.
 
Hi all,

My client has a device that prints to an Epson LX300+II printer. It is not a
computer, but an electronic measuring device.

I need to capture the data coming from the device.

Hello All -

I have a similar situation as David - I have a device printing to the same printer and I'd just like the data ( now being sent to the printer ) to end up in an excel spreadsheet - a csv file would work too -
It's just ascii text I am trying to capture - does anyone know of a converter I can use ? I do not have time to build anything - thanks

Marty B. PA USA -
 
Back
Top