Help with optocoupler optocoupler connect to schmitt trigger 74HC14 - Page 1
Forum section: electronics / projects

author: Danesh_SA
author_rank: Contributor
timestamp: December 30, 2019, 10:33:04 am
content: Hi everyone,I design a circuit that read 24V digital input .I want to use schmitt trigger after optocoupler ,since the Schmitt trigger is used to correct optocoupler output waveform fed into MCU.I realize that some Industerial boards used RC filter between optocoupler and 74HC14 ,whey it used?Since i don't see any reliable circuit that interface 74HC14 and an optocoupler ,I design the circuit below,does it perform right ?

author: Zero999
author_rank: Super Contributor
timestamp: December 30, 2019, 10:59:05 am
content: Why not use the H11LXM, which has the Schmitt trigger function built-in?http://www.farnell.com/datasheets/1874889.pdf?_ga=2.224244446.41188871.1577703349-157924787.1559479246&_gac=1.128826494.1576332778.Cj0KCQiArdLvBRCrARIsAGhB_sxJgbXZ1y39P0BlsCDX6_cxmAxk4dNR_hlDPrTptGxtAqRJ3XH9tWgaAoybEALw_wcBAn RC filter can be used to reject unwanted high frequency signals. It can be as simple as connecting a capacitor across the IR emitter.

author: Danesh_SA
author_rank: Contributor
timestamp: December 30, 2019, 11:52:08 am
content: Dear zero999,Actually I use LTV-814S which is an AC optocoupler ,therefore i want to add 74HC14 in opto's output to have staible signal,could you send me schematic of this?and explain about RC filter and values in this application?Thank!

author: StillTrying
author_rank: Super Contributor
timestamp: December 30, 2019, 01:13:07 pm
content: If it just 50Hz-60Hz switching and as long as there's enough current in the opto's LED, those values look about right to me, The opto and the hysteresis would do some filtering. About 2mA should flow in the indicatorredLED.

author: fcb
author_rank: Super Contributor
timestamp: December 30, 2019, 02:29:29 pm
content: Are you trying to detect the presence of 24VAC? The present design will give you a series of 50/60Hz pulses, which you'll have to interpret correctly further down the chain.If you want to create a filter then just add a capacitor across the opto-coupler transistor - calculating this is straightforward.74HC14 datasheet (Nexperia) shows a 'positive going threshold voltage' of 0.7V (minimum, Vcc=2.0V, any temp) and 1.7V at Vcc=4.5V, so lets assume we want to stay below 1.1V (Vcc=3.3V). Lets also assume that your phototransistor can get down to 0.3V when fully turned on and can discharge the new capacitor in that time. As 50Hz might be your worst case frequency, we need to hold the capcitor to <1.1V for at least 20milliseconds.Plug these values into one of the many online calculators:http://mustcalculate.com/electronics/capacitorchargeanddischarge.php?vfrom=0.3&vto=1.1&vs=3.3&r=4700&time=0.02And you get 13.7uF for your capacitor. So perhaps start by prototyping with a 22uF or change your 4K7 to higher value.

author: MarkF
author_rank: Super Contributor
timestamp: December 30, 2019, 03:52:37 pm
content: Since your optocoupler is AC/DC, why have the diode D4?Circuit with a RC filter on the input of the Schmitt trigger:Edit: Show MCU connection.Depending on the LED, I believe R2 should be something like 150Ω.

author: Danesh_SA
author_rank: Contributor
timestamp: December 30, 2019, 04:56:00 pm
content: Thanks all for your answers,Since industerial sensors may be sink or source ,therefore i use AC optocoupler ,depend on COM pin HIGH or LOW ,it will be in sink or source mode,So its NOT for just detect the 24VAC.D3 is indicator LED ,if there is any HIGH level in input,D3 will turn on (just like PLCs).I have these questions:1-How should i connect H4HC14 to MCU ,does it need any series resistor between 74HC14 output and MCU pin?2-Does the current draw by D2 has any effect on Schmitt trigger stability?Quote from: StillTrying on December 30, 2019, 01:13:07 pm3-As you say the schmitt trigger do some filtering ,is it ok not use RC filter in this circuit(and maybe all time when use schmitt trigger)?

