0
\$\begingroup\$

hope everyone is having a good couple weeks before Christmas, I was given this question for an assignment

How would you use an opto-isolator to sense a switch status in a 24VDC machine control circuit and transfer this status to a 3.3VDC/5VDC microcontroller input (something like an arduino uno). Explain how your circuit works. (this was posed to me as a general question, so i would assume the 24VDC motor circuit would have a transistor and diode for protection). NOTE***: I've only sim'd the 24VDC source in this case

So what I have done so far below is use a 4n25 optocoupler, to try and send a low signal to the controller when the 24VDC switch status is ON and a high state when the switch status is OFF. Pic 1 would be ON and Pic 2 below Pic 1 would be OFF. Any sort of clarification regarding the following would be much appreciated :)

  1. When the switch is closed, why is the voltage at PR1 4.5V? is there like an extra voltage drop(s) due to the IRLED inside the coupler and the resistor?

  2. Would an NPN BJT connected via separate 5VDC be a better idea to supply the IRLED rather than a voltage divider? If so, where would I connect it?

  3. This last a bit vague I apologize, but practically speaking, would this circuit even work? All I have right now is the sim and a lack of parts to realize it

enter image description here

\$\endgroup\$
4
  • \$\begingroup\$ I'm curious as to why you've used a 5V supply for a circuit that drives a 3.3V microcontroller input? \$\endgroup\$ – Finbarr Dec 11 '19 at 18:58
  • \$\begingroup\$ Hi Finbarr, so my thinking was practically I would want to apply this to something like an arduino. Per this website: cactus.io/platform/arduino/arduino-uno Serial: Pin 0 (RX) and 1 (TX). These pins are used to transmit and receive serial TTL (5V) data. These pins are also connected to the Atmega16u2 USB to Serial TTL chip on the Arduino board. \$\endgroup\$ – HP_123 Dec 11 '19 at 19:26
  • \$\begingroup\$ Does pin 10 of U1, P3B0RXD, have a rise/fall time specification on it? The opto's output, particularly when turning off, may be slower than what U1 can handle. If that turns out to be the case, you may want to add some flavor of a Schmitt trigger device, such as a 74HC14 between the opto and U1. \$\endgroup\$ – SteveSh Dec 11 '19 at 20:09
  • \$\begingroup\$ As to question #1: the branch through the optocoupler input side consists "almost only" of the R3=220 Ohms resistor, which is ~5 times as conductive as R4, so it takes as much more current than R4. If you dropped R4, the current through R1 wouldn't change much. So your voltage divider is effectively formed by R1 and R3, the ratio of which is 220/1220, equivalent to 4.32 Volts. The rest is the small effect of R4 and the diode voltage. So R4 is pretty useless, and R1 and R3 can be combined, as Elliot Anderson has already indicated in his answer. \$\endgroup\$ – oliver Dec 11 '19 at 20:10
1
\$\begingroup\$

You don't need the R1/R4 divider. Eliminate those resistors and choose a value for R3 that limits the LED current. It looks like setting R3 to 2.2kΩ would give you about 10mA maximum through the optocoupler's LED. I didn't look at the 4N25's datasheet...you might be able to go down to 5mA or so.

Note that the logic low voltage into the microcontroller is 1.01V (top picture). That is very high for a valid logic '0' but it might work for some microcontrollers at some supply voltages. I suggest that you delete LED2 and R6. Just use R2 as a 2.2kΩ pullup to the microcontroller's supply voltage and connect pin 5 of U2 (the NPN's collector) directly to the microcontroller input pin. If you want to add an LED indicator then use a separate NPN or NMOS transistor for that purpose.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.