[Home and Links] [Your PC and Security] [Server NAS] [Wargames] [Astronomy] [PhotoStory] [DVD making] [Raspberry Pi] [PIC projects] [Other projects]


[PC based digital oscilloscope] [The LPT] [Using the Printer Port] [Powering the front-end]



PC based digital oscilloscope

Whilst the PC makes a great waveform display, the problem is how to 'sample' the analogue signal in the first place.

PCI ADC (Analogue to Digital Converter) boards do exist, however these cost 'an arm and a leg'.
 
What I wanted was something a lot cheaper - and that means using an existing 'data input' path - the simpler the better !

All PC's have USB ports, however accessing these using DIY hardware is a total pain - what I needed was a 'real simple' way to get data into my PC - and that means using the LPT (printer port) or RS232 Serial link

[top]

The LPT (Printer Port)

Most PC's have motherboards equipped with an 8 bit I/O port capable of supporting data transfers of up to 2 mega-bytes per second = this is the EPP/ECP Parallel Port (or PRN:, Printer Port). One can be found on almost all motherboards (although modern PC's don't actually 'expose' the Printer Port as a 25way connector on the backplate anymore - instead you have to pick up the interface from a 'header strip' on the motherboard itself (some don't even have pins fitted = instead you have to solder direct to holes in the motherboard))

The LPT port really is the simplest way to get data into the PC - you present 8 bits of data, assert a flag bit to say 'data ready' and wait for a response, 'data taken'. Unlike the RS232 Serial Link, there are no 'start bits', no 'stop bits' and no need to maintain some set/chosen 'baud rate' (data transfer speed)
 
If you want to know if your PC motherboard actually has a printer port, go into the BIOS and look for 'EPP/ECP Printer Port' in the 'Legacy Devices' tab. Of course just because the BIOS says the port exists, this doesn't mean you can plug anything into it - many OEM's (such as Dell) don't actually bother to fit the 'header', and some don't even track the port pins to a row of 'holes' on the motherboard.


(-) PC Parallel port pin out


