Inconsistent inductive spiking in mosfet solenoid circuit

Thread Starter

KG0403

Joined Oct 5, 2018
33
Hello all. I am using a Raspberry Pi microcontroller to drive a mosfet switched solenoid valve circuit which will deliver a sucrose solution to a lab rat. While the rat is working, I am monitoring its neural activity. The problem I have is that the recording equipment is picking up the voltage spike from the solenoid switching, but not exactly consistently. The circuit I am using is below:
Capture1.PNG

V1 = RPi GPIO, 3.3 V pulse
V2 = 12 V battery
R1 = 100k
R2 = 68
D1 = 1N4001, standard diode
MOSFET = IRLB8721PbF
Solenoid = 12V DC valve, 3.6 W power rating, 50 ohm DC resistance, <300 mA rated current

What I'm recording is something like this:

Capture.PNG

where there is no spike for several trials, then the spike appears and has a variable amplitude.
All the grounds in this circuit, including the power supply to the pre-amp in the neural recording rig are tied together to earth ground.

If anybody could offer insight to help me understand this problem or to improve this circuit, I would be eternally grateful. Thanks for your time.
 

Attachments

KeithWalker

Joined Jul 10, 2017
3,063
Hello all. I am using a Raspberry Pi microcontroller to drive a mosfet switched solenoid valve circuit which will deliver a sucrose solution to a lab rat. While the rat is working, I am monitoring its neural activity. The problem I have is that the recording equipment is picking up the voltage spike from the solenoid switching, but not exactly consistently. The circuit I am using is below:
View attachment 161003

V1 = RPi GPIO, 3.3 V pulse
V2 = 12 V battery
R1 = 100k
R2 = 68
D1 = 1N4001, standard diode
MOSFET = IRLB8721PbF
Solenoid = 12V DC valve, 3.6 W power rating, 50 ohm DC resistance, <300 mA rated current

What I'm recording is something like this:

View attachment 161004

where there is no spike for several trials, then the spike appears and has a variable amplitude.
All the grounds in this circuit, including the power supply to the pre-amp in the neural recording rig are tied together to earth ground.

If anybody could offer insight to help me understand this problem or to improve this circuit, I would be eternally grateful. Thanks for your time.

The interference may be picked up through electrical connections or by electromagnetic radiation. What is the recording equipment and how is it connected to the rat?
 

DickCappels

Joined Aug 21, 2008
10,153
If it is the inductive spike on the solenoid winding placing a capacitor in series with a small current limiting resistance should slow it down, probably enough that you won't see capacitive coupling. It might also help to low-pass filter the signals you are observing.
 

AlbertHall

Joined Jun 4, 2014
12,343
You may need a star ground system like the diagram below. The solenoid current flows through a wire back to the power source. If any part of that route is shared with your measurement system the voltage drop across the resistance and inductance across that wire can be injected into the measurement.

Also you don't show any local decoupling of the solenoid power supply and that may cause problems too.
 

Thread Starter

KG0403

Joined Oct 5, 2018
33
The interference may be picked up through electrical connections or by electromagnetic radiation. What is the recording equipment and how is it connected to the rat?
The recording setup is like so: Platinum electrodes in the brain are soldered to a connector fixed to the skull, which has a high impedance unity gain headstage attached to it. A cable ~1.5 ft is connected between the headstage and a 1000x gain pre-amp, which is powered from a bench supply. There is a fairly long data cable (each data channel is twisted with a grounded wire) out the back end of the pre-amp which connects to an AtoD converter, which connects to a laptop computer via USB. The Labview recording software is operating in RSE mode.

I had thought that the noise might be radiation, so I tried moving the solenoid about to see if there would be any effect, and I didn't see any compelling changes. I also tried manually operating the solenoid with a battery (detached from the Pi and the rest of the circuit) in the vicinity of the recording equipment, and that got rid of the spike. However.. I can't manually operate the valve in my experiments.
 

Thread Starter

KG0403

