External Analog Voltage In

pilko

Senior Member
Thanks hippy ---another quick question --What is the max external voltage I can input (I realize it is 4.5v in this case) but is it OK to input 5v?
 

hippy

Ex-Staff (retired)
Maximum is up to whatever the PICAXE supply is ( actually a little more I recall, +0.3V ? ).

Note there's probably some discrepency on both sides, in that neither are likely to be exactly 5V, but as long as its below Vpsu+0.3V you'll be okay.
 

Dippy

Moderator
Take care if using zeners.
A zener is NOT an on/off 'protection'.
Read a full zener Data Sheet to see the real world response.
So many novices make this same old mistake.

Current flow approaching the 'zener voltage' may be signicant enough to act as a parellel resistance to the pot.
This will affect your ADC value and is not good.

I would suggest limiting the external voltage and having no zener unless abs necessary.
In which case a V/ADC calibration may be required. Not ideal.
 

MFB

Senior Member
ADC series protection resistor

You could just add a 10K resistor in series with the ADC input as protection against over-voltage. After all, thats how the PICAXE programming circuit works. It uses a 22K to protect up to a potential RS-232 input of +/-12V.
 

Colinpc

New Member
Take care if using zeners.
A zener is NOT an on/off 'protection'.
Read a full zener Data Sheet to see the real world response.
So many novices make this same old mistake.

Current flow approaching the 'zener voltage' may be signicant enough to act as a parellel resistance to the pot.
This will affect your ADC value and is not good.

I would suggest limiting the external voltage and having no zener unless abs necessary.
In which case a V/ADC calibration may be required. Not ideal.
I have also found this. But I found a simple way of getting a "switch at a particular voltage" function when using a voltage to turn on a transistor.

I required one pin to read ADC then output to turn on a relay. Using a white LED in the base of the switching transistor raises the base turn on voltage to approx 3.5v. If the ADC max voltage is kept below approx 3v, the relay will not turn on. Once the ADC value required has been read, turn the pin into an outout (5v) and the transistor will turn on the relay.

The LED does not conduct until the higher voltage is reached. A zener in the same position turned on at just over the 0.6v on the base due to leakage.

Fred
 

Dippy

Moderator
Well, we're going off target now.

Basically, if you keep to what hippy said in post 4 then you don't need zeners or anything else that could upset an ADC reading. A series resistor as suggested by MFB is perfect though I'd user a lower value myself.
Job done and Bob's yer Uncle.
 

BeanieBots

Moderator
Just re-emphasise what has been said about zener diodes.
They are fine as crowbar clamps on supply lines or as (not very precise) voltage references but they have no part to play in limiting analogue voltages where that voltage is needed to remain accurate.

The current limiting series resisitor is the best solution in this application.
 

jglenn

Senior Member
There is a way to prevent early zener conduction, pick a slightly higher one.

We use 5.6V, 5W TVS (Transient Voltage Suppressors) on analog inputs for our engine controls, oil pressure, water temp, fuel level, etc. Works great, no interference or distortion in the 0-5V analog signal. These are diesel engines, not spark, but there are still many sources of transients. Back EMF from contactors sneak in, static, lightning. It is not perfect, but saves many boards that otherwise would end up on my service bench (~4-15 per day).

Use a 1K to 10K series resistor to protect the zener or TVS (about the same).

Hobbyists can get by with 1W zeners. This also protects from negative input signals.

A PREVIOUS GENERATION of boards just had the TVS, no resistor, on a keyswitch input, 2 lines, auto/manual mode. Static from the operator touching the key has to date destroyed 240 of these boards, $100 each. The CPU gets fried. Total $24,000 US in the dumpster. Failure to put in five cents of resistors (2) caused this.
 
Last edited:

jglenn

Senior Member
Yes, but you don't need it for a pot. The clamp is for signal lines that can pick up noise of a severe nature. It is also useful for products where the user may make an error on the connection, or even abuse.

Make sure you have a .1 cap on right across the cpu power and ground pins.

We have an unusual static situation with our products, many are engines driving compressors, concrete pumps, high pressure water jets (can cut you in half :eek:) on trailers. The tires insulate the whole thing, they won't put on real earth ground wires, or even a dangling wire touching the ground. Rotating machinery acts like a van de graf generator, makes static charge.

When the dumb human comes along and touches the control panel, he provides a ground path, and a static spark goes thru the unit. We try many tricks, ground grids in the membrane faceplate, etc, but still have problems. We in engineering often cannot get the management to do what we want.

