??? 07/18/06 15:41 Modified: 07/18/06 16:33 Read: times |
#120493 - This will not work properly! Responding to: ???'s previous message |
Dick said:
Use a NPN (e.g. BC547) not PNP (BC557) transistor.
Connect the output pin of the controller to the base of the transistor. Connect the emitter to ground. Connect the collector to the relay and the other side of the relay to +12v. The diode goes over emittor and collecter. When the output pin is high the relay goes on. You mean something like that (free wheel diode corrected)? ![]() This circuit will not work, unfortunately! Have a look at standard port citcuitry inside 80C52 to find out why: pFET1 provides a strong pull-up and is turned-on for only two oscillator periods of micro. Whenever a 1s is going to be written into the according SFR (port latch), pFET1 is turned-on for two oscillator periods. pFET2 is turned-on, whenever 1s is written into the according SFR. It's permanently on, not only for two oscillator periods like pFET1. pFET2 serves as a very weak pull-up. Although not being a resistor but more a current source, pFET2 roughly behaves like a resistor of about 100...200kOhm. pFET3 is a weak pull-up, roughly behaving like a resistor of about 10...20kOhm. pFET3 is active, whenever the port pin is at high level. Now: When you have a pn-junction connected from port output to ground, then you force the output potential to be about 0.7V. But this will turn-off the weak active pull-up pFET3, leaving only the very weak active pull-up pFET2 driving the transistor, which results in about 20µA base current. This is not enough to fully turn-on the transistor and allowing a collector current of 30mA to flow, and this at a needed low collector emitter saturation voltage! Also, whenever 1s is written into the SFR of according port, pFET1 is turned-on for two oscillator periods and drives an enormous current into the base of transistor, not necessarily destroying the transistor, but causing huge ground noise due to the brief short circuit. Kai |