Silicon ChipParallel Port Interface Card - January 2000 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Switch those computers off when not in use
  4. Feature: Protel 99: Much More Than A PCB Design Tool by Peter Smith
  5. Review: B&W Nautilus 801 Monitor Loudspeakers by Louis Challis
  6. Serviceman's Log: They came in two by two by The TV Serviceman
  7. Project: Spring Reverberation Module by John Clarke
  8. Project: An Audio-Video Test Generator by Leon Williams
  9. Product Showcase
  10. Project: PICMAN Programmable Robot by Andersson Nguyen
  11. Order Form
  12. Project: Parallel Port Interface Card by Peter Smith
  13. Vintage Radio: Building a vintage radio replica by Rodney Champness
  14. Project: Off-Hook Indicator For Telephone Lines by John Clarke
  15. Book Store
  16. Back Issues
  17. Market Centre
  18. Advertising Index
  19. Outer Back Cover

This is only a preview of the January 2000 issue of Silicon Chip.

You can view 33 of the 96 pages in the full issue, including the advertisments.

For full access, purchase the issue for $10.00 or subscribe for access to the latest issues.

Items relevant to "Spring Reverberation Module":
  • Spring Reverb PCB pattern (PDF download) [01101001] (Free)
Items relevant to "An Audio-Video Test Generator":
  • Audio/Video Test Generator PCB pattern (PDF download) [04101001] (Free)
  • Audio/Video Test Generator panel artwork (PDF download) (Free)
Items relevant to "Parallel Port Interface Card":
  • DOS and Windows software for the Parallel Port Interface Card (Free)
  • Parallel Port Interface Card PCB pattern (PDF download) [K2805] (Free)
Items relevant to "Off-Hook Indicator For Telephone Lines":
  • Telephone Off-Hook Indicator PCB pattern (PDF download) [12101001] (Free)
  • Telephone Off-Hook Indicator panel artwork (PDF download) (Free)

Purchase a printed copy of this issue for $10.00.