It takes the fun out of the job sometimes!

A final tip, put a small cap across the zener to shunt rf to ground, incoming signal lines can act like antennas, for best noise immunity. A .1 is good.

ALSO, watch out for "voltage divider effect" on the pot and 10K input R. You want a 1K pot. Or use an opamp voltage follower
buffer (- input tied to output, input is +) between the pot and 10K.
 
Last edited:

jglenn

Senior Member
You don't always need it. Depends on the input impedance what you are trying to drive. The voltage buffer can convert a high impedance source to a low impedance drive. A/d inputs should not see too high of impedance of source,
more than a couple K I would guess.

Once you have an opamp there, filtering is easy, anti-aliasing problems are prevented. That has to do with sampling at the same rate as the signal (talking ac here, not dc). Someone else can flesh that out! :p
 

MFB

Senior Member
Anti-aliasing filters

Regarding the above comment about anti-aliasing filters, these would be difficult to implement using a single resistor and capacitor. This class of filter is suppose to make sure that the ADC input does not see a significant (more than LSB) signal at frequencies that are more than half the sample rate. Unless you are prepared to sample at a much higher rate than the maximum possible signal frequency, the filter cut-off characteristics will have to be pretty sharp and increase with the resolution of the ADC. An added complication relates to signal phase distortion, which can be a problem for certain applications, like impact measurement. The implications of all this is that active multi-pole filters are required.

However, for many measurements a RC low-pass filters can be used to simply reduce the level of noise seem by the ADC, but this technique should not be confused with anti-aliasing. Filtering is a complex subject that it is often overlooked when designing data acquisition systems.
 

Dippy

Moderator
Pilko.
I have to ask what level of accuracy you want?

With the values of components shown in your last drawing even a 5V6 zener will have a significant effect as you head towards 5V in.

Whilst it is true that the zener will provide over-voltage protection, the amount of current being 'bypassed' by the Zener is significant compared to the 10K+Potk. This, in effect, parallel resistance will reduce the measured voltage.

