CAD CAM EDM DRO - Yahoo Group Archive

Re: Print Servers for CNC

on 2003-02-25 11:21:36 UTC
--- In CAD_CAM_EDM_DRO@yahoogroups.com, ccq@x wrote:
> The following URLs have a print server on them;
> That's a 10/100 ethernet port feeding three parallel
> ports. Would these be usable for CNC work? Would the
> software be able to access them properly?

NO.

There is a fundamental difference between the parallel
port as used by CNC programs, and an Ethernet print
server.

Here is a very simplified tutorial on the parallel port.
For more details, browse these pages:
http://www.doc.ic.ac.uk/~ih/doc/par/
http://www.lvr.com/parport.htm

The standard parallel port actually contains three 8-bit
ports that may be addressed by the software. The first
is the DATA port, at the base address (for example 378hex).
It simply delivers the 8 bits written to it to pins 2-9 of
the port. Next is the STATUS register t the base address
plus 1 (ex. 379hex). It can by read by the software, and
contains the state of pins 10 (ACK), 11 (BUSY), 12 (Paper
End), 13 (Select In), and 15 (Error). Last is the CONTROL
register is at base address plus 2 (ex. 37Ahex) It can be
written by the software, and drives pins 1 (STROBE), 14
(AutoFeed), 16 (Initialize), and 17 (Select Out).

Each register in the port can be written (or read) by a
single program instruction. The when an output register
is written to, the corresponding pins change state
immediately (less than 1 micro-second).

First lets look at an ordinary printer port, as used with
a ordinary printer. The following sequence is executed
for every byte of data that any program wants to send
to the printer:

1) The printer driver recieves a byte of data from some
program. The data needs to go to the printer.

2) The printer driver software reads the STATUS port, and
checks the BUSY bit. If set, then the printer can't
accept data now. The driver repeats step 2 until the
printer is no longer busy. If the BUSY bit is clear,
then the printer is ready for more data and the driver
moves to step 3.

3) The driver writes the next byte of data to the DATA port.
The data immediately appears on pins 2-9.

4) The driver writes to the CONTROL port, setting the STROBE
bit active.

5) When the printer sees the STROBE pin go active, it grabs
the data from pins 2-9 and stores it internally. If this
byte of data results in the printer's internal storage
getting full, the printer will activate the BUSY signal
to keep the computer from sending more data.

6) The driver writes to the CONTROL port again, setting the
STROBE bit inactive.

7) The driver is finished with this byte, and it returns
control to the program that generated the data. If the
program needs to send more data to the printer, it will
call the driver again, and we resume at step 1.

The main thing to note here is that for every byte of data
transferred to the printer, there are at least four accesses
to the hardware - read BUSY, write DATA, set STROBE, clear
STROBE.

Now lets look at an ethernet print server. The server adds
another layer:

1) The network printer driver recieves a byte of data from
some program that is supposed to go to the printer.

2) The driver adds the byte to a temporary storage area
that holds somewhere between 500 and 1500 bytes.

3) If the storage area is not full yet, the driver is done,
and it returns to the program. If the program needs
to send more data, it will call the driver again, and
we resume at step 1. If the storage area is full, then
the driver goes on to step 4.

4) The driver assembles a TCP/IP data packet containing
all of the data from the storage area (500-1500 bytes)
as well as some other information, like the network
address of the printer.

5) The driver sends the entire TCP/IP packet to the network
card, which sends the packet out onto the network cable.
At this point the storage area is empty and the driver
can return to the program. If the program needs to send
more data, then we resume at step 1.

Meanwhile:

6) The ethernet print server sees the TCP/IP packet on the
network cable and reads it into it's internal memory.

7) The print server sends the all of the data in the packet
to the printer, one byte at a time. Each byte requires
the entire sequence that was described for a standard
parallel port - read BUSY, write DATA, set STROBE, clear
STROBE.

The main thing to notice about the ethernet print server is
that data is transferred to the printer in chunks of 500 to
1500 bytes. While the direct connected printer recieves
each byte as soon as the program generates it, the ethernet
connected printer doesn't receive _any_ bytes until a full
packet worth of data had been generated. Then it gets the
whole packet as fast as the server can deliver it. For a
printer, that's not a problem. The other thing to note is
that each byte still checks BUSY, sets and clears STROBE, etc.

So much for printing - now let's look at CNC.

A simple 2 axis CNC program might connect the X direction
signal to pin 2 (DATA bit 0), the X step signal to pin 3
(DATA bit 1), Y direction to pin 4 (DATA bit 2), and Y step
to pin 5 (DATA bit 3). In addition, it might connect
the X limit switch to pin 10 (ACK), and the Y limit switch
to pin 11 (BUSY).

