Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Designing a Analog to Digital Converter

Status
Not open for further replies.
I tried using the LM311 in one of my circuits and although supposedly a simple device in theory, as a newbie to electronics I had some problems getting it to work properly. Here are some pointers.. .The LM311 will work with a single +5V supply ( Pin 8 ) and 0V ( Pins 1 and 4 ). Pins 5 and 6 should be shorted together. The inputs ( Pins 2 and 3 ) can range from 0v-5V ( i.e. rail-to-rail ) without adversely affecting the 311, BUT you must ensure that at least one of the inputs is at, or below 3.5V or switching won't occur! ( another head scratcher, 'til I found out about common mode voltages! :D ). Adding a bit of hysteresis wouldn't go amiss either and will help eliminate output oscillations around the switching threshold, but again watch that the varying switching threshold due to the added hysteresis doesn't wander above that 3.5V upper limit..!
 
j.p.bill said:
Could you get your instructor to explain how one may do analog to digital conversion without a vlotage comparator?

Ooooh! If I were the student, I might get creative with using 4XXXB series CMOS in linear mode. :D Of course, I'd have to be allowed to use resistors.

Bob
 
Hey Bob, thanks for the suggestion but i am only allowed to use discrete parts such as resistors, diodes, caps and all 74 series family ICs. So i need to eventually make a comparator using those. For now untill i get it working i will use the comparator chip.

Thanks for the suggestions saiello i believe i have the lm311 working, it took a few shots to understand it but its ok now.

Here is an overall update with a few questions. Like i said before i am using the 74c905 12 bit succ approx register. I have it all connected as it suggests in the typical application parts of its spec sheet (i have a cropped link below). There are a few exceptions to the way i have it connected but i think that should not matter much..For one i am using the LM311 instead of the suggested MM54C909 and i am using a R=10k instead of 50k for the DAC ladder.

Using these components the A/D will not work unless i disconnect the OR gate (7432) and just connect the /S to /CC directly. If i do that by inputting a variable analog voltage i get various digital values outputting. Any ideas on why thats happening ? I blieve that OR should be there bc the fact i am using this chip in 8 bit mode not 12b ??

Anyway look at the spec sheet link and let me know guys...thanks again..
PEte

**broken link removed**
 
Last edited:
saiello said:
I tried using the LM311 in one of my circuits and although supposedly a simple device in theory, as a newbie to electronics I had some problems getting it to work properly. Here are some pointers.. .The LM311 will work with a single +5V supply ( Pin 8 ) and 0V ( Pins 1 and 4 ). Pins 5 and 6 should be shorted together. The inputs ( Pins 2 and 3 ) can range from 0v-5V ( i.e. rail-to-rail ) without adversely affecting the 311, BUT you must ensure that at least one of the inputs is at, or below 3.5V or switching won't occur! ( another head scratcher, 'til I found out about common mode voltages! :D ). Adding a bit of hysteresis wouldn't go amiss either and will help eliminate output oscillations around the switching threshold, but again watch that the varying switching threshold due to the added hysteresis doesn't wander above that 3.5V upper limit..!
Why do you think pins 5 and 6 should be shorted together? This lowers the gain of the comparator by a factor of about 5, although it may speed it up a little. Otherwise, you have done a good job of deciphering the datasheet.
I'm assuming you used a pullup resistor from the output (pin 7) to +5V.

Amdkickass, have you used a pullup? It won't work without one.
Also - for dynamic input signals, you are going to need a sample-and-hold.
If you really get stuck on discrete circuit design (e.g., the comparator), I can help. For the comparator, it would be really helpful if you could use transistor arrays (e.g. CA3046). Can you, or would that be considered an IC?
I also think you will need positive and negative power supplies.
 
Well Ron i really appreciate your response. The way i look at it, is i would prefer to get the project working pretty well with the lm311 chip and then eventually replace it with discrete components to satisfy the project design specifications. As far as transistors are concerned i can use all BJTs and MOs transistors. By doing it this way i can kinda get an idea of where i should be with values and what not.

