Operating 12v relay by single power source using L7805 is not working

I am using 12v 800ma power adapter as single source for both my Atmega8 IC and 12v 30A relay , I have used L7805 to Power up Atmega 8 IC .

Taken output from pin 2, the output of pin 2 connected to BC547 base using a 100ohm resistor .
Emitter is connected to -ve and Collector is connected to relay and another end is connected 12+ terminal.

If I connect a 12v relay , the voltage is dropped from 12v to 7v in Emitter, if I remove the relay it is normal to 12v. ( The output of pin 2 is 4.7v ).

If I directly connect the base of BC547 to L7805 output with 100ohm resistor its working ,
If I change to Atmega8 Ic output its not working.

Please help me on this

You should have posted your code using code tags.
Using the 7805 if you look at the data sheet you will notice capacitors used on the Input and Output sides (0.22 uF Input) (0.1 uF Output) and while the latter is optional it's a good design practice.

If you have a DMM which you should I would measure your output (Pin 2) driving your transistor.

You also make no mention of your relay coil current but I assume it's under 80 mA since the BC547 is only good for 100 mA Emitter Collector.

Ron

Thanks for ur reply,
The coil current is 70 mA. I have mentioned the pin 2 output is 4.7 v. Can u pls suggest some solutions.

This may be a silly question, but your drawing shows the 7805 ground pin, the Atmega 8 ground pin, and the BC547 emitter all connected together. But are they also connected to the negative terminal of the 12V power supply?

Try using a 1K resistor instead of 100 ohms, and tell us the voltage on the three BC547 pins, on pin 2, and on the 5V output of the 7805, all with respect to ground.

Also, you should have capacitors on the 7805 input and output, as shown in the datasheet.

100R base resistor is too low, pulls 40mA from output pin (should be 20mA or less), try 470 ~ 560), collector V should fall to less than 1V.

Your circuit will work as drawn. You should add capacitors on the input and output of the 7805.

I suspect:

  1. your wiring does not match you drawing
  2. you are using a solderless breadboard and have poor connections.

I would connect your meter ground to the 12+ ground and without moving it measure all the other pins on your schematic.
i.e. 7805 in, 7805 out, all 3 pin of the transistor (at the transistor leads). The arduino 5V, Pin 2, ground....etc. You will find one is not as you expect. If your not sure what to expect add numbers to your drawing and post the voltages you measure at those numbers.

One indicatior the connections are not right. The Mega will not output 4.7V into 100 ohms even with the 0.7 volts across the transistor b - e

You should also read this post on Flyback Diodes

Input of 7805 is 12 v and the output of 7805 range from 4.9v to 5v . Ic pin2 output is 4.7v without resistor . If I connect 100 ohm or 220 ohm resistor then base voltage measures is 0.6v . The output of collector is 12v. When i connect a relay to transistor then the voltage drops to 7v, if i removed means it becomes again 12v.

If i use 12v 30 mA relay then its working. If i change to 12v 80mA then the voltage drops from 12v to 7v

After adding a capacitor to 7805 also its not working

So it seems the transistor is only partially turned on, not enough to activate the relay. Assuming you have the wiring connected as you describe, the only explanation I can think of that fits the facts is that you have a software problem, not a hardware problem.

You are missing a "pinMode(2,OUTPUT);" instruction, so pin 2 is still in INPUT mode. So when you execute a "digitalWrite(2,HIGH);" command, all you are doing is enabling the internal pullup resistor, which is something like 35K, so the base resistor is actually the combination of the pullup resistor and your 100 ohms, which is not enough to saturate the 547 transistor.

You say that pin 2 is 4.7V when the resistor is not connected, and the transistor base voltage is 0.6V when you connect the resistor, but what is the pin2 voltage when the base is 0.6V? Is it still 4.7V, or is it very close to 0.6V? If it's the latter, the software explanation is probably the correct one.

The base is 0.6v and the pin 2 value also become 0.6v . I measuring voltage by keeping multimeter +ve to base transistor and -ve of multimeter to 12-ve of power source.

Hi this is my code:

const int trigPin = 11;
const int echoPin = 12;
const int RelayTrig = 0; // ic Pin2
int PumpON_distance = 36; // inches
int PumpOFF_distance = 8; //
void setup() {
Serial.begin(9600);
pinMode (RelayTrig, OUTPUT);
pinMode (A4, OUTPUT);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop() {

long duration, inches;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

inches = microsecondsToInches(duration);

if (inches >= PumpON_distance ) {
digitalWrite(RelayTrig, HIGH); //Switch ON pump
}

if (inches <= PumpOFF_distance ) {
digitalWrite(RelayTrig, LOW); //Switch OFF pump
}

delay(1000);
}
long microsecondsToInches(long microseconds) {

return (microseconds / 74) / 2;
}

You do have the pinMode instruction, but since digital pin 0 is also Rx, perhaps there is some conflict with the serial function. All I can suggest is changing RelayTrig to 4, which I believe would be IC pin 6 on the 28-pin DIP package, and see if that makes any difference.

Could you use your multimeter to measure the current flowing into the base when it's 0.6V?

I found this on page 63 of the datasheet relating to the alternate functions of the I/O ports:

• RXD – Port D, Bit 0

"RXD, Receive Data (Data input pin for the USART). When the USART Receiver is enabled this pin is configured as an input regardless of the value of DDD0. When the USART forces this pin to be an input, the pull-up can still be controlled by the PORTD0 bit."

If Serial.begin enables the USART, then the pinMode instruction would have no effect, and the pin would remain in INPUT mode. But a digitalWrite would still control the pullup resistor. This would explain what is happening. Moving this to digital pin 4 or some other pin would then solve the problem.

This time tried with Nano board with two power supplies . The nano is connected to laptop and the relay is powered by 12v power supply and changed the output to D9 (Even tried pin D4). But now also its not worked

Code Used :

void setup() {
pinMode(9, OUTPUT);
}

void loop() {
digitalWrite(9, HIGH);

}

Connected D9 to Base Transistor BC547 with a resistor 10K and the Emitter is connected to -ve 12V and the collector is connected to Relay .

10k is too high a value for the base resistor. 470Ω (as suggested before) or 1k would be a more sensible value.

Also I don't see a ground connection between the 12V supply and the Arduino.

Thanks for your support, it worked after replacing 1k resistor for base of bc547 in nano board. But I need to check with my Atmega8 IC. Let me check and update that.

With the relay working, check the voltage from BC547 emitter to collector, if more than 0.3V, you need to lower the base resistor to 270 ~ 680, but not lower than 270 (about 16mA base current). I would think 9mA (470 Ohms) would be good.

You also need a flyback diode across the relay coil. If you omit this, you will probably damage or destroy the transistor at some point. And a damaged transistor could explain some of your problems.

Does the relay turn on if you connect the base through a 1k resistor directly to +5v?

Flyback diodes: see:

S.

Thanks for every one support, it worked after replacing 10 k to 1k resistor for base of bc547 in Atmega8 IC .

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.