The CNC program doesn't use a printer driver at all. It
reads and writes directly to the DATA, STATUS, and CONTROL
registers. For example, here is the sequence to move the
Y axis one step:

1) The program reads the CONTROL register and checks the
BUSY bit. If set, then the Y axis is against the limit
switch and shouldn't move - the program will cancel the
move and report the error to the user. If the BUSY bit
is clear, the program goes to step 2.

2) If the new step is going the same direction as the last
step, the program goes on to step 3. If the new step
is in the opposite direction, the program writes to the
DATA port, modifying bit 2 to indicate the new direction.

3) The program writes to the DATA port, setting bit 3 to
start the step pulse.

4) The program waits for the required pulse length, then
writes to the DATA port again, clearing bit 3 to end
the step pulse.

5) The program loops or does some more sophisticated form
of delay, waiting until it is time to generate the next
step pulse.

Note that each step pulse takes one read from the STATUS
register, two writes to the DATA register, and no access at
all to the CONTROL register.

Now imagine trying to use the ethernet print server. The
first problem is that the CNC program doesn't use a printer
driver. Since the program never calls the printer driver,
no data ever gets stored, no TCP/IP packet ever gets sent,
and nothing ever happens. Even if we somehow solve that
problem, and send packets of data to the server, the data
gets sent in chunks of 500-1500 steps at a time, rather
than in a smooth stream of step pulses. In addition,
the limit switch data either never gets back to the CNC
program at all, or it gets back only after a packet of
500-1500 steps has been sent to the motors. On top of all
that, the server is using the BUSY and STROBE pins as if
they are connected to a printer. It has no idea that BUSY
is actually connected to a limit switch.

Now, IF you had access to the software (firmware) that is
running inside the ethernet print server, and IF you had
the compilers, etc., to allow you to modify that firmware,
and IF you had all the documentation for the hardware in
that server, and IF you had the ability to modify the CNC
program to send its data out in TCP/IP packets, then MAYBE
you could make it work. But the unmodified ethernet print
server will never work for CNC.

John Kasunich

Discussion Thread

ccq@x... 2003-02-25 04:30:28 UTC Print Servers for CNC turbulatordude <davemucha@j... 2003-02-25 05:15:22 UTC Re: Print Servers for CNC Jeff Goldberg 2003-02-25 05:36:52 UTC RE: [CAD_CAM_EDM_DRO] Print Servers for CNC Tony Jeffree 2003-02-25 06:30:06 UTC RE: [CAD_CAM_EDM_DRO] Print Servers for CNC ccq@x... 2003-02-25 06:34:49 UTC Re: [CAD_CAM_EDM_DRO] Re: Print Servers for CNC ccq@x... 2003-02-25 06:48:27 UTC Re: [CAD_CAM_EDM_DRO] Print Servers for CNC turbulatordude <davemucha@j... 2003-02-25 07:01:01 UTC Re: Print Servers for CNC alex 2003-02-25 07:01:38 UTC Re: [CAD_CAM_EDM_DRO] Print Servers for CNC Tony Jeffree 2003-02-25 07:07:44 UTC Re: [CAD_CAM_EDM_DRO] Print Servers for CNC Jeff Goldberg 2003-02-25 07:12:16 UTC RE: [CAD_CAM_EDM_DRO] Print Servers for CNC Jon Elson 2003-02-25 10:02:21 UTC Re: [CAD_CAM_EDM_DRO] Print Servers for CNC Jon Elson 2003-02-25 10:07:12 UTC Re: [CAD_CAM_EDM_DRO] Re: Print Servers for CNC jmkasunich <jmkasunich@y... 2003-02-25 11:21:36 UTC Re: Print Servers for CNC ccq@x... 2003-02-25 11:35:14 UTC Re: [CAD_CAM_EDM_DRO] Print Servers for CNC alex 2003-02-25 11:45:41 UTC Re: [CAD_CAM_EDM_DRO] Print Servers for CNC ccq@x... 2003-02-25 19:33:07 UTC Re: [CAD_CAM_EDM_DRO] Print Servers for CNC alex 2003-02-26 07:18:20 UTC Re: [CAD_CAM_EDM_DRO] Print Servers for CNC glee@i... 2003-02-26 07:33:14 UTC Re: [CAD_CAM_EDM_DRO] Print Servers and SBCs for CNC control ccq@x... 2003-02-26 08:20:30 UTC Re: [CAD_CAM_EDM_DRO] Print Servers for CNC alex 2003-02-26 08:41:21 UTC Re: [CAD_CAM_EDM_DRO] Print Servers for CNC alex 2003-02-26 09:49:51 UTC Re: [CAD_CAM_EDM_DRO] Print Servers for CNC