Silicon ChipA Low-Cost PC-to-I²C Interface For Debugging - March 2008 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: High-definition TV in limbo until the Olympics
  4. Feature: How To Get Into Digital TV by Alan Hughes
  5. Review: Tevion TEV8200 HD Set-Top Box by Leo Simpson
  6. Feature: How To Solder Surface Mount Devices by Jim Rowe
  7. Project: 12V-24V High-Current DC Motor Speed Controller, Pt.1 by Mauro Grassi
  8. Feature: PICAXE VSM: It’s Time to Play; Pt.3 by Clive Seager
  9. Project: A Digital VFO with LCD Graphics Display by Andrew Woodfield, ZL2PD
  10. Feature: The I²C Bus: A Quick Primer by Jim Rowe
  11. Project: A Low-Cost PC-to-I²C Interface For Debugging by Jim Rowe
  12. Feature: Electric Flight by Ross Tester
  13. Vintage Radio: The batteries used to power vintage radios by Rodney Champness
  14. Project: One-Pulse-Per Second Driver For Quartz Clocks by Jim Rowe
  15. Book Store
  16. Advertising Index
  17. Order Form

This is only a preview of the March 2008 issue of Silicon Chip.

You can view 32 of the 104 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.

Articles in this series:
  • How To Get Into Digital TV (March 2008)
  • How To Get Into Digital TV (March 2008)
  • How To Get Into Digital TV, Pt.2 (April 2008)
  • How To Get Into Digital TV, Pt.2 (April 2008)
Items relevant to "12V-24V High-Current DC Motor Speed Controller, Pt.1":
  • PIC16F88-I/P programmed for the DC Motor Speed Controller [0910308A.HEX] (Programmed Microcontroller, AUD $15.00)
  • PIC16F88 firmware and source code for the 12-24V High Current Motor Speed Controller [0910308A.HEX] (Software, Free)
  • 12-24V High-Current Motor Speed Controller main PCB pattern (PDF download) [09103081] (Free)
  • 12-24V High-Current Motor Speed Controller display PCB pattern (PDF download) [09103082] (Free)
Articles in this series:
  • 12V-24V High-Current DC Motor Speed Controller, Pt.1 (March 2008)
  • 12V-24V High-Current DC Motor Speed Controller, Pt.1 (March 2008)
  • 12V-24V High-Current DC Motor Speed Controller, Pt.2 (April 2008)
  • 12V-24V High-Current DC Motor Speed Controller, Pt.2 (April 2008)
Articles in this series:
  • PICAXE VSM: The PICAXE Circuit Simulator! (January 2008)
  • PICAXE VSM: The PICAXE Circuit Simulator! (January 2008)
  • PICAXE VSM: The PICAXE Circuit Simulator, Pt.2 (February 2008)
  • PICAXE VSM: The PICAXE Circuit Simulator, Pt.2 (February 2008)
  • PICAXE VSM: It’s Time to Play; Pt.3 (March 2008)
  • PICAXE VSM: It’s Time to Play; Pt.3 (March 2008)
Items relevant to "A Digital VFO with LCD Graphics Display":
  • AT89C4051 firmware and source code for the Digital VFO with LCD Graphics Display [DDSFINAL.HEX] (Software, Free)
  • DDS VFO PCB pattern (PDF download) [06103082] (Free)
  • DDS VFO front panel artwork (PDF download) (Free)
Items relevant to "A Low-Cost PC-to-I²C Interface For Debugging":
  • Philips Universal Register Debugger software for the Low-Cost PC-to-I²C Debugging Interface (Free)
  • Low-Cost PC-to-I²C Interface for Debugging PCB pattern (PDF download) [04203081] (Free)
Items relevant to "One-Pulse-Per Second Driver For Quartz Clocks":
  • One Pulse Per Second Driver for Quartz Clocks PCB [04103081] (AUD $2.50)
  • 1pps Quartz Clock Driver PCB pattern (PDF download) [04103081] (Free)

Purchase a printed copy of this issue for $10.00.

