A discussion group for the PICMicro microcontroller. Also called the Microchip PIC, this list is dedicated to the use and abuse of this fine, simple, microcontroller. Close to topic posts are welcome, ie. general electronics.
|
Hello to everyone, I would like to make two questions. First of all i noticed that when i power up one pic at the very first (not even second) the output of its ports is somehow random and after reading some code they become as they are supposed to be. Is there any way that at the very beginning they have some predefined condition. Let say one port is connected to a relay. When i sometimes power up the pic i hear the "click" sound. Of course i don't want the relay to work at that time. Second, is it ok to connect an input port directly to Vcc or is it neccessary to put a pull up resistor. (Sould I activate the on-chip pull-up resistors? Sould the port be destroyed otherwise? Thank you all in advance, Have a nice day, Nikolaos Trikoupis |
|
|
|
Powering up (or down) any type of circuit may cause an unstable condition activating an output. This is true in any and all types of electronic control circuits. If it is important for this not to occur, you may want to delay the power energizing the relay(s). I designed an automation system for a radio station some years back and every time there was a mains power interruption, all the machines would start. I had to "fast off, slow on" circuit in the relay power circuit. In your application, all that may have to be added is a transistor, capacitor and resistor. Never tie port pins directly to +5 or ground. In the event of a wrong command, glitch, or power up condition, you could latch up the port so it may try to drive low when it tied high and thus damage the port pin. Good engineering practice is to pull them high so as an output, it won't matter and as an input, an erronious read won't cause an unstable software condition. Your software should always set the ports to outputs unless needed. Rick ntricoup wrote: > Hello to everyone, > > I would like to make two questions. > > First of all i noticed that when i power up one pic at the very first > (not even second) the output of its ports is somehow random and > after reading some code they become as they are supposed to be. Is > there any way that at the very beginning they have some predefined > condition. Let say one port is connected to a relay. When i > sometimes power up the pic i hear the "click" sound. Of course i > don't want the relay to work at that time. > > Second, is it ok to connect an input port directly to Vcc or is it > neccessary to put a pull up resistor. (Sould I activate the on-chip > pull-up resistors? Sould the port be destroyed otherwise? > > Thank you all in advance, > Have a nice day, > Nikolaos Trikoupis |
|
--- In , "ntricoup" <ntricoup@y...> wrote: > Hello to everyone, > > I would like to make two questions. > > First of all i noticed that when i power up one pic at the very first > (not even second) the output of its ports is somehow random and > after reading some code they become as they are supposed to be. Is > there any way that at the very beginning they have some predefined > condition. Let say one port is connected to a relay. When i > sometimes power up the pic i hear the "click" sound. Of course i > don't want the relay to work at that time. > > Second, is it ok to connect an input port directly to Vcc or is it > neccessary to put a pull up resistor. (Sould I activate the on-chip > pull-up resistors? Sould the port be destroyed otherwise? > > Thank you all in advance, > Have a nice day, > Nikolaos Trikoupis It is a good idea to always assign a safe value to any variable upon declaring it in you code. By safe I mean if that variable controls a relay like your example, always set the intial value to something that will not energize the relay. Secondly, with the exception of the power and ground pins, you should never tie a pin to Vcc or GND, always use a pull-up or pull-down resistor. Most all pins can be either input or output. If tied high or low and you inadvertently make it an output and set it to the opposite state that it is hard-wired to then you risk destroying that pin or the entire PIC. Mike |
|
|
|
--- In , "mikerey35475" <mwrey@b...> wrote: > --- In , "ntricoup" <ntricoup@y...> wrote: > > Hello to everyone, ... > > Secondly, with the exception of the power and ground pins, you should > never tie a pin to Vcc or GND, always use a pull-up or pull-down > resistor. Most all pins can be either input or output. If tied high > or low and you inadvertently make it an output and set it to the > opposite state that it is hard-wired to then you risk destroying that > pin or the entire PIC. the main issue that you could inadvertently create a short-circuit which would definitely exceed the mA rating of the pin in question. Using a limiting resistor will prevent that. Now, if you KNOW that you will never create the short circuit, then its ok but it is definitely a potential landmine waiting to be stepped on. I'd put copious notes in the source code so that you don't screw-up down stream. |
|
|
|
Good advice so far. Let me add a little additional info/opinion. Safe is to make all unused pins outputs and leave them unconnected. Six sigma safe is to make all unused pin outputs and tie them with a high value resistor either high or low. The PIC is designed to have all I/O pins power up as high impedance, therefore design the interface so that high impedance yields a proper power up condition. Set the outputs to the correct values, then enable the outputs. Applying power to any pin before the PIC is a disaster, but the interface can look like power, i.e., you are driving a relay with an output pin. If that relay is powered before the pic, the output pin is as good as connected to the power supply, and the PIC will not work, or worst case, some smoke, maybe fire, the curtains may catch next, then your house, spreading to the neighborhood, then wildlands. Massive lawsuits for neglegence then result, possible divorce, and jail time. :-p Chad --- Phil <> wrote: > --- In , "mikerey35475" <mwrey@b...> wrote: > > --- In , "ntricoup" <ntricoup@y...> wrote: > > > Hello to everyone, > .... > > > > Secondly, with the exception of the power and ground pins, you > should > > never tie a pin to Vcc or GND, always use a pull-up or pull-down > > resistor. Most all pins can be either input or output. If tied high > > > or low and you inadvertently make it an output and set it to the > > opposite state that it is hard-wired to then you risk destroying > that > > pin or the entire PIC. > > the main issue that you could inadvertently create a short-circuit > which would definitely exceed the mA rating of the pin in question. > Using a limiting resistor will prevent that. Now, if you KNOW that > you will never create the short circuit, then its ok but it is > definitely a potential landmine waiting to be stepped on. I'd put > copious notes in the source code so that you don't screw-up down > stream. ===== My software has no bugs. Only undocumented features. __________________________________ |
|
|
|
On Sat, 12 Jun 2004, mikerey35475 wrote: > --- In , "ntricoup" <ntricoup@y...> wrote: > > Hello to everyone, > > > > I would like to make two questions. > > > > First of all i noticed that when i power up one pic at the very > first > > (not even second) the output of its ports is somehow random and > > after reading some code they become as they are supposed to be. Is > > there any way that at the very beginning they have some predefined > > condition. Let say one port is connected to a relay. When i > > sometimes power up the pic i hear the "click" sound. Of course i > > don't want the relay to work at that time. > > > > Second, is it ok to connect an input port directly to Vcc or is it > > neccessary to put a pull up resistor. (Sould I activate the on-chip > > pull-up resistors? Sould the port be destroyed otherwise? > > > > Thank you all in advance, > > Have a nice day, > > Nikolaos Trikoupis > It is a good idea to always assign a safe value to any variable upon > declaring it in you code. By safe I mean if that variable controls a > relay like your example, always set the intial value to something > that will not energize the relay. > > Secondly, with the exception of the power and ground pins, you should > never tie a pin to Vcc or GND, always use a pull-up or pull-down > resistor. Most all pins can be either input or output. If tied high > or low and you inadvertently make it an output and set it to the > opposite state that it is hard-wired to then you risk destroying that > pin or the entire PIC. Mike, you have right. However I test some similar situation with the one mentioned above. Power dissipation depends a lot from the PIC package. As an example a PIC12F675 in DIP8 package (I know you are playing with this, so you may check) keeped in shortcircuit *with just one output pin* will have a dT/dt (where T is temperature and t is time) greater than a PIC16F628 in the same circumstances (including the starting package temperature which must be the same). With other words, keeping one PIC pin in short-circuit (ie PIN is digitally output and short circuited to gnd, Vcc is 5V) will not distroy the PIC only if the package dissipated power is greater than maximum rating specified. If you keep the supply up to 3V, will be no problem for a long time shortcircuit or more than one pin in shortcircuit. my english stinks, please accommodate :) best regards, Vasile |
|
On Sun, 13 Jun 2004, Chad Russel wrote:
> The PIC is designed to have all I/O pins power up as high impedance, > therefore design the interface so that high impedance yields a proper > power up condition. Set the outputs to the correct values, then enable > the outputs. What if, the output are set to correct values, then the output are enabled, but when power on the relays are still clicking for a short time ? :) This is a transitory power on. PIC outputs are high and when power on are going low for a very short time but enough to make the user crazy... > Applying power to any pin before the PIC is a disaster, but the I will not be so affirmative. You may power a PIC just from the analogic signal aplied on an AD input pin. There is no disaster there. Just another current flow than usualy is. The signal current must be high enough to supply the PIC and the rest of the circuit. Internal protection diode (that one connected to Vcc) will be on. Of course you can't pass 100mA through it. best regards, Vasile |
|
|
|
. Hi guys, the subject line left me thinking it as the typical montly notice on how to behave on the list, or about spam and yahoo. please do the rest of us a favor and make the subject line reflect the actual topic under discussion. Dave --- In , "Phil" <phil1960us@y...> wrote: > --- In , "mikerey35475" <mwrey@b...> wrote: > > --- In , "ntricoup" <ntricoup@y...> wrote: > > > Hello to everyone, > ... > > > > Secondly, with the exception of the power and ground pins, you > should > > never tie a pin to Vcc or GND, always use a pull-up or pull-down > > resistor. Most all pins can be either input or output. If tied high > > or low and you inadvertently make it an output and set it to the > > opposite state that it is hard-wired to then you risk destroying > that > > pin or the entire PIC. > > the main issue that you could inadvertently create a short-circuit > which would definitely exceed the mA rating of the pin in question. > Using a limiting resistor will prevent that. Now, if you KNOW that > you will never create the short circuit, then its ok but it is > definitely a potential landmine waiting to be stepped on. I'd put > copious notes in the source code so that you don't screw-up down > stream. |
|
Yes, you are quite correct. I was being a little general. The real problem occurs when an input/output pin rises above the VDD clamp diode level(even a very short time) with impedance low enough to supply the PIC. From experience, I can tell you this makes for some almost magical operating senerios, often from the reset circuitry. If your relays chatter, you need to figure out why, and correct the problem. If you can remove the PIC, the circuit should come up properly with or without the PIC installed. On power up, I like to think of the PIC as an inert lump. Once it has reset properly, checked itself out if possible, then it is ready to grab the reigns and do something. Chad --- Vasile Surducan <> wrote: > > On Sun, 13 Jun 2004, Chad Russel wrote: > > > > > The PIC is designed to have all I/O pins power up as high > impedance, > > therefore design the interface so that high impedance yields a > proper > > power up condition. Set the outputs to the correct values, then > enable > > the outputs. > > What if, the output are set to correct values, then the output are > enabled, but when power on the relays are still clicking for a > short time ? > > :) This is a transitory power on. PIC outputs are high and when power > on > are going low for a very short time but enough to make the user > crazy... > > > > > Applying power to any pin before the PIC is a disaster, but the > > I will not be so affirmative. You may power a PIC just from the > analogic > signal aplied on an AD input pin. There is no disaster there. Just > another > current flow than usualy is. The signal current must be high enough > to > supply the PIC and the rest of the circuit. Internal protection diode > (that one connected to Vcc) will be on. Of course you can't pass > 100mA > through it. > > best regards, > Vasile ===== My software has no bugs. Only undocumented features. __________________________________ |
|
|
|
I suppose a system could be designed with active high outputs driving a relay through an NPN transistor. When the PIC powered up the IO pins would be defined as input and pulled high through weak pull-up where available. I don't know if that will forward bias a transistor or not but it might. It would certainly bias one of those darlington relay drivers. It would probably be a good idea to set the output values before doing the TRISx thing. A schematic would be helpful. --- In , Chad Russel <chadrussel@y...> wrote: > Yes, you are quite correct. I was being a little general. > > The real problem occurs when an input/output pin rises above the VDD > clamp diode level(even a very short time) with impedance low enough to > supply the PIC. From experience, I can tell you this makes for some > almost magical operating senerios, often from the reset circuitry. > > If your relays chatter, you need to figure out why, and correct the > problem. If you can remove the PIC, the circuit should come up > properly with or without the PIC installed. On power up, I like to > think of the PIC as an inert lump. Once it has reset properly, checked > itself out if possible, then it is ready to grab the reigns and do > something. > > Chad > > --- Vasile Surducan <vasile@s...> wrote: > > > > > > > > On Sun, 13 Jun 2004, Chad Russel wrote: > > > > > > > > The PIC is designed to have all I/O pins power up as high > > impedance, > > > therefore design the interface so that high impedance yields a > > proper > > > power up condition. Set the outputs to the correct values, then > > enable > > > the outputs. > > > > What if, the output are set to correct values, then the output are > > enabled, but when power on the relays are still clicking for a > > short time ? > > > > :) This is a transitory power on. PIC outputs are high and when power > > on > > are going low for a very short time but enough to make the user > > crazy... > > > > > > > > Applying power to any pin before the PIC is a disaster, but the > > > > I will not be so affirmative. You may power a PIC just from the > > analogic > > signal aplied on an AD input pin. There is no disaster there. Just > > another > > current flow than usualy is. The signal current must be high enough > > to > > supply the PIC and the rest of the circuit. Internal protection diode > > (that one connected to Vcc) will be on. Of course you can't pass > > 100mA > > through it. > > > > best regards, > > Vasile > > ===== > My software has no bugs. Only undocumented features. > > > __________________________________ |
|
|
|
I've met the problem when IO pin direction involved in relay driving was set after a quite long delay after the PIC was supplied. If the relay pins direction are set first, the problem is solved. BTW I was wrong with the pulse polarity, it's a short spike low-high-low. Initially I correct the problem using a RC network, anyway the best relay's response is greater than 2mS (tipical 8-12mS for common relays) so integrating the command with 1-2mS is not a problem. The real problem is when you have 8 relays which are not allowed to switch on in the same time, even by mistake or at power up. I have solution for this. I've guess you too. :) best regards Vasile http://surducan.netfirms.com On Mon, 14 Jun 2004, rtstofer wrote: > I suppose a system could be designed with active high outputs > driving a relay through an NPN transistor. When the PIC powered up > the IO pins would be defined as input and pulled high through weak > pull-up where available. I don't know if that will forward bias a > transistor or not but it might. It would certainly bias one of > those darlington relay drivers. > > It would probably be a good idea to set the output values before > doing the TRISx thing. > > A schematic would be helpful. > > --- In , Chad Russel <chadrussel@y...> wrote: > > Yes, you are quite correct. I was being a little general. > > > > The real problem occurs when an input/output pin rises above the > VDD > > clamp diode level(even a very short time) with impedance low > enough to > > supply the PIC. From experience, I can tell you this makes for > some > > almost magical operating senerios, often from the reset circuitry. > > > > If your relays chatter, you need to figure out why, and correct the > > problem. If you can remove the PIC, the circuit should come up > > properly with or without the PIC installed. On power up, I like to > > think of the PIC as an inert lump. Once it has reset properly, > checked > > itself out if possible, then it is ready to grab the reigns and do > > something. > > > > Chad > > > > --- Vasile Surducan <vasile@s...> wrote: > > > > > > > > > > > > On Sun, 13 Jun 2004, Chad Russel wrote: > > > > > > > > > > > The PIC is designed to have all I/O pins power up as high > > > impedance, > > > > therefore design the interface so that high impedance yields a > > > proper > > > > power up condition. Set the outputs to the correct values, > then > > > enable > > > > the outputs. > > > > > > What if, the output are set to correct values, then the output > are > > > enabled, but when power on the relays are still clicking for a > > > short time ? > > > > > > :) This is a transitory power on. PIC outputs are high and when > power > > > on > > > are going low for a very short time but enough to make the user > > > crazy... > > > > > > > > > > > Applying power to any pin before the PIC is a disaster, but the > > > > > > I will not be so affirmative. You may power a PIC just from the > > > analogic > > > signal aplied on an AD input pin. There is no disaster there. > Just > > > another > > > current flow than usualy is. The signal current must be high > enough > > > to > > > supply the PIC and the rest of the circuit. Internal protection > diode > > > (that one connected to Vcc) will be on. Of course you can't pass > > > 100mA > > > through it. > > > > > > best regards, > > > Vasile > > > > > > > > > ===== > > My software has no bugs. Only undocumented features. > > > > > > > > > > __________________________________ > > > to unsubscribe, go to http://www.yahoogroups.com and follow the instructions > Yahoo! Groups Links |