As I told you, I'm almost completely new to electronic... Trying to understand, and I'm a bit slow...
- in the open collector scheme, If I understand it well.
the transistor is an NPN, and we have arduino pin A0 (or any other) working in INPUT_PULLUP.
- when TTL input is 0V pin A0 is connected to VCC (5V) through its internal pullup and is HIGH
- when TTL input is ~+5V, pin A0 is now connected to ground and is LOW, the internal pullup avoids a short between VCC and GND
- when the arduino is powered off, the pin has a potential of ~0V which is the same as arduino GND
the voltage divider (the two resistors) is just here
- to ensure that Voltage between base and ground does not exceed 5V?
- to limit the flow of current through the base?
and in that case, how do I calculate the values of R1 and R2?
- in the diode scheme
the anode is linked to the arduino input pin, which is in INPUT_PULLUP
- when TTL input is 0V, the current flows from arduino pin to TTL, Hence the pin is connected to ground, and the state is LOW
- when TTL input is 5V (or more), the diode is blocking and the pin stays in HIGH mode
- when the arduino is powered off, the pin has a potentiel of ~0V, which means that the diode is always blocking
- if I switch TTL5V and TTLGND (I won't do it!), then the diode is passing , lots of current flows from the arduino and the unit smokes!!
with an opto-isolator such as 4N35 (https://www.vishay.com/docs/81181/4n35.pdf)
TTL5V is connected to 4N35 pin 1 (do I need a resistor, and how do I calculate its value?)
TTLGND is connected to 4N35 pin 2
4N35 pin 3 is not connected
4N35 pin 6 is the base of the internal transistor and I don't need to connect it
4N35 pin 5 is connected to arduino input pin in mode INPUT_PULLUP
4N35 pin 4 is connected to arduino GND
In the first scheme (open collector) and 3rd scheme, I cannot use AnalogRead (in case i would like to replace the TTL by an analog trigger), because the input voltage is given by arduino VCC
In the second scheme (diode), I can use AnalogRead to adjust trigger level within the range of 0-5V
Am I right, or did I miss something? If that's not clear I'll try to upload a scheme