computer ferie~.102
edited by JAMES P. BlRK Arizona sbte universiv,Tempe, Az s 5 m
Bits and Pieces, 40 Guidelines for Authors of Bits and Pieces appeared in July 1986; the number of Bits and Pieces manuscripts is expected to decrease in future-see the July 1988 and March 1989 issues. Bits and Pieces authors who describe programs will make available listings and/or machine-readable versions. Please read each description carefully to determine compatibility with your own computing environment before requesting materials from any of the authors. Several programs described in this article and marked as such are availablefrom Proiect SERAPHIM.Diskettes are available at $5 per 5%-in.disk, $10 per 3'12-in. disk; program listings and other written materials are availahle for $2 each; $2 domestic or $10 foreign postage and handling is required for each shipment. Make cheeks payable to Project SERAPHIM. To order, or get a Project SERAPHIM Catalogue, write to: John W. Moore, Director, Project SERAPHIM,Department of Chemistry, University of WisconsinMadison, 1101 University Avenue, Madison, WI 53706. (Project SERAPHIM is supported by NSF: Directorate for Science and Engineering Education.)
Molecular Mechanics/Gomputer Graphics Experiment for the Undergraduate Organic Chemistry Laboratory John M. Simpson The Pennsylvania State University Beaver Campus Monaca, PA 15061 The molecular mechanics or force field method is a popular, empirical tool for calculating optimum moleculargeometry. The me tho do lo^ that has heen reviewed here and elsewhere quite extensively ( I 4 treats a molecule as a system of atoms with ideal values for bond length, hond angles, torsional aneles. and nonhonded interactions. T o determine the structu; of a specific molecule, deviations from these "ideal" values are evaluated bv a force field that twicallv .. consists of potential energy rerms for hond stretching (EWJJ, bond aneledeformation (E(h)),torsionalstrain (E= FIXST).TJL-I) 9368 if ijw 0 0 THEN IF HID$(ARICHT.IJM.1) HISSED MISSED * 1 9310 NEXT Ijn 9172 IF FNSCOREIMISSEDI < FRAC THEN RE-N 9174 NEXT IJL 9376 TSTlll = -1 9178 RETURN 9161
9166
-
O
MIDf(MTUD.IJN.11 T m N
Figure 5. Anaiogldigltal interface circun for use with Apple ii game port.
Figure 4. Basic pmgram for comparison of student responses with accepted answers including detection of simple misspellings.
because i t was misspelled, prompting the student that his answer is probably right, but the spelling needs checking, induces no gratitude. They seem to expect that the computer would detect spelling errors and given them the chance to make necessary corrections. A listing of the subroutine is included (Fig. 4). The author expresses appreciation for helpful comments from the reviewers.
Interfacing the TLC548 Analogue-to-Digital Converter Bruce D. Westllng John Burroughs School 755 South Price Road St. Louis, hi0 63124 Allan K. Sefdel Lambelt-St. Louis International Airport Authority
For the past few months we have been using the Texas Instrument TLC548 analogue-to-diaital converter IC t o collect laboratory data. his device is sold a t Radio Shack stores and costa $6.95. The literature provided with the TLC548 describes it as, "a complete data acquisition system on a single chip designed for serial interface with a microprocessor". The chip is built around an %bit switched-capacitor successive-approximationADC and includes its own system clock, which operates a t a 4 MHz. Because of the Apple IIe game port design, which includes a power source, annunciator outputs, push-button inputs, game control inputs, and a strobe, i t is easy to interface the TLC548 with this computer. We combined the TLC548 with a 7404 inverter chip and a small wftware control program to create an %bit voltage data sampler. Figure 5 shows the interface circuit. We uue the wire wrap terhnique for joining circuit components together. This method allows the builder to make auirk connertions. The TLC548 IC and inverter wire wrap sockets are glued to a small perfboard. After wire wrapping, this assembly is housed in a plastic case. Connection with the computer's game port is by way of a ribbon cable and 16-pin socket. Holes for thissocket are drilled in the case's lid; and then the Table 2. Interface Park Llst
Margaret E. Bahe John Burroughs School Those who have been using the Apple I1 game port as an interface with the outside world now have the opportunity to expand the range of physical parameters that may be studied with the computer. Using the TLC548 analogue-to-digital converter (ADC) i t is possible to measure the voltage output of specific ion probes, the differential voltage output, after amplification, of Wheatstone bridge circuits, and the voltage output of current-to-voltage amplifiers. Analogue data collection no longer needs to be restricted to game paddle input, which requires a resistance and associated current change from the transducer circuit.
Radio Shack No. or alhs source
TLC548 analogtodigital converter Hex inverter 7404 Project case 2% X 4%X 1%
Perfboard micrminlahm Wire wraooina .. socket: 8 oin Wire wrapping Eockel: 16 pan
-
W re wrapping sockel: 14 pin 16-Pin d p pmper caoie
Wire-wrapping tool 30Gauge wire for wrapping Phone aids, mduiar jack Volume 66
Number 5
May 1989
Cost
Figure 6. Program for collection of data using be TLC548 chip and Apple I1 game port. socket is glued in place. The holes are positioned accurately by drilling through a template made from perfboard. Transducer input is through a modular phone jack and extension cord. A source of +5 V is also provided a t this location as a power supply for transducer circuits. This voltage is obtained from the game port, which provides up to 100 mA. The parts needed t o build the TLC548 interface are listed in Table 2. The TLC548 chip is controlled by a three-routine, machine-laneuaee This oronram also assembles the - moeram. serial d a t i into a number that & stored in memory. Bask is used to call the routines for each A D conversion. A PEEK of 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 sample information to be available on its Data Out pin. In the arrangement used, the AN0 pin controls the CS pin and the data are picked up with the PB2 pin of the game port. The CS in must he in the hieh state before startine a sarnpling'session. CALL 768 accomplishes this by bring& the AN0 in hieh which in turn brines the CS vin hizh. The ~ & o h eG n is used to clock out the sample daia from the TLC548. Extracting the sample data also starts the process of taking the next sample. CALL 772 arms the TLC548 chip and tosses out any data already present in the chip. CALL 784 causes the conversion to start, zeros the previous stored sample a t memory location 255, pauses a few microseconds for the conversion to he made.-and ~~~~.then loads the new conversion into memory location 255. The program listine in Fieure 6 overates the TLC548 and mints the data taken to the monitor screen. According to its specifications, the TLC548 chip makes the A D conversion in about 17 ps. When the data transfer time limits and the control time limits are included, the sample speed is around 40,000 samplesls. The final speed obtained will he 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 sample rate will vary considerably as one increased the number of operations performed by this program between samples. We tested the TLC548 by using the interface to monitor 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 examole is onlv one of a vast number of possible uses for an A D Eonverter. Like us, you probahly have a need to collect data from other kinds of transducers such as potentiometers, strain gauges, phototransistors, photoresistors, thermistors, and IC temperature transducers. Some of these work well when combined in a Wheatstone bridge circuit, 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 School.
-
~
~
~
~
~~~
~~
-
410
Journal of Chemical Education
~~
~
~
PH
$:01/2Y/SS 09:J0:04 E:01/2Y/W3 07:30:46
X-GR1D:Z.S DUR:41.75 T:.2 4 / 62.7
SEC SET:
SEC
Figure 7. pH test sample
Digltlzing Circuit for Measuring Voltage with the Apple II Game Port Tong B. Tang
Physics Department Albert. W. M. Lee Sebastian H. 1.Chan
Chemistry Department Hong- Kong- Baptist College . . Kowloon, Hong Kong I t is well-known that microcomputer game ports can he used t o measure resistance. However. sienals from scientific instruments as well as household appliances come encoded as voltages. For voltage measurement there exists a wide variety of analog-to-digital conversion (ADC) cards that may be plugged into peripheral 110 slots (10).but their costs are relatively high. In our search for a low-cost analog interface to an Apple II+, we have designed and tested a 10-hit ADC circuit that makes use of their game port and is very cheap. The heart of our circuit is a Motorola MC14447 (Fie. . 8). ~. which carries out voltage-to-pulse-width conversion. The annunciator o u t ~ u t (ANO-2) s selects a channel. The c a ~ a c i tor C is charged to the input voltage when the ramp 'start signal (AN3) goes low. After an adequate delay the ramp start is brought high, and then the capacitor discharges a t
-
e.m. hn
l"".d..
+I"
Figure 8. Analogldigltal converter circuit for voltage measuremew with Apple 11.
.
Table 3. Truth Table Iw Address Inputs Select
Figure 9. Assembly pmgam for data acquisition.
#,,,RE"
Input Selected
A2
A1
A0
0 0 0
0 0 1
0 1 0 1
V, Chl Ch2
0 1
Ch4 Ch5 Ch6 V,
0
1
i
0
1
0
1 1
1
0 1
1
Ch3
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 AID conversion seouence. The input voltage is sampled 50 timesand the average taken. The loov counter. Y-reeister. is set to 50. The X-reeister and the accknulator combines to serve as a 10-bit counter. At ramD start sienal low ($COSE). the ca~acitoris eiven 2.4 ms tocharge to ihe input voltage. The interval of 2.4ms, adjustable hv the built-in timedelav. loov . inSFCA8,corresvonds to 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 t o be
RC < 9.7 ms 1
(1)
On the other hand, as specified on the data sheet ( l l ) ,the reference current should lie within 10 PA and 50 FA and is given by (VDD- V d R , where VDDis the supply voltage and Vrefthereference voltage (pin 8).In our circuit, with VDDa t 5 V and V d a t 2.5 V, therefore
********-*in****t*****(i*****w*~~~w~~****~~~~~*~*~~*~
20 pA < 2.5lR < 30 pA 320 1 310 X
---
1
PEEK (813
+ I)
3 1 0 I - 1 + 1 310 A 360 N
PEEK ( 8 1 3 + 1) 256 X + A
* ,7"s-s+I isoi-i+~
-
390 1F I < 100 THEN COT0 330 392 RE" w**'****X**'****""n 394 RE" Hean of 50 Samples 396 RE" *****-'*w"'**+*""m 600 5 S / 50 b10 P R I N T S 620 END
-
Figure 10. Besic progam fw system operation.
From eqs 1and 2,
In the circuit we constructed, a 0.1-pF capacitor and a 109kQ resistor are used. The data acquired are retrieved, manipulated, and displayed by Program 2 (Fig. 10). The input channelnumber 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 AID 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 (hits 9 and 10). Results obtained show that the averaged counter value is proportional (to +I% + 1bit) t o the input voltage within O2.5 V (Fie. 11).Outside this ranee. the simal needs to be amplified-or akenuated suitably ifthesamldegreeof linearity is desired. A slight offset is observed but can be eliminated simply by subtracting it from every digitized value. The sole drawback of our AI)C circuit lies in its relatively long conversion time, which approaches 10 m ~ ~ .e v~e r t h ~ -
*u Flgwe 11. Conelation between dlgltal output and Input analog voltage.
$Total number of execution cycles: 22 $302-$30F $31E-$327 19 loop $310-$31D 9970 : I001 1 cycles (or 9.786 ms) Volume 66 Number 5 May 1989
411
less, whenever s ~ e e matters d little. i t is a comoetitive choice that offers advantages in cost," res&tion, a n d ~ i n e a r i tThe ~. speed may be 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 . av~lications, .. 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 a o ~ e a r e din 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 papeis forms the basis of a microcomputer-managed information hase which can be searched for &pic, compuier, and type of application. This information hase has heen used to produce a printed version of these details, viz., Microcomputers in Chemical Education, Parts 1 and 2. Part 1 contains the hihlioeravhic - . and abstracted details (subject, computer, application, language, availability). Part 2 consists of the results of kevword searches and contains lists of papers referring t o subjects (92). computers (105), and types of application (45). Both parts are spiral hound and consist of 470 pages (size A4) in total. Thev cover the literature UD to 1986, and i t is intended to update this resource a t yea& 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 I1 software). Acknowledgment This compilation was produced during a project sponsored by CNAA.
PC Abstracts: A Database of IBM PC Articles G. Scotl 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
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 P C Tech Jourrual as we have found this to be one of the best of the iournals. There are also some articles from the s ~ e c i a l IBM issues of Byte magazine. The Dromam named PCahstrx. written bvTavlor Binklev. perf&^ ihe text search by usingatring rnaiching on the teit file named ~cahstrx.txt,which is the database of articles. Pcabstrx 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.". PCahstrx allows vou the ootion of ~ r i n t i n ethe search results, saving themeto a text i l e , or jusidispla$ng them on the screen. If i t finds a match i t will d i s ~ l a vthe c o m ~ l e t e abstract and then prompt you for a continued search. ' Thecurrent version (2-1-88)of Dcahstrx.txt 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. Pcahstrx.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 database as long as you follow these rules: 1. In pcabstmtxt no words are hyphenated over line boundaries, unless the word itself is hyphenated normally. In "pcabstrx.com" no search extends across line boundaries. 2. Everv abstract is nreceded bv a line startine with two blanks followed by four a s h k s : ' "*". ~ v e r y a b s t r kisalso followed by such a line. Pcabsrrx.com relies upon these markers to locate the beginning and end of abstracts.
".
Literature Clted 1. Burkart.U.; AUioger,N.L. MokrukrMochonics;Ameti~aoChemicalSodety: Washington. 1982. 2. Allinger, N. L. Adu.Phya. Org. Chem. 1976, 13,1-82. 3. Boyd, D. B.;Lipkoaitz. K. B. J. Chom. Edw. l982.59,26%274. 4. Cm, P. J. J. Charn.Edue. 1982,59.27%277. 5. Midland. Mark M.J. Am. Chem. Sac. 1986,108,5012. 6. Allingsr, N.; Wertz.0. H. Tefrohedron. 1979.35.3-12. 7. Engler.E.M.;Ando~e, J. D.:vonR Seh1eycr.P.J.Am.Chom.Soc.1973.95.8WLSO25. 8. Clark, J. M., Jr.; Sdtzer, a. L. E~psrimonfolBixhembtry; W . H. heernan; San Fmndseo, 1977:p 20. 9. Fiseher, L. An Infmductiii f f Gel Chrhrmffgmphy;Ehvivivi:New Ymk, 1969. 10. Gregg.D.A.:Maaro,O.J.Col6A.PP.C.E.1986.16 11. DigitollAnolag and Amlog/Digitol Comemian Hondbaok, Motomla, 1980; p 122. 12. Vitz.E. W. J.Chem.Educ.198463.803and804. 13. Wood, J. A.J. Chem. Educ. l987,64,501.
Accadlng to informationsupplied by the manufacturer, the unit price of the MC 14447 is US01.70, if over a thousand are bought. Obtained from a local distributor, the chip will probably cost some 30% more, but stlll under $2.50. 'As examples, the 10-bit AD573JN and ZN502E, made by Analog Davices and Ferranti Semiconductors, respectively, both cost about $30 apiece.