Design of a ADC Interface for Microcontroller.

Design of a ADC Interface for Microcontroller.

This is in continuation of the thread called "Design of a Thermocouple Amplifier" doc00023.html which is in the same section .

This is just a formatted-edited email thread exported from Eudora from my mailbox using the content concentrator. The circuits below were made by TF a student, This thread has been put online to share information.

The part under "From: delabs" are my writing. there may be some mistakes and broken links.

Tutorials on Basics and Instrumentation Electronics  

Circuits Drawn by the Student.

1. ADC Circuit.



2. Power Supply Circuit.

 Power Supply Circuit.
From: TF

Now I will start working on the CTC and the ADC part.

From: delabs

Now it looks ok, use bases for all ICs, which ADC you are using ? Try to look at LTC1298 a 12 bit 2 channel, look at link below....

8051SBC V1.0 - Microprocessor learning board demonstrates exemplary design of 8-bit singleboard computer. More peripheral and easy to adapt to be a dedicated controller.

I hope you study this site and other related.

From: TF

Thank you for the link. I am planning to use the following ADC ( MCP 3002,10 bit resolution ). Features 2 channels one for T/C input and the other for CTC compensation. Avlbl in mumbai for Rs. 70 /-.
I have attached the link to the .pdf in case you have time to glance through it. Your inputs would be very much appreciated and helpful. I have coded for devices in SPI hence I have planned to use this chip.
PDF

I am also planning to use TL431 along with a LM317 to make a 5V reference for the ADC which will also be used to power the rest of the circuits.I think this should be ok. The datasheet asks to use 0.1% resistors , is this avlbl in the market ?


From: delabs

The LTC1298 is also a serial device. But what you have chosen is good. TL431 is a good as a reference and that is sufficient for the circuit. What is the purpose of LM317, how do you plan to use it ?

The 0.1% resistors were available but were costly, i have no idea of the market now. What you need is a low ppm around 10-20 ppm for the resistors. The bourns 10 turn trimpots (Rs 10) can be used in place of 0.1% and trimmed.

what is important is temperature coefficient of components indicated in ppm. other measurements are relative and should be calibrated in reference to an absolute instrument. calibration is done by hardware with trimpots or software with the offset in eeprom.


From: TF

I am planning to use the LM317 to make a precision power supply in conjunction with TL431. This can deliver 1.5 A.

I will use this to power the digital circuitry and the reference voltage for the ADC. I will use 78L09 / 79L09 for power to the Opamps or is 78L05 sufficient ?The reason why I ask this is , because op07 does not have a rail to rail swing and the datasheet does not say how much drop will be there for 5V.It only specifies for 15 V, Should we reduce the same proportionately ?


From: delabs

78L09 / 79L09 for power to the Opamps is sufficient, you cannot drive LEDs or Relays with 78Lxx as it will heat up and blow. a max of 100mA that is all you should load. if the unregulated is 9V then drop across regulator is 9 - 5 = 4V .

4V * 100mA = 400mW = Pd that is what you look at and design.

for 5V OP07 will swing to +/- 3.5V only. it is 1.5 V less than rail. Use and ADC at 1/2 its supply voltage.
If supply is 5V use ADC from 00mV to 2000mV do not use till 5V or you can adjust ADC for a Full scale of 2V if possible.

From: TF

I am attaching two files for your kind perusal. One is the opamp circuitry and the other is the power supply.
I am using the OpAmp with a 9V rail supply so that I can tune it to give a FS output of 5V. I need to use the serial ADC at 5V , as the reference and the supply are the same for this ADC.So , since I will be interfacing with a 5V micro I can interface the SPI protocol witout buffers etc etc.

Also having a 5V gives a better noise margin for the ADC as compared to 2.5V is it not ? Or am I wrong ? Do you see any fatal flaws in my design so far ?


From: delabs

yes use a 7809 and 7909 or the L version. MCP3002 may need low value pull-ups like 4.7K, for interface to uC.

These pull ups or a RC network prevent noise, and may be required. the CS pin is open, probably you still are working at it. practically try it out and see if you get any problems.

Power supply is ok, it seems incomplete, so i cant say much. LM317 output is 1.25V above the voltage at ADJ, do you know that. that means the adj must be at 3.75V, check the datasheet.

