Single BJT voltage level shifter issue

Thread Starter

Vilius_Zalenas

Joined Jul 24, 2022
159
Hi,

I encountered strange problem with a simple BJT voltage level shifter.

Quick background: I am doing a 74HC590 based counter that is outputting data to Arduino Uno, my supply is regular USB (exact measured voltage is 4.6-4.7V, I guess that is in the tolerance region). 74HC590 works as intended only the output bits go only as high as 3.2-3.4 V at logic ,,1" I guess that is due to the internal semiconductor junction losses in the chip itself. Since Uno operates at 5V, 3.4V is considered logic ,,low", hence I am making a voltage shifter.

I tried to use both NPN (2N2222) and PNP (BC640 and S8550) transistors to make a non-inverting voltage shifter 3.4V to 5V. I have used similar circuits in the past without any problems. This time (with both NPN and PNP configurations) I am still getting only around 3.9V at the output which should be way above 4 Volts (considering the supply) and Arduino is still reading 3.9V as logic low. I checked my wiring really good, I am getting the right signals on the right pins, I am sure that everything else in the circuit works flawlessly, but this voltage shifter...

What is the problem with such voltage shifter and how do I fix it? I want to keep the circuit as simple as possible. Thank you in advance.20231014_131129.jpg
 
Last edited by a moderator:

sarahMCML

Joined May 11, 2019
352
Hi,

I encountered strange problem with a simple BJT voltage level shifter.

Quick background: I am doing a 74HC590 based counter that is outputting data to Arduino Uno, my supply is regular USB (exact measured voltage is 4.6-4.7V, I guess that is in the tolerance region). 74HC590 works as intended only the output bits go only as high as 3.2-3.4 V at logic ,,1" I guess that is due to the internal semiconductor junction losses in the chip itself. Since Uno operates at 5V, 3.4V is considered logic ,,low", hence I am making a voltage shifter.

I tried to use both NPN (2N2222) and PNP (BC640 and S8550) transistors to make a non-inverting voltage shifter 3.4V to 5V. I have used similar circuits in the past without any problems. This time (with both NPN and PNP configurations) I am still getting only around 3.9V at the output which should be way above 4 Volts (considering the supply) and Arduino is still reading 3.9V as logic low. I checked my wiring really good, I am getting the right signals on the right pins, I am sure that everything else in the circuit works flawlessly, but this voltage shifter...

What is the problem with such voltage shifter and how do I fix it? I want to keep the circuit as simple as possible. Thank you in advance.View attachment 304932
Where did you get your I.C.s from? 74HC590 should have no trouble getting close to VDD, unless you have some kind of excessive load on the output, such as a LED to ground without a suitable resistor in series.
 

Alec_t

Joined Sep 17, 2013
14,192
Wire your single transistor in common-emitter mode to get the 5V voltage swing. This will, however, invert the logic.
 

BobTPH

Joined Jun 5, 2013
8,649
Since Uno operates at 5V, 3.4V is considered logic ,,low"
Where did you get that info?

Arduino logic levels are .3 Vdd for low and .6 Vdd for high. So at 5V it will recognize anything over 3V as high. At 4.6V, 2.7V is high.

I don’t know why you would be having this problem.
 

Thread Starter

Vilius_Zalenas

Joined Jul 24, 2022
159
Where did you get that info?

Arduino logic levels are .3 Vdd for low and .6 Vdd for high. So at 5V it will recognize anything over 3V as high. At 4.6V, 2.7V is high.

I don’t know why you would be having this problem.
Well, in my last PNP config, if I disconnect the 74HC590 output from transistor`s base, or I just tie my arduino inputs straight to Vdd, I am getting that logic 1. So it seems that 4.6+ V really does work as logic high, but 3.9 V gives my zeros in the serial monitor running the same code...
 

BobTPH

Joined Jun 5, 2013
8,649
Well, in my last PNP config, if I disconnect the 74HC590 output from transistor`s base, or I just tie my arduino inputs straight to Vdd, I am getting that logic 1. So it seems that 4.6+ V really does work as logic high, but 3.9 V gives my zeros in the serial monitor running the same code...
You are doing either something wrong or you have a damaged Arduino. 3.9V should definitely be read as a 1. Where is the 3.9V coming from?

