Controlling a 12v proportional solenoid valve

Hi all,

I am a high school student working on a science research project involving 3D printing of biomaterials.
My group is trying to create a device that can accurately control air flow coming from an air compressor and going to a syringe for extruding of various biological solutions. To do this, we are planning to use proportional solenoid valves and pressure transducers to measure the system pressure in real time.

I recently purchased two HF Pro miniature proportional solenoid valves from eBay that are rated for 12v and come with a schematic and instructions for control with a PWM signal
Link: http://aldax.se/wp-content/uploads/2012/12/HFPRO-9_26_12.pdf

The schematic that the manufacturer recommends seemed "relatively" simply to put together, so we made a custom etched circuit board with all the components laid out (image attached below). Alas, after lots of soldering and selecting of components we have been unable to make it work.

My understanding of what this circuit does is to provide a constant 12 volts to the solenoid valve, but then vary the amount of current flowing through the coil based on a 5v PWM signal. It seemed like I could just attach a variable 5v Arduino pin to the circuit and be done with it, but it appears there is something wonky happening that we're unaware of.

Here are some of my current theories on what's happening-

  1. Bad transistor type
    The schematic calls for a TIP 120 NPN transistor, which we did not have on hand. After scrounging around we found a different transistor that was still NPN, however some of the voltage or current ratings on it may be different from the TIP 120.

  2. Op-Amp Wiring Wrong
    We've double checked multiple times, but the variable voltage from the Arduino feeds correctly into the Op-Amp's non-inverting input (+) and comes through output pin 1, which is connected to the transistors base pin. The inverting output is connected to a 1 ohm resistor which grounds the solenoid valve. We followed the pinout of the LM358 op-amp and the diagram on the solenoid datasheet, but something could have been lost in translation.

  3. Arduino PWM Frequency Set Incorrectly
    I read in this other post (Help required for controlling proportional solenoid valve! - Motors, Mechanics, Power and CNC - Arduino Forum) that the valve has to be controlled with a PWM frequency between 5 and 12 kHz. I looked up how to change the frequency on the Arduino Uno using this resource: https://etechnophiles.com/change-frequency-pwm-pins-arduino-uno/
    He said in this blog post that you can change pins 5 & 6 to operate at 7812.50 Hz or 7.812 kHz
    The following code I used to change it:

TCCR0B = TCCR0B & B11111000 | B00000010;

Unfortunately this did not solve our problem.

I understand this issue may be out of the scope of this forum, but I was wondering if anyone could offer some insight. It would be greatly appreciated.

I have attached a detailed image of our circuit board and the manufacturers design side by side so its easier to compare the two. If you have any questions or need more information, please feel free to ask.

Thanks,
Frank Parsons

Connections on custom circuit board:

+A = 0-5v Arduino PWM signal
+5v = Arduino 5v power
+PS = 12v power supply positive
-PS = 12v power supply negative
+VC = output to solenoid valve positive
-VC = output to solenoid valve negative

Capacitor and resistor values are labeled on manufacturer diagram

Hi,
Where on your PCB is the 1 Ohm resistor?
The PCB image is of the copper side I assume.
Have you a scope to check your circuit operation and the PWM frequency?

Can you please post your code?


Thanks.. Tom.. :slight_smile:

I may be wrong but looking at this circuit, while I suppose that it could be used with PWM, it is not really intended for PWM. The input shows 0 to 5 volts which implies an analog voltage not PWM.

Indeed, won't work well with a PWM signal. You have to add an RC low pass filter to convert the PWM signal into a stable voltage. Possibly even two RC circuits in series for less ripple.

Hi,
This might help, from the datasheet;

Tom... :slight_smile:

So for the code I'm using nanpy to control the Arduino: https://nanpy.github.io.
I uploaded the Arduino slave code exactly as it is on github, but I did modify the void setup code with that one line:

TCCR0B = TCCR0B & B11111000 | B00000010;

The python code I'm using to control the arduino is as follows:

from nanpy import ArduinoApi, SerialManager
from time import sleep

#Declaration of pins and variables
#This section concerns inputs and ouputs from ultra-switchy boi
solenoidPin1 = 5
solenoidPin2 = 6

usrInput = 0
valvenumber = 1

try:
	connection = SerialManager(device = '/dev/tty.usbmodem14101')
	a = ArduinoApi(connection = connection)
