How to Protect Your Circuits Using a IRF540N
by That Easy Engineer in Circuits > Electronics
37 Views, 0 Favorites, 0 Comments
How to Protect Your Circuits Using a IRF540N

So you want to protect your electronics when you make a mistake by accidentally swapping the positive and negative, hmm? Well, I have the (almost) perfect solution for you! If using one component to solve your +12V reverse polarity issue sounds great, then keep scrolling!
Supplies



.jpg)
.jpg)
.jpg)
.jpg)
The list of materials that you will need are as follows:
- A P-channel MOSFET (if you use an N-channel MOSFET, you will need to refer to datasheet, but the concept is generally the same) --> I used the IR540N P-channel MOSFET
- Two 470 ohm or higher value resistors (for the LEDs) ---> I calculated this using this link
- A 220 ohm (I know it's not in the video, but just try to use it for the gate of the transistor - just to be safe)
- A 12V power adapter (wall)
- A red and green LED
- A breadboard
- *Optional* - 4 push buttons
Hookup
)



So a question you might have is why the push buttons are optional, or better yet, why they are even a thing. Well, I added the push buttons as a test feature. They were more or less for visual effect/experimentation. In a practical setting, you can just swap the wires from positive and negative to negative and positive. It's the same thing, I just wanted to demonstrate how it worked. Do make sure to check out the notes in the images and ask questions down in the comments if something is not clear. I promise, I won't bite!
To start, make sure you have your materials ready. Plug the 12V wire (positive - also make sure the circuit is off) into the source hole (on the breadboard - with the transistor in the sockets you choose). If you are connecting the push buttons, you can just connect the 12V to the farthest switch (mine is on the right - in my video I called it P3).
Next, you'll want to connect GND (negative) to the gate of the transistor. Do note that you need a resistor for the gate of the transistor, so make sure to plug in the 220 ohm resistor in front of the +12V. The reason why the gate (I guess it could be optional, but I like to keep my expensive stuff - AKA the IRF540N - safe) needs a resistor is to protect the other circuits attached to it. Here is a link for more information (about the second or third paragraph). In my opinion, it could be because of accidental voltage spikes. All in all, it's just a good idea all around.
Anyway, if you are connecting the push buttons, GND will go to P1 (the first switch). The purpose of the switches is to "simulate" a reverse polarity. In essence, it is taking one side of the switch to positive and the other side to negative. I, effectively, made an AND gate. Pretty cool, huh?
Next, connect one lead of the 470 ohm resistor to the gate of the transistor. Connect the other lead to the positive of the green LED. Connect the green LED's cathode (negative) to drain of the transistor. Next, connect the other 470 ohm lead to the gate as well to the gate. Connect the other lead of the resistor to the anode of the red LED. Last, connect the red LED's cathode to the source of the transistor. Yes, my schematic shows it going to the drain, but, honestly, it connects the same (since we are using the transistor, effectively, as a switch). And, yes, the setup is the same for the push buttons.
Before moving on, I want to mention something I forgot to tell you. You need to daisy-chain the 12V positive to the other push button (I chose P3 and P4 as positive) and daisy-chain GND to the other push button (P1 and P2). Also, make sure to connect the output of the button to the input of the gate and drain. So, P1 goes to the gate and P3 (as they are the positive and negative pair) goes to the source. P2 goes to source and gate. So, essentially, they are "flip-flopped" or inverted.
Power It Up!
Yeah, I think this one is pretty self-explanatory, but, just in case, you need to plug in the wall adapter to power on the circuit. Yes, don't forget this step, otherwise, your circuit won't work.
Testing
To test it, push P1 and P3 simultaneously. DON'T PRESS THEM AT THE SAME TIME, OTHERWISE YOU WILL CREATE A SHORT!!! Once you have verified that the green LED turns on, time to test the other circuit. Test #2 is just pressing - you guessed it - P2 and P4 at the same time. The red LED should turn on now.
If, however, you are just testing with just the wires, you just swap the two wire's placement. So, from 12V on the gate, switch that to the source. Take the GND from source to gate. Simple.
Troubleshooting/Comments
If you have any questions, or you need help with this project, please comment down below. Again, I promise I don't bite. I am more than happy to answer any relevant - I should say - questions to the project. And as always, I am That Easy Engineer and thanks for reading, and happy testing!