Discussion in 'The Projects Forum' started by yougarage, Jul 13, 2011.

1. ### yougarage Thread Starter New Member

Nov 29, 2010
16
0
hello I'm going to make an analog input buffer for a microcontroller.
I came out with this solution but I don't know if it's right.
the op amp (rail to rail)is powered from a 5v source

JP1 and JP2 are two jumpers.
JP1 allows me to choose the input range: JP1 installed, 0-12v, JP1 removed, 0-5v
JP2 allows me to change the op amp gain: JP2 installed, gain = 10, JP2 removed, gain = 1
do you think this design could lead me to problems because the resistors R1 and R3 are unuseful with the jumpers removed?
I thought the tlv2371 rail to rail is a good choice for this purpose, what do you think about it?

File size:
25.4 KB
Views:
75
2. ### R!f@@ AAC Fanatic!

Apr 2, 2009
8,791
771
Buffers are considered as current amplifiers.
An opamp buffer will have unity gain, meaning no voltage amplification.

A buffer in short allows to match low impedance input to a high Z output

3. ### SgtWookie Expert

Jul 17, 2007
22,183
1,728
You're calculating the gain for the opamp improperly.
Your gain will be (R3/R4)+1, or (10k/1k)+1 = 11. If you want to use 1k for R4, you'll need 9k for R3, but 9k is not a standard value of resistance.
Here are some series (+) and parallel (||) configurations of standard resistance values that will work for you:

7500 + 1500 = 9000 (0 %)
6800 + 2200 = 9000 (0 %)
5100 + 3900 = 9000 (0 %)
4700 + 4300 = 9000 (0 %)
12000 || 36000 = 9000 (0 %)
18000 || 18000 = 9000 (0 %)
9100 || 820000 = 9000.121 (0.001 %)
Calculated using:
http://www.qsl.net/in3otd/parallr.html

4. ### yougarage Thread Starter New Member

Nov 29, 2010
16
0
Perfect you are right!
I'm just trying to make a universal input stage for various sensors.
this should be my final layout, I added a capacitor to the input to have a lowpass filter
and a zener to clamp the voltage, preventing op amp damage.
I was wondering if the zener could act as a resistor in the normal voltage range(below the zener thresold).
I'm afraid it can form a voltage divider with R1
is there a value in the datasheet I can consider for this?

I attached a table referring to the zener, the underlined one is the one I need.

File size:
106 KB
Views:
26
File size:
19.5 KB
Views:
35
5. ### SgtWookie Expert

Jul 17, 2007
22,183
1,728
You will have some leakage through the Zener, which will affect your readings.
Rather than using a Zener, you might consider using a pair of 1N914/1N4148 diodes or Schottky diodes to clamp the input to ground and Vcc.

C1 will help to remove resistor noise, but will skew the phase from the input; and you'll filter out higher frequency artifacts. If you're going to use a cap there, make it a very small value.

You should also have a 10nF capacitor to ground at the ADC input. The ADC requires a very low impedance input for it to sample. A capacitor provides that low impedance. This will tend to skew the phase relationship from your input signal, so keep that in mind.

I see you've added the power pins, however you don't show a bypass capacitor across the power pins. That's pretty critical; without it you will have problems. I suggest that you use an 0.1uF poly metal film or ceramic cap directly across the pins, and have a 1uF or larger aluminum electrolytic cap nearby.

It appears that you are using Cadsofts' Eagle. You're showing the symbols for +5v and GND, and that will cause the PCB layout editor to show "air wires" between any nodes with those labels; but be aware that you have to add a connector, wire pad, etc. in order to have a means to actually connect them to the board.

That also goes for your input and output signals.

Last edited: Jul 14, 2011
6. ### yougarage Thread Starter New Member

Nov 29, 2010
16
0
could the phase skew be a problem in very slow varying signals like those coming out from ntc or variable resistors?
yes I'm using Eagle cad, and those airwires are a bit messy you are right! what would be the right approach to layout vcc and ground? I'd like to make a ground plane on my board...

