Go Down

Topic: Tansistor help to power motors (Read 2 times) previous topic - next topic

patduino

Can you post your code?  Put it in a code block by selecting it and pressing the # button above.

It might help find the problem.
There are 10 types of people in the world, those that understand binary, and those that don't.

harshvardhan

ok
everything is working fine with the 3904 !

(i burned up 3 of those, , but got one running in the SAME breadboard)


harshvardhan

Code: [Select]
#define fadePin 9

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

void loop(){

  for(int i = 0; i<360; i++){
    //convert 0-360 angle to radian (needed for sin function)
    float rad = DEG_TO_RAD * i;

    //calculate sin of angle as number between 0 and 255
    int sinOut = constrain((sin(rad) * 128) + 128, 0, 255);

   
    analogWrite(fadePin,sinOut);
if(sinOut==0)
delay(200);
    delay(15);
  }

}



im 100% sure that the code is not wrong(its too basic to go any wrong !)

patduino

#18
Jan 11, 2013, 03:34 am Last Edit: Jan 11, 2013, 04:24 am by patduino Reason: 1
Yes, the code looks fine.  I even tested it myself to make sure that the sinOut variable went the full range from 0-255, which it does.

Motors have a very low resistance and require a lot of current (which is why the 3904 got so hot).  This is why the project plan required the high-current Darlington transistor.  

If you haven't yet - go back to your original design with the TIP-120 or -122 and make sure you include the resistor and diode.  If you can, try a fresh transistor:

Quote from http://bildr.org/2011/03/high-power-control-with-arduino-and-tip120/

Quote
What's the diode used for?
This circuit is pretty simple. This type of transistor is switched by current and not voltage, so we need to make sure to supply the correct current to the base to switch it, so a resistor is connected from the Arduino to the base to limit the current to the proper amount.

You can see that in ... illustrations, there is a diode parallel to the device we are powering. Any time you are powering a device with a coil, such as a relay, solenoid, or motor, you need this guy, and don't leave home without it. What happens is when you stop powering the coil, a reverse voltage, up to several hundred volts, spikes back. This only lasts a few microseconds, but it is enough to kill our transistor. So this diode (only allows current to pass one way) is normally facing the wrong direction and does nothing. But when that voltage spikes comes flowing the opposite direction, the diode allows it to flow back to the coil and not the transistor. We will need a diode fast enough to react to the kickback, and strong enough to take the load. A rectifier diode like the 1N4001 or SB560 should do the job. If you are looking for extra protection you could use an optoisolator between the Arduino and the transistor. An optoisolator optically isolates both sides (high and low power) of the circuit so the high-voltage can not possibly come back to the microcontroller.

Just make sure that protection diode is facing the correct way (stripe facing the V+ of device). If it is facing the wrong direction, the device you are trying to power will not work as the diode will just allow the current to bypass it.
There are 10 types of people in the world, those that understand binary, and those that don't.

harshvardhan

i have been thinking about it

whats the point of having 4 transistors in an H-Bridge?
i mean, wont i be able to reverse, foward and stop a motor using just two transistors?

Go Up