Analog Interface Board
We designed our laboratory analog/digital interface board based on the PIC 16C774 microcomputer made by MicroChip. This PIC is relatively inexpensive, easy to program and it contains the features we require. MicroChip provides a good selection of technical notes and sample programs/routines that simplified our task. An outline of the features we use follows:
- We use Timer1, a 16 bit timer, to control when measurements are made.
- We use the PIC's 12 bit Analog to Digital Converter to measure signals
- We use the internal 4.096 V voltage reference, so the circuit handles signals from 0-4095 millivolts with 1 mV resolution.
- We implement six of the ten available Analog Input Lines (AN0-2 and AN4-6.)
- Note that Analog Input 3 is not available when the internal reference is used since the reference voltage appears on the same pin.
- PortC is configured to serve as a fully functional RS232 serial port operating at 9600 baud.
- Commands are received from the host computer and the PIC responds accordingly
- Data, once measured, is converted to Binary Coded Decimal and transmitted to the host computer as a character string
- Port B is configured to provide four Binary Input lines and four Binary Output lines.
- One Analog Output Signal is available (this is a 10 bit Pulse Width Modulation PWM signal)
Other features are shown on the schematic at the end of this document.
Full version of the schematic
- Power is derived from the computer's power line transformer. A 5V regulator provides a +5V line. A MAX7660 voltage inverter provides the -5V needed for two amplifier chips.
- Since our laptops operate from a 3Amp 18V power pack, we have enough power for this board and this board can supply 250 mA to other devices such as out titration stands.
- The Analog input signals are buffered.
- AN0 passes through a LT1167 Instrumentation Amplifier with a gain of 4 and an offset of about 1.5 volts. This is connected to a BNC terminal and is designed to accept pH electrodes.
- In retrospect, this was not the best design since the output of this amplifier is limited to about 3.6 volts when used on a 5V supply. This means that the full 4.095 volt range of the ADC is not used.
- AN1-2 and AN4-5 are buffered by a rail to rail quad Op Amp used in a voltage follower configuration, allowing the use of signals covering the full 0-4.095 V range. AN6 is available at an unbuffered pin.
- AN1-2 and AN4-5 are connected to two BT (British Telecon) connectors. This matches the connectors used by Texas instruments, Vernier Software, Pasco Scientific. This allows us to use sensors and probes from those sources. Each connector has two input lines, ground and a +5V power connection.
- The BT jacks and plugs are elusive and very difficult to obtain in the US. As far as we can tell, this style is used only in the U.K., Hong Kong and New Zealand. We found plugs, jacks, cable and a wiring tool on a Web site for R.S. Electronics, a U.K. firm that does not handle orders outside the U.K. Fortunately, Allied Electronics (U.S.) is part of the same system and for a modest additional fee they were able to place our order.
- The PIC has a built in USART that was configured for asynchronous port. The voltage level conversion was produced by a MAX232 chip.
The PIC is nominally an 8-bit computer, but it uses single word 14 bit instructions that are written to a 4K Read Only Memory. The PIC has 192 memory locations (general purpose registers) available and some are used for data storage. This memory would be considered an extremely limited resource for a general puprose computer, but it is more than adequate when the microcomputer functions mainly as a controller.
The program is prepared using the PIC START PLUS system (from MicroChip, $199.) This includes an assembler, a simulation program useful in testing programs, and a chip programmer connected to the serial or USB port of a standard PC.
Our program operates with interrupts on the RS232 input line (PIC's RC line.) All characters received are built into a string until a CR is received. At that point the string is treated as a command and processed. The first character determines the type of command. Characters 2-3, if present, become constants; additional constants are ignored.
- R (no constants) causes the PIC to do a full reset
- T (two constants) resets the timing interval for data collection
- to get a time T (microsec) requires a contsant of about (650,000 -T)/4 -50 set as two 8 bit binary words
- C (one constant) determines which of the input channels is used
- b (no constant) reads the four input binary lines and their value is sent to the host computer as b followed by a Character (CHR(30+n) =0,1,2, ...9, <special characters> .
- B (one constant) changes the four binary output lines
- A (one constant) starts signal averaging with up to 16 measurements per channel
- If multiple channels are used the first active chanel in measured n-times before the second channel is read.
- The RS232 RTS line is used to toggle data collection and transmission.
- The timer routine runs continuously without interrupts.
We chose the PIC 16C774 since it is the only member of the PIC family that offered both 12 bit ADC and a full serial port. (The 16C773 is similar but fewer Ports; it would have worked equally well.) Newer Flash models (electrically programmable and erasable chips) would be preferable, but they currently do not come beyond 10 bit capability.
- This comes as EPROM UV Erasable chips ($14.85 each in single or multiple quantities.) It also comes as a OTP device (One time programmable, without the UV erase window.) The OTP chips sell for $5.97 in single quantities. (Prices are Digikey Web Site, July 2004.)
- We assembled our circuit on a 1.75" x 6 " PC Board we had made by PCBExpress. This size was chosen to match the dimensions of the external port adapter device of our laptops. The DB9 connector was on one side of the board and all other connectors were on the other side. This is an odd dimension and we were unable to find standard electronics cases to fit; we assembled the cases from 1x3" Aluminum channel.
return to the index page