author: Zero999
author_rank: Super Contributor
timestamp: December 30, 2019, 05:39:04 pm
content: Quote from: Danesh_SA on December 30, 2019, 04:56:00 pmAs long as the MCU's input is just an input and can't be configured as an output, then just connect the 74HC14 directly to the MCU.There is no D2 in any of the schematics you've posted. If you're talking about D3 loading the output of the Schmitt trigger then yes, that can be an issue. With a 4.5V supply, the lower limit for a standard 5V rail, the 74HC14 is only specified to give valid logic output levels when the output current is under 4mA. Assuming an LED forward voltage of 2V, the current will be just over 6mA with a 470R current limiting resistor. I think you should increase the series resistor value to 750R or 1k, which should still give sufficient brightness with modern efficient LEDs.You can probably get away with no RC filter at all.

author: Danesh_SA
author_rank: Contributor
timestamp: December 30, 2019, 06:13:02 pm
content: Thanks for complete answer Zero999,1-I cant understand you say this"As long as the MCU's input is just an input and can't be configured as an output, then just connect the 74HC14 directly to the MCU."It Will be and EVM board and maybe someone configure that pin as output accidentally,would you explain what happend if this pin on MCU configured as output?2-I will change the resistor to 1k.3-4-another question ,would you please explain about the maximum speed of this circuit ? is it possible to capture more than 100 Hz ,input signal?Thanks!

author: Zero999
author_rank: Super Contributor
timestamp: December 30, 2019, 07:05:22 pm
content: Most microcontrollers have the ability to set the ports as inputs or outputs. If the port is intended to be used as an input, but it's misconfigured as an output, then it will present a low impedance to one of the supply rails, depending on whether it's set high or low. If the port is set to an output, with a logic level low, it will be connected to 0V, via a low impedance. If the 74HCT14's output is high, then a high current will flow into the MCU's output pin, causing excessive power consumption and possible damage to the port. If it's possible the port could be accidentally configured as an output, add a series resistor to limit the current to a safe level.The opto-coupler will be the the bottleneck, speed wise, but it will certainly be fast enough for 100Hz, so don't worry about it.

author: StillTrying
author_rank: Super Contributor
timestamp: December 30, 2019, 07:39:52 pm
content: Quote from: Danesh_SA on December 30, 2019, 06:13:02 pmWith only 3.3V I don't think having a couple of the MCU's and the 74HC14's outputs fighting each other for a while would cause any permanent damage in practice.QuoteZero's calculations seem to be on a Vcc of 4.5V, your schems show only 3.3V, with 1k the LED current will only be ~1.4mA.We don't know if the red LED is just a PCB indicator, or something that's to be easily visible in a brightly lit room.The proper way to do it would probably be to useanother gateto light the LED, that way the MCU doesn't see any of the damaged logic level due to the LED's mA.QuoteWith those values switching the 24V at ~5kHz would still get through to the MCU, once you've decided the max speed needed some RC filtering can be added to reduce higher frequency noise level below the 74HC14 hysteresis levels, so it doesn't switch on the noise, - in theory.

author: Zero999
author_rank: Super Contributor
timestamp: December 30, 2019, 09:11:52 pm
content: Oh I missed that the supply voltage as only 3.3VIn that case it will be fine since the output resistance of the 74HC14 is higher, at low supply voltages, so the current will be limited to a safe level, even if it's connected to a short circuit. 1.4mA might be bright enough for a modern efficient LED, under normal office lighting, but the current might need to be increased, requiring a lower, not higher value series resistor.