7. ### #12 Expert

Nov 30, 2010
16,703
7,338
Going back to your first post, your theory is correct. The circuit is valid. The jumper method will work.

The capacitors you are considering will only mess up (skew) high frequencies.

8. ### SgtWookie Expert

Jul 17, 2007
22,183
1,728
As #12 said, the relatively small caps being used won't noticeably skew low speed signals.

What package are you planning on using; DBV, D, or P?
Are you going to use thru-hole resistors and caps, or surface mount?
Are you going to actually use jumpers, or perhaps a dual rocker DIP switch so there aren't jumpers to lose?

9. ### SgtWookie Expert

Jul 17, 2007
22,183
1,728
Well, haven't heard back from you - but I'll just assume you're going to use a DIP and thru-hole components.

Have a look at the attached. I adjusted the feedback resistors so that you will get a selectable gain of 1 or 10.
Instead of just plain jumpers, I put in a dual DIP switch - however, you can just use jumper headers instead.
The generic opamp you selected had an incorrect pinout for your selected opamp; I chose an existing library model that had the correct pinout.
I added a 100nF cap across the opamp supply pins.

The board layout isn't perfect but it'll work. I'm not keen about the long signal path for the feedback from R3/R6 to the opamp inverting input (pin 2). I'll leave that up to you to fix.

When you open the board file, the GND polygon won't be filled in. Just click the RATSNEST tool (looks like an X with rounded ends on the left toolbar) and the polygon will fill.

File size:
20 KB
Views:
61
File size:
93.5 KB
Views:
14
File size:
10.3 KB
Views:
11
File size:
85.9 KB
Views:
30
10. ### yougarage Thread Starter New Member

Nov 29, 2010
16
0
sorry for my late reply,great board, thanks a lot.
If the sensor is far from the ADC, say 1 meter, is it better to place this input stage close to the sensor or to the ADC? As you said, C3 is a bypass capacitor.I noticed it is placed very close to the vcc supply pin, but many manuals advise to place it close to GND pin. Is it the presence of the ground plane that change this need? Or maybe is it decoupling?

11. ### SgtWookie Expert

Jul 17, 2007
22,183
1,728
Good question. Since I don't know what kind of sensors you're going to be using, you will probably be better off having the buffer as close to the sensor as possible. If it's a high-impedance or passive sensor, you'll pick up noise on the wires to the sensor. You could help to reduce the noise by using twisted pair or coax. If noise proves to be a problem with the sensor you're using, you may have to go to a different kind of amplifier; an instrumentation amplifier, which will require a different board. Noise won't be quite so much of a problem on the output side, as the opamp will actively try to cancel it out.

You still really need a 10nF cap right at the input pin to ground for the ADC.

Ground planes have very low inductance compared to traces. An infinite plane has virtually no inductance. Were this a larger multilayer board (more than 2) I'd have a power plane and a ground plane, with caps sprinkled around to decouple the layers. You really can't do that with the freeware version of Eagle, as you're limited to two layers.

But, the copper pour ground area I made will still have much lower inductance than a 24 mil wide trace.

There are plenty of improvements that could be made to the board; a big one would be going to all SMD/SMT parts. That would reduce the lengths of the traces quite a bit. SMDs are kind of challenging for newbies, but once you get the hang of using them, it's easier and faster to make boards for them - as there aren't any holes to drill.

12. ### yougarage Thread Starter New Member

Nov 29, 2010
16
0
You re right about smt.I think I'd better switch to this technology for my projects, it's so much cleaner, and I feel like trough hole is not the right way to go these days.I will try to redesign the board with smt components and then show you my work as soon as it's done, if you could take a look at it would be great, expert's critiques are the best way to learn!

13. ### SgtWookie Expert

Jul 17, 2007
22,183
1,728
0805 devices are about the smallest I can go nowadays. The 0403's are really tiny. 1206's are relatively easy.

14. ### ErnieM AAC Fanatic!

