Take a look at this one:
There are a couple of ways to do it.
There are a couple of ways to do it.
Attachments
-
85.4 KB Views: 112
To reverse the output polarity, connect the output collector to 3.3V and connect the resistor from the emitter to ground. The signal from the emitter to ground will now be in phase with the input.Circuit looks good, but it has reverse logic from desired. When 10V present at pin 1, pin 5 will be low. Sorry my earlier post suggested this configuration.
Depends on the switch type. Personally, I'd allow for multiple bounces lasting several mS in total.Hard to say about the debounce. I think it's about a millisecond.
I updated the diagram, and also changed it slightly to make it more easily understandable of what is going on. I cannot change anything associated with the machine, I can only tap off the wires.Will you stop focusing on the output until we get the input squared away?
Follow the netlist I gave you and update the diagram. I don't have Eagle so I can't do it for you. What I want you to do is setup the following situation, you can make changes to your hearts content AFTER you understand what is going on.
1) Connect the power supply through a 562 ohm resistor to the anode of the LED.
2) Connect one terminal of the normally open switch(pin 3) to the anode of the LED.
3) Connect the other terminal of the switch(pin 2) to GND.
4) Pin 1 of the switch is irrelevant, leave it disconnected
5) connect the cathode of the LED to GND.
If you do this, when the switch is open, you will have:
a current of approximately 15 mA flowing through the resistor and the diode to GND. The LED will be emitting lightWhen the switch is closed, you will have:
a current of approximately 17.8 milliamps flowing through the resistor to GND. The LED will be dark because no current will flow through it. No current flows through the diode because the voltage at both terminals is the same. Ohms Law -- no voltage drop, no current flow.
(3.3 Volts - 0.1 Volts Vce drop) / 0.0016 ≈ 2.0 K Ohms
Where did you get the 1.6 mA for the collector current from? And where did you get the 0.1 voltage drop from? I thought the current coming in from the diode side had something to do with the output? (e.g. the CTR value?)What I can infer about the unknown circuit is, that it should not contain outputs that will will fight with GND or +10Volts.
On the output side we can do one of two things depending on the sense of the logic.
Assume a resistor R4 of some value we will calculate
Netlist A: Grounded Emitter
- +3V3 to R4(pin 1)
- R4(pin 2) to 4N35(pin 5)
- 4N35(pin 6) to GND
When current flows in the LED, and the LED is BRIGHT, the output transistor is ON and current flows from the 3.3V power supply through R4, into the collector, out the emitter to ground. How much current you ask? Depends on R4. There will be some voltage drop across the transistor and we can choose 1.6 milliamps as the collector current.
When no current flows in the LED, and the LED is DARK, the output transistor is OFF. No current flows through the transistor. No current flows through the resitror R4. Quick Ohms Law question: If there is no current flowing through the resistor, what is the VLOTAGE DROP across the resistor? If you answered 0, you are correct. If there is no voltage drop across the resistor then the voltage at the collector of the output transistor must be the supply voltage, namely +3.3 Volts.Code:(3.3 Volts - 0.1 Volts Vce drop) / 0.0016 ≈ 2.0 K Ohms
Netlist B: Emitter Follower
R4 is still 2.0 K Ohms
- +3V3 to 4N35(pin 5)
- 4N35(pin 6) to R4(pin 1)
- R4(pin 2) to GND
Can you work out the fact that in this case the logic is inverted from Netlist A?
Ok I think I am understanding now thanks!1.6 milliamperes is one standard TTL load. As such it will drive 1 TTL input, or 4 LSTTL inputs or a whole bunch of CMOS inputs. The Arduino input is a CMOS input and if that is all that is connected to this output then that amount of drive current should be more than sufficient. Now for where CTR comes in. We set the diode current for 15 milliamperes, but whe chose the load resistor in the collector circuit to limit the output current. This means that under all conceivable conditions there will be enough light from the LED to guarantee that the photo transistor is turned on hard. Even if the CTR deteriorates with age there will be sufficient light from the LED to ensure turn on.
0.1 volts is a "typical" Vce voltage drop for an NPN tansistor in the ON condition. You can read the datasheet closely for the actual value, or you can measure it.
Netlist A and Netlist B are not essentially the same circuit. If you line up both circuits you will see that the output of B is the opposite or inverse of A. That is why the circuit is referred to as an emitter follower. The emitter literally follows the input on the base.
A:
Current flows, LED ON, output low (GND)B:
Current off, LED OFF, output high(+3.3V)
Current flows, LED ON, output high (+3.2V)
Current off, LED OFF, output low (GND)
Now that you understand the basic circuits of optoisolators you can experiment with debouncing and other stuff.
The output of the optocoupler is just going to an input pin on a microcontroller (3.3v input). I was not sure if the capacitor should go on the diode side, or on the transistor side.Both the circuits I posted are de-bounced.
What are you driving with the output of the opto.