Use Arduino Uno to control solenoid valves.
Follow the steps below to set up your own valve control station.
- Clippard, E310C-2C012, 10 mm N-C 3-way Valve, In-line Connector w/LED, 0.030" Orifice, 1.3W, 12 VDC
- Valve connector cable
- Manifold
Details can be found on page 215-221 in Clippard Full-line Catalog
Send PCB design Out For Manufacturing
- Highly recommend JLCPCB. Fabrication and shipping took ~1 week for me in the U.S.
- If you choose JLCPCB, go here, upload plots.zip, and leave everything else as default.
- If you have access to a PCB baking oven, buying a SMT-Stencil will save you a lot of time for soldering. If not, all the components can still be soldered by hand.
Top Layer | Bottom Layer |
---|---|
Part | Label on PCB | Qty. (per PCB) | Purchase |
---|---|---|---|
Shift register, SN74HC595N | plug on the DIP socket (U1) | 1 | link |
Optoisolator, HCPL 2731 | plug on the DIP sockets (U2-U5) | 4 | link |
Resistor, 2.32 kΩ, package 0805 | R1-R16 | 16 | link |
Common anode diode | D1-D4 | 4 | link |
PMOS | Q1-Q8 | 8 | link |
1 uF capacitor, package 0805, voltage rating 10V | C1 | 1 | link |
DIP socket, 2x8 | U1 | 1 | link |
DIP socket, 2x4 | U2-U5 | 4 | link |
Stacking headers | J2-J4, H1, H2 | 1 | link |
Connector, Molex 50212-8000 | N/A | 18 | link |
Connector housing, Molex 0873690200 | N/A | 9 | link |
JST header, Molex 0894010210 | J5-J13 | 9 | link |
2.5 mm barrel jack, 5A max, CUI PJ-057BH | J1 | 1 for each setup | link |
Download zip and extract all files.
- Connect an Arduino Uno to computer via USB
- Download and Install Arduino IDE
- Open
arduino_valve_control.ino
inarduino_valve_control
folder with Arduino IDE - Select USB port:
Tools
>Port
- Click
Upload
(the right arrow at the top left corner) - Wait for uploading to complete
- Download and Install Python 3.6
- The Python distribution, Anaconda is recommended, because it comes with pre-installed packages.
- Note: On Windows, the directory of installed Python must be added to environment variable.
- Install Python dependencies
- Windows: double click
platforms/windows/setup.bat
- MacOSX:
$ bash <path to>/platforms/macosx/setup.sh
- Windows: double click
(ADD photos of top and bottom layer after soldering)
Solder all the components according to the table above. The surface mount components are soldered to the bottom layer, while the rest are mounted on the top layer.
In the table above, the stacking headers contains the following headers.
Stacking Header | Label on PCB | Qty. |
---|---|---|
1 x 10 | cut out a 1x2 for J4 | 1 |
1 x 8 | H1, H2 | 2 |
1 x 6 | 2 | |
2 x 3 | J2+J3 | 1 |
Because the JST headers at J11 and J12 block H3 on the top layer, I would do the following:
- Cut a 1x2 stacking header out of an unused one
- Solder it on H3 from the bottom layer
- Cut off the female portion on the top layer
- Put more solder from the top layer
Each setup only needs one barrel jack to connect to a 12 V power supply. The barrel jack can be soldered on any one of the boards.
(The images shown below are all taken for the previous PCB design, which is marginally different from the current design.)
After soldering, plug the shift register and optoisolators into their corresponding DIP sockets. Refer to the following image for their orientation.
- Bend or remove the data pins on all boards except Board 1. See the left image below.
- Make a connector for serial input and serial output. See the right image below.
- Stack the PCBs and plug in the connector just made.
Data Pin | Serial Input/Output |
---|---|
In the images above, there are 4 boards stacked on an Arduino Uno.
Each board provides 8 solenoid valve connectors, and the current design supports up to 6 boards.
Before putting the boards together, the data pins on all boards except Board 1 must be bent or removed.
This is because the data pin connects to the serial input of shift register.
On Board 1, the shift register receives data from the Arduino directly.
For the Board 2-n, their shift registers must have its serial input connected to the serial output of board right beneath it.
-
Electron Version
-
Python Version
- Open the "platforms" folder.
- Open the folder corresponding to your platform.
- Run the setup script.
- Run the application
- Electron version
- Run the "Valve Control" app.
- Python version
- Run the "run" script in the platforms folder.
- OR
- Run run.py in the root folder
- Electron version
- Select the correct serial device.
- Click the numbered buttons to toggle valves on and off.
- Select "Built-in Program" at the bottom of the screen.
- Click the "Load" button.
- Fill in the desired values in popup window.
- Enter the number of cycles you wish to run in the "Cycles" field.
- Enter the number of ms you want between phases in the "Phase interval" field. (See the Writing a Program section for more information)
- Click "Run"
- If needed the program can be stopped with the "Stop" button
- Select "..." to the right of the "Program" field.
- Navigate to the desired program in the "Open File" dialog.
- Enter the number of cycles you wish to run in the "Cycles" field.
- Enter the number of ms you want between phases in the "Phase interval" field. (See the Writing a Program section for more information)
- Click "Run"
- If needed the program can be stopped with the "Stop" button
- Create a .txt file.
- Create 3 section headers in the file: BEFORE, CYCLE, and AFTER.
- The BEFORE section describes the inital state of the valves (this section is optional).
- The CYCLE section is the section that is repeated during operation.
- The AFTER section is the final states of the valves (this section is optional).
- In each section, specify the desired states of the valves.
- There are 2 states: ON and OFF.
- One or more valves can be set in a single line (eg. ON 1) (eg. OFF 1 2 3)
- On each line in the section describe a single phase.
- Each line should begin with a tab.
- Each line/phase is seperated by a timed delay called the "Phase interval".
- Between each section leave an empty line.
- You should now have a program that looks similar to the program below
BEFORE
ON 3
ON 2
ON 1
CYCLE
OFF 1 2
ON 1
OFF 3
ON 2
ON 3
AFTER
ON 3
- If it follows this format, it should be a funtioning program.
- Save the file and run it using the "Self-Programmed Mode" instructions.