Apr 24, 2011
7,436
1,626
QFT. 8085's also have the advantage of having the value printed on the resistors, any smaller and they are unmarked. They are easily hand soldered, smaller means harder. (Ceramic caps are always unmarked no matter the size.)

I do go smaller when I have to, but I have special tools such as a reflow machine and a hot air pencil.

15. ### SgtWookie Expert

Jul 17, 2007
22,183
1,728
Actually, this can be optional depending on how they're ordered - but yes, really small resistors aren't marked. I have a hard enough time with 0805's; I have launched a number of the little guys into space.
And boy, are the little ones hard!
This can also be an option for 0805's and larger. Laser-marked ceramic caps are of course more expensive than unmarked. The code is a letter and a digit. Kemet uses a K prefix. I've attached an image of a cap value marking table from Kemet.

It sure is easier when you have the right tools. But, just trying to hold the darn tiny things with tweezers can be a real challenge. Having a microscope with good lighting is a big help.

• ###### CapSMTMarkings.PNG
File size:
78.6 KB
Views:
17
R!f@@ likes this.
16. ### yougarage Thread Starter New Member

Nov 29, 2010
16
0
here is my half-work. Now I have to route the traces and design the ground plane, but first I'd like to hear from you if I have to improve the components placing or other aspects of this board.
I used a quad op amp (tlv 2374) so I have 4 inputs and outputs, and changed the values of some resistors to fit better my needs.Now the input voltage range can be switchable between 0-5v and 0-20v. I will have to change the value of C2,C3,C4,C5 due to the increased resistance of the input resistor. I also came back to the gain = 9 solution, so I can use one single feedback resistor instead of two. I had to edit the op amp in the library because I couldn't find it, I followed the recommended land pattern I found in the datasheet.Right now I'm following some tutorials on Eagle cad...

File size:
16.5 KB
Views:
9
File size:
138.1 KB
Views:
12
File size:
58.2 KB
Views:
33
File size:
280.3 KB
Views:
22
17. ### yougarage Thread Starter New Member

Nov 29, 2010
16
0
here is my finished board. I used smt components, I placed them on both sides.
The electrical and design rules checks are ok, but I'm wondering if this design can be improved in any way, or if are there any errors...
This is my first layout, so I hope you can advise me.

File size:
138.4 KB
Views:
15
File size:
20.8 KB
Views:
8
File size:
153.9 KB
Views:
20
18. ### SgtWookie Expert

Jul 17, 2007
22,183
1,728
Gee, I completely missed your previous post. It's been busy, and lots of folks want help.

You've run traces at odd angles. I don't use angles smaller than 45°; I use some multiples of 45° - unless I absolutely must use something less for a special case.

You may have had the grid off at some point. I generally keep it set on 50 mils, unless I'm checking for alignment on 0.1", or have an oddball size part - but I return it to 50 mils ASAP. I see you had the primary set to 25 mils, aux to 5 mils; that's a bit too fine.

Your isolate and spacing for the polygon is too small. I'll use 12 or 16 mils.

You have quite a few vias, and I'm not sure why at this point. Were you really planning on routing all of those signals to the other side of the board?
You have parts on both sides of the board. 2-sided boards are very difficult to make at home. Were you planning on having them made somewhere?

There seem to be inaccuracies in the schematic, but I haven't looked at the one I made in awhile; so that's pending review.

I guess you didn't find an existing package for the TLV2374, so you just used the drawing tools to manually add it. Not good; you bypass much of the ERC and DRC checks when things are not properly stored in the libraries. It also makes it a real pain to make updates to the schematic and board. If you ran into difficulties routing things with one amplifier setup, you could just move the amps around to see if you could get an easier routing.

In linear.lbr, there are several generic opamp/comparator packages defined; 1AMP_xxx, 2AMP_xxx, 4AMP_xxx where the xxx refers to various power pin configurations. The D suffix packages are SMD, the N's are DIP. So, you would want to use: 4AMP_P4+11D - where the power pins are 4 and 11, and the package is SMD.

Last edited: Jul 24, 2011

Nov 29, 2010
16
0