Joined Oct 5, 2018
33
If it is the inductive spike on the solenoid winding placing a capacitor in series with a small current limiting resistance should slow it down, probably enough that you won't see capacitive coupling. It might also help to low-pass filter the signals you are observing.

I'm not sure I understand. In relation to the schematic above, would that be a capacitor in series with the diode and R2? Wouldn't that prevent the diode from functioning as it's meant to? Or do you mean a series resistor and capacitor in parallel with the diode-resistor branch?
 

ebp

Joined Feb 8, 2018
2,332
You might do better with a faster diode. A 1N4148 or similar is quite adequate for the current involved.

Unless you need the solenoid to "drop" quickly, eliminating the resistor in series with the diode will lower the spike amplitude. Since the resistor and diode will carry current equal to what the solenoid was carrying when the current was interrupted, you'll get roughly 20 V across the resistor.

The 100k resistor in series with the FET gate will make switching slow which is to your advantage in this situation. You'll get a "power spike" in the FET at each switching transition when there is both voltage across the FET and current through it, but that should be completely insignificant for the application.

Be sure the leads to the battery are twisted together or otherwise fastened into a closely spaced pair. This reduces inductance by allowing the equal and opposite magnetic fields around the conductors to partially cancel each other. It also reduces radiation.

It may help to add some capacitance as close as possible to the solenoid between the positive supply and ground. A combination of a reasonably large electrolytic capacitor (I'd try at least 100 µF) and a ceramic cap of at least 100 nF may help by reducing the "loop area" for the current when the solenoid is energized and forming a place for energy stored in the connecting wires to the battery to go when the solenoid opens. You can create a resonant circuit, but usually the electrolytic capacitor will dampen the resonance into non-existence. Usually. You might need to experiment a little.
 

ebp

Joined Feb 8, 2018
2,332
There may be issues with ground currents. The measures I mentioned previously should help by keeping currents "local."

Ferrite "beads" on connections might be beneficial. I'd put one on the pair of conductors between the FET and the Pi. I'd try something intended for lower frequency range and on the order of centimetre in OD and 1.5 to 2 cm long. Fair-Rite has lots of info on their website about ferrites. One of the sort intended to go over a computer cable (split cylinder of ferrite in a snap-together plastic case) might work and might be available at a local computer store. The intent is to partially "decouple" the ground connection of the solenoid circuit from the instrument ground without impairing operation.

An opto-coupled gate drive circuit would allow complete galvanic isolation of the solenoid circuit from everything else. Because slow switching is OK, the circuit can be very simple. A 4N35 driven with a 2 or 3 milliamps by the Pi, with the output transistor between +12 V and the FET's gate through around 50k, with a 100k resistor between the gate and source of the FET would probably do.
 

crutschow

Joined Mar 14, 2008
34,280
I would put the RC in parallel with your present diode and resistor, sort of a belt and suspenders approach.

How far is the solenoid from the MOSFET?
The inductance of a long wire between those two could be a problem.
If so, try adding an RC circuit (say 100nF in series with 50Ω) from the MOSFET drain to V+.
 
Last edited:

Thread Starter

KG0403

Joined Oct 5, 2018
33
Thank you all for your input. I tried various approaches culled from the suggestions, and unfortunately I just could not reliably attenuate the interference in the end. I did find a work-around for the problem, however. I swapped out the solenoid for a motor based peristaltic pump, and placed the pump and FET circuit on the other side of the wall (I had already smashed a hole in the drywall from previous wiring), and that seemed to do the trick.

I hate to give a problem up without understanding, but time is running short on this experiment, so I must move on. This is a wonderful forum, I wish I had known to come here when I was an undergraduate. You all provide a really valuable service, and I'm sure this won't be the end of my forays into electronics projects, so I'll be around sooner or later with more questions. Thank you again.
 

-live wire-

Joined Dec 22, 2017
959
3.3V is pretty low for a mosfet. It may be in the ohmic region, leading to much greater losses and heating. You should consider using a BJT to control the mosfet. And the gate resistor certainly won't help. You shouldn't be using frequencies so high that it draws too much current from a GPIO. Just some general issues here.
 
Top