Controlling Solenoid Valves & Sensors with Microcontroller

In summary: V.In summary, the author is trying to control some solenoid valves and sensors with a microcontroller and is not sure what type of circuitry might be best. There are outputs and inputs that he is not sure about. He is looking for help with the inputs and sensors.
  • #1
j777
148
0
Hi,

I'm trying to control some solenoid valves and sensors with a microcontroller and I'm not sure what type of circuitry might be used to best accomplish this. For the outputs I think a ULN2003AI made by Texas Instruments might work but for the inputs I'm not real sure what I need to take into consideration. The sensors I'd like to read consist of 8 inductive proximity sensors (NPN) and 1 photoeye (NPN). Any help would be greatly appreciated.

Thanks
 
Engineering news on Phys.org
  • #2
Which uC are you using? Is it a 5V part or 3.3V part? What are the output voltages of your sensors? What are their [tex]V_{OH}[/tex] and [tex]V_{OL}[/tex] output voltages? Are the outputs noisy and bouncy, or are they cleaned up with hysteresis already? How long are the wires to the sensors?
 
  • #3
Thank you for the reply berkeman.

I'm using an ATMEGA32 uC run at 5V. The sensors are powered by a 12V supply and VOH = VCC and VOL = 0V. The outputs are cleaned up with hysteresis and the wires are 8ft max.
 
  • #4
j777 said:
I'm using an ATMEGA32 uC run at 5V. The sensors are powered by a 12V supply and VOH = VCC and VOL = 0V.
Which Vcc? The 5V or 12V supply? If the sensor output VOH values are 12V, then you'll need to limit them to 5V at the uC inputs. You can use a series dropping resistor and diode clamp to 5V for that.

After any clipping at 5V, it sounds like the sensor outputs are pretty well-condidioned to run into the uC directly. One thing I would do, especially with 8' cables, is to use diode clamps to the rails on each IO line where the cable comes into your uC board. This is done almost always on IOs like that, in order to protect the uC inputs from ESD and other transients coming in the IO cable. For each line, you connect a diode up from ground to the IO (anode=GND, cathode=signal), and from the IO up to 5V (anode=signal, cathode=5V).
 
  • #5
Sorry, VOH = VCC = 12V.

Should the diode clamps come before or after the series dropping resistor?

At the risk of showing how new to this stuff I actually am I must ask...how do you calculate the value of the series dropping resistor so that 12V is reduced to 5V? My hangup is the current portion of ohm's law...if this fluctuates at all the reduced voltage will fluctuate also.

Also is there a way of dropping the voltage to safe levels that will work with a range of possible output voltages from sensors? This way the circuit would be more flexible.
 
  • #6
The connection goes sensor, resistor, diode clamps at the uC IO input. The 5V clamp diode keeps the IO voltage from getting above about 5.7V (to avoid latching up that uC input pad), and the resistor limits how much current the diode has to catch.

The resistance needs to be big enough to keep the clamp current small (say a couple mA), but small enough that it doesn't cause too much of an RC lowpass filter effect on the signal going to the IO. So let's target 1mA as a round number first, which would give you a resistance of (12V-5V)/1mA = 7kOhms. That's pretty big if your signal is fast, since 20pF of IO input capacitance and that 7kOhms has a lowpass filter corner frequency of [tex]\frac{1}{2 \pi R C}= 1.1MHz[/tex] For slow IO signals that should be fine. But for a clock or high-speed sensor signal, that kind of round-off on the signal can be a problem. The tradeoff is that you burn more current in the 5V clamp diode if you need to go faster with a smaller resistance value.
 
  • #8
Thanks again berkeman for your help. I think I have a fair understanding of how all this works now.
 
  • #9
Opto-Isolators might be a better idea than diode clamp.
Worth looking into for remote sensors.
 
  • #10
NoTime said:
Opto-Isolators might be a better idea than diode clamp.
Worth looking into for remote sensors.
That's a very good additional suggestion by NoTime. Optos have limitations, but the biggest one is usually how to get power to both sides of the opto interface. But the OP said that the sensors had 12V power, and the uC side has 5V power, so an opto level translator and noise isolation would be a definite possiblity. The OP can check out the 4N25 jellybean opto datasheet for more info.
 
  • #11
Yes, thank you NoTime for the additional suggestion. I'm not sure if an opto-isolator would give me much additional protection though because the main system supply is 12V (used for sensor VCC) which is dropped down to 5V using a 7805 regulator for the uC. In other words the power supplies are not isolated.
 
  • #12
I have seen a 74hct245 chip used in circuits that provide the types of inputs that I'm looking for. Can somebody explain how this chip might accomplish the voltage level translation that I require?
 
  • #13
j777 said:
Yes, thank you NoTime for the additional suggestion. I'm not sure if an opto-isolator would give me much additional protection though because the main system supply is 12V (used for sensor VCC) which is dropped down to 5V using a 7805 regulator for the uC. In other words the power supplies are not isolated.
One point of the opto-isolator is that you can easily do level transforms with one, in addition to general protection from the sensor and its environment.

IIRC the 245 is just a buffer/line driver chip, not specific to level conversion.
There are any number of ways to accomplish this task.
 
  • #14
The only reason that may make some sense for the use of the 74hct245 would be with a sensor that has a VOL that is not low enough for TTL logic levels. It seems like the 74hct245 has a much higher VOL on its input side which will produce a TTL compatble low on its output side.

In any case it seems like an opto-isolator is the best all around solution. The only problem is I've never used one and don't know how a circuit that provides opto-isolated inputs might be designed. Can anybody point me in the right direction?
 

1. How do I control a solenoid valve with a microcontroller?

To control a solenoid valve with a microcontroller, you will need to use a relay or a transistor. The microcontroller can send a signal to the relay or transistor, which will then activate the solenoid valve. Make sure to check the voltage and current requirements of your solenoid valve to ensure compatibility with the relay or transistor.

2. Can I use any microcontroller to control a solenoid valve?

Yes, you can use any microcontroller as long as it has enough digital output pins to connect to a relay or transistor. Additionally, make sure the microcontroller has enough processing power to handle the task of controlling the solenoid valve.

3. How do I connect a sensor to a microcontroller?

To connect a sensor to a microcontroller, you will need to use one of the analog input pins on the microcontroller. The sensor will typically have three pins - power, ground, and signal. Connect the power and ground pins to the appropriate pins on the microcontroller, and the signal pin to the analog input pin.

4. What type of sensors can be used with a microcontroller?

Many different types of sensors can be used with a microcontroller, including temperature sensors, humidity sensors, pressure sensors, and motion sensors. The type of sensor you use will depend on the specific application and the data you need to collect.

5. Can I control multiple solenoid valves and sensors with one microcontroller?

Yes, you can control multiple solenoid valves and sensors with one microcontroller as long as it has enough digital and analog input/output pins. You may need to use additional components such as multiplexers or demultiplexers to expand the number of pins available on the microcontroller.

Similar threads

  • Electrical Engineering
Replies
5
Views
1K
  • Electrical Engineering
Replies
3
Views
1K
Replies
7
Views
834
  • Thermodynamics
Replies
8
Views
1K
  • Electrical Engineering
2
Replies
38
Views
5K
Replies
6
Views
6K
  • Electrical Engineering
Replies
2
Views
3K
  • Electrical Engineering
Replies
1
Views
2K
Replies
21
Views
7K
Replies
2
Views
992
Back
Top