Controlling Solenoid Valves & Sensors with Microcontroller

Click For Summary

Discussion Overview

The discussion revolves around controlling solenoid valves and sensors using a microcontroller, specifically focusing on the circuitry required for interfacing inductive proximity sensors and a photoeye sensor. Participants explore various methods for voltage level translation and protection for the microcontroller inputs.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Exploratory

Main Points Raised

  • One participant suggests using a ULN2003AI for controlling outputs but is uncertain about the input circuitry for the sensors.
  • Another participant inquires about the specific microcontroller being used, its voltage levels, and the characteristics of the sensor outputs.
  • Clarifications are made regarding the sensor output voltages and the need for voltage limiting to protect the microcontroller inputs.
  • Discussion includes the use of series dropping resistors and diode clamps to manage voltage levels from the sensors to the microcontroller.
  • One participant raises a question about the calculation of the series resistor value and the implications of fluctuating current on voltage reduction.
  • Suggestions are made to consider opto-isolators for better protection and isolation, with some participants discussing their advantages and limitations.
  • Another participant mentions the 74hct245 chip as a potential solution for voltage level translation and seeks clarification on its functionality.
  • Concerns are expressed about the effectiveness of opto-isolators given the shared power supply between the sensors and the microcontroller.

Areas of Agreement / Disagreement

Participants express multiple competing views regarding the best approach for voltage level translation and protection. There is no consensus on whether diode clamps or opto-isolators are preferable, and the discussion remains unresolved on the optimal solution.

Contextual Notes

Participants note various assumptions about the sensor outputs and the microcontroller's operating conditions, but these assumptions are not fully validated within the discussion. The effectiveness of proposed solutions may depend on specific circuit configurations and environmental factors.

j777
Messages
148
Reaction score
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
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?
 
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.
 
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).
 
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.
 
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.
 
Thanks again berkeman for your help. I think I have a fair understanding of how all this works now.
 
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?
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
7
Views
2K
  • · Replies 21 ·
Replies
21
Views
8K
  • · Replies 6 ·
Replies
6
Views
7K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 38 ·
2
Replies
38
Views
8K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
Replies
2
Views
1K