How to operate proportional solenoid valve with ESP32 module

For a research project I am making something called an "Arterial Constraint" using an ESP32 module.

Much like a BP cuff, a small air filled cuff (embedded with an IR sensor "watching" the rise and fall of blood in arteries) is to be wrapped around the finger.

When the pulse rises, the cuff pressure is to be increased to constrain the flow, when the pulse drops the pressure is to be reduced. Pressure profile matches the pulse profile

Desired Capability :

  1. Dynamic altering of pressure in the cuff.
  2. Frequency : Since max human heart rate is 250 beats per minute (before someone starts seeing Jesus), upper limit of 300 beats per minute should do the trick. So 5Hz.
  3. At 5Hz, time period of single pulse is 0.2 seconds.
  4. Rise happens for roughly half, so pulse is rising in say, 0.1 seconds.
  5. If the arterial pressure rises to 300 mmHg max in 0.1 seconds, so the constraint will have to achieve the same.
  6. To over compensate I thought I'll need something which can vary cuff pressure from 0-500 mmHg in 0.1 seconds, so 1 mmHg in 200 microseconds.
  7. When the IR sensor sees the pulse rising, the microcontroller tightens the screws on the proportional solenoid valve so pressure in the cuff rises and the pulse is not allowed to rise.
  8. I figured I'll have a continuously running air pump and vent the pressure through the proportional valve.
  9. To solve it I was looking for a proportional valve and found one who's hysteresis is very high (25%), and another who's operational voltage is so high (310VDC) I didn't even know such high DC even existed (Hysteresis and reaction time not specified for this one).

I need help understanding how either of them will be operated with an ESP32 module

how do you plan on measuring that ?

the rest seems to be a PID loop of some sort, assuming you can drive your valves.

There is a pressure sensor attached.

What is a PID loop?

And how do I drive the valve?

➜ Proportional–integral–derivative controller - Wikipedia

with a suitable relay or transistor / MOSFET and given it's an inductive device, you'll need a flyback diode

You'll find plenty valve control circuits on the internet, here is a first google hit (did not read it for accuracy)

https://www.martyncurrey.com/controlling-a-solenoid-valve-from-an-arduino-updated/

Your valve, if you ever decide to buy one, will require considerable current in the pulses. You should be sure to get the technical information on the valve of choice so you can size all the other components, including the power supply.

If the valves are not fast enough, you may be able to get the speed by driving a servo connected to an air cylinder that is connected to the cuff.

I have heard piezo electric valves can be much quicker and with much less hysteresis.

I am worried that the working voltage of the valve is 0-310V DC.

Isn't so high DC dangerous? Although the cables would be insulated, but if someone accidentally comes in contact...this can be deadly...right?

No, consider the 5000+ volts you generate when walking across your carpeting and touch a grounded metal object. It is current flow that is dangerous. Put both high voltage and high current together and then there could be problems.

I have never understood this. If current is dangerous then why would a live 220V AC line kill one? Also, static current from carpet lasts for an instant only, right?

The valve itself doesn't use much current, but its in an enclosure using cabling to connect it to the driver circuit. If there's a crack in the cable insulation and skin comes in touch, wouldn't there be shock? Why do they say High Voltage DC is more dangerous than high voltage AC?

@J-M-L @Paul_KD7HB @leharker @jim-p for now I am going to use the proportional valve with the below datasheet.
datasheet.pdf (467.0 KB)

I am planning to use the below circuit to drive it. Would it do? My MOSFET is going to be this below.
stp90nf03l (1).pdf (242.5 KB)

The link is dead. Post the datasheet.

Posted

It may or may not work with that MOSFET.
You should find one with a specified maximum Rds(on) of 2 ohms or less at a Vgs of 3.3V or less.

You colud also use a common BJT transistor. A BC337 would be a good choice.

Thank you. I'll test it with the BC337...with a base resistor of 1K Ohm?

Also, one question. I am using a proportional valve for the first time. I had imagined earlier that there would be way to continuously vary the voltage by the microcontroller. But everyone on the internet is using PWM, which in my mind seems to mean that we are switching power to the valve on-off very fast.

Is there a way to actually vary the voltage signal? Would that be more neat or less neat way to do the job? How do the professionals do it?

Please also look into my concern here and let me have your thoughts

PWM is the easiest way.
A variable current is possible but the circuit is a little more complicated.

1 Like

so its the current controlling the valve not the voltage?

If can get better resolution and control with the variable current then I'd like to try even if its more complicated. Please let me know how to do it.

If you look at the graph in the datasheet you will see it's flow vs. current. Of course you can't change the current without changing the voltage but it may not be as linear as it is with current.

If can get better resolution and control

With current control you will but now you will need a DAC for the ESP and another circuit for current control.

1 Like

Don't the ESP32 modules have built in DACs?

Or maybe a 15 bit DAC?

Do you know Ohm's law - Wikipedia ?
If not then please study it, Ohm's law is fundamental to electrical circuits, if you know Ohm's law a lot of things become clear.

It is indeed current that harms you, but for current to flow there must be enough voltage to overcome whatever resistance is in its path. Human skin is usually dry and has a high resistance. Wet skin has a low resistance, which is why you are more likely to get a shock when your hands are wet, but might possibly touch a high voltage with dry hands and get little or no shock.

Whatever is supplying the current also has some internal resistance, in the case of the mains electricity supply the internal resistance is so low that for the purposes of discussing whether you will get a shock or not it can be considered to be zero. So, when you touch a mains wire the things protecting you are the resistance of your skin and the resistance of the path to earth of the current. If you are luck and have very dry skin and are standing on an insulator, such as a nylon carpet, then there is a good chance you will only get a mild or no shock as there is a high resistance protecting you. Wet hands and standing on a wet flood and the resistance is low and you are at much greater risk.

Other sources of electricity have much higher internal resistances. The 5000V or more from walking on a nylon carpet comes with a very high internal resistance, as soon as you touch the 5000V the voltage drops to almost zero as it is incapable of supply much current, so you might get a brief shock but won't come to any harm as it's too quick to do anything much.

Yes, 300VDC is dangerous if it is from a supply capable of supplying enough current to harm you. It the supply cannot supply that much current then you'll (probably) be OK. Do some reseach on the levels of harm for different levels of current and find out if your proposed 300VDC power supply can supply that much current. If you use a 300kOhm resistor, for example, in series with the 300V then the current cannot exceed 1mA (see Ohm's law).

2 Likes

The ESP32 is not highly praised for it's analog functions ADC or DAC, it's best to use an external device, besides it's only 8 bits.
The DAC you selected is fine. Another choice is the MCP4725. It's more common and well tested within the Arduino community. It's 12 bits which will give you plenty of resolution but it's your call, either will do.

1 Like