transistor or mosfet instead of relay  - Page 1
Forum section: electronics / beginners

author: Turbochardged
author_rank: Contributor
timestamp: April 15, 2021, 02:33:50 pm
content: I'm currently using a 12V 20A relay to switch on and off a 12v 500ma timer. I'm not sure on what to use. I was thinking of using a transistor or mosfet, But i'm not sure on what and why. Does anyone have have a part they recommend? Currently the relay is powered 247, when the power drops out, the timer turns on.

author: tooki
author_rank: Super Contributor
timestamp: April 15, 2021, 05:18:29 pm
content: Please explain the current setup better. What is driving what exactly? Can you explain what you're trying to do exactly?

author: AmnevaR
author_rank: Contributor
timestamp: April 15, 2021, 05:19:41 pm
content: Maybe N-channel mosfet as a switch circuit is what you need?Instead of the switch you can feed any signal to the gate of the mosfet (within reason of course, look at mosfet's datasheet)https://circuitdigest.com/electronic-circuits/simple-mosfet-switching-circuit-how-to-turn-on-turn-off-mosfets

author: pigrew
author_rank: Frequent Contributor
timestamp: April 15, 2021, 05:27:37 pm
content: One key advantage of a relay is isolation; there is no electrical connection from the primary to the secondary.Is your control signal AC or DC? 12V logic? 5V logic?Is your load AC or DC? Does it need electrical isolation from the control signal?How often do you need to switch the load?A photo of your setup could also be helpful.

author: Turbochardged
author_rank: Contributor
timestamp: April 15, 2021, 05:38:44 pm
content: No isolation is needed. Basically a 12v DC 3A supply feeds a touch bar sensor that disconnects 12v when touched. I have a 12v DC 500mA timer that activates a 12v DC 30mA sounder. Since the touch bar drops power when activated, I have it connected to a 12v DC relay (C, NO). When the relay dies, it powers the timer and sounder until the bar is released.

author: Turbochardged
author_rank: Contributor
timestamp: April 15, 2021, 05:55:12 pm
content: I was thinking about a high output transistor. I have a few " TIP42C" and with a 10k across the base and emitter and a 2k from the touch bar 12v dc output to the base. The tip42c has a -5v Vebo.

author: ledtester
author_rank: Super Contributor
timestamp: April 16, 2021, 02:43:37 am
content: Quote from: Turbochardged on April 15, 2021, 05:55:12 pmA schematic would be very helpful.

author: perieanuo
author_rank: Frequent Contributor
timestamp: April 16, 2021, 07:20:30 am
content: if i guess right, you wanna cut power to your timerthe transistor driving the relay coil can drive a pnp transistor with emmiter on 12VDC rail, in that pnp collector you have the voltage for powering your timeror using a mosfet in some equivalent configuration (mosfet is nicer and you'll lose less voltage compairing with pnp solution)the schematic depends on how your transistor drives your relay coil, put the schematic on paper and someone will show you the modifications accordingly

author: Turbochardged
author_rank: Contributor
timestamp: April 16, 2021, 02:49:02 pm
content: Quote from: perieanuo on April 16, 2021, 07:20:30 amActually the opposite.

author: ledtester
author_rank: Super Contributor
timestamp: April 16, 2021, 04:34:59 pm
content: You should tell us how you've programmed the XY-LJ02 -- i.e. which mode it is in:https://www.katranji.com/tocimages/files/438402-214756.pdfThis is my understanding of how the circuit works - let me know if it's correct or not.1. The touch bar normally holds relay RY2 energized which keeps the timer unit de-powered.2. When the touch bar is activated RY2 is de-energized and power is supplied to the XY-LJ02 timer and the piezo alarm.3. If the touch bar is deactivated RY2 is energized and power is cut from the timer and piezo.4. If power remains supplied to the timer for some period of time the XY-LJ02 connects the NO and C terminals which energizes RY1.5. When RY1 is energized it latches becoming permanently latched. This make the piezo alarm sound whether RY2 is energized or not.So it seems you want an piezo to sound when the touch bar is touched and not sound when it's not touched except you want it to sound permanently if the touch bar is touched for more than a certain amount of time.

author: Turbochardged
author_rank: Contributor
timestamp: April 16, 2021, 06:39:48 pm
content: Quote from: ledtester on April 16, 2021, 04:34:59 pmYou got it. The timer is used in "P4" so the count down starts upon energize.

author: ledtester
author_rank: Super Contributor
timestamp: April 16, 2021, 07:10:38 pm
content: An Arduino would be ideal for this kind of timing logic. You could replace the XY-LJ02 and both relays with an Arduino and a transistor.Note that the XY-LJ02 is just a pre-programmed Arduino + a relay. If you could change its program you could get rid of the other relays. But Arduinos are so cheap you might as well just get one and program it yourself.

author: perieanuo
author_rank: Frequent Contributor
timestamp: April 19, 2021, 06:54:11 am
content: Quote from: Turbochardged on April 16, 2021, 02:49:02 pmwell, your schematics shows i'm right, you have the relay cutting/giving power to that timeranyway, what i said before stays, just as someone sayd, arduino that drives some bjt/mosfet like i proposed is also my recommended solution, cheap, simple so reliable

author: Turbochardged
author_rank: Contributor
timestamp: April 19, 2021, 01:28:26 pm
content: I'm not good at programming arduinos. What would a simple mosfet replacement look like?

author: ledtester
author_rank: Super Contributor
timestamp: April 20, 2021, 04:06:20 am
content: This is what an Arduino program would look like:Code:#define TOUCHBAR_PIN 5#define ALARM_PIN 6#define RESET_PIN 7// TIMER LIMIT is in milliseconds, 5000 = 5 seconds#define TIMER_LIMIT 5000// 0 = timer not started, 1 = timer started, 2 = timer reached limitint state;unsigned long touch_time; // when the touch bar was last touchedvoid setup() {pinMode(TOUCHBAR_PIN, INPUT); // input from touchbarpinMode(ALARM_PIN, OUTPUT); // connected to gate of MOSFET, activates alarm when set to 1pinMode(RESET_PIN, INPUT); // input from reset buttondigitalWrite(ALARM_PIN, 0);state = 0;}void loop() {if (state == 0) {if (digitalRead(TOUCHBAR_PIN)) {digitalWrite(ALARM_PIN, 1);touch_time = millis();state = 1;} else {digitalWrite(ALARM_PIN, 0);}} else if (state == 1) {if (digitalRead(TOUCHBAR_PIN)) {unsigned long elapsed = millis() - touch_time;if (elapsed > TIMER_LIMIT) {state = 2;}} else {digitalWrite(ALARM_PIN, 0);state = 0;}} else {if (digitalRead(RESET_PIN)) {digitalWrite(ALARM_PIN, 0);state = 0;}}delay(1); // delay a millisecond}