> I'm attempting to have a PIC 16F877 in my project controll a small cooling > fan. The fan is a 5V 0.09A dc brushless type, and is connected to a > transistor which actualy drives the fan, it is connected like so: > > Transistor is a typical PNP 2N3906.. > Base through a 4.7K resistor to a PIC I/O pin, > Emitter to +5, > Collector to + side of fan, with a 4.7K resistor pulling to ground. I see no reason for this resistor, although this isn't causing your problem. > (-) side of fan to ground, small diode between the +/- side to block any > return voltages. > > By setting this I/O pin (PORTE,2) low, the fan comes on as expected. > However i cannot turn the fan off by setting the port high! If i jumper +5 > directly to the i/o pin manualy the fan goes off Check the +5 supply. Is the fan causing it to droop? Glitching it? Is everything properly bypassed? Keep in mind that the fan startup current will be much higher than the continuous current of 90mA. A properly operating PIC will have no problem driving a 4.7K resistor with the other end anywhere from 0 to 5 volts. What is the voltage at the PIC pin when the fan won't go off? Overall, I think this is either a power supply problem, or more likely a software bug where the port latch is getting set low when you don't expect it. ******************************************************************** Olin Lathrop, embedded systems consultant in Littleton Massachusetts (978) 742-9014, olin@embedinc.com, http://www.embedinc.com -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.