if the opamp swings to 9 - 1.5V the ADC will blow is it not. you have to use a clamping back to back zener 5.1V .


From: TF

Thank you for your reply. I have attached the circuits for your reference. " MCP3002 may need low value pull-ups like 4.7K, for interface to uC. These pull ups or a RC network prevent noise, and may be required. the CS pin is open, probably you still are working at it. practically try it out and see if you get any problems. "

These will get directly connected to the SPI pins on the uC ( 89V51RD2 ). I saw a couple of reference designs , they have not used any pull ups. This is unlike the Philips I2C bus which needs the pull ups for proper operation.

Power supply is ok, it seems incomplete, so i cant say much. LM317 output is 1.25V above the voltage at ADJ, do you know that. that means the adj must be at 3.75V, check the datasheet.

I got the circuit for the same from the datasheet of TL431, where they have used the same in this configuration.I have used a 4uF ceramic for de-coupling.Other designs I saw had 4 * 0.1uF ceramic , 10uF electro in parallel,so I am replacing all with the 4uF ceramic. I am also adding a ceramic disc cap for the OpAmp power supply.

Why do you feel it is incomplete ?Please tell me if I am making any mistake.

if the opamp swings to 9 - 1.5V the ADC will blow is it not. you have to use a clamping back to back zener 5.1V . I have put the protection for the same now. I hope this is okay. Thank you very much for your wonderful help


From: delabs

The protection zener diodes are to be put after the resistor R12, Then R12 will limit the current load on opamps. and the ADC also is protected by clamping.

The way it has been put will now heat the opamp, this may not be that good. The opamp is say at 7.5 and zener conducts loading opamp.

The circuits are incomplete because parts details absent. IC1, IC2, Diodes and transformer, all have to be specified.

show all input ports and output ports not junctions. like the transformer goes to a connector or port saying 230V AC.

See if you can run an ERC and a get a Netlist from eagle.

Transformer like 3-0-3 50Hz 100mA Capacitor Like 10uF 63V


From: TF

Thank you for the design tip of putting the zener after the resistor. I have incorporated the same.Please give your view on whether the circuit is now suitable for assembly .I have also put all the parts list for the power circuitry.

I hope it is satisfactory.

Why should I do the netlist ? I am planning to assemble the circuit using a general purpose PCB manually. So the circuit drawing is only for this.If there is any use of doing the ERC , then I will do the same.
Kindly suggest.


From: delabs

Netlist and ERC are for learning to use the tools better. ERC and netlist can point out some schematic capture mistakes.

Later you can make PCBs in a automated way. The PCB need not be made, but this can be used to check your work.

The AD590 circuit you made gives 1mV per deg kelvin. which comes to around 300mV for room temp 26 deg C

The ADC MCP3002 is 10 bits that means 1024 counts right ? Then 5000mV / 1024 = 4.8mV that is the LSB resolution. then 300mV / 4.8mV = 62 counts digital data. 26 deg is around 62 data 0 deg is around 56 data

62 - 56 = 6 steps and that is very bad resolution. you cannot resolve 1 deg C. This you should know.

Solution :

Substract 273mV from the AD590 output and amplify difference using opamps. see the theory circuits here

Basic Opamp Circuits and design, hint : sum +300mV to -273mV then it is a subtract.


From: TF

I understood your previous mail. The problem is that the voltage difference in the compensating circuit is not sufficient to provide adequate resolution when I feed it to the ADC, right ? So like you said we will have to amplify this further.

So I have to revert back to the hardware compensation by feeding the voltage to the OpAmp circuitry as shown in the drawing. The advantage also is that I can go for a single channel serial ADC which will reduce the cost still further.

I have drawn the schematic for your kind perusal. The problem I can foresee is how to do calibration using ice reference point. This is because the o/p from LM324B will now be negative which cannot be read by the ADC.

Am I completely on the wrong path ?? Total gain of the OpAmps: 23(adjustable) * 8 = 184. Room temp = 1.58 mV

Output = 290 mV which can be equated to the reference from the AD590 Also I am using only 7805 and not 7809 and use these supplies for the micro and the reference voltage circuits also.This will keep the size of the board down and the costs down too.

