equals
Posts: 11
Joined: Thu Oct 27, 2016 7:48 pm

Solenoid wiring (did I do it right?)

Thu Dec 08, 2016 8:07 pm

I am trying to hook up a solenoid to a raspberry pi 3. I cannot get the solenoid to activate. If I hook the solenoid directly to the battery I can hear it click open. Can someone look over my wiring to see if I did this correctly please.

Thanks
Attachments
Solenoid.png
Solenoid.png (40.08 KiB) Viewed 4391 times

RaspISteve
Posts: 100
Joined: Wed Oct 24, 2012 9:15 pm
Location: Cheltenham, UK

Re: Solenoid wiring (did I do it right?)

Thu Dec 08, 2016 8:44 pm

==,
Have you tried setting the MOSFET gate to high/low (3.3/0v) manually to confirm the next level of operation?

Similarly, a simple LED on the driver's input to confirm you've got the GPIO enabled/setup correctly.
Share and Enjoy.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13279
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Solenoid wiring (did I do it right?)

Thu Dec 08, 2016 10:24 pm

its possible the FET doesn't fully open with a gate voltage of just 3.3V, otherwise the schematic is fine, though a resistor in the gate connection isn't really needed, as a gate has a very high impedance (resistance), unlike a bipolar transistor.
post details about the FET.

equals
Posts: 11
Joined: Thu Oct 27, 2016 7:48 pm

Re: Solenoid wiring (did I do it right?)

Thu Dec 08, 2016 10:36 pm

This is the transistor I am using https://www.adafruit.com/products/355.

I tried setting the pin high, sleep for a second then back to low. I did not hear the solenoid click. I am not at work now and this is a work project, I will test the gpio pin to make sure that it is indeed turning on with a multimeter when I get the chance later this week. I also tried the circuit without the 1k resistor and it still did not work.

I do have a possible issue...I left my circuit hooked up and the transistor got really hot and began to melt the bread board! Is it possible that the circuit may be shorting causing the transistor to heat up? My program wasn't running, just hooked up to the battery.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13279
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Solenoid wiring (did I do it right?)

Thu Dec 08, 2016 10:47 pm

That Transistor (FET) is okay, good choice! It has a very low switching threshold of just 2.5V, so 3.3V should work well, it also has a very low Res-on, who should be able to switch large currents without overheating.
If it got very hot, as in "melted the solder", then something went very wrong, as in you solenoid acts like a short, or perhaps you put the diode the wrong way around across the solenoid, but then the diode should have burned out as well. Its likely the transistor wasn't used as a switch, not fully open or closed, but halfway open, which means that it dissipated lots of energy.
the gate should NEVER be left floating! When the FET gets very hot, consider it damaged, and buy a new one.

Start with the essentials, does the solenoid attract when you exchange the FET for a switch, and close the switch?

debugging (fixing it) depends on dividing the problem into smaller parts, so start with the most basic conditions, then work your way up....

equals
Posts: 11
Joined: Thu Oct 27, 2016 7:48 pm

Re: Solenoid wiring (did I do it right?)

Fri Dec 09, 2016 12:29 am

This is the diode I used https://www.adafruit.com/product/755 I am assuming the silver line side indicates the direction?

What switch would you suggest swapping out the FET with? Just a regular toggle switch and keep the circuit separate from the pi?

What would cause the FET to remain floating? The gpio pin staying high?

I did notice the solenoid felt warm, so maybe the diode was put in backwards? If you look back at my wiring diagram, I have the silver end of the diode closest to the red wire, if that helps.

I appreciate the help, this gives me a good place to start. I won't be able to test this out again till Saturday.

User avatar
Burngate
Posts: 6347
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Solenoid wiring (did I do it right?)

Fri Dec 09, 2016 11:39 am

Yes, the silver ring denotes the cathode, so you had it the right way round.

If the solenoid was getting warm, then current was passing through it, so the circuit was at least half-working.

Any switch will do - a regular toggle is as good as any