author: Danesh_SA
author_rank: Contributor
timestamp: December 31, 2019, 07:22:23 am
content: Thank you all for the replies.All the system power is 3.3V.I add my final schematic for this EVM ,I change this items:1-I place "MCUIN1" after R3 wihich is 1K res .R3 will Limit the current for D3 which is aGREENLED and limit the current,when someone accidentally configure this MCU pin as output Low and 7414 output is High ,It will prevent short circuit and damage to MCU pin and 74HC14.(Is it OK? or i should add another 1k resistor paralell with R3 and connect it to "MCUIN1"?)2-Since it will be an EVM ,Finally maybe someone wants to install it in din rail rack , in this situation ,brightness is NOT important ,LEDs just for indicator.(Thanks for your attention @StillTrying)

author: Zero999
author_rank: Super Contributor
timestamp: December 31, 2019, 09:44:56 am
content: I was wrong about R3 because I missed the 3.3V supply and assumed 5V. If it's a high efficiency green LED you might get away with 1k, but if it's a crappy old yellowish-green LED, you might need to reduce the resistor value back to 470R or less.Are you talking about connecting the MCU input to the LED? If so, check the LED's forward voltage is high enough to be a valid logic level high for the MCU. Failing that connect it directly to the output of the 74HC14. Again, I was wrong about high currents flowing, because I missed that the supply voltage is only 3.3V, which will mean the output resistance of the 74HC14 will limit the current to a safe level, even if the MCU's I/O port is configured as an output.

author: Danesh_SA
author_rank: Contributor
timestamp: December 31, 2019, 11:37:01 am
content: Thank's for your response,So you mean is it OK to connect 74HC14 Directly to MCU pin without any current limit resistor? and the reason is 3.3V voltage .I can't find that you say "...at low supply voltages, so the current will be limited to a safe level, even if it's connected to a short circuit" on 74HC14 datasheet ,i think short circuit is always short circuit and it cause draw current(even in 3.3V or 5V ),why you say it's safe because it's 3.3V and NOT 5V?I wasWrongabout connecting the MCU input to the LED,the LED's Vf=1.25v ,and i think it's a little bit creepy to sense input signal from here,therefore i connect the 74HC14 output directly (or with series limit current resistor ) to MCU input.I attached the schematic below after correct it,now all things OK?Thanks Zero999

author: fcb
author_rank: Super Contributor
timestamp: December 31, 2019, 02:07:43 pm
content: We don't know what your end goal is? examples:a. If you are building a PLC or something similar and cost is an issue, I wouldn't bother with 74xx device at all, just the pull-up resistor and wack it straight into the microcontroller (do you need the LED?).b. If you need to 100 channels of this then I'd scan them with perhaps a bunch of 4051's, each with it's own pull-up resistor on the output.c. If it's purely educational, then stick with an LED and gate.d. If it's a commercial device, does cost factor? size? assembly time?I'm all for helping, but some idea of what your goal is will help.Also, if the purpose of your 74xx to MCU resistor is to current limit, i'd make it more like 10K - as you've probably got multiple channels going into the MCU and if you misconfigure one channel, you are likely to misconfigure a whole ports worth. Again, some idea what your goal is will help.

author: StillTrying
author_rank: Super Contributor
timestamp: December 31, 2019, 03:31:29 pm
content: It never fails to surprise me how much is going on in even just 4 or 5 components, especially when you start to tune them to accept a suitable range of input and output.The low power LED indicationseemsto be sorted."We don't know what your end goal is?"Yep.We still don't know enough about the 24V input, it needs defining to get much further.Max. 100Hz 24Vpp square waves?Should a 2ms wide 18V pulse be counted as a switching or rejected as noise?Could 2ms wide pulses more easily be rejected by the software as noise?