Considering a maximum rail swing of 3.5 V.This means that the circuit can measure upto 650degC which is more than adequate. Also the negative of the T/C is getting grounded , will this lead to stray noise pickups? I am so sorry to trouble you like this but I do hope you will guide me to get the analog part right. I am more good at programming , but I want to get my concepts in analog also.


From: delabs

This circuit may help it was in the datasheet...

AD590 Cold Junction Compensation


The circuit you have drawn is wrong. you have to convert Kelvin to Centigrade. As the instrument you are making is in centigrade. that circuit is also present.

Ad707A and AD590 Two Temperature Trim

change the 97.6K to 10K to get 10mV per deg C, feed this to channel two.

From: TF

I have remodified the circuit by using one more OP07. This I am not very happy as it does not seem to be the right way to do it.Kindly have a look at the circuit. I have made an amplification of 10 so that Deg. Amplified o/p ADC bits

0deg 2.73 V 569 bits 26 deg 2.99 V 625 bits ( 56 bits ) This is giving a precision of 0.5 degrees. Assuming a maximum ambient temperature of 40deg the op will swing to 3.13 V which will be within the OP07 for an rail input of 5V.

I will calibrate with a ice bath for 0deg or use a mV generator to calibrate this.Then the software can be made to offset the value which is read to set the zero point.

Is there any commercial precision quad opamp which can be used to replace the two OP07 and the one LM324 with one chip, which comes to your mind. Thank you for your patience.


From: delabs

Please use this circuit for your second channel of ADC. Nothing else will do........try to study this circuit. you have not understood the point. So i have made the circuit use it for second channel.

Tl431 and AD590 and OP07


From: TF

Thank you for you circuit. I have studied it and my understanding is as follows :
The voltage at the point 1 of R4 will be : Vo=( 1+ ( 1/2.2)) * Vref = 3.5V. This is from datasheet of TL431.
So total voltage across AD590 is 3.5-(-5) = 8.5V Going by figure 5 of the AD590 the Iout of the device is independant of the voltage across the device. So why have we done this configuration ??

Also there seems to be an error as the voltage at anode of the AD590 is fed directly to the non inverting pin of the OP07 which means the gain is infinity as per the formula given in the non-inverting amplifier : Vout=Vin*(-1)*(rf/ri) where ri=0. So if we remove the short then Zero Adj poti R5 become Ri but in this case the gain will get adjusted by both R2 and R5 whenever any changes are made.
Also since this is a non inverting input the output from the OpAmp is negative which will be a problem for the ADC.

Sir I cannot use your circuit unless I understand the operation. Can you please mail me a small explanantion? Can I give you a call on any number so that I may get my doubts clarified by calling you up at your convenience ? I know this has been a long drain on your time. Request you kind patience.


From: delabs

yes you are right The voltage at the point 1 of R4 will be : Vo=( 1+ ( 1/2.2)) * Vref = 3.5V it is 3.63 ....as nominal ref is 2.5V

But i have made a mistake here ! R6 is not 1K but 10K and R8 is not 2.2K but 22K. Because if it is 1K + 2.2K it will need a smaller R3, so this change has to be made.

now for the rest of the circuit which is based on the AD590 datasheet application note.

AD590 is a current source which gives 1 uA / kelvin It is independent of the voltage across the device. you can treat it like a current source or sink or impedance.

Anyway total voltage across AD590 is 5V. as opamp pin 2 is at virtual ground. You did not study the opamp fundamentals link i sent you. anyway i will explain it again for you.

This is the way you try to understand the design. The AD590 here is a constant current sink as cathode goes to -5.
The current it sucks away or drains from node pin 2 of OP07 is 1uA/ kelvin. at 0 deg C the current drained is 273 uA at 26 deg C it is 300uA.

In your earlier circuit the AD590 was a current source. The uA was fed into a 1K resistor so output was 273mV and 300mV. as V = I * R. for 0 Deg C and 26 deg C respectively. you know according to theory that the amount of current entering the node, is equal to the amount of current leaving the node. do not look at voltages now, look at the currents.

