Hey guys!
So we have this project we're working on where I need to control 4 proportional solenoid valves through the Arduino. This is the valve I want to control HF-Pro(click here). We'll be using the 5 V version, and plan to use PWM to control the valves. My questions are:
1)Do we need any specialised circuitry for PWM? Or is it as simple as connecting one terminal to ground and other to the PWM pin?
2)4 valves is a lot of power draw. I was thinking of using a transistor as a switch,connecting PWM output pin to base while the collector gets external power supply, and emitter goes to the valve. So I use 4 of these transistors for the 4 valves. Will it affect anything while it's working in conjunction with the PWM? And is it feasible?
For PWM (voltage) control you need a current amplifier, because the valve draws 435 mA at 5V. Be sure to follow the PWM frequency recommendation, use a flyback diode and DO NOT use the Arduino to supply the voltage to the valve.
You should use a current driver as recommended in the valve data sheet:
Basic Control:
The HF PRO valve can be controlled by either voltage or current; however, it is highly
recommended that current control be employed to ensure the most repeatable valve flow
performance.
PWM Control:
For PWM control, the signal applied to the valve should have a frequency between 5-12kHz.
Are current driver circuits, and PWM circuits different? The current driver circuit looked complex because it required an op-amp. That's why I went for PWM. Also, I don't understand where I have to vary the current, in which part of the circuit, to control the flow.
Is it at the control voltage input part? Then maybe I could analogWrite to it, to control the current!? Electronics is not my strength here. I am a mechanical student.
For PWM (voltage) control you need a current amplifier
The "current driver" circuit is better described as a "constant current driver" and gives accurate and repeatable valve control.
A current amplifier, which of course uses transistors of some sort, permits the PWM output to apply voltage control. This is less accurate and repeatable than constant current control because of the coil characteristics.
To see how to go about the latter, google "arduino motor control" and use a circuit intended for a brushed DC motor.
Ok then, the former option looks more appealing now. What exactly, do I have to control in the current driver circuit, and how? As in, where should the input pin connect to in that circuit, should it be digital or analog, and stuff like that.
What exactly, do I have to control in the current driver circuit, and how?
You apply a voltage between 0 and 5V to the "control voltage" input in the figure shown in your reply #2.
Do that with a PWM output on the Arduino, using analogWrite(). Normally you would add a capacitor to smooth the PWM output. I would suggest a 10 uF capacitor, from the junction of R1 and R2 to ground.
Mosfets are the way to go as their voltage driven with flyback diodes built in and transistors are basically current amplifiers. Don't get me wrong, transistors will work but there is an intense amount of math involved. A "N" channel mosfet can be saturated with 5v with little loss and the industry is switching to their use. in fact there are many driver circuits ready for your application. Some important facts are to use a 10-100 ohm resistor to the gate from your logic, and tie the gate to ground with a 1000-10000k resistor. N channel mosfets have the source tied to ground and the drain tied to the load and the other side of the load goes to b+ power. The benefit with PWM is mosfets create little heat and transistors waste heat.
So if I apply PWM(voltage) at the "control voltage", it will become PWM(current) at the proportional valve solenoid coil? Is that the purpose of a current driver circuit? Acc. to Wikipedia -
In electronics, a driver is an electrical circuit or other electronic component used to control another circuit or component, such as a high-power transistor, liquid crystal display (LCD), and numerous others.
Right, after I do that, I also have to manually change the PWM timer frequency. 5-12 KHz is not normally what the PWM pins supply. I found this resource - Arduino Playground - HomePage
It says it changes PWM frequency on pins 3,5,6,11 to one of these frequencies-
Setting Divisor Frequency(Hz)
0x01 1 31372.55
0x02 8 3921.16
0x03 64 490.20 <--DEFAULT
0x04 256 122.55
0x05 1024 30.64
None of them fall within the valves' desired PWM frequency range!!! There is pin 9 and 10 which is suitable, but we need to control 4 valves, so.... :-X !
@notfet you think the tip120 transistor could be replaced by a suitable MOSFET? Time is not on our side, and we would like to avoid experimentation.
The circuit shown in reply #2 is more correctly called a voltage controlled, current limited driver.
The op amp measures the current passing through the coil via the 1 Ohm resistor and cuts off the coil supply voltage when the current exceeds a certain level, set by the input control voltage.
PWM in this case is used to have the Arduino output a voltage that is somewhere in between 0 and 5V. The resulting voltage is the average of the two, over one cycle, if you use a capacitor to filter the output. You don't need to worry about the PWM frequency.
Note that the op amp supply voltage should be higher than 5V. Also the circuit should have a flyback diode across the coil, and the fact that it is missing is cause for concern.
The alternative to the circuit shown in reply #2 is to use a PWM signal with a current amplifier (not the same thing as the above). Google "arduino motor control" for any number of examples, and be sure to use a flyback diode. In this case the valve coil itself does the averaging and the PWM frequency is very important.
Note that the op amp supply voltage should be higher than 5V.
So if we have 4 current driver circuits like this, what should be the op amp supply voltage for all the circuits? Can it be supplied through a common source? And we were thinking of running the whole circuit(s) through mains power. Or will a 9 V battery suffice? :
The pure PWM method doesn't seem too appealing now, especially since the manufacturer says that for accurate flow we should be using a current driver circuit, which we are ready to build.
1N4001 would be fine, and your modified schematic shows the correct way to use it.
A 9V battery would power the op amp, but not the valve. In that circuit the op amp supply voltage has to be higher than the valve supply voltage as well.
I would use a slightly rearranged circuit, in which the op amp can be powered by the 5V Arduino supply. I would also recommend to use a "rail to rail" op amp. See below.
[Edit 4/16/2017: swap signs on op amp inputs below]
in which the op amp can be powered by the 5V Arduino supply.
For 4 op amps??? Will the Arduino be enough to supply all those?
For the valve drive voltages I might use an external 9/12 V power supply. Or should it exactly be at 7 V?
Quick Question : If there are 4 sources that require 7 V supply, should the external power supply have a voltage of 28 volts? (I think there only has to be a required voltage difference between source and ground, doesn't matter how many grounds exist. It's only the current that gets split. Voltage can be thought of as pressure, and current as flow rate)
I would also recommend to use a "rail to rail" op amp.
Um, which one? It also seems that rail to rail supply op amps do not need a separate power source.
For 4 op amps??? Will the Arduino be enough to supply all those?
Easily. They typically use a few mA.
It also seems that rail to rail supply op amps do not need a separate power source.
Of course they do. "rail to rail" means that the input and output voltages can be approximately equal to either the positive or negative op amp power supply voltage. Most op amps can't do that.
Google "rail to rail op amp" and choose one that will run on 5V.
It seems that there is no resistor of 95.3 ohms. What is the closest value resistor that we can substitute in place of R2? We simulated what would happen if we used a 100 ohm resistor.
Should we select the resistor in such a way that the current coming from the voltage divider is less than what will be supplied when a 95.3 ohm resistor is connected(4.35 uA)? In the attached image, the 100 ohm resistor is outputting a current of 4.54 uA. This is in excess of 4.35 uA, which is also stated in the valve specifications, for 5 V. We are concerned because these valves are costly, and we don't want to damage them!
You can use a 100 Ohm resistor, and that won't force "excess current" through the valve. The valve will draw an amount of current determined by its winding resistance and the valve power supply voltage.
If you do use a 100 Ohm resistor, that will reduce the range over which the circuit responds linearly to input voltages, which may or may not matter. If it matters, substitute a 100 Ohm potentiometer, adjusted to 95.3 ohms.
We built the circuit according to your circuit diagram, and we sat down today to test the voltage and current across the coil as the valves will only be received on Monday. When we set the PWM value to 0, the voltage across the coil(we didn't substitute anything in it's place) showed up as 6.8 v. When I set it to values > 0, the voltage drops, suddenly and inconsistently. We later visualised it by putting an LED across where the coil is supposed to be, with 13.6 ohm resistance in series. The LED lit up only when PWM freq. was 0, otherwise it would go off. What could we be doing wrong?
For supplying 7 V, we did a voltage divider circuit, and we connected the +ve terminal from this circuit to the diode and coil junction, and the -ve to the ground. Is this correct?