except:
	print("Failed to connect to CRIOLE")

#Setting up solenoid outputs
a.pinMode(solenoidPin1, a.OUTPUT)
a.pinMode(solenoidPin2, a.OUTPUT)

#Main loop
while True:
	valvenumber = input("Which valve pin would you like to change? (5 or 6): ")
	usrInput = input("Enter a value for Valve Pin " + valvenumber + " between 0-255: ")

	a.analogWrite(valvenumber, usrInput)
	print(valvenumber + " , " + usrInput)

Using a multimeter, I have verified that this code outputs a variable voltage from either pin 5 or 6 on the Arduino. I will try to track down a scope, but I am unsure of what the PWM frequency actually is at the moment. The 1 ohm resistor is labeled as R5 on the PCB, and yes the PCB image is of the copper side.

As far as the whole PWM situation goes, I'm pretty sure that this circuit can accept PWM signals judging by the datasheet. However, if not do you think that an analog pin would work better in this case? I will also look at adding an RC low pass filter.

Thanks for the help,
Frank

Some Arduinos have a true analog output pin. The analog outputs on an Arduino Uno are PWM only, not analog voltages.

frankplants:
However, if not do you think that an analog pin would work better in this case?

Analog pins are for analog input only, no analog output. PWM is the closest to an analog output that you can get. The common Uno and Mega series don't have a DAC.

The default PWM frequency of an Arduino is about 480 Hz or 960 Hz depending on the PWM pin used.

I think the circuit is using the solenoid coil to smooth out the current (it's an inductor after all). But no flyback diode??

Thanks for clarifying the difference between analog and PWM pins.

wvmarle:
Analog pins are for analog input only, no analog output. PWM is the closest to an analog output that you can get. The common Uno and Mega series don't have a DAC.

The default PWM frequency of an Arduino is about 480 Hz or 960 Hz depending on the PWM pin used.

I think the circuit is using the solenoid coil to smooth out the current (it's an inductor after all). But no flyback diode??

I do have an Arduino Due, which has a 12-bit DAC. Would that be suitable for analog output?
I will definitely try attaching a flyback diode between the solenoid valve pins first because like you said, the circuit does measure current across the solenoid coil. I will let you know if that works.

Frank

The DUE DAC is extremely limited. It cannot get close to zero or close to 3.3V. The datasheet doesn't like to admit this limitation, so most people don't find it.

Find a library to control the PWM frequency. If the valve says it needs a minimum of 5kHz then you should try to achieve that.

You wrote, and I quote:"To do this, we are planning to use proportional solenoid valves and pressure transducers to measure the system pressure in real time. ".

May I suggest you already have a problem. If your end product is "extrusion", then you need to measure the speed of the syringe plunger movement. The air pressure just needs to be adjusted to maintain the desired plunger speed. The actual air pressure is irrelevant.

Paul

Paul_KD7HB:
You wrote, and I quote:"To do this, we are planning to use proportional solenoid valves and pressure transducers to measure the system pressure in real time. ".

May I suggest you already have a problem. If your end product is "extrusion", then you need to measure the speed of the syringe plunger movement. The air pressure just needs to be adjusted to maintain the desired plunger speed. The actual air pressure is irrelevant.

Paul

I see what you're saying, but wouldn't the backed up air pressure in the system affect the extrusion rate?
Or do you think the pressure change from when the syringe is full to when its empty would be negligible?
I would like to measure the speed of the plunger, but I'm not sure how to do it accurately. Maybe with some sensor or camera?

Thanks for the advice,
Frank

frankplants:
I see what you're saying, but wouldn't the backed up air pressure in the system affect the extrusion rate?
Or do you think the pressure change from when the syringe is full to when its empty would be negligible?
I would like to measure the speed of the plunger, but I'm not sure how to do it accurately. Maybe with some sensor or camera?

Thanks for the advice,
Frank

Of course the air pressure affects the extrusion rate and the is why you have to control it. And you have to control the temperature as well, if you hope to reproduce the same extrusion results each time you run the device. The standard for all the controls is the plunger speed.

Without seeing a drawing of your physical set up, I can't offer any suggestions for monitoring the plunger speed.

Paul

Others use precision manual air pressure
regulators set for the viscosity of the
material being dispensed.
Herb