3
\$\begingroup\$

I see a lot of repeat answers and instructions how to convert dual supply levels to logic levels, but I have the inverse situation, converting 0/+5 V TTL logic to +/-9 V, and I don't see a lot of info about it. Strange, this should be very common for driving an RS232 line.

In principle for AC of a reasonable frequency range, it should be doable with just a simple transistor and decoupled with a capacitor at the base, etc.

schematic

simulate this circuit – Schematic created using CircuitLab

But in my case I need to transform a digital signal that may both change at 4 MHz frequency, but also may be in the same state for a long time, so any decoupling capacitor with a simple transistor circuit would end up not working.

schematic

simulate this circuit

I played around with an op-amp and this is working in principle for low to moderate frequencies, except I am getting into the problem of the dynamic range of the op-amp, I put it between +/- 9V and I can dial up the gain from the 5 V peak-to-peak to about 8.5 V peak to peak, but not better. That's one problem why I would rather just use a single transistor.

I don't really care about distortion, since my signal is a square wave anyway. But I care about gain and rail to rail, but I don't have, nor can I get a rail-to-rail op-amp (I can't order from Mouser or Jameco and my selection at the local store is small and the hit/miss ratio too low if I come in with the part number for some fancy R2R op-amp.)

I also don't want my signal to be integrated and reduced to a tiny triangle wave, as it is at higher frequencies.

Here are some impressions from my op-amp circuit in practice:

enter image description here

As the frequency doubles 3 times we start getting the triangle:

enter image description here

and it gets downhill from there

enter image description here

and this is the maximum frequency we need to support, about 2 MHz.

enter image description here

What might be done?


UPDATE: Michael responded and helped me try the LM393 comparator, I didn't realize I need a pull-up resistor on the output. So I tried a few values, 4.7 kΩ, 1 kΩ, 10 kΩ. And I am just leaving the scope pictures here because I found the behavior of the low very peculiar, and I suppose one needs to add some capacitor somewhere too. But anyway, it has a bit better frequency response but not good enough. I just hope that 75188 line driver chip will meet the frequency response requirement.

enter image description here

enter image description here

enter image description here

Further update: I could get this instability fairly well in check, but still the LM393 is just too slow. It has a nice gain, but at 2 MHz the square wave reduces to a tiny triangle also. Here is how that looked, but this was about the last frequency where it was useful, I think this was at 125 kHz or so, really not great at all.

enter image description here

while this here is at 2 MHz. And don't be fooled by the scaling, the triangle there is tiny and super amplified on the scope.

enter image description here

FINAL UPDATE: Bruce Abbot's circuit rocks! And I want to show the scope pictures of it. Here is at 250 kHz:

enter image description here

and this is at 2 MHz:

enter image description here

and at 4 MHz. We can see that it's getting a little sluggish with switching down to full negative, but hey, this is about solving my problem for now so that I can focus on other things.

enter image description here

I will report back on how this compares with the 75188 line buffer when it arrives in the mail.

FINAL UPDATE: The jury is out folks and the 75188 came in the mail. Here I present to you a head to head comparison between it and Bruce Abbott's simple two transistor level shifter.

enter image description here enter image description here

You can see that in terms of maxing out the available range from he power supply (same pair of 9V batteries) they both are equivalent. The little ripple on the roof of the square wave gives away the IC. But it is at the high frequency that the simple (and probably more power-hungry) design of Bruce Abbott is shining as it still performs at the full amplitude and only slightly rounds off the falling edges. Remember that this is on a breadboard, so capacitance is an issue, but this time I measured with x10 probes as Bruce suggested.

Now I am sitting on those 25 chips of 75188 I bought for cheap in bulk, not going to use them.

\$\endgroup\$
13
  • 1
    \$\begingroup\$ The "standard" method of achieving this for RS232 applications is to use an RS232 line driver. Something like a 1488 or 75188 if you already have dual supplies, or one of the many MAX232 clones if you don't. Is there a particular reason you want to go all "first principals" with discrete components? \$\endgroup\$
    – brhans
    Jul 22, 2020 at 1:00
  • \$\begingroup\$ @brhans, I love that 75188 line driver! This is neat, small, and versatile and I need it inverted anyway! Lovely! I didn't find a max frequency in the data sheet, but it said something about 1 MHz somewhere, so I guess it will work. \$\endgroup\$ Jul 22, 2020 at 1:16
  • 1
    \$\begingroup\$ I wrote something a while back. It's a start. I targeted a low-speed application though. \$\endgroup\$
    – jonk
    Jul 22, 2020 at 2:23
  • \$\begingroup\$ Thanks @jonk, interesting. What would you think is the frequency limit here? At least there are no capacitors. \$\endgroup\$ Jul 22, 2020 at 2:29
  • 2
    \$\begingroup\$ @GuntherSchadow have you added the required decoupling capacitors on the voltage rails near the comparator? \$\endgroup\$
    – BeB00
    Jul 22, 2020 at 2:41

3 Answers 3

4
\$\begingroup\$

An inverting level shifter can be made with an NPN and PNP bipolar transistor, like this:-

schematic

simulate this circuit – Schematic created using CircuitLab

Q1 is configured in Common Base mode with a bias voltage of 2.5 V. When the TTL signal pulls down below ~1.8V the transistor turns on and (almost) the same current flows through both R3 and R4, causing the voltage at R4 to go down from 9 V to ~5 V. This then turns Q2 on via R5, causing it to pull the voltage at R6 up from -9 V to +9 V.

It's a simple circuit, but getting good performance at 4 MHz is tricky. Parasitic capacitances in Q2 cause charge to build up on the Base, which normally prevents it from turning on and off quickly. This problem is solved by adding C3, which bypasses R5 at high frequencies to get charge in and out of the Base quicker. This also requires that R4 (and therefore R3) have a low value.

R6 has a low value to improve the output fall time. R5 has a high value to avoid turning Q2 on too hard, as this would cause more charge to accumulate on the Base, slowing down the turn-off time.

Although this circuit is 'TTL compatible' it requires about 18 mA of driver sink current, so you may need to pass your logic signal through a high current buffer if you driver isn't strong enough.

\$\endgroup\$
9
  • \$\begingroup\$ Wow! Beautiful! Thanks. Can I use BC547 and 548 instead for Q1 and Q2 respectively? The signal comes from a 74LS166, and I suppose it only sinks 8 mA at logic low. So can another transistor be slapped in front of it? I checked, a 74LS126 can do 16 mA, a '245 can do 24 mA, but takes a lot of space for unused pins. \$\endgroup\$ Jul 22, 2020 at 13:52
  • \$\begingroup\$ ... ok, no need to worry about another transistor, because I have the 74LS299 shift register on hand, that can also sink 24 mA. I can swap this. \$\endgroup\$ Jul 22, 2020 at 15:49
  • \$\begingroup\$ Awesome! This circuit rocks! Even directly on the output of the 74LS166 shift register it produces way sharper edges. I show it in my original question (appended scope pictures at the end.) @BruceAbbott, you're the hero! \$\endgroup\$ Jul 22, 2020 at 19:20
  • \$\begingroup\$ Another observation: that R4 and R6 get pretty hot even though the transistors don't. So my batteries will be drained quickly. I guess I ran drive this on +/- 12 V too (building myself a little power supply with a 15V transformer I have here and a pair of 7812/7912 voltage regulators, or do I need to change the resistors? \$\endgroup\$ Jul 22, 2020 at 20:48
  • 1
    \$\begingroup\$ The circuit draws about 60mA, a bit much a PP9 battery but no problem for a 1A regulator. Use 1W resistors to keep surface temperature down. Not much can be done about the power consumption, it's the price you pay for large amplitude with wide bandwidth. You could use a push-pull emitter follower buffer to isolate the load capacitance, then R6 etc. could be made larger (but not by too much because the the transistors themselves have significant capacitance). \$\endgroup\$ Jul 22, 2020 at 21:17
1
\$\begingroup\$

Looking at the Datasheet:

enter image description here

Maximum output-swing bandwidth is 140kHz. You will not be able to have a signal that slams 18Vpp @ 4 MHz. Not to mention you are heavily loading the op-amp with a 100Ω resistor on the output.

You will need to use a much higher speed op-amp. I recommend a dedicated comparator or line driver, as they are good at this kind of level shifting behavior.

https://www.ti.com/lit/ds/symlink/ne5532.pdf?ts=1595379290387&ref_url=https%253A%252F%252Fwww.google.com%252F

\$\endgroup\$
4
  • \$\begingroup\$ I'm so sorry, that 100 Ω pot was just nonsense that circuit editor added by default. This is just the feed-back pot for the gain control and I used 1 MΩ, the load is high impedance, around 30 kΩ. \$\endgroup\$ Jul 22, 2020 at 1:11
  • \$\begingroup\$ oh, and I did try to swap in an LM393 comparator instead (pins are drop-in compatible) and it didn't seem to work at all. \$\endgroup\$ Jul 22, 2020 at 1:13
  • 1
    \$\begingroup\$ Did you attach a pullup resistor to the output? \$\endgroup\$
    – Michael
    Jul 22, 2020 at 1:27
  • \$\begingroup\$ thanks, that helped to at least see its frequency response. I added scope pictures in the initial question. Better, but in other ways weird and still no cigar. \$\endgroup\$ Jul 22, 2020 at 2:26
0
\$\begingroup\$

Let us convert that first circuit into an inverting level translator.

Replace the -batter (BATT2) with a short. We don't need a --voltage.

The output will be +9v to 0.5volts (not a hard ground).

Replace that input capacitor with a schottky diode, pointing away from the transistor. Remove the resistor from base to Ground.

Make the resistor from base to VDD be 1Kohm (you can use 4.7K if you want.)

In series with the base, insert an diode, pointing to the base. This gives good noise immunity.

Make the collector_VDD resistor be 470 ohms. This is important to fast rime time.

And for speed, add a capacitor from the 0/5v input, to the base. Use 100pF, or larger.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.