Now as i was saying earlier the AD590 drinks 273uA from Node pin 2 of OP07 at 0 deg C. Now no current can come from opamp OP07 pin 2 as resistance is in giga ohms and leakage in pico amps. now the pot R5 and resistor R4 are just in series and connected to 3.63 V as established earlier. The TL431 is a shunt regulator with reference and has a low impedence. Now the R5 + R4 combination should not load the TL431, that is not the case as 3.6 / 10K = 360uA .

now by varying R5 pot you can pump 3.6 / 10K = 360uA down to 130uA when R5 is max into node pin 2 of OP07.

This pot will be calibrated with AD590 in ICE to give a 0 mV output of the Op07. When calibrated R5+R4 pump 273 uA into node pin 2 of op07. this is sucked away by the AD590 which is draining 273uA at 0 deg C. This leaves the pin 2 at zero potential as currents leaving = currents entering.

Now to understand the opamp functioning.. The pin 2 of opamp is a 0 potential as calculated above and pin 3 also is at zero pulled down by R7. Now as both inputs are at same potential the output of opamp also is zero. The feedback resistors R1 and R2 will carry no current as both their ends are at 0. the Vout is now 0 mV and AD590 is on a block of ICE and opamp is stable.

If pin 2 (-) becomes more dominant or positive than pin 3 (+) the output swings negative. If pin 3 (+) becomes more dominant or positive than pin 2 (-) the output swings positive. The opamp on feedback tries to maintain both the inputs at the same potential. This thumb rule can be used to make opamp oscillate, amplify or compute.

Now what happens when the AD590 is removed from the block of ICE. It comes to room temperature say 26 deg C which means 300uA.

Now the AD590 demands to draw 300uA from node pin 2 of OP07. The R4 + R5 from 3.6 V can give 273uA as it is fixed, not a uA more. The rest which is 300 - 273 = 27uA leads to a drop in potential at pin 2 and it turns negative.

as demand is greater than supply. which makes pin 3 which is at zero more positive than pin 2. ( theory : 0 is positive compared to -1) as pin 3 is more dominant opamp swings positive as per thumb rule. and a current starts flowing thru R1 + R2 till the current reaches 27uA. at this point the extra current 27uA drawn by AD590 is supplied by opamp thru R1+R2. The Pin 2 now comes to 0 as currents leaving = currents entering.

At this point the voltage at opamp output is given by ( R1 + R2 ) * 27uA = 270mV (assume R1+R2 is 10K after calibration) now opamp gives 10mV per deg C. as opamp now is a closed loop control the rise and fall in temperature,
results in AD590 current variation which produces a proportional OP07 output.

Now the explanation above is in steps but all that happens in real time in an instant. tell me now what ever doubts you have after studying this and analyzing circuit many times. I may be unable to help you much unless you put in the required study effort.


From: TF

I have been studying your circuit. I have understood thoroughly the part about the op-amp. This is an eye opening configuration.

1) Have you increased R6 and R8 to ensure the minimum current of 1mA through TL431 ? If so what is the calculation ? Or is it just empricial ?

2) The AD590 K is connected to -5V to ensure the potential drop of 5V across the AD590. This you have mentioned is because the non inverting of OpAmp is a virtual ground.I did not understand this point only. Since the I/P impedence of an OpAmp is very high , I assumed that it is floating and not at any potential ? If this point is cleared out then circuit is crystal clear thanks to your fabulous explanation.

3) One more thing remains of generating a 5V ref voltage for the ADC. I cannot use the 7805 output because the absolute value and the drift will make the ADC conversion unreliable. My idea is to use another TL431 and calibrate it for 4V and use it for Vref.Then the firmware can be written to give the output pro rata. This is because the OpAmps will anyway swing to a MAx of 3.5V only.Am i ok on this ?

4)The circuit I had drawn with the AD590 as the source , what is the error in that design ?Because the current from the source is dropped across the burden resistors to get a proportional voltage.

Can you reccomend any good text books / design papers to help us to thorughly understand op-amp circuits ?
Thank you sir for your fabulous mentoring. We appreciate it a lot.

From: delabs

I have been studying your circuit. I have understood thoroughly the part about the op-amp. This is an eye opening configuration.

1) Have you increased R6 and R8 to ensure the minimum current of 1mA through TL431 ? If so what is the calculation ? Or is it just empricial ?

