1

With my team we constructed a circuit using Arduino. The circuit works on the Proteus simulator. It worked fine with LEDs connected directly to Arduino outputs.

However, when I used Arduino output to trigger a BC 337 transistor to try and actuate a 12 V DC coiled relay, it wouldn't trigger. I measured voltage across transistor collector and emitter, it reads 12 V, just like the source I gave... (The transistor is not switched on I guess).

Supply for the Arduino is a constant 5 V DC.

Where have I gone wrong? Picture as uploaded.

Full circuit

Furthermore, we are trying to build a controller for an ice making machine. The power circuit (12 V) is to be controlled by Arduino through the transistors.

I am uploading the codes we used and the full circuit diagram.

const int start = 13;
const int comp= 2;
const int cond=3;
const int hGas=4;
const int wbut=12;
const int watersol=5;
const int dumper=6;
const int iced=11;

int startButton=0;
int waterButton=0;
int dumperlimswitch=0;

void setup() {

  pinMode(start, INPUT);    
  pinMode(comp, OUTPUT);    
  pinMode(cond, OUTPUT);    
  pinMode(hGas, OUTPUT);    
  pinMode(wbut,INPUT);    
  pinMode(watersol, OUTPUT);    
  pinMode(dumper, OUTPUT);    
  pinMode(iced, INPUT);
}

void loop() {

startButton = digitalRead(start);
waterButton = digitalRead(wbut);

 if (startButton == HIGH) {

    digitalWrite(comp, HIGH);
    digitalWrite(cond, HIGH);

    waterButton = digitalRead(wbut);
    if (waterButton == HIGH){
      digitalWrite(watersol,HIGH);
      }
    else{
      digitalWrite(watersol,LOW);
      }
     delay(800);
    digitalWrite(hGas,HIGH);
    digitalWrite(cond, LOW);

    waterButton = digitalRead(wbut);
    if (waterButton == HIGH){
      digitalWrite(watersol,HIGH);
      }
    else{
      digitalWrite(watersol,LOW);
      }
    delay(500);
    digitalWrite(hGas, LOW);
    digitalWrite(dumper, HIGH);
    digitalWrite(cond, HIGH);

    waterButton = digitalRead(wbut);
    if (waterButton == HIGH){
      digitalWrite(watersol,HIGH);
      }
    else{
      digitalWrite(watersol,LOW);
      }
    delay(800);
    digitalWrite(dumper, LOW);
  } 
else {
    digitalWrite(comp, LOW);
    digitalWrite(cond, LOW);
  }
}
19
  • 1
    Circuit...? Code...?
    – Majenko
    Commented Jun 6, 2017 at 15:42
  • 1
    What's an ardinho?
    – gre_gor
    Commented Jun 6, 2017 at 15:44
  • 1
    @gre_gor It's what you get after you use a "Harduino".
    – Majenko
    Commented Jun 6, 2017 at 15:49
  • 1
    What is pin 13 doing? Are you putting 12V into p13? Can you take the Arduino out of the equation, just supply 5V out into the wire that would have been pin 2? I don't think your problem is an Arduino one, it would have been nice to see the code, but if its working with LEDs then it looks like an electronics issue and would be better on Electronics Exchange. But if you include Arduino in it they will send it back here :) Commented Jun 7, 2017 at 11:48
  • 1
    @Greenonline - I broke the image links not the OP. Sorry :( Commented Jun 8, 2017 at 11:24

2 Answers 2

2

TL/DR: Your LEDs without resistors are diverting all the current away from the transistors so they are unable to switch.

In detail:

Let's take a quick look at just one small portion of your circuit in more detail:

schematic

simulate this circuit – Schematic created using CircuitLab

I have added an extra resistor into the circuit - Rw - which represents the resistance of the wires and pins of the LED, and I have given it a nominal 0.1Ω value.

Now, let's say you set the GPIO HIGH, so it outputs 5V. The LED, D1, is a typical red LED with a forward voltage of, say, 2V. Let's calculate the current through the LED.

  • I = (VCC - VF)/R = (5 - 2) / 0.1 = 3 / 0.1 = 30A

30A?! But the GPIO can't provide more than 40mA absolute maximum. So all that can come from the GPIO is being sent straight through the LED leaving nothing (much) for the transistor.

Oh and yes, all that current demand is doing unspeakable damage to the Arduino's GPIO pin.

The transistor's Base-Emitter junction has about a 0.7V drop across it, and, if it weren't for the LED, with the 1kΩ resistor that gives (5-0.7)/1000 = 4.3mA. Which with a hFE of around 100, would give a collector current of around 430mA. And that should be fine for most small relays.

But with all the current being dumped through the LED what can get through to the transistor won't be enough to turn on the relay.

So increasing the resistance of the wire to the LED will decrease the current demands of the LED. And of course you do that by adding a resistor. So let's make that 1kΩ - a decent enough value for a simple indicator LED:

schematic

simulate this circuit

Now let's do the calculation for the LED's current:

  • I = (VCC - VF) / R = (5 - 2) / 1000 = 3 / 1000 = 3mA

Add that to the 4.3mA that wants to go through the transistor, and we have 7.3mA in total.

Now that is way below what the Arduino's GPIO can provide, so the IO pin is happy, the LED is happy and, most importantly, the transistor is happy.

0
1

This is not an answer but its too big to be a comment. I can't solve your problem, but hopefully I can point you in the right direction.

I think the first problem you have is you have talked this problem in one chunk. I think even some of the more experienced users would have a problem hitting this in one go. You need to break it down into simple units (Functional decomposition if you want to be posh).

The problem you are asking about is why your transistor doesn't work. You have used an LED and you think the correct signals are being sent.

So Phase one, take the transistor and test it in isolation, then you know its working. Secondly does it still work when the Uno is controlling it rather than just a battery?

Does the object you are powering via the transistor work on its own? Does it work when you add it to the uno and transistor?

You get the idea. To be honest I suspect it might be an issue with lack of power.

3
  • thanks @code Gorilla , yes, i guess, i'll have to break it down. somehow, i thought of giving a full picture. Commented Jun 8, 2017 at 11:54
  • The either the transistor is broken or its not getting enough current from the uno. Commented Jun 8, 2017 at 12:01
  • and:the uno is giving the output signals alright. correctly as per the program. however, the uno output signal is not firing up the transistor. the battery is a secondary circuit. the transistor was supposed to close that secondary circuit . secondly, yes the object i am trying to power through the transistor works fine. yes you may be right, the voltage reaching the base of the transistor is 0.7v (due to the 1k ohm resistor, ) i am lowering that value. but somewher i also read that even if the transistor fires, it shall limit the voltage to 4.3 volts . he suggests to use mosfet. Commented Jun 8, 2017 at 12:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.