4

I am a beginner in DIY electronics, and I am attempting to control a 12V Solenoid valve from a Pi B2 connected to a 12V Battery and WiringPi Pin 1. I am using a 1kOhm Resistor between the gpio pin and a 100V MOSFET (IRF510). My problem is that when I set wPi Pin 1 to output mode with value 1, nothing happens.

Below is a close up of the circuit I have so far:

Circuit Closeup

And a more zoomed out view:

Zoomed-out Circuit

Here is how I believe this circuit can be represented in a diagram:

Circuit Diagram

I have double checked my connections, and everything seems like it's seated well. Do I have the wiringPi pin numbers confused, or is my circuit somehow incorrect?

4
  • 1
    Does the solenoid operate if you use the 3V3 pin (pin 1) rather than a gpio? If it does then it's a software problem. If it doesn't then it's a hardware problem.
    – joan
    Commented May 9, 2015 at 15:17
  • @joan No. Switching it over to RPi Pin 1 has no effect Commented May 9, 2015 at 15:36
  • connecting the solenoid directly to the battery works, yea? Without any bits attached....
    – Piotr Kula
    Commented May 9, 2015 at 17:33
  • yes. direct connection between battery and solenoid causes the valve to open. I did notice that the bag containing the transistor is labeled as 60V rather than 100 (which is what the datasheet was saying) Commented May 9, 2015 at 17:47

2 Answers 2

1

First, your diode is misplaced. It should be placed in reverse orientation, in parallel with the FET. Where you have it in series, it is simply reverse biased and will prevent the circuit from operating.

Next, an IRF510 is a dubious choice. It is both delicate (subject to damage from static discharge) and has a threshold voltage which may vary from 2-4v, while the pi only outputs at most 3.3v. To utilize this FET well you would really need a gate drive circuit - it's specifications are characterized at a gate drive of 10v.

What current does your solenoid draw if you connect it directly to the 12 supply? If it is not too much you may be able to use a simpler NPN power transistor circuit. Or you could use a small relay (driven by a small transistor or the optocoupler version importers sell everywhere) to control it.

1
  • The direction of the diode is correct, but it must be placed in parallel with the coil of the valve magnet. This to "discharge" the energy generated by the coil, over the coil itself rather than the rest of the electronics, to avoid damage because of high voltage spikes.
    – GeertVc
    Commented May 15, 2015 at 4:58
0

Try by adding 10k resistor between G and S.

G and S are gate and source in the MOSFET elements (you can see them in the data sheet that is attached to the question, so I guess the place for the 10k is obvious). If my assumption for 10k is correct - you raise the level of input voltage to gate so minimal change in gate voltage makes MOSFET opened.

After reading some other similar question regarding GPIO it dawned on me where the solution was/is. I used opto coupler to power the MOSFET and 5V on the transistor side of it. So 3.3V are used to power the led side of opto coupler (mind the max. current allowed) and on the transistor side I added 5V and that was enough to power the MOSFET. Hope that helps.

4
  • I'll have to get back to you on that, no 10k on hand. I tried 5 1k and 5 560 Ohm all in series (7800 total) with no difference. I did verify my solenoid / battery combo works by hooking positive / negative directly to the valve which subsequently clicked open. Commented May 9, 2015 at 17:09
  • 4
    What is G and S? And why would we need to add a 10k there? Please expand on your answer
    – Piotr Kula
    Commented May 9, 2015 at 17:34
  • G and S are gate and source in the MOSFET elements (you can see them in the data sheet that is attached to the question, so I guess the place for the 10k is obvious). If my assumption for 10k is correct - you raise the level of input voltage to gate so minimal change in gate voltage makes MOSFET opened. Commented May 9, 2015 at 19:00
  • 1
    After reading some other similar question regarding GPIO it dawned on me where the solution was/is. I used opto coupler to power the MOSFET and 5V on the transistor side of it. So 3.3V are used to power the led side of opto coupler (mind the max. current allowed) and on the transistor side I added 5V and that was enough to power the MOSFET. Hope that helps. Commented May 10, 2015 at 20:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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