yes you are right, it is empirical, only the 1mA is important and the ratio of R6-R8 so as to get around 3.5V
2) The AD590 K is connected to -5V to ensure the potential drop of 5V across the AD590. This you have mentioned is because the non inverting of OpAmp is a virtual ground.I did not understand this point only. Since the I/P impedence of an OpAmp is very high , I assumed that it is floating and not at any potential ? If this point is cleared out then circuit is crystal clear thanks to your fabulous explanation.

AD590 is a current source a bias of 4V to 30V required so that it sinks or sources current depending on polarity.

The AD590 acts like a water tap and a trickle of current is at pin 2 which is at virtual ground due to feedback from opamp output. Virtual ground means if you measure the voltage at that point with DMM it will be zero yet it is not the real low impedance ground of your power supply. But pin 3 of opamp can be connected to real ground or thru a resistor.

3) One more thing remains of generating a 5V ref voltage for the ADC. I cannot use the 7805 output because the absolute value and the drift will make the ADC conversion unreliable. My idea is to use another TL431 and calibrate it for 4V and use it for Vref.Then the firmware can be written to give the output pro rata. This is because the OpAmps will anyway swing to a MAx of 3.5V only.Am i ok on this ?

You need 5V supply as the uC 8951 also works on 5V and the two have to work together, voltage levels must be same. The rest is ok.

4)The circuit I had drawn with the AD590 as the source , what is the error in that design ?Because the current from the source is dropped across the burden resistors to get a proportional voltage. there is no error only the output of that circuit is in Kelvin you need Celsius to get good resolution as explained earlier.
Can you reccomend any good text books / design papers to help us to thorughly understand op-amp circuits ?

Thank you sir for your fabulous mentoring. We appreciate it a lot.

you have to go to a bookstore and have a look, see at amazon.com or you need to search with multiple keywords in google. google is also adding a new service in which you can search thru a collection of books and buy what you want. Also look at national semiconductor and analog devices application notes before you start a design.

Contents

Basic Electronics
Basics of Electronics
Product Production
Work Discipline
Testing Points
Learning Electronics
Electronics Theory

Production Notes
Prototype Fabrication
Electrical Circuits
Electromechanical


Library
Scots Guide Electronics
Engineering - Wikibooks
Design Lab - Jim Svoboda
DC Circuits UOG
Socratic Electronics
Blobz Guide Electric Circuits


Product Design
Product Development
Constant Current Source
Good Voltage Regulators
Insulation Resistance
Digital Insulation Tester
DN Schematic PCB 04
DN Product Design 07


Hobby Circuits
VU Meter Circuits
LED brightness control
555 Incredible Chip
Process Control
liquid level measurement
Thermocouples and RTD
Design ADC Interface uC
Thermocouple Amplifier
IA Instrumentation 02
Temperature on DMM
Optical Proximity Switch
Analog Mux - Data Acquisition


Test Measurement
Instrumentation Automation
NI Test and Measurement
DMM Digital Multi Meter
Oscilloscope in T&M
IA Automation 01
Build Instruments
Tektronix T&M Equipment
Educators Corner – Agilent


Power Electronics
UPS Background
Transformer Connections
DN Power Electronics 03
DN Power Electronics 02
Half Bridge Convertor SG3525


Embedded
Interfacing Microcontrollers
Embedded Process Control
80C31 8052 Microcontroller
Microprocessors and uC
Embedded Systems Design

Components
Good Voltage Regulators
Relays and Contactors
Potentiometers Trimpots
Prototype Boards Types
Types of Capacitors
Types of Switches
Resistors How they Work
Coils Transformers SMPS
Mains Transformers Types
DN Components Selection 05

Tutor Gadgets
Count-Up Timer
Digital Logic Gates
Electronics Tutors

History
Teaching Instruments
Charles Proteus Steinmetz
Muntzing a Circuit Design
Teralab Electronics projects
Historical Instruments


Tables, Charts, Videos
Binary and Hex
Resistor Color Code
Ohms Law
Giga, Tera, Pico, Nano
High Resistance Materials

Analog
School - Analog Design
DN Analog Basics 06
DN Op-Amps 01
TI Semiconductors