When I first apply power to the board the relay switch for a short time. If I change the base resistor to a bigger one it stops (i assume base current gets lower). What is the explanation for this? How can I avoid this behaviour without compromise the relay current?
Thanks in advance.
Ric
P.S PIC software is not doing any write to outputs at the beggining (not intentionally at least)
It may mean that the Power On Reset signal has not yet forced the output drivers to known states and/or disabled internal pullups ..
You can call it a gap in output pin tracking (Vcc ramp), as the pins remain unconfigured until the configuration point ..
I was thinking about this possibility. I've tried to insert a pull down resistore right before transistor base but it make no difference (maybe it was not the correct value though).
I was thinking about this possibility. I've tried to insert a pull down resistore right before transistor base but it make no difference (maybe it was not the correct value though).
You have a low-high-low spike on your IO output at power on, called transitory spike.Without any changing in your schematic you may avoid that using an RC filter between the IO output and transistor input and/or choosing carefully the software delays between defining the IO port as output and pull down moment.
Try IO to 2k2 + 47nF...100nF to ground. The resistor from the transistor's base connected to common point 2k2+47nF. This delay will be added also every time when relay will be connected. However the best relay you may get, it has more than 8mS between the coil supply time and contact make/brake.
if i was you i would change the npn transistor for a pnp type and then you would put a pull up resistor from the base of the transistor to vcc, this will hold the relay off until you changed the pic output pin to a low state.