If you don't believe me then breadboard it for yourself.
Just try it with a DMM and I'm sure you will see the effect. Asuming a 5V supply to PICAXE I'm sure you will notice an increasing non-linearity above 4V in to ADC, probably getting up to ~5% @5V in.
(I don't know if the tempco is significant either, haven't time to check, that's your job)
Obv all this may depend on zener manufcaturer etc. so this is merely ballpark.

For good, sharp voltage protection you will have to design a slightly more complicated little input circuit. But, is it actually needed? The series R will provide a limited amount.

If you have 'control' over the external voltage, and there are no other nasties, then dump the zener.

I completely agree with good decoupling for PICAXE power supply for good ADCing as I 've experienced this affect with PICs.

At times like this it's best to try it ad see it, rather than debate for days about it ;)
 

jglenn

Senior Member
Dippy:

I hear what you say, and will try some breadboard tests with a 5.6V TVS on tuesday (I got mondays off for awhile due to the depression) to see if there are preconduction effects, but consider this.

http://www.onsemi.com/pub_link/Collateral/MMBZ5V6ALT1-D.PDF

These devices are labelled for "Sensor Interface/Signal Conditioning".

Check out page 3. Vbr is the breakdown voltage, in the zener mode.

For a 5.6V TVS it is 5.32V. This should mean it does not conduct at 5V.

We measure engine analog values, like degrees of temp and PSI, if we are
off too much the customers complain. It is possible leakage and temperature can affect these diodes though. Will let you know what I find.

Don't want to give any bad advice! :rolleyes:
 

BCJKiwi

Senior Member
Looking at the referenced data sheet and taking the 5V6 ZENER there are a few critical values to compare to the curve.

1. @ 3V there is a leakage current of 5uA
2. @ 5.32 to 5.88V there is a current of 20mA (Actual voltage depends on the individual Zener)
3. @ 8V there is a current of 3A
The transition thru these three points is shown by the curve.

So anywhere from <3V upward there is an increasing current flow so if the system is working constantly at 5V there could be close to 20mA current flow thru the Zener.

What effect this will have on sensor accuracy will depend on the individual Zener (20mA could be at anywhere from 5.23V to 5.88V), AND, on the rest of the circuit - i.e. how significant is this leakage in relation to the sensing circuit.

Oh, and if the individual Zener happens to have it's knee at 5.88V it probably won't protect the PICAXE at all.
 
Last edited:

jglenn

Senior Member
Where are you getting the 20mA leakage value? That would seem to be impossible. The test current is 1mA, even before it conducts, so the 1mA is
probably not even really there, until you go below 5V. We have thousands
of circuit boards out there, some have a dozen TVS on them, on analog and
digital inputs. This is standard practice in industrial design. Everybody does it,
I don't know why it is new to you guys!

Here is a fancy implementation of this idea:

http://focus.ti.com.cn/cn/lit/an/sboa039/sboa039.pdf

The PIC chips have internal diode clamping of the inputs, about
.7V drop, so the zener technique is close enough that protection occurs. Many consider that depending on the internal chip diodes is bad practice.

I myself hate the use of the internal pullup resistors, for rugged
applications. They are weak. Probably some kind of funky transistor in reality.
 
Last edited:

MFB

Senior Member
Opamp input clamp

I still think that, if you are prepared to trust Rev-Eds programming input circuit, then you should also be happy to use a series protection resistor on the ADC input.

The only limitation to this simple approach (and diode based alternatives) is that an overloaded input can introduce errors on other ADC input channels, even if they are still operating well within range. The only circuit that I have found to avoid this cross-talk is to use a rail-rail I/O opamp on each ADC input. The opamp needs to be configured in the unity gain mode, with a series input protection resistor (e.g. 100K) on the non-inverting input. The output of the low cost TS922 dual opamp will clamp within about 50mV of the PICAXE power rails. This apprach also has the advantage of providing a high input impedance, even when powered-down, and a capacitor can be added between the opamp input and ground for low-pass filtering.
 

Dippy

Moderator
JGlenn and everyone.
I tried it on breadboard before I posted. I am a borne Doubting Thomas and didn't believe that even a 5V6 would have no effect.

Using a simple 10K + 5V6 and then measuring with DMM.
Bench PSU set to 5.00V.
Without 5V6 zener the DMM showed 4.96V.
With zener it showed 4.80V

So, even if there is a tiny abs error in DMM and PSU you can see the difference the zener makes.
Obv as we turn PSU O/P below 4.50V the difrence reduces.

People often look at zener response curves but forget the change wrt current.
Actually most newbies think a zener is some magic on-off....

Anyway, you will get different responses with different series R and Zener makes and at different temps. I dunno what else to say except what I said before.

I'll hand it over to you guys now as I want to see Roddick vs Federer now.
 

BeanieBots

Moderator
Bottom line.
If you put a zener on an analogue sensor, it will sigificantly reduce its accuracy.
That's physics, not an oppinion.
It's also proven by practice, not just a theory.
TRY IT as Dippy has already done.
 

Dippy

Moderator
Try it? That's far too scary and sensible.
Nah, let's theorise /debate /argue over it for another few weeks, it's more fun :)