On the output of the comparator , i have resistor connected to +5 ( thats the pull up ?). The main two problems i am having is that connecting the OR gate (as stated in the spec sheet) causes the circuit to not function, like i said before above. I really dont understand why that not working. The other problem i am having is that as i turn the pot to mimic various analog input voltages (10k pot) i get a serial digital stream (serial out of Succ approx Reg) viewable on the scope until i get to 3.3volts input approximately then all of a sudden the digital out goes all High. I am not sure but this may be associated to what you mentioned above dynamic analog input , but i think the output shouldn't go high until i approach 5 volts (the reference voltage).

THanks
pete
 
As Saiello pointed out, the common mode range of the LM311 only goes up to about 3.3V with a 5V supply, and down to about 0.5V above the negative supply (GND in your case). You will probably have to get a CMOS comparator to get rail-to-rail input range, and then I'm not sure if you can get one that's fast enough, although it might be for proof-of-concept. I think I would bite the bullet and go with multiple supplies. Actually, considering that you are having to use discrete-component circuits (comparator, sample-and-hold, etc.), I would probably use around +/-9V to +/-12V for my supplies, with a 5V regulator (do you have to use a zener for this?) running off the positive supply for the logic and the reference.
 
Well currently i am using a +12 power supply and everything in my circuit is running off a 5 volt regulator (i believe its a 7805).
I am sorry i am not sure if i understood you 100%. Are you saying i need to supply the lm311 with a negative voltage or rather replace it with another unit ? Because if supplying it with a negative voltage wouldn't be a problem if that would take care of that issue.

pete
 
amdkicksass said:
Well currently i am using a +12 power supply and everything in my circuit is running off a 5 volt regulator (i believe its a 7805).
I am sorry i am not sure if i understood you 100%. Are you saying i need to supply the lm311 with a negative voltage or rather replace it with another unit ? Because if supplying it with a negative voltage wouldn't be a problem if that would take care of that issue.

pete
On the LM311, connect pin 8 to +12V, pin 4 to a negative voltage (any voltage between -1V and -15V), pin 1 to GND, and your output pullup resistor to +5V (as you already have it connected). Leave pins 5 and 6 floating. Your input will then work over the full range of 0 to 5V.
You should decouple the power supplies on pins 4 and 8 with 100nF caps to GND, as close to the pins as possible, and with leads as short as possible (surface mount caps are best, but not required). In fact, you should decouple the power on each IC this way, and also the discrete circuits, when you get them built.
 
Last edited:
After connecting the LM311 like you said plus messing with the D/A Ladder i got it to work across the full scale.
The next problem is its inaccuracy ? What i mean by inaccuracy is the fact that the guess voltage thats being spit out of the D/A is about.3V off the actual input voltage. I believe this is happening because the the fact we are only using 8 of the 12 bits in the conversion process. I think the spec sheets takes care of that by using the OR gate (see attatched link above), but like i said connecting it causes the circuit to simply not work at all any ideas ?

Thanks
pete
 
amdkicksass said:
After connecting the LM311 like you said plus messing with the D/A Ladder i got it to work across the full scale.
The next problem is its inaccuracy ? What i mean by inaccuracy is the fact that the guess voltage thats being spit out of the D/A is about.3V off the actual input voltage. I believe this is happening because the the fact we are only using 8 of the 12 bits in the conversion process. I think the spec sheets takes care of that by using the OR gate (see attatched link above), but like i said connecting it causes the circuit to simply not work at all any ideas ?

Thanks
pete
What is the part number of your OR gate? Is it a 74C32? What D/A are you using?
 
Well for the D/A i am using a R2R ladder with R=10k . As far as the OR gate i am using a SN7432N, is that ok ?
I think the guess by the d/A is off because its not taking into account the other 4 bits.

pete
 
amdkicksass said:
Well for the D/A i am using a R2R ladder with R=10k . As far as the OR gate i am using a SN7432N, is that ok ?
I think the guess by the d/A is off because its not taking into account the other 4 bits.

