Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

I am trying to control an electromagnet with a signal from a small microcontroller (a BeagleBone Black). Obviously, I need to amplify the signal. I have a lead from a power source that I want to pass through to something when the pin on my board goes High (3.3v). I think that a relay is what I want here (correct me if I'm wrong), but have no idea how to find one that will do what I need. The separate power supply will range anywhere from 5 Volts 0.5 Amps to possibly 20 Volts 3 Amps. Because of the circumstances where I'll be using these relays, I would rather use solid-state relays so that there aren't more magnets than there needs to be in the vicinity.

Are relays what I'm looking for? If so, are relays that fit these specs available, and what exactly am I looking for?

EDIT: To add some more detail, it will be High for approximately 50-100 ms. For most of the time, the separate supply will be at 20 Volts 3 Amps, but I will be testing my stuff with it, so I may try it at higher or lower values.

share|improve this question
"Amplification" implies that there's some state between "full off" and "full on" that matters. Is this the case here? –  Ignacio Vazquez-Abrams Mar 1 at 6:48
To clarify @IgnacioVazquez-Abrams's comment. If you have a binary signal, and you need to change the voltages that correspond to "on" or "off", you need a level translator, not an amplifier. This may also be called a buffer. –  Connor Wolf Mar 1 at 7:03
Semantics. Op's using amplify in a grammatically correct way... –  Passerby Mar 1 at 7:07
@Passerby: Sure, but the technical differences mean different solutions. –  Ignacio Vazquez-Abrams Mar 1 at 7:09
Wasabi, how often are you switching the relay on/off? Are you using pwm? And how much current does the electromagnet use? –  Passerby Mar 1 at 7:13
show 2 more comments

2 Answers 2

Here is a mosfer driver version, I added a zener to limit Vgs to about 15v since the input can range up to 20v which is usually the max Vgs spec and can damage the mosfet (check yous mosfet specs, you may need to use a lower zener value).


simulate this circuit – Schematic created using CircuitLab

Vgs can be as low as 5v so you should select the output mosfet accordingly so that it can turn on with a low Rds-on at that voltage. A logic level mosfet should do.

If a low side switch is an option you can use the following


simulate this circuit

The load supply can be as high as the mosfet can take as a max Vds

share|improve this answer
This would work pretty well (a bit complex, but it would work) accept for the fact that I need 20v to work, and I would prefer to be able to test it at higher. –  Wasabi Fan Mar 1 at 22:11
@WasabiFan accept for the fact that I need 20v to work, and I would prefer to be able to test it at higher I'm not sure what you meant by that. Also a low side switch (ground side) would be much simpler but is that an option with your load? The circuit I showed will work at higher voltage too like 30 or 40v but R2 will need to be of a higher value to reduce the zener current (and power dissipation). –  alexan_e Mar 1 at 22:18
I mean that my separate supply will be >20v, and you seem to have indicated that that won't work. Are you saying that I would need a higher signal to make that work? How high would it need to be? –  Wasabi Fan Mar 1 at 22:44
@WasabiFan I never said that it wouldn't work, I just used a range of 5-20v in the schematic because that was the original specification. The circuit can work with a higher input as long as it is within spec of the power mosfet (below max Vds). Also I have calculated resistor R2 for a drop of 5v (20v-15v), if that increases significantly then the power consumption on the resistor and zener will be too high. Depending on the max input the resistor value should be increased. –  alexan_e Mar 1 at 23:48
add comment

It's really an interfacing problem. Your controller outputs a 3V3 signal at very low current. The electromagnet needs a higher voltage and a much bigger current.

enter image description here

The P channel MOSFET makes a very good high current switch. R1 ties the gate to the source and turns the MOSFET OFF. When the gate input is pulled to ground (0V) by Q2 (an NPN transistor) the MOSFET turns ON and current will flow through the electromagnet.

When Q2 is turned OFF the MOSFET is turned OFF and the electromagnet needs to dump the energy stored in the magnetic field. This is the job of D1 which shorts out the back emf produced which would otherwise damage Q1.

Q2 is a simple NPN transistor switch. If the input voltage is above 0.6V it turns ON. If it is below 0.6V it turns OFF. R2 limits the current to the base.

share|improve this answer
You should probably explicitly limit V_gs on Q1. –  Dave Tweed Mar 1 at 12:30
What's the max voltage on this? –  Wasabi Fan Mar 1 at 22:11
@WasabiFan The max voltage (and current) depends on which P-Channel Mosfet you use. –  Passerby Mar 2 at 1:19
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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