Digitizing circuit for measuring voltage with the Apple II game port

The authors have designed and tested a 10-bit analog-to-digital circuit that makes use of the Apple II+ game port and is very cheap. KEYWORDS (Audienc...
0 downloads 0 Views 2MB Size
Figure 6. Wagram for collection of data using the TLC548 chip and Apple I1 game port.

PH X-GR1D:Z.S SEC socket is glued in place. The holes are positioned accurately $:01/29/8R 09:30:04 DUR:a1.75 SEC by drilling through a template made from perfboard. TransE:01/29/88 09:30:46 T:.2 4 / 62.7 SEC ducer input is through a modular phone jack and extension cord. A source of +5 V is also provided a t this location as a Figure 7. pH test sample power supply for transducer circuits. This voltage is obtained from the game port, which provides up to 100 mA. The parts needed to build the TLC548 interface are listed in Table 2. Digitizing Circuit for Measuring Voltage with the The TLC548 chip is controlled by a three-routine, machine-laneuaee This oronram also assembles the Apple II Game Port - uroeram. . serial data into a number that & stored in memory. Basic is Tong B. Tang usedto call the routines for each A D conversion. A PEEK of Physics Department memory location 255 reveals the conversion results. The TLC548 control requirements are simple. A change of state from high to low of its Chip Select pin (CS) causes the Albert. W. M. Lee sample information to be available on its Data Out pin. In Sebadian H. T. Chan the arrangement used, the AN0 pin controls the CS pin and Chemistry Department the data are picked up with the PB2 pin of the game port. Hong Kong Baptist College The CS pin must he in the hieh state before startine a - ~ o w i o oHong ~, K O ~ silmpling'session. CA1.L 768 a&mplishes this by bring& I t is well-known that microcomputer game ports can he the AN0 pin hieh which in turn brings the C S nin hizh. used to measure resistance. However. sienals from scientific The ~ & o h & e is used to clock o G the sample data from instruments as well as household appliances come encoded the TLC548. Extracting the sample data also starts the proFor voltaee measurement there exists a wide 8 cess of taking the next sample. CALL 772 arms the ~ ~ ~ 5 as4 voltaees. variety of analog-to-d:lgital conversion (ADC) cards that chip and tosses out any data already present in the chip. may be plugged into peripheral I10 slots (10). but their costs CALL 784 causes the conversion to start, zeros the previous are relatively high. In our search for a low-cost analog interstored sample a t memory location 255, pauses a few microface to an Apple II+, we have designed and tested a 10-bit seconds for the conversion to he made, and then loads the ADC circuit that makes use of their game port and is very new conversion into memory location 255. The program listcheap. ing in Figure 6 operates the TLC548 and prints the data The heart of our circuit is a Motorola MC14447 (Fie. taken to the monitor screen. . 8). ~.. which carries out voltage-to-pulse-width conversion. The According to its specifications, the TLC548 chip makes annunciator o u t ~ u t (ANO-2) s selects a channel. The ca~acithe A D conversion in about 17 fis. When the data transfer tor C is charged to the input voltage when the ramp 'start time limits and the control time limits are included, the signal (AN3) goes low. After an adequate delay the ramp sample speed is around 40,000 samplesls. The final speed start is brought high, and then the capacitor discharges a t obtained will be greatly reduced by the interface program required for communication between the computer and the A D converter. The simple Applesoft program listed in this article only takes data a t the rate of about 38 samplesls. The GSrn, h., Cm".do. +I" sample rate will vary considerably as one increased the number of operations performed by this program between samples. 88 We tested the TLC548 by using the interface to monitor ma l5 the voltage produced by a pH meter. The pH probe was placed in a buffer of pH 4, then in a pH 7 buffer, and finally in a pH 10 buffer. Figure 7 shows the output obtained. The above example is onlv one of a vast number of possibie uses for an A D Eonverter. Like us, you probably have a need to collect data from other kinds of transducers such as potentiGNLl CUI ometers, strain gauges, phototransistors, photoresistors, REF I thermistors, and IC temperature transducers. Some of these work well when combined in a Wheatstone bridge circuit, OUTPUT CHS others require current-to-voltage conversion. In either case the output is always a voltage, and that is just the ticket for the TLC548. Detailed plans for the construction of the single channel interface are available. Send $2.00 to cover the cost of mailing and printing to the authors a t the John Burroughs Figure 8. Analag/digital converter circuit for voltage measurement with Apple School. 11.

-

-

410

Journal of Chemical Education

~

Table 3. Truth Table lor Address Inputs Select lnput A2

A1

A0

Selected

0 0 0 0

0 0

0 1 0

V, Chi Ch2

1

Ch3

1 1 1

0

0

0 1 1

1 0 1

Ch4 Ch5 Ch6 V,

1

Figure 9. Assembly pmgam for data acquisition.

30 a0 50

".):-

-

INPUT "Channel: IF X I THEN ~ ( 1 ) 1: 6 0 m 200 IF X - - 0 THEN B ( 1 ) 0: 6 0 m 200

~- .,..

-

1 1

Channel 0 (ground) Channel 1 Channel 2 Channel 3 Channel 4 Channel 5 Channel 6 Channel 7 (external reference)

constant current. The input voltage is, therefore, proportional to the discharge time, which is counted by means of software. Promam 1(Fie. . .. 9). handles the A D conversion seauence. The input voltage is sampled 50 timesand theaveragetaken. The loo^ counter. Y-reeister. is set to 60. The .Y-register and the acc~mulator'comGnes to serve as a 10-bit c&ter. At ramD start sienal low ($COSE). the ca~acitoris eiven 2.4 ms tocharge to the input voltage. The interval of 2.4ms, adjustable hv the huilt-in time delav. l o . o in ~ SFCA8, corres~ondsto the time elapsed before the voltage across the capaiitor was previously found in a test t o reach a sufficiently constant value. Note that the timer will overflow its 10 bits if the capacitor requires a discharge time larger than the time loop ($312$31B) to repeat 1024 times. This corresponds to 9970 cycles or 9.7 ms. Under constant current, the discharge time, RC, is thus required to be RC < 9.7 ms

(1)

On the other hand, as specified on the data sheet ( I I ) , the reference current should lie within 10 uA and 50 uA and is given by (Vnn - V,,f)IR, where Vuo is the supply voltage and V,*t.the referencevoltaee (oin8). Inourcircuit. with Vnnat 5

-

320 1 = l 310 X PEEK (813

--

3 4 0 1 - 1 + 1 350 A PEEK (813

+ +

I) 1)

*X +A isoi-i*i 390 I F I < 100 THEN COT0 392 RE" ,.*******-**"***+** 360 N

256

1 7 0 s - S + I

-

From eqs 1and 2, 330

396 RE" Hean of 50 Samples 396 RE" *********"*n**,.** GOO S S I 50 410 PRINT S 620 END

-

Figure 10. Besic pmgam fw system operanon.

In the circuit we constructed, a 0.1-pF capacitor and a 109k0 resistor are used. The data acquired are retrieved, manipulated, and displayed hy Program 2 (Fig. 10). The input channel number in decimal form is converted t o binary (lines 30-110). Each binarv bit determines the state of an annunciator and selects a channel according to Table 3. The data acquisition subroutine is then called. for A D conversion. This subroutine consists of a 45-byte main program located from memory address $300 to $32E. The LOMEM for data memory area is set a t $32D. Each 10-bit datum is stored in the accumulator (low byte) and the X-register (bits 9 and 10). Results obtained show that the averaged counter value is proportional (to +I% + 1bit) t o the input voltage withino2.5 V (Fie. 11).Outside this ranee. the sienal needs to be amplihed-or a k n u a t e d suitably i?thesamLdegreeof linearitv is des~red.A slieht offset is ohserved but can be eliminared simply by subtracting it from every digitized value. The sole drawhack of our AI)C circuit lies in its relatively long conversion time, which approaches 10 m ~ ~ .e v~e r t h ~ -

