Inverter + Logic level converter - Page 1
Forum section: electronics / beginners

author: mr_byte31
author_rank: Regular Contributor
timestamp: October 21, 2024, 06:19:13 pm
content: 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 transistorThe 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

author: LoveLaika
author_rank: Frequent Contributor
timestamp: October 21, 2024, 06:32:36 pm
content: 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.

author: tggzzz
author_rank: Super Contributor
timestamp: October 21, 2024, 06:40:05 pm
content: Quote from: mr_byte31 on October 21, 2024, 06:19:13 pmWhether it will cause "issues" depends on the rest of the circuit.Whether Vcesatwill 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 VIHand VILwith Vcesatand 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.

author: mr_byte31
author_rank: Regular Contributor
timestamp: October 21, 2024, 06:49:00 pm
content: 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).

author: tggzzz
author_rank: Super Contributor
timestamp: October 21, 2024, 07:26:16 pm
content: Quote from: mr_byte31 on October 21, 2024, 06:49:00 pmAllcomponents and circuits are analogue, except for APDs and femtoamp circuits."Digital" circuitsinterpretanalogue 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".

author: edavid
author_rank: Super Contributor
timestamp: October 21, 2024, 08:02:06 pm
content: 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.

author: langwadt
author_rank: Super Contributor
timestamp: October 21, 2024, 08:06:32 pm
content: Quote from: mr_byte31 on October 21, 2024, 06:49:00 pmuart doesn't need inverting, you could do with a resistive divider

author: mr_byte31
author_rank: Regular Contributor
timestamp: October 21, 2024, 08:35:41 pm
content: I am simulating with Arduino S.BUS protocol where the UART signal is inverted.

author: mr_byte31
author_rank: Regular Contributor
timestamp: October 21, 2024, 08:41:20 pm
content: Quote from: edavid on October 21, 2024, 08:02:06 pmcan you please elaborate more about using diode ?

author: Benta
author_rank: Super Contributor
timestamp: October 21, 2024, 09:10:48 pm
content: 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.

author: bson
author_rank: Unknown
timestamp: October 21, 2024, 09:49:33 pm
content: If you don't object to SMD/SMT you can also use a 74AHC1G04 inverter with a 3.3V supply.

author: edavid
author_rank: Super Contributor
timestamp: October 21, 2024, 09:57:23 pm
content: Quote from: mr_byte31 on October 21, 2024, 08:41:20 pmDelete transistor and base resistor, wire diode with cathode to Arduino and anode to RPi. I suggest keeping the pullup resistor.