pete
The TTL logic high level of the 7432 may be too low for your 74C905. Try adding a 10k pullup from the 7432 output to +5V.
As I mentioned in a previous post, you will need either a commercially available R2R ladder, or 0.25% (or better) resistors if you make it from discrete resistors. Otherwise, it will be nonmonotonic. Also, the ON resistance of the Q outputs is about 200 ohms typical, 350 ohms max. This resistance adds to the value of the 2R resistors in your ladder, which causes additional error.
The unused bits will only cause quantization error, which for 8 bits is 5V/2^8, or about 20mV.
 
amdkicksass said:
So what exactly in the schematic is the function of the OR gate in this application ?

Pete
According to the datasheet,
If the register is truncated and operated in the continuous
conversion mode, a lock-up condition may occur on power-
ON. This situation can be overcome by making the START​
input the “OR” function of CC and the appropriate register

output.
I looked at the truth table to try to understand this, but I still don't. It looks to me like you would need a minus OR (AND) for this function. If no one else here explains why it is an OR on the datasheet, you might want to try a 74HC08 or a CD4081 (quad 2-input AND gates). These have logic levels compatible with your SAR.










 
I will try using the AND gate later on today, thanks for the suggestion...I will let you know of any observations..

The way i have it running now is by connecting the /cc to /s, what negative effects would that have ?

Thanks for all your help by the way Ron.
pete
 
amdkicksass said:
I will try using the AND gate later on today, thanks for the suggestion...I will let you know of any observations..

The way i have it running now is by connecting the /cc to /s, what negative effects would that have ?

Thanks for all your help by the way Ron.
pete
I already answered this question in my previous post (or rather, the datasheet answered it). I like helping people, but carefully reading each post is important.
 
I was just re asking differently because its sometimes hard to decipher spec sheets.

Anyways, first i tried replacing the 7432 IC with another to make sure the same thing would happen and indeed it did. I then proceeded to place a pull up resistor on the output of the OR gate and that really didn't change much. My next change was to replace the OR gate with an AND gate specifically an 7408 IC. Interestingly this actually yielded some decent results, At zero input volts the serial out yielded a straight line at level zero while turning the pot yielded various waves.
To further test things i also replaced the resistors with more accurate metal oxide type ones and the results where pretty decent and improved. One slight issue is the highest analog input voltage its willing to display digitally is 4.35V . Anything more than that and it just goes all HIGH. Not sure whats the deal with that.

THanks
pete
 
Last edited:
Any new ideas on the low voltage thing ?

Also RON if you can possibly help me out with the circuit to replace the LM311, i would highly appreciate it.

Thanks
pete
 
amdkicksass said:
Any new ideas on the low voltage thing ?

Also RON if you can possibly help me out with the circuit to replace the LM311, i would highly appreciate it.

Thanks
pete
4.35/5 ~ 7/8. A 3 bit converter with a 5.000V reference would have 4.375 as the maximum output. If the reference were 4.971V, a 3 bit converter would have 4.35V as the maximum readout. Are you sure you are getting all 8 bits to your display? Or maybe you only have a 3 bit converter. Are you feeding pin 7 back to the AND gate? I noticed that if the opposite pin (18) were fed back by accident, you would have a 3-bit converter.
Sit down before you look at the comparator schematic. This works well in simulation. Offset voltage can be a problem with discrete transistor comparators. You can either live with it, or you can match them in pairs - Q1 and Q2, Q12 and Q13. You should use 1% resistors for R5 and R6.
 

Attachments

  • comparator.PNG
    comparator.PNG
    30.7 KB · Views: 1,565
Last edited:
I have verified the circuit and indeed all 8 bits are connected correctly. Pin 7 (Q3) goes to the and gate and not 18. I have made some voltage measurments, maybe they can aid in some speculation of the problem.

Analog IN ... D/A Out AND Gate ... D/A Out Direct /S to /CC
.20 ...... .61 ..... .46
1.26 ..... 1.26 ..... 1.25
2.0 ..... 2.01 ..... 2.04
2.5 ...... 2.23 ..... 2.3
3.5 ...... 3.69 ..... 3.68
4.25 ...... 4.11 ..... 4.17
5 ..... 4.39 ..... 4.56

+5Volt Regulator OUT : 5.00 volts
-5Volt Out : -4.78 volts
+12volts Supply: 11.93 volts

Anything look odd ? Ideas ...

pete
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top