I'm designing a board based on atmega328p microcontroller in order to control some solenoids valves (2 proportional solenoids and 9 ON/OFF solenoids valves).

This is the valve datasheet. These are the solenoid details:

V = 12Vcc, R = 3.7 Ohm, I = 1.80A

This is my first PCB schematics and my first board. I power the board with 12V, 40Ah. I use Eagle and I never did something like this before so the board has many errors. In fact, I tested my first prototype and these are the problems:

  1. When I try to control proportional solenoids (VSX, VDX outputs), the board crashes randomly after few seconds and get stuck. I need to power off and on the board to make it works again.
  2. The datasheet says that the valve should draw 1.8A when powered at 12VDC, but I measured 3A when PWM is 100%. This is very strange!

In order to solve the problem, using the community suggestions, I added these modifications:

  • Added a big 2200uF 35V capacitor at the main power connector
  • Added a filter cap between VCC (7) and GND ( 8 ) and AREF (21) and GND (22) and AVCC (20) and GND (22) on the atmega328p
  • I cut the trace on pin 22 and I directly connected it to the L7805CV GND
  • Added a diode across each valves pins.

By doing this, the board can work well for 1 or 2 minutes, but then it crashes again.

Now, I'm going to design again my board, so I would like to ask you how I can fix my errors and improve my design in order to make my board works correctly.

IMPORTANT: After few experiments, I notices that if I put in series, between the mosfet output and the valve, a 20R 10W resistor, the board works OK. The problem is that the resistor becomes hot in no time. The board works fine also if I put a voltmeter in series between the mosfet output and the solenoid to measure the current: in this case, the board works fine for several time. This is very strange for me!!

I was thinking to:

  • use optoisolator (like ILD213T) to control the MOSFETs
  • use an isolate 5V regulator (like NME0505SC or AM1S-0505SZ) in order to isolate the atmega328p from the board
  • adding filter caps on main power and on atmega328p

What do you think about this?

Can you give me some suggestions, please?

How can I limit the current to 1.8A when the PWM is at 100%?

I know that the board design is not correct, how can I improve it?

Should I use the second layer for GND traces and the upper layer for power traces only?

Please, help me!


I was thinking to use LM25011 with this schematics. I did this schematics by using the online TI calculator.

Can you tell me if this design could work for my board? I set the Rsense to limit current up to 1.8A at 12VDC.

  • 2
    \$\begingroup\$ "The datasheet says that the valve should draw 1.8A" No, it doesn't. What it actually says is that you should not allow it to draw more than that. The graphs in the data sheet seem to indicate that the required current for operation depends on fluid pressure. You may need to build a chopping current regulator with a sense resistor - see stepper motor driver circuits to get an idea. \$\endgroup\$ Commented Oct 16, 2016 at 16:29
  • \$\begingroup\$ I forgot to add these details, sorry. These are the solenoid data: V = 12Vcc R = 3.7 Ohm I = 1.80A \$\endgroup\$ Commented Oct 16, 2016 at 16:32
  • \$\begingroup\$ Also, before you redesign the board, try removing the 5v regulator and substituting an external 5v supply for that, with only the ground common between the logic supply and the actuator one. Consider making the power and ground connections for this test 5v supply right at the ATmega or its bypass capacitor. \$\endgroup\$ Commented Oct 16, 2016 at 16:33
  • 1
    \$\begingroup\$ No, what you need is not a step sequencing stepper motor driver, but the general type of chopping circuit topology used in one. While it is not a part you would want to use for your project, the "LOAD CURRENT REGULATION" section of the L297 data sheet explains the concept. \$\endgroup\$ Commented Oct 16, 2016 at 20:49
  • 1
    \$\begingroup\$ The circuit at your link is a linear current regulator, which means that the difference between the maximum power and the power needed will go up as heat in the power transistor, which is basically used as an electronically controlled rheostat. That can be made to work, but a switching regulator is less wasteful, and as a result runs far cooler. \$\endgroup\$ Commented Oct 16, 2016 at 21:09

4 Answers 4


The solenoids generating a large back EMF and the diodes can't dissipate that power rapidly.So I will suggest that you could add some MOVs instead of diodes.They dissipate power much better than diodes.Also you should check if your powrr supply could sink so much current from solenoids.

  • \$\begingroup\$ Comments are not for extended discussion; this conversation has been moved to chat. \$\endgroup\$
    – Dave Tweed
    Commented Oct 23, 2016 at 15:21

I faced a similar problem when using a relay circuit to actuate pistons. The back EMF generated due to the actuation of the piston would short the control circuit thus resetting the micro-controller.