-

* I / I I I I I I I / I Fbue 11. Conelation between dlgWl output and Input analog voltage.

5T~tal number of execution cycles: 22 $302-$3OF $31E-$327 19 loop $310-$31D 9970 : 10011 cycles (or 9.786 ms) Volume 66 Number 5 May 1989

411

less. whenever soeed matters little. i t is a comoetitive choice that offers advantages in cost," res&ution, andlinearity. The speed may he increased with the use of a faster integrated circuit, which, however, is much more expensive.? Our circuit has found mans such as an autotitrator. Data . a~olications, .. from a pH meter are converted and read into an Apple that also controlls a step motor driving a syringe, the design for which part hears similarity to the system described in an earlier article (12).

Application of Microcomputersin Chemical Education: An Information Base James A. Wood The Polytechnic Queensgate,Huddersfield, HD1 3DH United Kingdom An earlier note (13) referred to a com~ilationof Daoers concerned with theapplication of microc~mputersin chemical education that had aooeared in two of the maior education journals in the unitkd Kingdom. That compiiation has now been extended to cover 29 international iournals and the information abstracted from >I500 papers forms the basis of a microcom~uter-managedinformation hase which can he searched for topic, computer, and type of application. This information hase has heen used to produce a printed version of these details. viz.. Microromouters in Chemical Education, Parts 1and'2. ' Part 1 contains the bibliographic and abstracted details (subject, computer, application, language, availability). Part 2 consists of the results of keyword searches and contains lists of papers referring t o subjects (921, computers (105), and t m e s of a~olication(45). ~ 0 t parts h are spiral hound and consist of 470 pages (size A4) in total. They cover the literature up to 1986, and i t is intended to update this resource a t yearly intervals. Interested parties are invited to contact the author for details of cost of this printed version and of copies on disc (compiled using an IBM-PC compatible microcomputer and Open Access IIsoftware). Acknowledgment This compilation was produced during a project sponsored by CNAA.

PC Abstracts: A Database of IBM PC Articles

simple program that allows for text searching of the database. For each article the datahase contains the reference and a brief abstract. Most of the articles are from the PC Tech Journal as we have found this to be one of the best of the journals. There are also some articles from the special IBM issues of Byte magazine. The oromam named PCahstrx. written hv Tavlor Binklev. perforisihe teat search by usinistrinR maichingon the tent file named ocahstrx.txt, which is the datahase of articles. Pcahstrx mkches strings regardless of case; for example, T H E = the = tHE, etc. No wildcards or Boolean operations (AND, OR) are supported. PCahstrx performs string matching, as opposed to word matching. Thus, a search for "graph" will find "graph", and "photograph", and "graphics". If you only want to find the word "graph", you might search for "graph "or " graph However, this will not find "graph," or "graph.". PCabstrx allows vou the ootion of orintine the search results, saving themeto a t e x t i l e , or just'displa$ng them on the screen. If i t finds a match i t will d i s ~ l a vthe comolete a b t r a c t and then prompt you for a continued search. ' The current version (2-1-88) of ~cahstrx.1~1 and ocabstrx.com requires a t least 320K in system memory, because the entire datahase is loaded into memory (as a linked list) to speed up the searching. Thus, this memory requirement will grow as references are added to the datahase. Pcabstrx.txt is a text file of abstracts from pertinent articles from P C Tech Journal and Byte magazine, compiled by Laurie Hawkins, summer 1987. You can add articles to the datahase as long as you follow these rules: 1. In pcabstrx.txt no words are hyphenated over Line boundaries, unless the word ibelf is hyphenated normally. In "pcabstrx.com" no search extends across line boundaries. 2. Everv abstract is oreceded bv a line startine with two blanks followed by four ashsks:' very abstract isalso followed by such a line. Pcabsrrx.com relies upon these markers ta locate the beginning and end of abstracts.

".

Literature Clted 1. Burkcrt,U.;AUingex, N. L. MokcuhrMmhanics; AmericcChsmicalSodety: Washington. 1982. 2. Allinger, N. L. Adu.Phye. Org. Chem. 197413, 1-82. 3. Boyd, D. B.;LipkoGh, K. B. J. Cham. Edw. 1982,59.26%274. 4. Cm, P. J. J. Chsm. Edue. 198.59.27E-277. 5. Midland. Mark M. J. Am. Cham. Sac. 1986, I@, 3342. 6. Allinger, N.; W8m.D. H. Tefmhedron, 1973.35.3-12.

7. Engler,E.M.;Andae,J.D.:vonRSchleycr.P.J.Am.Chem.Soc.l91&95.8W~25. 8. Clark. J. M., Jr.; Svizer, a. L. Experimer~folBioehemielry; W. H. heeman; San Frandaeo, 1971: p 20. 9. Firher, L. A" INmduelion to Gel Chramfogmphy: Ekevier: New York. 1969. 10. Gregg,D.A.;Msam,D. J. Col6A.PP.L.E 1986.26 11. Digifol/Anolagond AnologIDigital Convenian Handbook, Mdomla, 1980;~122. 12. Vitz,E. W.J. Chem.Edur. 198463,803and804. 13. Wood, J. A. J. Chem.Educ. 1981,64,501.

G. Scott Owen

Department of Mathematics and Computer Science Georgia State University Atlanta, GA 30303 There are many articles of interest to programmers in the general literature. The difficulty is in finding and then rememhering these articles. In this project we have developed a datahase of approximately 300 articles together with a

412

Journal of Chemical Education

According to information supplied by the manufacturer,the unit price of the MC 14447 is USS1.70, if over a thousand are bought. Obtained from a local distributor, the chip will probably cost some 30% more, but still under 52.50. ' A S examples, the 10-bit AD573JN and ZN502E, made by Analog Devices and Ferranti Semiconductors, respectively, both cost about 530 apiece.