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.

18F2550 taking power from A1

Status
Not open for further replies.

arhi

Member
Hi,

I have a strange "problem" ... now .. let us ignore rest of the circuit, the important part is:

GND from USB connector is connected to GND on the board
GND from the regulated 5V source is connected to GND on the board

1 (mclr) is pushed up to vcc with 10K
3 (RA1) is connected to 5V from USB connector (so I can detect when usb is connected)
8,19 (VSS) is connected to the GND on the board
20 (VDD) is connected to regulated 5V source

RA1 is set as digital input

now, I connect 5V regulated and everything works ok, now I connect USB connector and all works ok .. communication works etc etc...

I disconnect 5V regulated - AND EVERYTHING WORKS !!!!

I disconnect USB, (so nothing is connected to device) and device shuts down

I connect USB only - AND EVERYTHING WORKS...

on board is also one 3V stabilizer (using 5V as a source), few i2c devices ...

the only way USB 5V can power up all this is trough PIC !! like RA1 and VDD pin's are shorted out ?!?!?!

anyone?
 
There is a protection diode from each pic pin to Vdd and this is what is powering your circuit. Place a 10k (maybe 100k) resistor in series with RA1.

Mike.
 
I would have expected exactly what you describe. You should be very, very careful in designing anything that has input or output voltages higher than the positive supply or lower than the negative supply at any time.

From the data sheet:-

Voltage on any pin with respect to VSS (except VDD and MCLR) .............. -0.3V to (VDD + 0.3V)

There are clamping diodes from every pin (except MCLR and the power pins) to Vss and Vdd, so the input pin cannot rise much above Vdd. In your circuit, the diodes stop Vdd falling below the input voltage.

Use a continuity tester and you can see that those diodes are there. You can power a PIC like that from any pin, not that you should. Current flows from the pin, through the clamping diode and you will see about 4.4 V on the power rails. The decoupling capacitors will help the PIC run under those conditions.

There are several things you can do to stop that happening.
1. Use a transistor as a buffer, with a pull-up to Vdd
2. Put a big resistor in series. The input current on a digital input is tiny, so you can use a 100kΩ or so, which won't provide enough current to run much.
3. Use a PIC with high voltage tolerant inputs. Most are 3.3 V devices. In the data sheet they say:-

Voltage on any digital only pin with respect to VSS ........................................ -0.3V to +6.0V

Now that has no reference to Vdd, so you can feed it with 5V at any time. They have different clamping systems. You have to chose your pins because analogue capable pins generally don't like higher voltages.
4. Use a gate like a 74AHC1G04 as a buffer. It can run from 5V and can stand 5V input even with no supply voltage, so if you wire the supply to the gate to the PIC supply, both can fall to 0V while the input (USB) is still at 5V
5. Power everything off the USB anyhow.
 
Last edited:
Mike, thanks, I forgot about the diode :) .. that explains it ..

Diver, powering from USB is not an option, the device is "logger" .. it has some 20+ sensors and log data into few i2c eproms every 30min ... I just connect it to computer from time to time to download data into my application...

the 100K in series will do the job, in general, this works as is, problem was I forgot about the diode so was wondering "why" it worked :) (the pic is anyhow powered with 4.8V to be able to properly get data from 3v spi sensor on board without level shifter :) )
 
Hello!

I have one PIC18F2550 and a PicKit2 from Microchip, where i can find the code to
make a LED flash with this PIC?

For the circuit i will connect the PIC to 5V and put a LED via a resistor on one
of its I/O pins..

I just want a simple "hello world", im using MPLab...

Sorry for this question and thank you
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top