0

Prevent serial rx pin from connecting before bat
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Prevent serial rx pin from connecting before bat

by scotjmonaghan on Sat Jan 12, 2019 5:05 pm

I am using the trinket M0 3.3v as the brain of some blocks that connect and talk to each other via surface pads. Each block has 3 pads: 3.3v power in, ground, and signal (which connects to the Trinket serial RX pin).

When power connects first they work great! But if the serial pad connects before power then the trinket has a fault (a weak power signal passes from the serial in to ground).

I’d like to prevent the rx pin from receiving any load until the power is connected.

My idea is to use a PNP transistor as a switch to block any signal to the rx pin until the trinket initializes.

I’m a super noob at this so 2 questions:
1. Will this work?
2. Is this a good idea or is there a better way to prevent signal to rx until the trinket has power?

Note: the signal is from a an Arduino Uno TX pin.

Thanks in advance!

scotjmonaghan
 
Posts: 6
Joined: Sat Jan 12, 2019 2:55 pm

Re: Prevent serial rx pin from connecting before bat

by adafruit_support_mike on Mon Jan 14, 2019 5:13 am

You'll need more than a single transistor. A PNP can control whether a high input passes through, but can't control a low input.

The official circuit for that job is called a 'transmission gate', and is made from an N-mosfet and a P-mosfet in parallel. The P-mosfet transmits signals near VCC, and the N-mosfet transmits signals near GND.

You don't need a transmission gate's analog voltage range for a digital signal though. A logic buffer with an enable pin, like the 74x125 or the 75x245, would fit your requirements better:

https://www.adafruit.com/product/1787
https://www.adafruit.com/product/735

Those can run from the same power as the microcontroller, and you can route all your external IO through them. The 74_125 has an enable pin for each signal, and the 74_245 has a single enable pin for 8 channels of data.

adafruit_support_mike
 
Posts: 57493
Joined: Thu Feb 11, 2010 2:51 pm

Re: Prevent serial rx pin from connecting before bat

by scotjmonaghan on Mon Jan 14, 2019 11:12 am

Thank you!

scotjmonaghan
 
Posts: 6
Joined: Sat Jan 12, 2019 2:55 pm

Re: Prevent serial rx pin from connecting before bat

by scotjmonaghan on Mon Jan 14, 2019 11:49 am

Thanks again! The MOSFET offered by adafruit is a bit cost prohibitive for this project. For the serial digital signal can I use a pair of PNP and NPN BJTs to achieve the same result?

scotjmonaghan
 
Posts: 6
Joined: Sat Jan 12, 2019 2:55 pm

Re: Prevent serial rx pin from connecting before bat

by adafruit_support_mike on Tue Jan 15, 2019 3:59 am

Sort of.

The circuit would look like this:

bjt-transmission-gate.jpg
bjt-transmission-gate.jpg (34.37 KiB) Viewed 121 times
Setting EN high will turn on both NPNs, and the one shown to the right will generate /EN which turns on the PNP.

The NPN in the transmission gate will carry signals close to 3.3V, but the maximum output voltage will be about 0.6V lower than EN. Assuming a 3.3V supply, that will be around 2.7V.

The PNP will carry signals near 0V, and the lowest output voltage will be around 0.6V.

Mosfets don't have the 0.6V diode voltage of BJTs.. their channel resistance is purely resistive, so the output voltages can get within a few millivolts of the rails when the current through flowing through them is low.

The SAMD21E is spec'd to accept 0.6V as low input and 2.7V as high input when running from a 3.3V supply though, so the offsets shouldn't cause any major problems.

adafruit_support_mike
 
Posts: 57493
Joined: Thu Feb 11, 2010 2:51 pm

Re: Prevent serial rx pin from connecting before bat

by scotjmonaghan on Tue Jan 15, 2019 3:52 pm

Thanks so much.

I'm super new to this so I prototyped the transmission gate out in tinkercad. It definitely took a few tries.

I used a potentiometer to simulate my high an low signal, and I put slide switches on my transistors to simulate EN and /EN.

Does this look correct?

Transistors on (signal high):
2019-01-15 13_42_16-Window.png
2019-01-15 13_42_16-Window.png (94.88 KiB) Viewed 110 times


