Transistor NPN as swtich without current flowing

Thread Starter

Goxeman

Joined Feb 28, 2017
171
Hello,

Ive been reading this forum for long but I couldnt get to find something similar to what I am about to propose

Through GPIO of an MCU I want to give o not give GND (lets say reference of low signal of the general circuit) to a pad.
The way I do it without the MCU is just a physical switch, while pushing connects to GND, without activating the switch the pad would be floating, not connected to anything.

I want to do the same but with an GPIO of the MCU and I thought about doing with a NPN transistor but I dont know if there is a better way as far as there wont be any current flowing through the transister when giving a high signal to the base. As I said before GND will be just a reference to the pad, it will not be powering anything


Regards,
 

AnalogKid

Joined Aug 1, 2013
10,986
It must be connected to something or you wouldn't want to do it, so what is the "switched GND" output for? Depending on the output current (even if microamps into a meter) there will be a voltage drop across any solid state device used as the switch. For a power MOSFET this can be milliohms. Next up would be an NPN transistor, more milliohms.

ak
 

ErnieM

Joined Apr 24, 2011
8,377
Hello Goxeman, welcome to the forums.

I'm having trouble understanding what you are trying to do. I'm willing to bet you are not a native English speaker and we're loosing something in the translation.

All I can gather is you want a micro I/O pin to give either a low for ground or to simple float and not connect anything. There are two ways offhand to do this directly right out of a micro:

First, some micros have output pins that are open collector or open drain, meaning they only can drive the pin low, or let it float.

The other way is to switch the pin from an output type set to low to an input type to allow the floating action. This is a bit more complicated as the pin MUST change to a valid input voltage level (either a high or a low) or the input may be damaged, or just draw too much current internally leading to an early failure.

Schematics break any language barrier. Can you post a schematic sketch of what you are trying to control?
 

Thread Starter

Goxeman

Joined Feb 28, 2017
171
Hello, thank you, as you said I am not English native speaker, I am from Spain

Here I attach two schematics, one of what I doWhat I do.JPG and the other of what I want to doWhat I want to do.JPG . Basically I am trying to control the code of an encoder IC, changing the code.
The code is set applying (I dont know the right term) a high or low signal, floating would be also consider high nor low. I force always the high signal using VDD but wether I apply low or not, I would have two different codes:
1. If I apply VDD only I would have the code: 1,2 in high
2. If I apply VDD and GND I would have the code: 1,2 in high and 3,4 in low

I hope is more clear now and again thank you for reading
 

AlbertHall

Joined Jun 4, 2014
12,343
The PIC16F18854 has the option of setting individual pins of ports A, B and C to open drain. This will do the same thing as your switch. The following from the datasheet for PORTB:
upload_2017-2-28_16-44-42.png
 

Thread Starter

Goxeman

Joined Feb 28, 2017
171
The PIC16F18854 has the option of setting individual pins of ports A, B and C to open drain. This will do the same thing as your switch. The following from the datasheet for PORTB:
View attachment 121501
Thank you AlbertHall
That sounds exactly of what I want to do, so basically if I set the ODCONB bit the MCU would be connecting the output pin with its VSS? But when the bit is cleared what would be the status of the pin, would it be like I left the pin floating? I have never heard of this possibility and is totally new to me.
 

AlbertHall

Joined Jun 4, 2014
12,343
Thank you AlbertHall
That sounds exactly of what I want to do, so basically if I set the ODCONB bit the MCU would be connecting the output pin with its VSS? But when the bit is cleared what would be the status of the pin, would it be like I left the pin floating? I have never heard of this possibility and is totally new to me.
No. Set the bit for the pin you are using and set the pin as an output. Then if you output '0' from that pin it will pull the pin to 0V. If you output '1' the pin will be floating.
 

AnalogKid

Joined Aug 1, 2013
10,986
The pin can be set to either float or pull high. If you set it to float, the inputs to U1 should have a pull up resistor so they do not float.

ak
 

Thread Starter

Goxeman

Joined Feb 28, 2017
171
The pin can be set to either float or pull high. If you set it to float, the inputs to U1 should have a pull up resistor so they do not float.

ak
Hello AnalogKid,

I am activating the inputs with a high signal, so I have pulled them down with pull-down resistors, at the end is the same purpose. The best thing to do related to the mentioned pin that I will use for open-drain control, would be to pull it up when npt in use, but I need it to be floating as far as I need 0V signal or nothing


Regards and thank you
 

ScottWang

Joined Aug 23, 2012
7,397
In your application, you don't need the npn transistor, because it is as an inverter and it will also causing the problem and didn't match what you want.

You just need to connect the RB1 of Pic to the A5, A6 of U1.
When you send an '0' to RB1 and then A5, A6 will be connected to Gnd, and that is as the Sw1 is ON.

When you send an '1' to RB1 and then A5, A6 will be in the floating state, and that is as the Sw1 is OFF.
 
Top