Photo: ../Other_projects/photos/ParallelPortView.gif
The Parallel port is a D-Type 25 Pin female connector. The connector supports 8 Data pins, 5 Status pins and 4 Control pins. Voltage levels are TTL (logic '0' 0v (<0v7), logic '1' 5v (>1v8 = some modern motherboards likley use 3v3 not 5v as Vcc). The other connector pins are all 'Gnd'.

Each of the pin sets (Data, Status, and Control) has a specific address assigned in sequential order. For example, if you set the Data port to the 'normal' LPT1 address 0x0378, the Status port is 0x0379 and the Control port 0x037A.

Originally, the Data port (Pins 2 through 9) was a 'write-only' port (i.e. limited to data output). However, in 'bi-directional' mode, the Data port becomes a 'read/write' port. The Status port (Pins 10 through 13 and Pin 15) is read-only. The Control port (Pins 1, 14, 16, and 17) are 'read/write'.

The Data Register
The IEEE-1284 standard refers to the Data lines as 'D1' through 'D8', however, to avoid confusion, I will use 'd0' to 'd7' which matchs the more normal usage (and matches the approach taken with the Status and Contol ports)

Thus pin2 = d0, through to pin9 = d7

The Status port
An 8 bit port (S0-S7) that 'senses' the state of the five Status pins on S3 through S7. S1 and S2 are unused, however S0 is a 'timeout' flag when the port is operated in EPP mode (when S0 can be written, i.e. cleared, by software).

In most implememntations, the Status pins are terminated with pull-up resistors (so all 5 pins default to '1' when nothing is plugged in)

S0: Timeout. In EPP (Enhanced Parallel Port) mode, this bit sets to '1' on a timeout of an EPP data transfer. Otherwise unused.
S1: Unused.
S2: Unused, except for a few implementations where this bit indicates the parallel port interrupt status (PIRQ). 0 = parallel-port interrupt has occurred; 1 = no interrupt has occurred. On these ports, reading the Status register sets PIRQ = 1.
S3: (pin15) /Printer Error (/Fault). Pulled Lo by the printer when it detects paper jam (or other fault condition).
S4: (pin13) Printer Ready. High when the printer is 'on-line', Lo when plugged in and powered on but not ready.
S5: (pin12) No Paper. High when the printer is out of paper (Lo when paper ready to print).
S6: (pin10) /dACK. Data acknowledge. Pulled Lo by the Printer to indicate it has accepted a byte. When interrupts are enabled, a transition (usually the rising edge) on this pin triggers an interrupt.
S7: (pin11) Printer Busy. Pulled Lo by the printer to indicate that it is unable accept any more data.

Note that, when the cable is out (or the printer is powered off), all the Status bits are 'Hi'. This signifies 'No error', 'Ready', 'No Paper)', 'no ack', 'not Busy' i.e. S5 is the only 'flag' that shows the printer is not ready to start printing !

The Control Register
The Control register sets the states of four Control bits, C0 through C3. Although used as outputs, on almost all implementations, the Control bits are 'open-collector' (or open-drain) driven, which means that they can also function as inputs.

C0: (pin1) /dRDY. Lo to indicate to the Printer that new data has been placed on the Data port. The Printer typically latches the state of the data lines at the end (rising edge) of this pulse.
C1: (pin14) /Line Feed (or /Auto-line feed). A low tells the printer to automatically generate a line feed (ASCII code 0Ah) after each Carriage Return (ASCII 0Dh).
C2: (pin16) /Reset. Pulses Lo to reset the printer (clear its buffer etc). The minimum pulse width is 50 microseconds.
C3: (pin17) /.
C4: Enable Interrupt. Set Hi to allow interrupt requests from /dACK (S6) to the PC�s IRQ (interrupt-control) circuits.
C5: Data I/O mode. Sets the direction of the Data port, 1=input, 0=output (note that the Printer Port has to be configured for bidirectional use in the BIOS (PS/2 mode) in order for this bit to have an effect).
C6: Unused.
C7: Unused (although in a few implementations, this bit is used instead of C5 for Data I/O setting)


This note last modified: 8th Feb 2018 14:59.

[top]

[top]

Using the Printer Port (see also external link)

The printer connector is/was a 25pin 'D' type socket found on the back of most older PCs (next to the Serial Port, something else that's often omitted these days). Of the 25 pins, 8 are unused (Gnd) and the others 'fed' from/to the CPU via 3 i/o ports.

First we have the 8 bit data (d0-d7) port, then the 5 bit status (s3-s7, normally inputs) and the finally the 4+2bit control port (4 control pins c0-c3, normally outputs, are wired to the 25pin D connector, and two 'mode control' pins, c4 (enable IRQ from ACK) and c5 (enable bi-directional data EPP/ECP mode) are used 'internally').

Originally, the data pins were output only (i.e. the port supported only printing), however the 4 status pins were often used for the 'cunning trick' of reading data 'nibble at a time' - it was even possible to add 4 of the control lines (so long as you used 'open collector' drivers) to the 4 status pins to support byte input (but don't try this if the Printer Port supports bi-directional mode - why ? because then the Control pins become 'outputs' (only) and you risk blowing them !).

WARNING - by default (eg PC power-on) the Printer Port data pins will always be enabled as outputs ! If you plug in your own device designed to 'input' to the Port and allow it to 'enable' on it's own power-on, you can blow the Port (or your own device) !! It is thus VITAL to use PC based software to 'enable' your own device drivers

Although the max data rate supported by the basic printer port was about 125k bytes/s, any motherboard that's less than 10 years old will have an EPP (Enhanced Parallel Port, aka IEEE 1284) or ECP (Extended Capability Port) mode which not only supports both output (for printers) and input (for scanners) but offers data rates exceeding 1 Mbytes/s !

Note that ECP is just EPP with DMA support (usually ISA DMA on channel 3). In theory, EPP can achieve 'up to' 2 Mbytes/s bandwidth, whilst ECP supports 'up to' 2.5 Mbytes/s (the limit of 8-bit ISA DMA) - and this sets a limit on the 'real time' samples per second (sps) that a simple parallel port oscilloscope can achieve.
 
To support higher 'real time' sps via LPT, some form of compression would have to be used.
 
Of course a large 'front end' data buffer would allow non-real-time 'snap shots' at much higher sps.

If you can't get access the parallel port on your motherboard, you can buy PCI / PCIe based ECP/EPP Parallel Port cards (rated at 1.5Mbytes/sec or better) on eBay (from China) for less than £5.

For a good explanation on how to drive the Parallel Port, visit here

Whatever the data rate limit, a Parallel Port based DIY project will 'come in' at a fraction of the cost of a dedicated 'digital input' card (let alone the cost of a dedicated analogue input card or a 'commercial' parallel port 'picoscope' (which does, however, incorporate some buffer RAM - typically 32kb))

Note that, unless buffer RAM is used, the max. samples per second (sps) will be divided by the channel count.
 
So whilst 1 ch might get you >1m sps, 2 will share the 1m sps (so 500k sps each). Even so, this is more than enough when working with audio frequencies (500k sps will define a 20kHz audio tone with 25 sample points which should be more than enough to detect distortion in even the highest audio frequency)

[top]

Powering the front-end

On some PC's, you can find +5v on pin17 of the physical DB25 Parallel Port socket. If not, then simplest approach is probably to 'steal' +5v from a spare USB socket.

If you have to open the PC case (to get to the motherboard Parallel Port pins) you can wire your 'pin 17' to any of multiple +5v sources -
 
- for example, spare USB port 'pin sets' (where you can pick up +5v) or, if you are going to use an external DC-DC converter anyway, +12v from one of the many cooling fan connectors.
 
If all else fails, you can always pick up +5v from an unused connector off the power-supply cable harness (eg. +5 is on pin 1 of the floppy disk connector - usually a red wire (but watch out = the other end of the plug, pin 4, is +12v (usually a yellow wire)) whilst Gnd can be found on the two center pins (2 & 3, usually black wires)

Note that for maximum 'noise immunity' it's not a bad idea to run the analogue 'front end' from a battery supply - and for this I recommend using a 'Power Bank'

It is (just) possible to align the Power-bank against one side of the case and cut a hole in the end to access to it's micro-USB 'recharge' socket
 

Next page :- RS232 PC Serial Port use

[top]

This page last modified: 29th May 2018 14:41. Page Clicks to date: 20. User 81.136.232.145 @ host81-136-232-145.in-addr.btopenworld.com.
� Copyright 2013-2018