Author Topic: Inverter + Logic level converter  (Read 480 times)

0 Members and 1 Guest are viewing this topic.

Offline mr_byte31Topic starter

  • Contributor
  • Posts: 38
  • Country: de
Inverter + Logic level converter
« on: October 21, 2024, 06:19:13 pm »
Hi Folks,

I have digital signal (0-5v) and I want to logically invert it and keep it in 3.3v for my microcontroller.

I made this circuit and seems to work. I used PN2222 transistor


The max frequency of the input signal is around 100Khz.

I believe that the transistor is in the saturation region when signal voltage is 5v and the transistor is in cut-off mode in case of signal voltage is 0v.
I am just worried about the V_ce saturation voltage since it will never reach zero volts.

I need your opinion if this circuit shall be stable and won't cause any issues... ex voltage spikes, ..etc
 

Offline LoveLaika

  • Frequent Contributor
  • **
  • Posts: 597
  • Country: us
Re: Inverter + Logic level converter
« Reply #1 on: October 21, 2024, 06:32:36 pm »
I don't really work with BJTs a whole lot (not as much as I should have), but if going into saturation mode is an issue, could you cut the base voltage in half so that it will go into forward-active mode? Though, for a logic application like this, perhaps saturation is the way to go.

That said, it doesn't seem like an issue at low voltages, especially with the 10k resistor limiting the current.
 
The following users thanked this post: mr_byte31

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 21077
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Inverter + Logic level converter
« Reply #2 on: October 21, 2024, 06:40:05 pm »
Hi Folks,

I have digital signal (0-5v) and I want to logically invert it and keep it in 3.3v for my microcontroller.

I made this circuit and seems to work. I used PN2222 transistor

The max frequency of the input signal is around 100Khz.

I believe that the transistor is in the saturation region when signal voltage is 5v and the transistor is in cut-off mode in case of signal voltage is 0v.
I am just worried about the V_ce saturation voltage since it will never reach zero volts.

I need your opinion if this circuit shall be stable and won't cause any issues... ex voltage spikes, ..etc

Whether it will cause "issues" depends on the rest of the circuit.

Whether Vcesat will cause a problem will depend on what the rest of the circuit is expecting. If it is a logic input, then compare the input's VIH and VIL with Vcesat and 3.3V. You'll probably be OK.

100kHz will probably be OK, but there will be some duty cycle distortion since the transistor will take longer to stop conducting (i.e. come out of saturation) than to start conducting. Whether that is an issue will depend on the rest of your circuit.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline mr_byte31Topic starter

  • Contributor
  • Posts: 38
  • Country: de
Re: Inverter + Logic level converter
« Reply #3 on: October 21, 2024, 06:49:00 pm »
Thx all for the answers.

I don't really have other analog components before or after this circuit.

The input signal is UART coming from Arduino (5v) and the inverted signal shall go to Raspberry Pi (3.3v).
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 21077
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Inverter + Logic level converter
« Reply #4 on: October 21, 2024, 07:26:16 pm »
Thx all for the answers.

I don't really have other analog components before or after this circuit.

The input signal is UART coming from Arduino (5v) and the inverted signal shall go to Raspberry Pi (3.3v).

All components and circuits are analogue, except for APDs and femtoamp circuits.

"Digital" circuits interpret analogue input waveforms as digital signals. Correct interpretation requires that the input waveforms conform to the voltage (or current) and timing limits specified in the datasheets; this is "signal integrity".
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline edavid

  • Super Contributor
  • ***
  • Posts: 3452
  • Country: us
Re: Inverter + Logic level converter
« Reply #5 on: October 21, 2024, 08:02:06 pm »
If you don't have to have signal inversion (why would you want to invert UART data?), you could use a diode instead of the transistor, since the Arduino has plenty of drive strength.
« Last Edit: October 21, 2024, 08:04:09 pm by edavid »
 

Offline langwadt

  • Super Contributor
  • ***
  • Posts: 4822
  • Country: dk
Re: Inverter + Logic level converter
« Reply #6 on: October 21, 2024, 08:06:32 pm »
Thx all for the answers.

I don't really have other analog components before or after this circuit.

The input signal is UART coming from Arduino (5v) and the inverted signal shall go to Raspberry Pi (3.3v).

uart doesn't need inverting, you could do with a resistive divider
 

Offline mr_byte31Topic starter

  • Contributor
  • Posts: 38
  • Country: de
Re: Inverter + Logic level converter
« Reply #7 on: October 21, 2024, 08:35:41 pm »
I am simulating with Arduino S.BUS protocol where the UART signal is inverted.
 

Offline mr_byte31Topic starter

  • Contributor
  • Posts: 38
  • Country: de
Re: Inverter + Logic level converter
« Reply #8 on: October 21, 2024, 08:41:20 pm »
If you don't have to have signal inversion (why would you want to invert UART data?), you could use a diode instead of the transistor, since the Arduino has plenty of drive strength.

can you please elaborate more about using diode ?
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 6385
  • Country: de
Re: Inverter + Logic level converter
« Reply #9 on: October 21, 2024, 09:10:48 pm »
Increase the base resistor to 50...100 kohm, you're wasting current.
Yes, it'll saturate, but that's fine for 100 kHz. Expect no problems.
The CE saturation voltage will be around 50...100 mV. Ignore it.
All the above only applies if you're using a standard small-signal BJT, like BC847.
 
The following users thanked this post: mr_byte31

Offline bson

  • Supporter
  • ****
  • Posts: 2488
  • Country: us
Re: Inverter + Logic level converter
« Reply #10 on: October 21, 2024, 09:49:33 pm »
If you don't object to SMD/SMT you can also use a 74AHC1G04 inverter with a 3.3V supply.
 

Offline edavid

  • Super Contributor
  • ***
  • Posts: 3452
  • Country: us
Re: Inverter + Logic level converter
« Reply #11 on: October 21, 2024, 09:57:23 pm »
If you don't have to have signal inversion (why would you want to invert UART data?), you could use a diode instead of the transistor, since the Arduino has plenty of drive strength.

can you please elaborate more about using diode ?

Delete transistor and base resistor, wire diode with cathode to Arduino and anode to RPi.  I suggest keeping the pullup resistor.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf