2

I'm trying to control small, plastic, 12 V solenoid valves with an Arduino Nano. I have an Arduino Nano hooked up to a Sainsmart 4-channel 5 V relay module, and finally connected to the solenoid valves, which are powered externally with an AC to DC converter.

The valves are controlling gas flow to tanks of seawater for a marine biology experiment. As such, I need the solenoid valves to open and close very quickly (on the order of tenths to hundredths of a second).

The problem is that after the solenoid valves fire, my Arduino resets and reinitializes, and this messes with the timing of gas flow.

I've isolated the problem to the powered solenoid valves (the code, Arduino, relays, and solenoids all work perfectly when the solenoids are unpowered. The second I plug them in, the problem resumes). I think that reverse voltage spikes are causing my Arduino to reset, but am not entirely sure.

I've looked into adding flyback diodes, but heard that those slow down the relays and again, I need the timing to be very fast. Does anyone know if adding a diode will solve my problem, and if so, how much will it slow down the relays?

My knowledge in electrical physics is limited, so if you could keep your explanations to more basic language, I'd appreciate it, but any and all help would be welcome.

ocrdu
  • 8,705
  • 21
  • 30
  • 42
  • 1
    Welcome to EE.SE. A schematic is better than words. You can add one in using the CircuitLab button on the editor toolbar. Double-click a component to edit its properties. 'R' = rotate, 'H' = horizontal flip. 'V' = vertical flip. Note that when you use the CircuitLab button on the editor toolbar an editable schematic is saved in your post. That makes it easy for us to copy and edit in our answers. You don't need a CircuitLab account, no screengrabs, no image uploads, no background grid. Add a link to the relay module datasheet too. – Transistor Jul 09 '19 at 18:41
  • Classic problems ignoring lack of EMI immunity. Without schematic, photos and your research skills you are stuck. – Tony Stewart EE75 Jul 12 '19 at 01:26
  • Does the reset happen, if the relay(s) turn on, or in the moment they turn off? Does it happen no matter if only one ore more relays are involved? Show a photo of your wiring, and all involved power supplies please. – datenheim Feb 13 '23 at 07:38

4 Answers4

2

Consider that you most likely already have flyback diodes in the relay module, and you don't seem to notice that your relays are "slow". Your valves won't appear any slower with flyback diodes unless the EM field decay is the limiting factor, as opposed to mechanical movement, and I doubt that will be the case.

Dmitry Grigoryev
  • 25,576
  • 5
  • 45
  • 106
1

You're on the right track. Inductive loads, like solenoids, usually need a flyback diode to prevent voltage spikes when they are switched from the on state to off state.

Tenths to hundredths of a second isn't all that fast for electronic devices. I suspect you'd be fine with nearly any diode type. Even relatively slow diodes will still have a reverse recovery time measured in microseconds, and your switching speed is considerably slower than that.

Getting an oscilloscope on the solenoid power line should help confirm that this is your root cause. It could also help you determine a specific diode to install based on the size and shape of the overshoot.

Chris Fernandez
  • 1,316
  • 14
  • 32
  • 1
    This post has a similar question, and some good answers: https://electronics.stackexchange.com/questions/26944/when-why-would-you-use-a-zener-diode-as-a-flywheel-diode-on-the-coil-of-a-relay The zener diode is a much faster way to turn off solenoids, if your circuit can handle it. – David Drysdale Jul 09 '19 at 21:41
  • 2
    Actually, The recovery speed of the diode is not what determines the time the solenoid turns off. v = L di/dt. A flyback diode only put as reverse voltage of whatever the diode is rated at, and is actually a poor choice generally speaking for dissipating the magnetizing current, and it is why many relay manufactures are now recommending other types of coil suppression. Check this [link](https://www.te.com/commerce/DocumentDelivery/DDEController?Action=srchrtrv&DocNm=13C3311_AppNote&DocType=CS&DocLang=EN) out. – David Drysdale Jul 09 '19 at 21:50
1

As far as I can see the sainsmart module already has flyback diodes.

Depending on the external power supply and how exactly you have wired it up the Nano may reset due to voltage dip on it's supply.

You say it's an external supply for the relay. How is the nano powered? Are both grounds connected decently, but not the 5 V rails? If the Nano is powered from a PC, does it share the same power outlet?

You could try to add a few hundred microfahrad capacitor to both VCC nets.

Show your wiring (photo) please.

datenheim
  • 900
  • 1
  • 15
0

Using a zener diode should solve your issue while keeping the speed fast enough. Since solenoids have inductivity fast switching causes the solenoid to demagnetize into the circuitry. You should definitely use a flyback diode when working with an inductive load. A Zener diode should do the trick well.

ocrdu
  • 8,705
  • 21
  • 30
  • 42
Robert Sabljo
  • 95
  • 1
  • 11