I would recommend adding a Optical Isolation feature to the circuit. Opto-Isolators such as ILD1, ILD2, ILD5, ILQ1, ILQ2, ILQ5 are cheap,small & come in DIP Packages .

  • Signal information, including a DC level, can be transmitted by the drive while maintaining a high degree of electrical isolation between input and output.
  • The ILD1, ILD2, ILD5, ILQ1, ILQ2, ILQ5 are especially designed for driving medium-speed logic and can be used to eliminate troublesome ground loop and noise problems.
  • These Isolators will protect your microcontroller & control circuit from the back emf generated by the actuation.
  • These couplers can be used to replace relays and transformers in many digital interface applications such as CTR modulation.
  • \$\begingroup\$ It is possible to control a servo motor with an opto-coupler? \$\endgroup\$ Commented Oct 22, 2016 at 18:03
  • \$\begingroup\$ -1 Marcus , Of course it can with a dedicated driver and isolated power supply \$\endgroup\$ Commented Oct 25, 2016 at 12:56

Before re-doing the PCB design again, spend more time on analyzing all the problems to ;

  • Define the problem better, then describe solution with a spec ( very important)
    • Such as root cause of heat dissipation issues.
    • Performance issues of PWM flow control vs pressure
      • there is a difference in source impedance using SPST vs SPDT PWM
      • SPST is an Open Drain or Collector BJT switch with a clamp diode
      • vs
      • SPDT action of a complementary driver where source Z is always low except during transient or crossover with deadtime during which there is a transient for V=L*di/dt

Having designed hundreds of boards in my career, I know it is possible to do what you are attempting designing a PCB before understanding all the issues, and you WILL learn from the process that there are better ways. These ways require much testing and scope analysis using all the principles you have been taught.

This is my simple advice above test parts of the circuit until they meet all your criteria; e.g. heat rise, performance, EMI, cost and time then try to measure this performance in terms of a specification that you can later Test and Verify ( or instruct someone else to do the same)

  • When you have good specs ( that meet customer expectations or yourself)

    • and pass them, with your own devised Design Validation Tests (DVT) or compare with datasheet
    • you end up with a perfect example design
    • good luck and remember these principles.
  • compare your Linear Solenoid waveform under load pressure and see if there is room for improvement.

  • to do this properly , you need a scope, and a variable lab supply and good shielded pair cable and a selection ferrite beads for single and wire pairs. enter image description here

Remember this: the solution is much easier after you understand all the problems by looking for them.

  • \$\begingroup\$ if you disagree , explain why \$\endgroup\$ Commented Oct 25, 2016 at 14:22

I don't think you need any special current regulators. At least not to start with.

I am concerned that you have written -12V and Gnd together connected to all the FET sources which are switching the solenoid coils.

Get a multimeter and measure the open circuit DC resistance of the solenoid coils. Then add a series resistor to the coil to limit the current to 1.8A with 12V.

Pay careful attention to peak power conditions as well as average power. This will tell you what sort of power supply you need.

I suspect your power supply is not meeting your peak power requirements. Edit: OP is using a car battery which is ample power in this case.

Design it with a little bit of headroom with respect to PWM control so that you never need to go to 100% (say 95% max duty)

The 12V supply for the solenoids can be separate from the PSU for the controller.

Hope this helps.

  • \$\begingroup\$ Thank you for your help! The power supply is a AGM battery, 12v and 200Ah.. it is very big.. do you think it is not enough to power the solenoids? \$\endgroup\$ Commented Oct 25, 2016 at 14:51
  • \$\begingroup\$ Oh sorry didnt realise you were using a car battery! That is plenty although the terminal voltage will be slightly higher than 12V, more like 12.7V-13V when fully charged. \$\endgroup\$
    – crowie
    Commented Oct 25, 2016 at 14:56
  • \$\begingroup\$ @MarcusBarnet do you have a multimeter? And please tell me that the -12V is a mistake on your schematic? \$\endgroup\$
    – crowie
    Commented Oct 25, 2016 at 14:59
  • \$\begingroup\$ Yes and -12v is obviously a mistake on the design.. -12v is ground.. sorry.. \$\endgroup\$ Commented Oct 25, 2016 at 15:03
  • \$\begingroup\$ The solenoid manufacturer said me that it is normal if the valve drains 3A when it is cold. Above 30 degrees, the valves drains about 2A. He said that if I won't limit the current to 2A, I will have different behaviors between cold and warm system. When the valve is cold, the oleodynamics motor will spin faster since the solenoid drains more current.. but i think this is not a problem for me.. \$\endgroup\$ Commented Nov 3, 2016 at 2:46

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.