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.

Safe input votage Pic..

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
I have a board ( pe-made and used for years ) It sports a pic18F26K80 and all is fine.

However!! I need to interface another pic running at 5V.. The circuit into the pin I need is thus..
1632483762960.png


The input is a slow (ish) pulse on one pin and a fast (ish) pulse on the INT0 pin ( direction and speed ) Now! The cap has to go as the input is destroyed.
BUT!! there is too much attenuation.. So! I took off the 10k and it works....

Qusetion! How long for.. I know the speed pulse should be fine but will the 39K enough to stop the pic pin frying ( I think it will be fine, but!! Hence the question ).
 

Pommie

Well-Known Member
Most Helpful Member
Assuming that the lower voltage pin has the protection diodes then they are seeing (5-3-0.7)/39k so ~ 33mA. They are rated at 20mA so maybe increase the 39k to something like 100k.

Mike.
 

JimB

Super Moderator
Most Helpful Member
Assuming that the lower voltage pin has the protection diodes then they are seeing (5-3-0.7)/39k so ~ 33mA.
I make it 33 micro-amps.

JimB
 

Diver300

Well-Known Member
Most Helpful Member
The pic18F26K80 data sheet is available here:- https://www.microchip.com/content/d...cedFlashMCUwithECANXLPTechnology30009977G.pdf

Page 527 says:-
Voltage on any digital only I/O pin with respect to VSS (except VDD)........................................................... -0.3V to 7.5V
Voltage on any combined digital and analog pin with respect to VSS (except VDD and MCLR)...... -0.3V to (VDD + 0.3V)

Input clamp current, IIK (VI < 0 or VI > VDD)......................................................................................................... ±20 mA

So, if it is a digital only input, it will be fine at 5 V with any supply voltage.

If it's an analogue input, you should limit the current to 20 mA. I would not recommend letting the input clamping diodes limit the current if you are using the A/D converter. Current from the input clamping diodes can cause the A/D to give small errors.

I would just make the resistor to ground just under twice as big as the series resistance. That will give a voltage divider that will reduce the 5 V to under 3.3 V. I suggest 180 k Ohm to ground with a 100 k Ohm series resistance. That will give 3.2 V out with a 5 V input.

The 10k was reducing the voltage to nearer 1.25 V which is often not high enough to be seen as a high level by a 3.3 V IC. Page 545 of the data sheet says that it should be over 0.8 * Vdd, so that is 2.64 V.
 

Nigel Goodwin

Super Moderator
Most Helpful Member
I have a board ( pe-made and used for years ) It sports a pic18F26K80 and all is fine.

However!! I need to interface another pic running at 5V.. The circuit into the pin I need is thus..
View attachment 133839

The input is a slow (ish) pulse on one pin and a fast (ish) pulse on the INT0 pin ( direction and speed ) Now! The cap has to go as the input is destroyed.
BUT!! there is too much attenuation.. So! I took off the 10k and it works....

Qusetion! How long for.. I know the speed pulse should be fine but will the 39K enough to stop the pic pin frying ( I think it will be fine, but!! Hence the question ).

The protection diodes simply clamp the input to the supply rails, you just have to ensure that that clamping doesn't increase the supply rail voltage, so the current needs to be limited, presumably to less than the PIC (and other circuits on that rail) is drawing.

It's VERY common practice, and shown on countless MicroChip application notes, to feed mains directly in a PIC pin, just using a simple series resistor of ahigh enough value to limit the current.

For 5V down to 3.3V the ratio for an attenuator is simply 1.7/3.3 (no maths really involved), so a 1.8K series resistor and 3.3K resistor to chassis would be fine, and shouldn't hit the clamps.
 

Nigel Goodwin

Super Moderator
Most Helpful Member
Nigel... The problem is the board is made... I can barely see the piggin resistors... let alone change them.. I need to mod it back..
That's why I try to avoid SM where ever possible :D

