Circuit Puts Analog Data into Excel
You can build a 16-bit voltmeter circuit that will transfer data into an Excel spreadsheet.
Clayton B. Grantham, Burr-Brown Corp., Tucson, AZ -- Test & Measurement World, 9/1/1996
A few integrated circuits, a simple Excel 5 macro, and a driver are all you need to transform a PC into a virtual voltmeter. The resulting 16-bit voltmeter circuit offers an input range of up to ±200 V, resolves to 6.1 mV, and has an accuracy of 0.005% after calibration.The interface circuit (Fig. 1) that connects the 16-bit ADS7807 analog-to-digital converter (ADC) IC to a PC's parallel port is simple. The control software forces nine of the port's signal lines to a high state, which lets the corresponding pins provide power to the circuit through 10-V resistors. Using the parallel interface's data lines to power the interface may not work for all PCs, though. If your PC cannot supply clean 4.75-V to 5.25-V DC power to the circuit, use an external source to supply the 35 mW the circuit needs. (For more information about the parallel port, see the IEEE 1284 standard,(See 1 which provides a thorough description of signals, controls, and hardware for a PC's parallel interface.)
The 74HCT04 inverter in the interface circuit provides a clean signal to a monostable (10-kV resistor and 100-pF capacitor) that produces a 150-ns logic-zero pulse for the ADC's R/C* input. When the R/C* input goes to a logic zero, the ADC starts a conversion. The short pulse ensures that the R/C* input is back at logic one before the ADC's BUSY* (conversion complete) signal goes to a logic one. The short pulse width also minimizes any digital feedthrough that might occur during a conversion.
Select a Byte
The 16-bit ADC's BYTE input selects the byte that appears at the ADC's outputs. In turn, the 74HCT157 multiplexer selects which nibble (four bits) of each byte to transmit to the parallel port. The macro controls the flow of four nibbles to the PC and reconstructs them into a 16-bit integer.
By itself, the ADS7807 has an input voltage range of ±10 V. Using an 866-kV input resistor, however, extends the range to ±200 V according to the equation:
Vin(max) = ±10 V * (1 + Rext/45.5k)
To reduce noise on your signal, place a capacitor between the ADS7807's input and ground to form an RC network with the input resistor.
To acquire voltages, select a cell or a range of cells in a spreadsheet and then execute the macro (Fig. 2), which contiguously fills each cell with a measurement. The Excel macro uses a dynamic link library routine, CUSER3.DLL, to communicate with the ADC through the PC's parallel port. (T&MW provides the DLL file for free; see "Notes," below.) Be sure to transfer the CUSER3.DLL into your main Excel directory so the macro can locate it.
Control Your PC's Ports
To keep Excel Basic--the Basic-like language built into Excel--independent of hardware, Microsoft excluded commands that control specific I/O ports. The CUSER3.
DLL circumvents this limitation and lets you transfer bytes to output ports and retrieve bytes from input ports.Typically, a PC's parallel port resides at h0378 (data), h0379 (status), and h037A (control). Check your PC's manual to be sure you have the proper addresses for the port you want to use. If necessary, change the three address definitions at the start of the macro.
|
'The following macro communicates through the PC's parallel printer port Declare Sub Out Lib "CUSER3.DLL" (ByVal Addr%, ByVal Byte%) Sub ADSinput() Dim Datum As Integer 'Temporary data element 'Hexadecimal Port Addresses If TypeName(Selection) <> "Range" Then Exit Sub 'Input low byte, high nibble. Isolate & shift nibble up. If (Datum And &h40) Then Out ControlPortAddr, &h8 ' Select high byte, low nibble. 'Input high byte, low nibble; Isolate & shift nibble up & add to word. 'Convert result to signed floating point. 'Scale result with offset and gain calfactors for +/- 200V input. Out ControlPortAddr, &h4 ' Reset for another conversion. |
|
When you run the macro, it initializes the control byte and starts the ADC. After a delay of at least 25 ms, the macro checks the ADC's BUSY signal. At the end of a conversion, the macro inputs the ADC's data. For example, if you select 15 cells, the macro acquires 15 readings, one after the other. The timing between conversions depends on your PC's timing and the timing overhead of Excel. My 33-MHz 486-based PC took 23 ms per conversion, and the Nyquist bandwidth was 22 Hz.
![]() |
|
Calculate Offset and Gain Errors
The basic circuit doesn't compensate for gain and offset errors. You can use nominal ADS7807 offset and gain errors (without external trimming) to scale the results obtained with the macro. Use the code shown in Fig. 3 with the ADSinput() macro to provide gain and offset coefficients, if you need them. To achieve the highest accuracy, add external trimmer resistors to the circuit. (See Footnote 2 below.) T&MW
FOOTNOTES Clayton B. Grantham is the Linear Div. product engineering manager at Burr-Brown Corp. He has B.S.E.E. and M.S.E.E. degrees from the University of Arizona. |



















