TTL input on powered off arduino?

Hi,

Completely new to electronics and arduino - but quite a decent background in programming.
I am designing a TTL pulse generator that should be triggered by another TTL pulse. Some seem to use one (https://www.frontiersin.org/articles/10.3389/fneng.2014.00043/full) whereas some other use much more basic wiring (GitHub - OptogeneticsandNeuralEngineeringCore/Arduino-TTL-Pulse-Generator-and-Controller: Design and Control your experiments with a TTL Generator and Controller)

From what I understand, the maximum input voltage is Vcc+0.5 (http://robotics.lib-ieronimoub.gr/?p=715)

  • Does that mean that there is a risk of damaging the arduino is the arduino is not powered (Vcc=0) and it recieves a TTL pulse between ground and A0 (or any other pin)
  • what are the possibilities to prevent this kind of damage? optical coupling or something else?

thanks

Y.

Does that mean that there is a risk of damaging the arduino is the arduino is not powered (Vcc=0) and it recieves a TTL pulse between ground and A0 (or any other pin)

Yes

what are the possibilities to prevent this kind of damage? optical coupling

Yes

Correct on pin voltages (VCC +0.5volt and ground -0.5volt).
Opto isolation could be a solution. Current limiting resistor could be another.
Post a diagram with proposed connections, and someone will look over it.

They got the external power supply current part completely wrong. "500mA to 1Amp" is wishful thinking.
With 12volt on the DC socket, combined max current draw of output pins and power pins is <= 100mA.
With 7.5volt on the DC socket this gets slightly better (500mA).
The reason is thermal limitations of the 5volt regulator. It can't dissipate more than ~1watt long term.
Leo..

I need to trigger both using a push button or a TTL input (mimmicked by the battery part as tinkercad does not provide TTL inputs).

The output TTL will be between pin13 and GND

As I understand, I have a 10k limiting resistor to input A1. is it sufficient, or should I switch to optical coupling?

thanks

As I understand, I have a 10k limiting resistor to input A1. is it sufficient

You will get a bit of parasitic powering and perhaps latch up. I would do the job properly with an opto but you could "get away" with a piss poor job.

Thanks, I'll definitively switch to optocouplers..But I need to order some!

Or, if isolation is not necessary, you can just use an open collector transistor, with input pullup selected.

TTL-Arduino.png

Note: that this will invert your signal, but you can account for that in your software.

Isn't a diode all that's needed? This will prevent exposing the Arduino to a voltage when it is powered off. When powered on, the Arduino can use its internal pull-up. If the input signal is low, the diode will allow the Arduino pin to be pulled low

Even simpler: a single diode, pointing away from the Arduino, and internal pull-up enabled.
That way the external signal can pull low the pin, but not high. Also works for signals >5V. The diode is basically a one-way level shifter. Perfectly safe as long as the external signal doesn't go over the reverse voltage of the diode (depending on the type this can be as much as 1,000V) or negative.

"Great minds think alike"

Or is it

"Fools seldom differ"?

Yes :slight_smile:

Thanks all!

As I told you, I'm almost completely new to electronic... Trying to understand, and I'm a bit slow...

  1. 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?
  1. 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!!
  1. 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

thanks

Y.

The only scheme you could use analogRead() with is the resistor you mentioned in post #3. But you describe the signal as "TTL". That L stands for Logic, ie. high or low. So why would you want to use analogRead()?

y33:
In the second scheme (diode), I can use AnalogRead to adjust trigger level within the range of 0-5V

No: the diode also has a voltage drop, of about 0.5V. So the voltage at the Arduino pin will always be a bit different than the signal voltage.

All these schemes are meant for reading digital signals, which is what you asked for.

  1. 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

No one or the other not both.
Yes you need a resistor, calculate it like you would for any LED. The data sheet shows you the forward voltage drop and current you need.

As others have pointed out this is a DIGITAL interface because that is what you said. If you want an analogue transfer then you can do this bit it requires an optical isolator with one LED feeding into two transistors. Then you need to have an op-amp in the circuit to make the thing a bit more linear.

Something like this:-

So the Vcc/GND on the left hand side are from a different power supply than the Vcc/GND on the right hand side? That's the only way you can keep the isolation.

Yes but we are not doing it for the isolation so the grounds can be common. We are doing it because the OP wanted a powered input to a device that is unpowered.

for analogRead, i was just wondering how flexible the wiring would be, in case i would need to trigger with something else than a TTL.

concerning the open collector, can anyone point me how to calculate R1 and R2?

concerning optocoupling with 4N35, why shoul only one of TTL5V or TTLGND be connected ( if TTLgnd and arduino gnd aare connected, it seems to me that there is no more isolation!)

concerning optocoupling with 4N35, why shoul only one of TTL5V or TTLGND be connected

Because if you connect both you have nothing limiting the LED current and you will blow the diode. Also with both connected there is nowhere to put the signal you want to read.

if TTLgnd and arduino gnd aare connected, it seems to me that there is no more isolation

True there is not full isolation but you don’t want or need full isolation. You just want to keep power out of an unpowered circuit.
However you will have full isolation if you have two separate power and ground signals, one for each system.

concerning the open collector, can anyone point me how to calculate R1 and R2

R1 - 1K
R2 - 10K

Thanks all,

the problem with diode is that we're on INPUT_PULLUP mode. when the TTL sending device is connected, everything is fine, but if someone unplugs the BNC connector that serves for TTL input, the pin will be HIGH, which I would like to avoid (although it's less dramatic that TTL input to powered off arduino...)
with diode
TTL5V ----> pin HIGH
TTL0V ----> pin LOW
TTL disconnected ---->pin HIGH

with the open collector transistor,
TTL5V ---->pin LOW
TTL0V ---->pin HIGH
TTL disconnected---->pin HIGH

I guess optocoupling will give the same results as open collector wiring