I'm pretty new to using transistors and I'm trying to make nfc doorlock. My electoric doorlock is working on 9V and 280-530mA, and have resistance about 20 Ohms. I'm powering it from external 9V power supply. I have transistor BC557 datasheet. I'm connecting output pin to base of transistor and putting between them 200 Ohm resistor. But tranistor won't go into active state. I'm using arduino uno r3, and voltage on output pin is almost 5V and can provide 20mA. What am I doing wrong? How do i calculate correct resistance?
There are a few problems with that circuit.
- The lock can draw up to 530mA. This means that the transistor must be able to pass 530mA from collector to emitter without damage. In the datasheet, in the Maximum Ratings - Collector Current Continuous the BC557 has a maximum rating of 100mA. If you tried using that transistor then it would burn up and fail.
- The 200 Ohm resistor would allow 21.5mA to flow from the I/O pin into the base of the transistor. That is just beyond the maximum for the Arduino I/O pin (20mA). It's not a serious problem, and the Arduino would tolerate it, but as a general design rule you shouldn't run a microcontroller I/O pin at its maximum current.
- Assuming that the lock is some sort of solenoid, when you turn off the current flowing through it you get a large back emf (voltage) generated by the solenoid which could damage the transistor. To protect against this you need to put a reverse biased diode across the lock. It's usually called a back emf diode.
You could use a "bigger" bipolar transistor, one with a Max collector current of more than 530mA. Again, playing safe, I would go for one with at least 1A maximum. However, 1A transistors typically have a low current gain and are difficult to drive from an Arduino. So for simplicity I would use an N-channel MOSFET. The following shows the schematic diagram.
D1 is the back emf diode.
Q1 is a N-channel MOSFET. It's one that I am familiar with, although it is a surface mount device.