Transistors off (signal high):
The attachment 2019-01-15 13_44_09-Window.png is no longer available
Attachments
2019-01-15 13_44_09-Window.png
2019-01-15 13_44_09-Window.png (94.62 KiB) Viewed 110 times

scotjmonaghan
 
Posts: 6
Joined: Sat Jan 12, 2019 2:55 pm

Re: Prevent serial rx pin from connecting before bat

by scotjmonaghan on Tue Jan 15, 2019 4:36 pm

Follow up question.

I created this simpler circuit, that seems to achieve what I need in simulation.

I'm only looking to block transmission of voltage on the Trinket M0 rx pin. This gets voltage down to 199 mV even when the signal is high.

Would this work?

npn_only_on.png
NPN on (signal high)
npn_only_on.png (66.95 KiB) Viewed 107 times


npn_only_off.png
NPN off (signal high)
npn_only_off.png (66.95 KiB) Viewed 107 times

scotjmonaghan
 
Posts: 6
Joined: Sat Jan 12, 2019 2:55 pm

Re: Prevent serial rx pin from connecting before bat

by adafruit_support_mike on Wed Jan 16, 2019 2:40 am

The implementation of the transmission gate above is close, but the PNP is reversed. The NPN's collector and the PNP's collector (labeled C on the transistor symbols) should be tied to the input, and both emitters (labeled E) should connect to the output.

The single-NPN version has a couple of problems.

First, it's measuring the voltage between the NPN's emitter and the 3V rail. A microcontroller will measure the voltage between the NPN's emitter and GND. That isn't a big problem by itself.. you can swap the voltmeter connections around easily enough.

Second, and much worse, the version that shows 2.98V is a special case of transistor operation that won't work under most other conditions.

All transistors are theoretically symmetrical.. an NPN is a layer of P-type silicon between two layers of N-type silicon, and both N-layers should be able to work as the emitter or collector, depending on how you connect voltage to them. Real BJTs are made asymmetrically, with heavily-doped N-type silicon (low resistance) for the emitter, and lightly-doped N-type silicon (higher resistance) for the collector.

Real BJTs do work backwards, in what's known as the 'reverse transistor region', but they work about a hundred times as well the normal way around.

In the circuit above, you've discovered the reverse transistor region.

In the version that shows 2.98V, the NPN's collector has to be connected to 0V while the base is still connected to 3V.

Any time you put a layer of P-type silicon up against a layer of N-type silicon, you get a diode.. that's basically what diodes are. An NPN has two P-to-N connections, one between the base and collector, and the other between the base and emitter. On their own, they both act like regular diodes.

With the base connected to 3V and the collector connected to 0V, the base-collector diode becomes forward biased and lets current flow from the base to the collector.

The layer of P-type silicon between the base and emitter of an NPN is extremely thin (a few atoms), which allows current from one diode to leak into the other. When an NPN is working normally, about 99% of the current that would normally flow from the base to the emitter gets swept off through the collector, which allows a small amount of base-emitter current to control about 99 times as much collector-emitter current.

In the reverse transistor region, 99% of the current that would normally flow from the base to the collector does go that way, and only about 1% leaks over to the emitter. The actual current through the emitter is quite weak, and the simulation shows about 200mV between the emitter and collector because a theoretical voltmeter has infinite resistance.

In real hardware, the circuit would be twitchy and unreliable. I wouldn't want to use it for a fast communication interface like a Serial connection.

adafruit_support_mike
 
Posts: 57493
Joined: Thu Feb 11, 2010 2:51 pm

Re: Prevent serial rx pin from connecting before bat

by scotjmonaghan on Wed Jan 16, 2019 11:26 pm

Wow. Thanks so much for your patience and thorough explanation. I learned a ton!

Here is the updated circuit design. I think I finally got it!

2019-01-16 21_23_43-Circuits BJT Transmission Gate _ Tinkercad.png
2019-01-16 21_23_43-Circuits BJT Transmission Gate _ Tinkercad.png (89.09 KiB) Viewed 87 times

scotjmonaghan
 
Posts: 6
Joined: Sat Jan 12, 2019 2:55 pm

Re: Prevent serial rx pin from connecting before bat

by adafruit_support_mike on Thu Jan 17, 2019 3:29 am

Yep, that looks right.

adafruit_support_mike
 
Posts: 57493
Joined: Thu Feb 11, 2010 2:51 pm

Please be positive and constructive with your questions and comments.