hello everyone
to connect some 24v sensors i wanted to use optocouplers like schematic below my sensors are a few proximity sensor and photoelectric sensor. about 15 inputs.
You are assuming that those schematics are correct and functional.
Do you know if that circuit actually works?
For you application you do need any extra parts. You could actually eliminate D1
D1 is for reverse voltages protection, do you think its unnecessary?
i dont know if those schematics work or not i dont care for other parts but i wanted to know is it better to use schmitt trigger for optocouplres output? if its helping i dont care cost or complicating design. and for what reason do you think they added 74hc245? is it to protect mcu pin for over current?
The 74hc245 is a bus transceiver. The have both the direction and enable hard wired, so they are just using it as a buffer. Since they are just driving one input with it I don't see the point (unless they got paid by how complex the circuit is).
what about schmit trigger? do you think its better to use it? my sensors are some proximity and photoelectric sensors. if yes can i use H11L1M optocoupler
In theory, the 245 can be used to switch different sets of inputs to the CPU.
Say you only have 8 CPU pins to dedicate to digital inputs, and 32 actual inputs that you want to read. You can connect the actual inputs to the 245 inputs, wire all (4) of the 245 outputs in parallel, and use another couple of CPU pins to enable one 245 at a time, effectively multiplexing 32 bits onto 8 pins.
I can't tell whether your more complex schematics are actually doing that (too small!), or whether they might allow that to happen via expansion modules, or whether they're just overly complex.
One bug: the diode D1 should be connected to the other end of R1 so that R1 limits the current through the diode. Else the diode is blown immediately on reversed voltage and has no use at all.
In theory, the 245 can be used to switch different sets of inputs to the CPU.
Say you only have 8 CPU pins to dedicate to digital inputs, and 32 actual inputs that you want to read. You can connect the actual inputs to the 245 inputs, wire all (4) of the 245 outputs in parallel, and use another couple of CPU pins to enable one 245 at a time, effectively multiplexing 32 bits onto 8 pins.
I can't tell whether your more complex schematics are actually doing that (too small!), or whether they might allow that to happen via expansion modules, or whether they're just overly complex.
yeah. i think it too but 245 is manually switched off/on. so i dont think its for multiplexing. it seems they are useless in this schematic.
One bug: the diode D1 should be connected to the other end of R1 so that R1 limits the current through the diode. Else the diode is blown immediately on reversed voltage and has no use at all.
yes i just drew it quickly to post it here. thanks
If you're putting this on a circuit board, and the MCU input/optocoupler output goes no where else, just use the built-in pullup(no mention of what MCU you're using, so I'll just assume internal pullups exist...) and save yourself a resistor. If, OTOH, the signal goes elsewhere as well, it's better to be assured of a strong pullup (4.7 or 10k), rather than depending on the weaker built-in. I like to hedge my bets, so I'd likely put a resistor network in, but leave it off until I decided it was needed.
YMMV
The selection of the pull-up resistor should be based on the optocoupler's CTR (Current Transfer Ratio) and the desired response time, regardless of the physical placement of the optocoupler relative to the MCU
24V(-1.4V for LED), 4.7k series, so input current ~5 mA, CTR >50%, output current achievable would be < 2.5 mA. No mention of which MCU so assume 5V input.
But with 4.7k pullup, Ic can't ever be more than ~1 mA, so VCE will be near-zero(see last figure of linked data sheet), resulting in a perfectly reasonable logic level for the MCU input. If internal pullup is used, the current is even less.
The above is mostly for the OP. @jim-p knows it, full well, and will likely have further information for you.