author: Danesh_SA
author_rank: Contributor
timestamp: December 31, 2019, 05:17:47 pm
content: Thanks all for your replys,My goal is to design a kind of DAQ and it will be open source in future.it has 4-8 isolated digital input.(Low speed),many sensors in industry are PNP or NPN ,there is link below of proximity sensors:http://www.ia.omron.com/products/category/sensors/proximity-sensors/My responsibility to engineering is to consider many situations and designreally goodproduct with considrable price,i see many of designs on net ,and they made without thinking and they are just copy and paste!anyway,@fcb really thanks for your attention about (a..d) situtions,i consider many of them ,i.e: I see design's from siemens and rockwell and ... ,many of them use Schmitt trigger IC after optocouplers ,and im interested to use it in my design ,and i want to know how it works and design my DAQ digital input with good protection level(i.e : I say maybe someone accidentally configure the MCU as output in low level and i don't want the circuit functionality fails.)@StillTrying,@fcb so i change R4 to 10K . green LEDs for input indicator, as R3 is 1k ,the current draw from 7414 will be a little(1mA each channel ) and i think its OK

author: StillTrying
author_rank: Super Contributor
timestamp: December 31, 2019, 06:14:42 pm
content: "so i change R4 to 10K"I'd leave it at 1k for speed and noise reasons.It's easy to roughly estimate the dissipation(s) if/when the 2 outputs were trying to pull in different directions thorough the 1k.With a 3.3V supply there'd be about 2.8V across the 1k = 2.8V x 2.8mA = 7.8 mW, that's never going to harm the 1k.For the output(s) themselves 2.8mA x 0.5V = 1.4 mW, that's never going to harm the outputs.You could have that 1k even a bit lower, - but might stop the dim LED lighting when the outputs were fighting!I'd concentrate on the 24V input's minimum acceptable voltage, maximum safe voltage protection ?

author: Danesh_SA
author_rank: Contributor
timestamp: December 31, 2019, 07:09:58 pm
content: Dear StillTrying,Thanks for response,Now i got it why 1k is reasonable value ,i can use 0603 package comfortably.I Know the better option is use another Driver for indicator LEDs but because of price ,i think its a good and stable design to connect both of them(LED ,MCUIN1) to 7414's output.1-you do this "With a 3.3V supply there'd be about 2.8V across the 1k = 2.8V x 2.8mA = 7.8 mW, that's never going to harm the 1k." for worst case scenario(outputs were fighting),and i think the 2.8mA came from (1.4mA -(- 1.4mA)) -> current going through R3 ,when the outputs are fighting.Is it right?2-I keep R4 ,1k as i say above and you mention it.3-The maximum safe voltage will be about Vc=45v(i use TVS).

author: Zero999
author_rank: Super Contributor
timestamp: January 01, 2020, 11:07:42 pm
content: How many channels do you need? The 74HC14 has six and is cheap.I'm not sure what you're asking. The output impedance of the 74HC14 depends on the supply voltage. At low supply voltages the impedance increases, as there isn't so much voltage drive on the output transistors' gates. At higher supply voltage, the transistors' gates are driven more hard on, so the output impedance is much lower. This means if an output is shorted to 0V and is set high, the current will increase exponentially with the supply voltage.I couldn't find a specification for 10V, just 2V, 4.5V and 6V. Refer to figure 33 on page 34 of the 74HC family data sheet. At a die temperature of 25oC, when the output is set low and the output is shorted to the positive rail, i.e. it has the same voltage as the supply, the output current will typically be 6.2mA, 32mA and 58mA for supply voltages of 2V, 4.5V and 6V respectively. At 3.3V the current will still be under the specified maximum current of 25mA, with the output short circuited, so it's safe to skip the current limiting resistor. To help matters the current reduces, as the die temperature increases, which to some extent will help to protect the IC to some degree, but it will probably still burn out if the output is shorted and the supply voltage is 4.5V or 6V.https://www.dectel.ru/analogues/ms/HCT_USER_GUIDE.pdf

author: Danesh_SA
author_rank: Contributor
timestamp: January 02, 2020, 07:39:41 am
content: Dear Zero999,Thank you for your detailed answer, that's exactly my answer.I need 4 channel of 74HC14.Now i got it.With 3.3V ,i connect 74HC14 directly to MCU ,there is no fear of burning!