Connect to the real world with this: Parallel port I/O card for PCs This easy-to-build input/output (I/O) card features 10 analog inputs, two analog outputs and eight digital outputs. It plugs into your PC’s parallel port and you can drive it with Windows-based software. By PETER SMITH If you have an application that would adapt well to comput­er control or would just like to learn about interfacing PCs to the real world, this project is for you. Connection couldn’t be simpler; just plug it in to the parallel printer port on your PC, hook up DC power and you’re ready to begin experimenting. The card’s eight digital outputs can be used to control devices such as 66  Silicon Chip relays, solenoids, motors and lamps. Ten analog inputs are provided too and these can be easily interfaced to a multitude of devices like temperature, pressure, light and posi­tion sensors. In addition, two variable voltages can be generated using the analog outputs. Software examples are available if you want to write your own control programs or you can download Windows software, writ­ten by James Rickard, from SILICON CHIP to get you off the mark right away. Low power consumption means that it can be battery powered or it will operate from any DC power source from 7.5V to 25V. In the following text, we take a brief look at the PC parallel port and how it connects to the interface board. We then look at how data is transferred from the parallel port to the interface board. Next, we examine how that data is used to gener­ate the digital and analog outputs. Last but not least, the analog-to-digital section gets the treatment. PC parallel port basics Software control of the interface board is carried out via the standard PC parallel printer port. Table 2 lists the function of each signal on the PC parallel port as related to its usage on the interface board. For reference, we also show the function of each signal when the port is used for its “normal” purpose – driving a printer! All signal lines in and out of the PC parallel port are at TTL or CMOS (05V) voltage levels. The port occupies three sequential addresses in the PC’s I/O memory map. The first ad­dress is called the “base” address. PCs support up to three parallel ports, commonly referred to as LPT1, LPT2 and LPT3. Generally, the first two ports are mapped to base addresses 378H and 278H, respectively. For example, to read the IC4 data out and EOC pins when the interface board is connected to LPT1, the software would read I/O address 379H (base +1). Communication The interface board is connected to the parallel port via connector SK6. The 1kΩ series resistors and 220pF capac­itors to ground filter the parallel port signals. The series resistors limit current flow into the IC pins to safe levels. High currents could occur when the PC is powered but the interface is not (or vice versa) or when the board or con­ necting cable is exposed to electrostatic voltages. In combina­ tion with the capacitor to ground, the series resistor also helps to remove high frequency noise. In addition, most lines are pulled up to +5V with 10kΩ resistors, ensuring that logic inputs always reach valid “high” voltage levels. Getting data in and out To keep the design as simple as possible, all data is transferred to and from the interface board in serial format (ie, one bit at a time). IC1, IC2 and IC3 are serial-to-parallel shift registers, connected in series (cascad­ed) to form a 24-bit shift register. This is done by connecting the serial out (or Qh’) pin of one 74HC595 to the serial input (SER) pin of the next. The software writes each data bit in turn to the serial input of IC1 (pin 14) and toggles the clock (pin 11) to shift it in. The clock inputs on all three 74HC595s are connected togeth­ er, allowing the entire 24 bits to be shifted together. The 74HC595 has a second clock input (pin 12) which is used to transfer data from the shift registers to an internal 8-bit output latch. This Fig.1: the Windows-based software is easy to drive, with everything controlled and displayed via this dialog box. “two-stage” method of update is used so that data does not change on the output pins until all bits have been shifted to their correct positions. Unlike the shift clock, the register clock (pin 12) of each 74HC595 can be individually controlled by the parallel port interface and software; this is the default configuration. Alternatively, they can be connected together and controlled via a single interface line by moving jumpers J4 and J5 from position 1-2 to 2-3. The Qa-Qh outputs of the 74HC595s can be enabled or disa­bled (switched to the high-impedance state) by controlling pin 13 (G). The output enable pin of each 74HC595 is controlled indi­vidually by the PC parallel port interface and software. Alterna­tively, connecting them to ground with jumpers J1, J2 & J3 will permanently enable the outputs. We recommend using the default positions (as shown Fig.2: this dialog box provides the setup options. on the circuit diagram) for all jumpers. A low-going pulse on pin 10 (SRCLR) zeros all 74HC595 out­puts on power up. This is generated by the RC network formed by R1 and C1. Transfer of data in and out of IC4, the A-D converter chip, is also performed serially. We describe how this works in the analog-to-digital section below. Digital outputs Fig.3: the output stage configuration for the ULN2083 driver IC. There are eight output channels in all. The interface board provides eight digital outputs, acces­ sible on connector SK4. All outputs are driven by a ULN2803A (IC5), a January 2000  67 68  Silicon Chip Fig.4 (left): the circuit connects to the PC’s parallel port. IC1, IC2 & IC6 perform D/A conversion, IC3 & IC5 provide the digital outputs and IC4 provides A/D conversion. high voltage and high current inverting buffer. A single output of IC5 is capable of sinking up to 500mA but for each additional output conducting simultaneously this needs to be derated by about 50mA. For more detailed information on derating, refer to the ULN2803A data sheet (see Table 3). Note that as the ULN2803A’s outputs are open collector, they can be connected together to increase sink current capability. Each output is protected by an internal diode, so inductive loads (such as relays) can be driven directly without any addi­tional protection. Zener diode ZD1 connects to the internal protection diodes on pin 10, clamping all outputs to a maximum of 33V. Fig.3 shows the equivalent circuit for each driver in the ULN2803A. Note that the cathodes of all the protection diodes have a common connection to pin 10. Additional protection is provided by R54, which helps to limit large current surges through the interface when switching heavy loads. It also provides some protection for the driver and PC board’s tracks should an output be momentarily shorted to the power rail. Digital-to-analog conversion Two digital to analog converters are provided on the paral­lel interface board. Both converters operate in an identical manner, so we’ll only look at channel 0. The eight outputs from IC1 give a total of 256 (28) possi­ble combinations. Each output is given a particular “weight” according to its connection point in the R-2R resistor network (or “ladder”). The result of adding all outputs in this way is a voltage on IC6 (pin 3) that increases by 20mV for each increment (or step) of the input byte. To find what the output voltage will be for a particular digital input, use the following formula: Vout = Digital input (in decimal) x Vcc/256. In our case, Vcc = 5V. For example, if our digital input value is 155, the output will be 3V (ie, 155 x 5/256). The output voltage is buffered by IC6, an op amp connected as a unity gain buffer. Note that this op amp cannot sink any significant amounts of current down to the 0V rail (see specs). This is due to the fact that the output needs to be about one diode drop above 0V to forward bias the on-chip high-current PNP output transistor. The designers recommend using the output as a current source (ie, resistive load to ground). Alternatively, you could replace the LM358 with a high-drive, rail-to-rail CMOS type op amp such as the MAX492. Note that IC6 is powered directly from the switched DC input (+Vb) rather than from +5V. In order to be able to drive its output all the way to +5V under load, IC6 needs a positive supply voltage at least 1.5V higher than the maximum output voltage. Analog-to-digital conversion The analog input section of the interface, made up of IC4 and a handful of resistors, appears to be the simplest part of our circuit – but looks can be deceiving! The TLC542 (IC4) is a complete data acquisition system on a single chip. Internally, it contains an analog-to-digital (A-D) converter, an analog multiplexer to connect the converter to one of 12 possible inputs and a serial interface for reading the digital result. The number of bits that an A-D converter can handle deter­mines its resolution. The TLC542 includes an 8-bit converter, giving a total of 256 (28) possible steps. This circuit uses +5V as the reference for the A-D converter and if we divide this by 256, we find that the resolution is around 20mV. When working with small voltages, the accuracy of the vol­tage used as the reference in the measurement and conversion process obviously becomes important. The TLC542 has separate reference supply pins (Vr+ and Vr-) but for simplicity these have been tied directly to the main supply rail. Fortunately, inaccu­racies in the 78L05 regulator’s output can be allowed for in software, so we can still maintain an accuracy of ±20mV over Fig.5: this parts layout diagram is shown 120% actual size. Note that some of the ICs face in different directions. January 2000  69 Table 1: Specifications Power Requirements Voltage range ........................................................................ +7.5-25V DC Current consumption ................................................. 8-10mA typical at 9V Analog outputs Voltage range ....................................................................0-5V (unloaded) Source current ................................................................ 20mA (maximum) Sink current ..................................... 5µA for 20mV (1 LSB) error at 0V out Resolution ...............................................................................8-bit (20mV) Digital outputs (open collector) Sink current ....................................500mA (maximum; derate by 50mA for each additional output – see text) Output voltage ..................................................................... 33V maximum Output protection .............................................. all outputs clamped to 33V Analog inputs Voltage range ......................................................................................0-5V Resolution ...............................................................................8-bit (20mV) Input protection ............................ 20mA absolute maximum for one input, 30mA abso­lute maximum total input current the entire 0-5V input range. Using a simple formula, we can calculate what the digital result will be for any given input voltage, as follows: Digital result (in decimal) = integer ((256 x (Vin - Vr-) / (Vr+ - Vr-)) As Vr+ = 5V and Vr- = 0V, we can simplify to: Digital result (in decimal) = integer (51.2 x Vin). Although the TLC542 has a total of 12 analog channels, only 10 of these are available on connector SK5. Each input has a 1kΩ series resistor that limits current flowing into the TLC542 pins if more that +5V is inadvertently applied. In fact, up to +25V and -20V can be tolerated for short periods before damage to the IC occurs. The eleventh input (pin 12) is wired to the switched DC input (+Vb) via voltage divider resistors R65 and R66. Software can read this input and report low voltage conditions – very handy for battery-powered applications. The 78L05 needs a minimum input of 7V to maintain output regulation. With the 4.1:1 ratio of R65 and R66, this equates to about 1.7V at the A-D input, for a digital reading of 87 (ie, 1.7 x 51.2). The TLC542 provides an additional twelfth channel that can be read by 70  Silicon Chip software but is not physically connected to an exter­nal pin. It is internally connected to a reference voltage of 2.5V, providing a simple “self-test” function. Reading this channel should always return a digital value of 128 ± 2 (ie, 2.5 x 51.2). Reading & writing Digital data is moved in and out of the TLC542 under soft­ware control, using signal lines on the PC parallel port inter­face. Basically, the software needs to be able to tell the TLC542 which channel to sample, wait for the sample and conversion process to complete and then read the result. A typical transfer sequence begins when the TLC542’s serial interface is enabled by driving CS (pin 15) low. As soon as CS goes low, the MSB (bit 7) of the previous data conversion can be read at DATA OUT (pin 16). Next, a 4-bit address for the channel that we want to read during the next conversion cycle is present­ed on ADDR IN (pin 17) and clocked in using I/O CLK (pin 18). As the address is clocked in, the next four bits of the previous data conversion (bits 6-3) appear at DATA OUT. Three more clock pulses are applied to I/O CLK to recover the final three bits of data (bits 2-0) from the previous conversion. Finally, one more clock pulse is applied to start the conversion cycle. The software now drives CS high and waits for the conver­sion to complete – about 20µs – which is signalled by the TLC542 driving the EOC (end of conversion) pin high. Power supply DC power for the board connects to SK1, with diode D2 pro­viding reverse polarity protection. Power is switched through to the regulation circuit under software control, using transistors Q1 & Q2 and a handful of biasing resistors. IC7, a 78L05 3-terminal regulator, brings the voltage down to a steady +5V, with C14 and C15 providing the usual filtering. Zener diode ZD2 shunts any stray voltages above +6.2V to ground – something that should­n’t occur during normal operation! The interface board accepts any regulated DC supply between +7.5V and +25V. Although the same supply can be used for powering external devices (relays, lamps, etc) driven by the open collec­tor outputs, this is not recommended if accurate A-D and D-A conversion is required. The board can also be powered from a single 9V battery. Construction All components, including the 25pin ‘D’ connector, are mounted on a single PC board measuring 144.8 x 67.3mm. The component layout in Fig.5 is shown 1.2 times actual size to make it easier to read. Begin by inserting and soldering all resistors. Note that instead of wire links, zero ohm resistors are used throughout. These are the same physical size as 0.25W resistors and are usual­ly brown in colour with a single black band. The only exceptions to this are the jumpers (J1-J6), which require the usual single-strand tinned copper wire. The jumpers can be installed in positions 1-2 or 2-3. The default for all is position 1-2 and this is what is required for the Windows software. To make test­ing a little easier, don’t install J6 just yet; we’ll come to that a little further on. Next, mount all the diodes, capacitors, transistors and 78L05 regulator in order. The six ICs should be mounted next, taking note that IC5 is mounted the opposite way around to ICs 1-4. These ICs are static sensitive, so use a soldering iron with an earthed tip and solder the ground and power pins first. Finally, mount connectors SK1 to SK6. Base 0 2 Write IC1 serial data in (pin14) Data bi t 0 Testing Base 1 3 Write IC1 to IC4 clock (pin 11) Data bi t 1 Once completed, it’s a good idea to do a few simple checks before connecting the interface board to your PC. First, temporar­ily solder J6 in the 2-3 position. This will allow transistors Q1 and Q2 to switch power through to the regulator. Now apply DC power to SK1 and using the circuit diagram as a reference, meas­ure the supply voltage across the power (Vcc) and ground (GND) pins of all ICs. This should be close to +5.0V. If not, check for problems around Q1, Q2 and IC7. If all is OK, remove power and remove link J6 from position 2-3 and solder it in position 1-2. To prevent possible damage to your PC’s parallel port, we also recommend checking that none of the interface signals on SK6 (pins 1-9, 14 and 17) are shorted to power or ground. The resistance between each of these pins and power or ground should be greater than 10kΩ. Base 2 4 Write IC1 l atch load (pin 12) Data bi t 2 Base 3 5 Write IC2 l atch load (pin 12) Data bi t 3 Base 4 6 Write IC3 l atch load (pin 12) Data bi t 4 Base 5 7 Write IC4 chip sel ect (pin 15) Data bi t 5 Base 6 8 Write IC4 address input (pin 17) Data bi t 6 Base 7 9 Write Power on/off Data bi t 7 Base + 1 3 15 Read Not used -Faul t Base + 1 4 13 Read IC4 data out (pin 16) Sel ect Base + 1 5 12 Read Not used Paper end Base + 1 6 10 Read IC4 end of conversion (EOC) (pin 19) -Ack Base + 1 7 11 Read Not used Busy Base + 2 0 1 Write IC1 output enabl e (pin 13) -Strobe Base + 2 1 14 Write IC2 output enabl e (pin 13) -Auto feed Base + 2 2 16 Write Not used -Ini t Base + 2 3 17 Write IC3 output enabl e (pin 13) -Sel ect - - 18-25 - Ground - Table 2: Parallel Port Pin Assignments I/O Address Software If you have computer hardware and programming skills, you might want to write your own software to control the interface board. Program examples written in QBasic are available for download from the SILICON CHIP website. Don’t want to write your own software? No problem. James Rickard has written general-purpose Windows 95/98 software which can also be down­loaded from the SILICON CHIP web site. To install the software, extract the downloaded file to a temporary folder and run the INSTALL program. The installation program is very basic but does get the job done. It copies two library files (called VB40032.DLL & WIN95IO.DLL) to the Windows directory and places the executable file K2805.EXE in a new directory on the C: drive named \K2805. It then copies a shortcut for the program to the default desktop in C:\Windows\ Desktop. Note that the shortcut will not appear on your desktop if you have profiles enabled in Windows (ie. Windows is maintaining desktop settings for more than one user); simply Bit D B 25 Pin No. Direction Printer Function Interface Function Table 3: Where To Find Additional Data Device Manufacturer URL 74HC595, U LN 2803A Motorol a http://scgproducts.motorol a.com TLC 542 Texas Instruments http://www.ti.com/sc/docs/schome.htm LM358 National Semiconductor http://www.national.com PC Parall el Port create a new shortcut to C:\K2805\ K2805.EXE. Double-click on the K2805 shortcut to launch the program. The main dialog box appears as in Fig.1. Before changing anything here, we have to tell the software which parallel port the inter­face is connected to. To do this, select Edit, Options from the menu bar to display the Options dialog (Fig.2). A useful feature of this program is its ability to record A-D samples in a text file which can later be imported to a database or spreadsheet for manipulation. The Options dialog box allows us to specify the location of this file, as well as the A-D sampling rate. Click the OK button to return to the main window. Driving the software is straightfor- http://www.rmii .com/~hi sys/parport.html ward, so we won’t go into the details here. Remember that channel 10 of the A-D con­verter reads the switched DC input voltage and channel 11 the A-D converter’s internal reference SC voltage. Where To Get It The complete kit is available from Dick Smith Electronics, Cat. K-2805. You will also need a cable with 25-pin male ‘D’ connectors on both ends to connect the interface board to your PC’s printer port. Dick Smith Electronics stock a suitable type, Cat. X-3574. To protect the completed board, it can be mounted in a plastic “Zippy” box, DSE Cat. H-2851. January 2000  71