| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| arrow 
 
 
 Joined: 17 May 2005
 Posts: 213
 
 
 
			    
 
 | 
			
				| Checking if PIC is being "powered" by input pins |  
				|  Posted: Thu Sep 28, 2006 4:31 am |   |  
				| 
 |  
				| 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: 1924
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Thu Sep 28, 2006 7:29 am |   |  
				| 
 |  
				| 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
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Fri Sep 29, 2006 1:15 am |   |  
				| 
 |  
				| 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: 1660
 Location: Perth, Australia
 
 
			        
 
 | 
			
				|  |  
				|  Posted: Fri Sep 29, 2006 1:44 am |   |  
				| 
 |  
				|  	  | 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
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Fri Sep 29, 2006 2:16 am |   |  
				| 
 |  
				| 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
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Fri Sep 29, 2006 2:22 am |   |  
				| 
 |  
				| 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: 1660
 Location: Perth, Australia
 
 
			        
 
 | 
			
				|  |  
				|  Posted: Fri Sep 29, 2006 2:26 am |   |  
				| 
 |  
				| 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
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Fri Sep 29, 2006 3:46 am |   |  
				| 
 |  
				| 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: 1660
 Location: Perth, Australia
 
 
			        
 
 | 
			
				|  |  
				|  Posted: Fri Sep 29, 2006 5:01 am |   |  
				| 
 |  
				|  	  | 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
 
 
			      
 
 | 
			
				|  |  
				|  Posted: Fri Sep 29, 2006 5:31 am |   |  
				| 
 |  
				|  	  | 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
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Fri Sep 29, 2006 8:20 am |   |  
				| 
 |  
				|  	  | 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: 1660
 Location: Perth, Australia
 
 
			        
 
 | 
			
				|  |  
				|  Posted: Fri Sep 29, 2006 7:30 pm |   |  
				| 
 |  
				|  	  | 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!!
 |  | 
	
		|  | 
	
		|  |