I am actually beginning to wonder if you have configured the Arduino pin as an output and it is outputting a zero. This could explain what you are seeing. It could not pull down a connection to Vdd but it could pull down a connection to your other 74HC590.

Please try a minimum program to set the pin to an input and light an LED when it is high. Then, when you test different inout levels, make sure you measure the voltage when the source is connected to the input.
 

Thread Starter

Vilius_Zalenas

Joined Jul 24, 2022
159
OK, I fixed the voltage shifter, now I either get 0V or strong 5V (added extra 5V supply for the current). My shifter is now an inverter, so I invert the bits in the software one more time to get the original 74HC590 result.

The thing is that no matter what is the real voltage on the arduino pin, the digitalRead always results in logic high (before software conversion). My wiring is 100% good, there are no floating or unconnected pins. It sound really bad, but this is what is actually happening: I hook a multimeter directly to the arduino pin I am interested in, lets say the multimeter reads 0V (every bit is set by 74HC590 according to the counting result) and my digitalRead still gives me logic high. I even freeze the 74HC590 output to examine the pins after the counting is done. On the other hand, if I disconnect the wire from the 2N2222 collector and put it straight to GND, my digitalRead becomes correct. Down below is my wiring and the demo code for pin testing.
20231014_175825.jpg
C:
const int BIT_1  = 2; //LSB
const int BIT_2  = 3;
const int BIT_3  = 4;
const int BIT_4  = 5;
const int BIT_5  = 6;
const int BIT_6  = 7;
const int BIT_7  = 8;
const int BIT_8  = 9; //MSB

void setup() {

  Serial.begin(115200);
  // put your setup code here, to run once:
  pinMode(BIT_1,INPUT);
  pinMode(BIT_2,INPUT);
  pinMode(BIT_3,INPUT);
  pinMode(BIT_4,INPUT);
  pinMode(BIT_5,INPUT);
  pinMode(BIT_6,INPUT);
  pinMode(BIT_7,INPUT);
  pinMode(BIT_8,INPUT);

  Serial.println(!digitalRead(BIT_1));

  Serial.println(!digitalRead(BIT_2));

  Serial.println(!digitalRead(BIT_3));

  Serial.println(!digitalRead(BIT_4));

  Serial.println(!digitalRead(BIT_5));

  Serial.println(!digitalRead(BIT_6));

  Serial.println(!digitalRead(BIT_7));

  Serial.println(!digitalRead(BIT_8));
}

void loop() {
  // put your main code here, to run repeatedly:



}
 

BobTPH

Joined Jun 5, 2013
8,649
Well, you are not addressing the real problem. There is no way the Arduino is not recognizing the output of the 74HC509 unless something else is wrong. It is silly to “fix” the wrong problem.
 

BobTPH

Joined Jun 5, 2013
8,649
74HC590 works as intended only the output bits go only as high as 3.2-3.4 V at logic
Do you understand that this is incorrect? That either the chip is bad or your circuit is bad?

The 74HC590 datasheet lists the minimum output voltage at 4.4V with Vdd = 4.5V. So it cannot be 3.9V unless it is overloaded. A single Arduino input will have not have any effect on the output voltage. Do you have something else connected to the pin, like maybe an LED that would overload it?

Also, the high input voltage recognized by Arduino is 3.0V at 5V Vdd. At 4.7V Vdd it is 2.7V. So it cannot read 3.9V as a low unless it is damaged or something is set up wrong.

So something else is wrong here. Fix that and you will not need a level shifter. And you will probably avoid other problems you don’t know about yet.
 
Top