(Let me know when it's over).
 

jglenn

Senior Member
If you mean the 20mA leakage, I do not see that, and just did some tests.

Dippy is right, for normal zener diodes, but TVS are designed for this purpose,
and have very tight tolerance.

All I have at home is a normal 5.1V, 1% zener, which is non-typical, they
are usually 5%. And a real TVS, but 6.8V.

I set it up directly across a power supply with ammeter set for 2 mA range,
and voltmeter.

The 5.1V will draw 1mA at 4.3V, not good for clamping.

The TVS will draw 1mA at 6.78V, which shows how close they are made.

I chose 1mA as a relatively insignificant current, you are usually not up at
the top anyway. That may be why we don't have trouble with the 5.6V
TVS on our engine controls, the analogs are generally never above 4.5V,
but the digitals are. So I am corrected, the zener clamp is a bad idea,
but I think TVS are applicable!

Again, I have had hundreds of real world boards cross my bench, with varying
levels of transient protection. The sloppier it is, the more damage you get.

I hope the gov does not send some flying bug or birdbots after
me for suggesting zeners!

http://www.flightglobal.com/airspace/forums/video-afrl-micro-air-vehicle-infomercial-20939.aspx
 
Last edited:

BeanieBots

Moderator
I chose 1mA as a relatively insignificant current
Insignificant to what? (that's more than many sensors can even supply)
What is your sensor source impedance?
What is your required accuracy? (temperature? Unit to unit repeatability?)

TVS are indeed better than the 'average' zener but still VERY BAD for putting on any analogue signal.

If you want to 'clamp' an analogue voltage, then the circuit you linked to using op-amps is the way to do it. (even better to use a REAL voltage reference if temperatures can vary by much).
 

pilko

Senior Member
Wow -- I thought I had just asked a simple question. I think I would be afraid to ask a difficult one.
 

jglenn

Senior Member
Never be afraid to ask a question. It's just that sometimes designers are
like chefs, get more than one in a kitchen and there are different ideas!

Beaniebots: 1mA was chosen as a comparison point, ideally you don't want any conduction until just past the max voltage used. Normal zeners start conducting before their rated voltage, which causes the interference you
claimed, I was not clear on that. TVS will not conduct at all, early, if
you select the correct device. I believe that 5.6V TVS will not cause any
preconduction on a 5V signal. It is like THERE IS NOTHING CONNECTED TO THE ANALOG LINE, until the signal exceeds the clamp level. Sure there is a little stray C and L, but who cares, we need protection.

These devices are used by the millions
on analog signals. I have worked for Allen Bradley, various medical eqpt companies, the military out at Sandia in NM, and on untold dozens of industrial
and space circuits that use this technique. If clamping did not work, our real world circuits would not survive. In space, transients are induced by energetic particles and cosmic rays.

It is notable to describe the lengths necessary to protect military units
from the EMP of a nuke blast (also check out TEMPEST). Very high voltages are impressed on any
leads coming out, and it actually goes thru slots in the case, if there
are any. A slot electrically is just like an antenna. Each lead has to have
a ferrite bead on it right when the wire comes in. Also at that point
a capacitor bypasses it to the case. Finally, a fast solid state diode finishes the job. If you look at MOV clamps you will have a seizure, as they clamp
at twice the rated voltage. One lab I saw fired 12' lightning bolts at a bomb,
there is a trick to stop it from entering connectors, and dissipate over the
surface. In that case you need a little inductance in series with the line
to slow the rate of rise of current, so the clamps have a chance to activate.

Another reason bombs don't go off from lightning, is the firing systems are
very high voltage. You don't want a 12VDC triggered 1MT bomb! :D
 
Last edited:

RobertN

Member
There is another input protection scheme that has worked well on transmission controls. It requires 4 elements, a 2 to 10K series resistor, a .01 or .001 cap to ground, and a pair of signal diodes. One diode blocks to ground and the other conducts to a positive regulated voltage. The resistor and cap values depend on the type input (digital or analog), frequency response, environmental protection, etc.

This circuit does not have issues with break over softness affecting the signal. However, the IC internal static protection circuit may conduct at a lower voltage than the external protection diodes. In this case external Schottkey diodes can be used, or a separate positive voltage for the clipping diodes can be trimmed to assure the external diodes conduct first.

Typically damage to input circuits occurs from installation errors, operation faults, or sparking around by service personnel. At minimum the inputs should with-stand a multiple of raw pre regulator supply voltage, normal and reversed. The above circuit configuration can handle nominal ESD, especially with a small value bypass cap to ground at the input pins.

Starting with the initial proto board, all inputs should have a series resistor and cap to ground to minimize ESD affects and inadvertent application of over/reverse voltage.

In any case the affects of input protection circuits should be tested like in Dippy’s post above.
 

jglenn

Senior Member
Robert: good points, but I have used that dual normal diode clamp to the Vcc
and ground, and have seen it actually pull up the 5V supply to an overvolt condition under a severe enough transient. I prefer the R+TVS. In the early days of homemade 20KW electric car controls, DC motor, shunt and series, I learned that when the clamp blew out, put in a bigger zener, and refine the R. It always worked.

Dippy and Beanie both have good points, but I think in many cases TVS can be used to protect signals, which include power supply voltages, with a minimal of interference. You have to know what you are doing, and test the heck out of it.

Most of the examples seem to be with power supplies:

http://www.vishay.com/docs/88439/typtvsap.pdf

At the top is a R+TVS for protecting a 28V avionics load from bus transients.
I will look around for some raw analog examples.

Beanie: the fancy opamp variable clamp circuit I posted seems ideal, but
it presents an unprotected opamp input to the nasty world. What good is the circuit if the opamp gets blown out? Clamping is often best placed on
the direct inputs and outputs of a circuit, where outside interference comes in.

AT REAL COMPANIES, not where I am working, they use an ESD gun to simulate real world inputs to products. Engineers are afraid of these things, because they can turn circuits into toast in a microsecond, requiring additional design time. But if you don't do it, you will get a lot of failures. Try walking across the carpet in the winter time, then touching a doorknob, or....

a PICAXE!

OK, read the first paragraph here, sums up my thoughts.

http://www.vishay.com/docs/88448/protect.pdf
 
Last edited:

RobertN

Member
jglenn,
I agree the clamp diode to +V can pull up the supply and make it noisy. That’s why the + clamps went to a separate regulated clamp supply. The clamp supply regulator output was loaded with a 120 ohm resister to ground and had a healthy dose of caps. The regulator output had a forward biased diode to prevent killing the regulator with reverse current. To compensate for the output diode, and reduce the clamp voltage, the clamp regulator voltage was trimmed down.

Using input resistors more in the order of 10K helps reduce current being dumped into the + 5V.

I have used R+TVS's for relay coil suppression and input voltage regulator transient protection, and was rather appalled by the soft voltage/current break over for the 25+ volt TVS's. For that reason I have not considered them for signal inputs. They work great on relay coils.

All our controls are designed and tested for the standard SAE transients including ESD on all I/O pins. Also environmental parameters like temperature, vibration, IP rating, EMI susceptibility and emissions. The main problem we have had is blown traces from uncontrolled current applied to the internally grounded signal returns. Inserting cost effective temperature stable automatic over current protection in the returns without affecting the signal, is problematic.

For home projects I try to use only ESD protected MOSFETs and ICs to avoid having non op circuits due to winter static electricity. A static discharge you can't feel or hear will kill them.
 

BCJKiwi

Senior Member
@jglenn

Well if you take another look at page 3 in the referenced datasheet:-

As the reverse voltage increases (moving to the left along the horizontal axis), the device starts conducting at 3V (Vwrm) passing 5.0uA.
As the reverse voltage increase, more current flows so that by the time the voltage has risen to 5.32-5.88 (VBr), the current passed increases to 20mA.
When eventually the reverse voltage rises to the max of 8V(Vc), the current is up to 3A.

That is what the data sheet says.
 

BeanieBots

Moderator
@pilko,
Never be scared to ask.
This forum is all about answering questions and education.
The important thing is that you have been furnished with all the information you require to make an informed choice.
The datasheets linked to contain all the required information and support all the statements I have made.

My background is +30 years of designing equipment used to manufacture silicon chips. I'll leave it that.

The important thing to remember is that ANYTHING connected to a sensor will effect its performance. The debate is over how much.
If you can't understand everything in the datasheets, try a few things out and learn from personal experience.
Don't forget, that even something as simple as connecting your DVM can effect a reading.

Try it. Do a few tests which exagerate the issue to see the effect clearly.
Take a stable voltage say from a 5v regulator. Then put say 100k in series with it. Then try your DVM again and note the voltage. Then fit a 5v6 zener and note the voltage again. Obviously 100k is an excessively high source impedance but it will show the issue well and you can scale back to a realistic impedance and see how much the signal would be effected by other values.

DESIGN is about reading and understanding datasheets. Construction (from a gut feel) and then test is what hobbiests do and in many circumstances will prove to be adequate.
Proper design should also be followed by testing but there should be no major surprises. Anything that falls outside predicted values should be fully investigated and the route cause fully evaluated.

Consider a simple analogy such as putting up a book shelf.
How many screws and what size?
Most people will get it right without needing to do a full 3D model and stess analysis. What about the floor panel mounts in a high speed lift or the cable tension on a suspension bridge?
Analogue electronic design is similar to using apropriate materials in mechanics.
For example, consider what material (and why) you make a ruler from?
More to the point, what would you NOT make it from?
Is the effect of temperature on the chosen material important?

Electronics has similar issues. What matters, what does not matter?
Don't forget, when you test something, you have a sample of ONE.
Read the datasheet again. It will give max, typical and minimum values for all the important parameters. These need to be included in your design calculation IF THEY MATTER to the perfomance you require.

Again, don't be put off by all this. We're here to help.
 

moxhamj

New Member
Can I go back to post #1 and ask something - what would happen if the pot happened to be wound round so the wiper was connected to the external supply (ie at the top end), and the external supply was powered up and the picaxe supply was not connected? There would now be 5V being fed into an input pin on an unpowered chip - would that upset a picaxe? I did it once and the picaxe actually powered up and started running - would this be parasitic powering via the protection diodes on the inputs. And would it hurt a picaxe long term?

I'm thinking - circuit as per diagram 1, 10k pot, and add a 1k resistor in series with the wiper to the picaxe - would that be ok?

I suppose it depends on the nature of that external supply. Is it batteries or regulated and is it switched on at the same time as the picaxe supply?
 
Top