By JIM ROWE 2 LPT-to-I C A low-cost interface for debugging Tracking down problems in circuits which are programmed via an I2C bus can be tricky and time-consuming, unless you take advantage of a debugging program running on a PC. Here’s a low-cost, easy-to-build printer port to I2C interface designed to work with the Philips/NXP debugging program URD312.exe. TO PC PRINTER PORT (DB25M) 15 SCL IN SCL Q2 17 11 SCL OUT SDA IN Q1 9 SDA OUT 18-25 GROUND RETURN 78  Silicon Chip TO I 2 C BUS ON PC BOARD SDA BEING TESTED GND Fig.1: the basic arrangement for the LPT to I2C interface. Mosfets Q1 & Q2 pull down the SCL & SDA lines for outgoing signals from the port, while the inverters interface the incoming SCL & SDA signals from the circuit under test. J UST RECENTLY, I was trying to finish a project which uses a couple of video-processing ICs that are programmed via the I2C bus. However, I struck trouble with one chip. For some reason, it wasn’t responding correctly to the set-up data I was sending to it from the project’s microcontroller, even after I had been through my control program umpteen times searching for bugs (or programming errors). Even when I wrote a test program and captured the I2C bus activity with my digital scope, I still couldn’t track down the source of the trouble. siliconchip.com.au Fortunately, before tearing out the last few strands of my hair, I decided to seek help from the support people at NXP (formerly Philips Semiconductors) – not only because the chip concerned happened to be one of theirs but because it was Philips that developed I2C in the first place. After all, if anyone should be expert at solving I2C problems, it should be NXP. As it turned out, they were very helpful. An NXP support engineer promptly sent me an email suggesting several things to try. Then, when that didn’t fix things, he suggested I try analysing the problem using a debugging program running on a PC. Not only that but he also sent me a copy of the latest version of their free I2C debugging program (called “URD”), which they developed quite a few years ago. The current version turned out to be v3.12, which comes as a self-installing package called URD312.exe (more on this later). Along with the program, he also sent a device data register set-up file for the video processing chip I was working with, so the URD program could communicate with it sooner. And last but by no means least, he sent me a PDF file with the circuit of the original PC printer port/I2C interface card that the URD program was designed to work with, so I could build one up for the troubleshooting. That’s pretty good support from the other side of the world, don’t you think? As it happened, the original interface used a 74LS05 chip that I didn’t have, so I decided to update the circuit to use devices that are readily available nowadays. And that’s the project described here – it uses a 4011B quad NAND gate, a couple of Mosfets and not much else. How it works Like the original NXP/Philips interface, this unit is designed to allow the URD program to communicate with an siliconchip.com.au 4 7 TO PRINTER PORT OF PC DB-25M +5V 5 SCL PULLUPS ENABLE S1 IC1: 4011B 10 14 8 IC1c 9 11 IC1d K –SCL 100 3.3k S2 12 +3.3V 3.3k 13 SCL D1 17 10 F 100n 6 10k 12 15 IC1b D A Q2 G S 100k SDA 11 –SDA 3 IC1a 1 K 2 D3 9 –SDA 100 A 23 K 24 GND D4 A Q1 S K D2 25 D G A 100k Q1, Q2: 2N7000 D1 – D4: 1N4148 A SC 2008 K D G S LOW COST LPT –I 2 C INTERFACE FOR DEBUGGING Fig.2: the complete circuit for the LPT to I2C interface. It’s based on Mosfets Q1 & Q2, a 4011B quad NAND gate (IC1a, IC1c & IC1d) and just a few other parts. Diodes D1-D4 are there to protect the Mosfets. I2C bus on a development board via the PC’s parallel printer port (LPT). The basic arrangement of the circuit is shown in Fig.1. In operation, the URD program sends out the SCL pulses in inverted form via pin 17 of the printer port (originally used for the SEL-bar line). So the interface uses this printer port line to control Mosfet Q2, which is used to pull down the SCL line of the I2C bus. Conversely, the URD program monitors the I2C bus SCL pulses via pin 15 of the printer port, which was originally used for monitoring the printer’s Error-bar line. As a result, the interface feeds back the SCL line status to pin 15 via a pair of inverters which function as a non-inverting buffer. Similarly, the URD program sends out data to the SDA line (in inverted form) via pin 9 of the printer port, originally used to send parallel data bit 7 to the printer. The interface uses this printer port line to control Mosfet Q1, which is used to pull down the SDA line of the I2C bus. Finally, the URD program receives data from the SDA line (again in inverted form) via pin 11 of the printer port, which was originally used for monitoring the printer’s Busy/Readybar line. So, in the interface, we feed March 2008  79 Parts List 1 PC board, code 04203081, 55 x 61mm 1 male D25 connector, 90° PCmount (CON1) (Jaycar PP0843; Altronics P-3220) 1 10-pin (5 x 2) vertical IDC header, PC-mount (Jaycar PP-1100; Altronics P-5010) 1 10-way IDC socket (Jaycar PS0984; Altronics P-5310) 1 250mm length of 10-way rainbow cable 5 EZ-hook test clips, 40mm long 1 4-way DIL slider switch (S1,S2) 1 14-pin IC socket Semiconductors 1 4011B CMOS quad NAND gate (IC1) 2 2N7000 N-channel Mosfets (Q1,Q2) 4 1N4148 diodes (D1-D4) Capacitors 1 10mF 16V RB electrolytic 1 100nF monolithic ceramic Resistors (0.25W 1%) 2 100kW 2 3.3kW 1 10kW 2 100W the SDA line data back to pin 11 via a single inverter. So that’s the basic idea of the way the interface works. Let’s now take a look at the full circuit which is shown in Fig.2. Circuit details As shown in Fig.2, two low-cost 2N7000 N-channel Mosfets (Q1 & Q2) are used as the SCL and SDA pulldown transistors. Inverter stages IC1c & IC1d (part of a 4011B quad CMOS NAND gate) are used for interfacing the SCL line, while IC1a is used to interface the SDA line. The fourth gate (IC1b) is unused. Most of the rest of the circuitry is used to protect Mosfets Q1 & Q2 from possible damage due to electrostatic charge build-up on the printer port lines when the interface is not connected to a PC. That’s the reason for the 100kW resistors connected from each Mosfet gate to ground and for diodes D1-D4. The latter prevent each gate from being taken more negative than ground or more positive than the +5V rail which is used to power IC1. The 10mF capacitor on the +5V line provides supply line filtering, while the 10kW resistor ensures that pin 12 of the printer port is pulled high. This is a requirement of the URD program which expects to find a logic high on this pin of the printer port (originally used for monitoring the “Out of paper” line). Switches S1 & S2 can be used to switch in two 3.3kW pull-up resistors on the SCL & SDA lines respectively. This is necessary if the I2C bus lines on the PC board being tested don’t already have pull-up resistors. Note that the interface line marked “+3.3V” must be connected to the +3.3V line supplying power to the I2C chips on the board being tested, so the interface pull-ups can function correctly. As indicated, the interface pull-ups aren’t needed if the board being tested is already provided with pull-ups of its own. In that case, S1 and S2 are simply left open (and the interface’s +3.3V lead doesn’t need to be connected to anything). Building it Building the interface is very straightf­ orward, as all the parts are mounted on a small PC board coded 04203081 and measuring 55 x 61mm. These parts include the male D25 connec- From the publishers of SILICON CHIP PERFORMANCE ELECTRONICS FOR CARS NOT A REPRINT: More than 160 pages of new and exciting projects never published before – all designed to get top performance from your car. FASCINATING ARTICLES: 7 chapters explaining your car – engine management, car electronics systems, etc ADVANCED PROJECTS: You’ll build controllers for turbo boost, nitrous, fuel injection and much more! We explain the why as well as the how to! Available direct from the Publisher ($22.50 inc postage): Silicon Chip Publications, PO Box 139, Collaroy NSW 2097. Ph (02) 9939 3295; Fax (02) 9939 2648; email silchip<at>siliconchip.com.au or via our website: www.siliconchip.com.au 80  Silicon Chip siliconchip.com.au L CS 18030240 V5+ L CS AD S 9 10 100 4148 4148 100 100nF L CS- tor used to mate with the PC TO PC PRINTER PORT printer port. Fig.3 shows the parts layout. Install the single wire link CON1 D25M first, then install the resistors, 71 51 25 the four diodes and the two 1 9 21 11 1 capacitors. Be sure to orien10k ADState the diodes and the 10mF ADSelectrolytic capacitor exactly as shown. IC1 4011B Follow these parts with the two Mosfets (Q1 & Q2) and 4148 4148 the IC, again taking care to Q1 Q2 2N7000 2N7000 ensure they go in the right way 100k 100k 3.3k around. The assembly can then 3.3k CON2 be completed by fitting the D25 + connector (CON1), the IDC V 3. 3 + header (CON2) and the 4-way D N G 10 F S2 S1 DIP switch. Take care when installing 5x2 IDC CON2 – the slot in its body SOCKET 2 I C LEADS goes towards the bottom edge Fig.3 (right): install the parts on of the PC board. TURN OFF S1 & S2 the PC board as shown on this Note that switches S1 & S2 IF PC BOARD BEING layout diagram and in the above are part of a 4-way DIP switch, TESTED HAS PULLphoto. Each pair of external UP RESISTORS ON with the other two switches not leads from the 10-way cable can SCL & SDA LINES used. If you happen to have a be terminated in a small “EZ2-way DIP switch, this could hook” test clip as shown in the +5V +3.3V GND be used simply by fitting it in lead photo. SDA SCL the two righthand positions (nearer the 3.3kW resistors). The 10-way IDC header (CON2) provides the interface to the supply rail on the board. program, we are posting a copy of I2C circuit under test. This allows you If you’re going to be using the pull- URD312.EXE on the S ILICON CHIP to make up a test lead cable from a up resistors on the interface, you’ll also website (www.siliconchip.com.au). 250mm length of ribbon cable which need to connect the +3.3V lead to the If you download this and execute it, is fitted with a 10-way IDC socket at positive rail of the chips connected you’ll find that it will install on most one end to mate with the header. Each to the I2C bus – and close interface PCs running Win98, WinMe, Win2000 pair of wires in the cable can then be switches S1 and S2, of course. and WinXP. When it installs, it also terminated in a small “EZ-hook” test On the other side of the interface, loads the driver it needs for commuclip to make the connections to the PC all that’s needed is to plug CON1 into nicating with the interface via the board being tested. a printer port connector on a suitable printer port. PC, either directly or via a short D25MI had no difficulty installing and Putting it to use D25F extension cable if necessary. running the URD program on a maThere’s not a great deal involved After that, it’s simply a matter of run- chine running Win98 but it did have in using the interface, apart from ning the URD program and using it to a problem talking to the printer port connecting the I2C leads from CON2 check and/or modify the contents of when I installed it on a machine runto the appropriate points on the PC the I2C subaddress registers inside the ning WinXP/SP2. I still haven’t sorted board you’re debugging. This means chips on the board you’re working on. out that particular problem at the time connecting the SCL and SDA leads of writing this article but it may be to the same lines on the board to be Obtaining the URD program part of the tighter security enforced tested, the ground lead to the board’s To make it easier for you to get by WinXP when the SP2 patches are SC ground and the +5V lead to a suitable the NXP/Philips URD312 debugging applied. 1 2 Resistor Colour Codes o o o o o siliconchip.com.au No. 2 1 2 2 Value 100kW 10kW 3.3kW 100W 4-Band Code (1%) brown black yellow brown brown black orange brown orange orange red brown brown black brown brown 5-Band Code (1%) brown black black orange brown brown black black red brown orange orange black brown brown brown black black black brown March 2008  81