CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Checking if PIC is being "powered" by input pins

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
arrow



Joined: 17 May 2005
Posts: 213

View user's profile Send private message

Checking if PIC is being "powered" by input pins
PostPosted: Thu Sep 28, 2006 4:31 am     Reply with quote

Hi

I might have a situation (hot plugging or unplugging of device)
where the input pins of the PIC are powered while Vdd=0.

Is it possible to detect if the PIC is powered through the input pins?
preferably via software.

Thank you
a.
newguy



Joined: 24 Jun 2004
Posts: 1903

View user's profile Send private message

PostPosted: Thu Sep 28, 2006 7:29 am     Reply with quote

Input a known voltage reference (zener diode, reference chip, etc) into a spare A/D pin, and use the PIC's supply rails as the A/D's references.

At full Vdd (5V, 3.3V, whatever), a 3V reference will give you a certain reading on the A/D converter. At lower voltages, it will give you a higher reading.
arrow



Joined: 17 May 2005
Posts: 213

View user's profile Send private message

PostPosted: Fri Sep 29, 2006 1:15 am     Reply with quote

Hi

Is there any way to detect if the input pins are providing the power
programatically (and Vdd is not supplied to the PIC)?

Also, if I set all the pins to "output" will this help?
(I will then change them to input as I need them).

Thank you
a.
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Fri Sep 29, 2006 1:44 am     Reply with quote

arrow wrote:
Hi

Is there any way to detect if the input pins are providing the power
programatically (and Vdd is not supplied to the PIC)?


If you mean by the PIC in question then it will already be too late atthis point because the input pins could be in latchup mode. In this mode it is like an SCR in that the only way oout of this state is to remove power to the PIC. If you means is there some way an external divice can tell if the PIC is being powered by input pins then two possibilities come to mind, 1 measure the current flow from the external pins to the PIC or 2, test for a voltage differention from the input pins to the PIC's VDD rail. Neither of these approaches are straight forward.

Quote:
Also, if I set all the pins to "output" will this help?
(I will then change them to input as I need them)


No.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
arrow



Joined: 17 May 2005
Posts: 213

View user's profile Send private message

PostPosted: Fri Sep 29, 2006 2:16 am     Reply with quote

Hi

I have the following bug. I have a 10pin header, two of the pins provide power to the PIC. The remainder of the pins provide power to an external device (not the PIC), but to which the PIC is connected.

The PIC software has 2 modes: a READ and a WRITE mode.
At the beginning of the code I check if one of the pins in the header is H.
(The PIC has a pin going to ground via a 10k resistor. This PIC pin is connected to the pin that will supply the H.)
If H then the code goes into READ mode, if L the code goes into READ mode.

Upon inserting the 10pin header (a H is now supplied to the Mode pin on the PIC) I find that the code goes into WRITE.

One explanation that I have come up with is that the 10pin connector is not being inserted uniformly. Part of the pins are "in" and supply the external device as well as the input pins on the PIC. The software starts to execute, and since the Mode pin is still not connected it sees a L, and goes into WRITE mode.

Can someone please give me a suggestion that would solve this problem?

Thank you
a.
Eugeneo



Joined: 30 Aug 2005
Posts: 155
Location: Calgary, AB

View user's profile Send private message

PostPosted: Fri Sep 29, 2006 2:22 am     Reply with quote

Does this happen when a pin exceeds 5.5v? If so you could insert an inline resistor. Optical isolation would be the best.

If it has a HLVD detect hardware, you could use that since it has an internal reference then halt your program until a normal voltage level is seen.
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Fri Sep 29, 2006 2:26 am     Reply with quote

The conventional way of deaing with the problem is to have the PIC power pins longer than the other pins.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
arrow



Joined: 17 May 2005
Posts: 213

View user's profile Send private message

PostPosted: Fri Sep 29, 2006 3:46 am     Reply with quote

Hi Asmallri

That is interesting!
Should I make the PIC power pin and Ground pin in the 10 pin header
physically longer then the rest?
If so how much longer should they be? is there a rule of thumb?

Thank you
a.
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Fri Sep 29, 2006 5:01 am     Reply with quote

arrow wrote:
Hi Asmallri

That is interesting!
Should I make the PIC power pin and Ground pin in the 10 pin header
physically longer then the rest?
If so how much longer should they be? is there a rule of thumb?

Thank you
a.


about 2mm is pretty typical but the longer the better.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
[mAnNaRo]



Joined: 02 Dec 2005
Posts: 28
Location: Italy, Milan

View user's profile Send private message Send e-mail

PostPosted: Fri Sep 29, 2006 5:31 am     Reply with quote

asmallri wrote:
arrow wrote:
Hi Asmallri

That is interesting!
Should I make the PIC power pin and Ground pin in the 10 pin header
physically longer then the rest?
If so how much longer should they be? is there a rule of thumb?

Thank you
a.


about 2mm is pretty typical but the longer the better.


...and a delay one or two second for having a stable situation before the test for READ or WRITE mode.

Ale
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Fri Sep 29, 2006 8:20 am     Reply with quote

asmallri wrote:

If you mean by the PIC in question then it will already be too late atthis point because the input pins could be in latchup mode. In this mode it is like an SCR in that the only way oout of this state is to remove power to the PIC. If you means is there some way an external divice can tell if the PIC is being powered by input pins then two possibilities come to mind, 1 measure the current flow from the external pins to the PIC or 2, test for a voltage differention from the input pins to the PIC's VDD rail. Neither of these approaches are straight forward.


The PIC won't necessarily latch up if powered through an I/O pin. In fact it may run quite happily though the supply voltage and any analog functions will be altered. It will usually recover as soon as proper VCC is reapplied. On the other hand this is very poor form and I do not recommend trying to utilize this "feature".
_________________
The search for better is endless. Instead simply find very good and get the job done.
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Fri Sep 29, 2006 7:30 pm     Reply with quote

Quote:
....It will usually recover as soon as proper VCC is reapplied.


If latchup does occur (which does not mean it will always occur) then there will be no recovery without power cycling. That is why the condition is refered to as latchup.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group