"Floating" means nothing is pulling it one way or t'other.
One way to stop it floating is to put a high resistance - 10k or there-abouts - between the gate and the source (ground). If nothing else is happening, it will hold it gently low, but a high from GPIO pin 18 will over-ride it.

equals
Posts: 11
Joined: Thu Oct 27, 2016 7:48 pm

Re: Solenoid wiring (did I do it right?)

Sat Dec 10, 2016 11:13 pm

So I turned the diode around just for a test and it blew up when using 12v, I switched over to 9v and it didn't blow up. But it does get warm, before it wasn't. So I guess it was backwards.

I have tried 3 different (same type) of MOSFETs and I still can not get it to work properly. I think it has something to do with the gate staying floating. As when I hook up the battery the solenoid engages and when I disconnect the battery is disengages. When pin is HIGH or LOW or when the gpio pin isn't even connected to the gate.

I have tried using a 1k resistor between the gate and pin and without the resistor.

I have tried several different resistors between the gate and source. I put the resistor on the gate pin going to source pin. I also put a 10k resistor from source to ground. When I do this I do not get any voltage to the solenoid.

I have also confirmed that the gpio pin is set to output and goes from high to low using "gpio readall"

I have even tried swapping out the MOSFET for a TIP120 transistor but I couldn't get that one to switch on the solenoid at all.

I also could not find any switch of any kind to manually test.

I am really stumped as to why this is not working...

equals
Posts: 11
Joined: Thu Oct 27, 2016 7:48 pm

Re: Solenoid wiring (did I do it right?)

Sun Dec 11, 2016 6:44 am

I am rethinking my setup since I am not making any head way with the MOSFET.

Can I just hook one of these to the pi and use this to switch on my solenoid?
https://www.amazon.com/SainSmart-101-70 ... 9QQA72A8MZ

Here are the specifications on my solenoid( taken from solenoid website) This one says 24VAC but I am using a 9VDC version that I can not find any info on.

This is my solenoid
http://store.rainbird.com/tbospsol-tbos ... enoid.html

Electrical Specifications
24 VAC 50/60 Hz (cycles per second) solenoid
Inrush current: 0.41A (9.9VA)
Holding current: 0.14A (3.43VA)
Coil resistance: 30-39 Ohms

blueboat
Posts: 7
Joined: Sun Dec 11, 2016 11:16 pm

Re: Solenoid wiring (did I do it right?)

Sun Dec 11, 2016 11:33 pm

Try a ULN2003, it has 500ma open collector outputs, and they can be paralleled for extra current handling.

I'd parallel 2 channels anyway to be more reliable.

It also has back emf diodes inbuilt for inductive loads like a solenoid. connect the common to your VCC (Supply Voltage).

The outputs sink current so they're wired VCC (power, solenoid and the output... the "E" pin goes to zero volts

Unused inputs don't have to be tied to any logic level.

Cheers

blueboat
Posts: 7
Joined: Sun Dec 11, 2016 11:16 pm

Re: Solenoid wiring (did I do it right?)

Mon Dec 12, 2016 12:51 am

In answer to your question, the relay board you've found will work fine and also wont need a diode.

blueboat
Posts: 7
Joined: Sun Dec 11, 2016 11:16 pm

Re: Solenoid wiring (did I do it right?)

Mon Dec 12, 2016 1:00 am

http://www.instructables.com/id/Use-Ard ... trol-moto/
Good blog using TIP 120


You'll need a bias resister on the base of a transistor as generally the transistor's base will pass all available current to emitter effectively shorting it out.

Regards

User avatar
Ferdinand
Posts: 236
Joined: Sun Dec 01, 2013 2:24 pm
Location: Leiderdorp, NL

Re: Solenoid wiring (did I do it right?)

Mon Dec 12, 2016 1:03 pm

Hi equals,

Do you have an ohmmeter to measure the coil resistance? You may also measure the dc current through your relay. I except that the dc current is much higher then 0.14 amp which is an ac value.

The resistance value specified is a ac impedance, dc coil resistance is much lower. That could explain your mosfet problems.
Electrical Specifications
24 VAC 50/60 Hz (cycles per second) solenoid
Inrush current: 0.41A (9.9VA)
Holding current: 0.14A (3.43VA)
Coil resistance: 30-39 Ohms
Success with your project!
Ferdinand

