Solenoid Driver PCB

A part of a bigger project needed control circuits for up to 16 DC solenoids. Instead of wiring up a one-off prototype, I decided to design and manufacture a PCB to do the job in a scalable manner, and with a minimum of Arduino pins, so that the same circuits could be used for future high power on/off control tasks.

Basic Control Circuit

The control circuit is a basic high powered transistor switch found all over the internet. The circuit can be used to power resistive or inductive loads. An example from here is shown below.

The TIP120 power transistor allows the digital signal from the Arduino to switch a larger voltage and current from the external power supply. Using the Arduino to control the solenoid is a case of setting a pin high for the required time.

The diode in the circuit is needed because, when the current is turned off, the energy stored as magnetic flux in the solenoid coils tries to push a current in the reverse direction. This could damage the digital pin as it is not optically isolated from the power circuit. The diode connected across the solenoid allows current to flow back through the solenoid and the energy is dissipated in the coil resistance.

Alternatives using MOSFETs are also common, the main difference being that the MOSFET does not require the resistor in the circuit. Either would work in this application, but the transistors were cheaper from my supplier.

Also to be noted is that most of the components in this circuit are not critical. The resistor R1 could be anything from 1k to 5k and still work, and the diode and transistor should just be sized for the expected loads – for my applications the TIP120 will have more than enough capacity.

Circuit Design

I had two additional aims for this design.

The first was to minimize the number of digital I/O pins required to manage the bank of solenoids. For a scalable design, the number of pins should not linearly increase with the number of solenoids or we run out of MCU pins very quickly.

My standard solution for this is to use a 74595 Serial to Parallel buffer IC. These ICs use an SPI interface to the Arduino (3 digital pins, 5V and ground) and and provide 8 digital output bits. The ICs can be daisy chained (serial data out to serial data in) to provide expansion in units of additional 8 bits per IC. Using the 595 IC also sets a logical design parameter of 8 powered outputs per PCB.

The second aim was to allow multiple boards to be ‘stacked’ so that all MCU signal connections are only to the first board, with the additional boards somehow plugged into the first. The concept was that, because the only difference is that the data out from one 595 needs to go to the data in of the next, the daisy chain should be implemented using board connectors and not additional wiring.

This physical arrangement was a bit more complicated than I expected and I only achieved the aim for 2 stacked boards, which is ok for now. I welcome any suggestions, in the comments section, on how to do this more effectively.

The first completed version circuit schematic is shown below.

Both the schematic and PCB layout in Eagle CAD format are available for download here.

PCB Design

The PCB layout was straightforward, as the majority of the board was a variation/repeat of the basic solenoid driver circuit.

The TIP120 can produce some heat if they are switching frequently, so the PCB design includes a large ground plane on the bottom and underneath each metal fin of the TO220 case. The two ground planes are connected using vias to distribute the heat around the board.

The the IN header and the solenoid power barrel connector only need to be populated on first board. Solenoid power is the distributed to the the boards through wire links connecting the power screw terminals.

The OUT header is in parallel to the IN header for all signals except the data in/out, which needs to be passed from the data out pin of one board to the data in of the next. The intent was to solder a wire link between out and in of all the boards except the first, but I later realised this would only work for 2 boards.

The completed PCB ended up being approximately 100mm by 80mm, and I sent 5 units to be made at the Seed Fusion service. This was the first time I chose black PCBs and am very happy with the resulting aesthetic (see below).

Building and Testing

Populating the board was an uncomplicated task. For additional heat transfer from each transistor, each metal fin has a small amount of heat transfer paste between it and the PCB.

The finished version is shown below. The solenoid screw terminals will be installed when I work out the best type for my application.

Once powered up, I wrote some simple test software (below) to turn each output on in sequence. By measuring the voltage produced at the terminals I verified the correct end-to-end operation of the board.

// 595 pin Definitions
#define  DATA_PIN  10   
#define  CLOCK_PIN  9
#define  LATCH_PIN  8

void setup(void)
{
  // We set the three control pins to outputs
  pinMode(DATA_PIN, OUTPUT);
  pinMode(CLOCK_PIN, OUTPUT);  
  pinMode(LATCH_PIN, OUTPUT);  

  Serial.begin(57600);
  Serial.print("\n[595 Tester]");
}

void send(uint8_t value)
// Send 8 bits to the SPI interface
{
  digitalWrite(LATCH_PIN, LOW);
  shiftOut(DATA_PIN, CLOCK_PIN, MSBFIRST, value);
  digitalWrite(LATCH_PIN, HIGH);
}

void loop(void)
{
  static uint8_t n = 1;

  Serial.print("\n0x");
  Serial.print(n, HEX);
  send(n);
  delay(2000);
  
  // keep counter within bounds
  n <<= 1;
  if (n == 0) n = 1;
}

Lessons Learned

  1. The PCB could have been made approximately 10mm narrower by arranging the resistors and diodes horizontally rather than vertically.
  2. In hindsight, the link between DIN and DOUT should have been a solder link rather than needing a wire on the underside. Version 2 of the design shown below, included in the download link, has this small upgrade included.

2 thoughts on “Solenoid Driver PCB

  1. John Smith

    Fantastic tutorial as always Marco. Quick question however – When you say “This was a bit more complicated than I expected and I only achieved the aim for 2 stacked boards, which is ok for now.”, was this due to how you physically designed the boards to stack, or was there some electrical noise / signal issue that prevented you sending the serial stream beyond two chained boards?

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s