As we hand assemble small production runs (more like production walks!!) it takes far too long using SM parts - some parts there's obviously no alternative, but by keeping what we can through hole it makes life easier and faster.
 

tumbleweed

Active Member
It's VERY common practice, and shown on countless MicroChip application notes, to feed mains directly in a PIC pin, just using a simple series resistor of ahigh enough value to limit the current.
Many of which have been superseded by later app notes such as TB3009 and TB3013 outlining why that's a bad idea. They even call out AN521, which was the source of that practice.

From TB3013:
Even if the silicon is not damaged, the out-of-specification voltage can cause unexpected application problems.

I hate "unexpected application problems".
 

Nigel Goodwin

Super Moderator
Most Helpful Member
Many of which have been superseded by later app notes such as TB3009 and TB3013 outlining why that's a bad idea. They even call out AN521, which was the source of that practice.

From TB3013:


I hate "unexpected application problems".

Yet there are countless thousands (if not millions?) of PIC's out there running perfectly doing just that. Why should the voltage be 'out of specification'?, the protection diodes keep it within specification, that's their purpose in life.

Imaginary "unexpected application problems", which they can't even tell you (or don't even know, because they are just imagined) are of little use in the real world.
 

rjenkinsgb

Well-Known Member
Most Helpful Member
app notes such as TB3009 and TB3013
Both appear to relate to analog input problems (in regard to a higher voltage and limiting resistor), not any fundamental problem with using that technique to a purely digital pin.

One says ADC accuracy may be lost if the protection diodes are being used to sink current, the other relates to using pin compatible newer devices in old designs, when the new device may have analog capability on pins that were digital only in the device it replaces.
 

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
Digital.... Only pulses.. I never said analogue... However!!!! It is going into ADC inputs.. Its that piggin circuitry I'm trying to get past.

The current is tiny so I'm happy.. Happy as a pig in SH1T..
 

tumbleweed

Active Member
When passing currents through the ESD protection
diodes of the device, the internal voltages may be
affected causing inputs to be read incorrectly, A/D
conversions in process to be disturbed and other
unexpected behavior.

Note: Passing current through the ESD protection diodes
of the device is outside of the operating conditions
of the device causing potentially shortened device life
span and incorrect functionality

TB3013 calls out many potential sources of failure, including such fun things as
the internal oscillator stopping, continuous resets, etc.

Of course, you're free to ignore all of those suggestions from the manufacturer
and keep referring to an app note written almost 25 years ago "as gospel".

Keep in mind that was written by the same people that had to withdraw "TB008 Transformerless Power Supply design" because it was dangerous.
 

tumbleweed

Active Member
and if you look around there are plenty of experiences like this one: PIC16F1847 HFINTOSC Slow and Unstable

I am looking at the oscillator output pin with an oscilloscope and for any HFINTOSC frequency I select (e.g OSCCON=0x70 or 0x72) the frequency is about half what it should be and is very unstable...
<later>
I have solved the mystery. I have a 22k from RA0 to -8.0V (about -0.35mA through the protection diode). I am puzzled that the chip works fine in all other respects, but yet this current has such a targeted and dramatic effect on the HFINTOSC. However, I now know how to fix it
 

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
Ahhh! Mr tumbleweed! It would appear you are right... I have spent two days debugging a fault.. I have a intermittent reading from the ADC module.. When the said direction is high, I get 3.4V on the RA3 pin... The ADC seems to stop working when this pin is high and then re starts when it's taken low.. Bugger... I have had to change the circuit... Alot of messing but now it is ALL digital...
 
PIC's seem to have 2 types of input. Analogue and purely digital.
The digital inputs have didoes to each rail so you can use a resistor in series with input to limit voltage into the PIC.
Analogue ports dont appear to have the diodes to the rails so any over voltage can latch up the PIC.
In this case I use external BAT85's to each rail and that seems to work OK.
 

Latest threads

EE World Online Articles

Loading
Top