equals
Posts: 11
Joined: Thu Oct 27, 2016 7:48 pm

Re: Solenoid wiring (did I do it right?)

Mon Dec 12, 2016 5:36 pm

I will have a chance tomorrow to measure the resistance of the solenoid. To measure the current do I measure from the two leads of the solenoid like I would for measuring resistance but with the circuit hooked up and powered with the battery?

If the resistance is low in the solenoid is it just a matter of adding a resistor at the (+) lead of the solenoid in the circuit?

So if I understand this right, if the DC solenoid has too low of a resistance, the circuit has too much current, which is possibly keeping the MOSFET gate floating?

I should have the relay board to test out by Wednesday, but it would be very neat if I can get this to work with the MOSFET.

After the holidays I am buying a basic electronics book. :)

User avatar
Ferdinand
Posts: 236
Joined: Sun Dec 01, 2013 2:24 pm
Location: Leiderdorp, NL

Re: Solenoid wiring (did I do it right?)

Mon Dec 12, 2016 7:17 pm

WARNING
The solenoid in your link is meant for (dc) battery operated irrigation controllers (9V).
It is not a ac solenoid.
This solenoid should work with your mosfet without problems. I think you made a mistake how this solenoid operates. Use a H bridge to latch and unlatch your solenoid by swapping polatity. A H bridge is a device that swaps the direction of the solenoid current. Then a short trigger (20 msec) will latch/unlatch your solenoid.
See:
https://youtu.be/sv49yWZKXow

Code: Select all


9 V -------red wire (solenoid)black wire -----push button----GND
short press on button will UNLATCH SOLENOID

Swap wires of solenoid
9 V -------black wire(solenoid)red wire------push button-----GND
short press on button will LACTH SOLENOID
Now you can write a script to control an H bridge.

You have to double check your system.

Skip text below.
I will have a chance tomorrow to measure the resistance of the solenoid. To measure the current do I measure from the two leads of the solenoid like I would for measuring resistance but with the circuit hooked up and powered with the battery?
See:
http://www.engineersgarage.com/tutorial ... nt-testing
If you are measuring a current then measure the voltage across the solenoid and measure the drain-source of the mosfet too.
If the resistance is low in the solenoid is it just a matter of adding a resistor at the (+) lead of the solenoid in the circuit?
No, a serial resistor will reduce performance of your solenoid. It is better to reduce your power supply, such as 5V 3Amp. Another solution is to mount a proper heatsink on your mosfet.

Code: Select all

5V ------(amp meter)-----/solenoid\-------GND
We need to know the current through your solenoid and the voltage across your solenoid. The voltage across your solenoid < 5V.
So if I understand this right, if the DC solenoid has too low of a resistance, the circuit has too much current, which is possibly keeping the MOSFET gate floating?
Use a resistor of 10 k across gate and drain. See previous post.

Do you have specs of your power supply?
Success with your project!
Ferdinand

equals
Posts: 11
Joined: Thu Oct 27, 2016 7:48 pm

Re: Solenoid wiring (did I do it right?)

Tue Dec 13, 2016 6:40 pm

IT FINALLY WORKS! :D

I uploaded a new image of my circuit. Turns out it was all from a simple mistake... I was using the same ground as my 3.3v source from my other sensors. So what I did was use a separate ground and now it works perfectly. I did add the 10k resistor from the gate pin to source pin too.

This article on diodes was helpful too. https://learn.sparkfun.com/tutorials/diodes

I was able to figure the problem out by creating a separate circuit on a new breadboard and used a 9v battery with the voltage divided in half for the gate. I was able to determine the circuit worked this way then moved it back over to my raspberry pi and found out the ground was the issue. :)

I guess I will use the relay board I ordered for something else.

Thank you all for the help! :)
Attachments
Solenoid.png
Solenoid.png (48.21 KiB) Viewed 3448 times

Return to “Automation, sensing and robotics”