Troubleshooting two transistor RS232 level shifter.

Status
Not open for further replies.

toodles

New Member
I've been trying to construct a serial Arduino from the schematics on arduino.cc on a piece of stripboard. The Atmega8 is already programmed with a bootloader, as confirmed by the flashing of an LED on Atmega8 pin 19, called digital 13 by Arduino. The flashing happens immediately after releasing Reset, and repeatedly every 12-13 seconds.

Here are the pages and the base schematic:
http://www.arduino.cc/en/Main/ArduinoBoardSerial
**broken link removed**

The problem I'm running into is with the serial communication. I am using a self made cable that ends in a keyed 3 pin molex KK connector. I've shorted the RX and TX lines at that KK connector, and Hyperterminal returns the keys I've pressed just peachy. So I feel confident that problem is somewhere on the board.

I'm using the RS232 level shifter described in the schematic I linked to above. After a bunch of troubleshooting and fidgeting, I noticed that the schematic for a level shifter on Sparkfun points out that the electrolytic capacitor should be reversed, with the positive leg going to circuit ground. So, I removed the cap and put it back in 180 degrees. The schematic for the level shifter on the Bill's Firefly board shows the same thing. Now after connecting it up and sending a few characters, the capacitor's positive leg shows a voltage of -6v to -8v compared to circuit ground. Unless someone is going to tell me otherwise, I'm going to have to say this is an error is the Arduino schematic.
https://www.electro-tech-online.com/custompdfs/2007/11/RS232-Shifter-v2.pdf

Thing is, that didn't fix the problem. Still nothing going back and forth. WHen I pop the Atmega out of the socket, and bridge the spots on the socket for RX and TX (atmega pin 2 and 3) I do NOT get anything echoed back to the terminal.

In case it matters, I should also point out that I am using 3904 and 3906 transistors. I couldnt find any of the BC's to use. If this could cause a problem, please let me know.

Im at a loss. The level shifter does have a ton of parts, but it has plenty. My multimeter doesn't have a method of testing inductance, capacitance or transistors. I do have an oscilliscope, but itll take forever to dig out after a recent move.

Help me break down the level shifter into testable parts, so I might figure out what's wrong. I simply don't know enough analog to be able to say 'if I do this here, this should read X'. If you were troubleshooting this on your project, how would you test the pieces to determine where the problem was?
 
Last edited:
blueroomelectronics said:
The level shifter does work for the Firefly and is discussed in detail on Petes site (he's a user here too, Geko)
http://picprojects.org.uk/projects/simpleSIO/ssio.asp
I never doubted it worked; I pointed it out as an example of the positive leg of the capacitor connecting to ground, like the schematic from Sparkfun.

It was one of two examples why I believed the orientation shown in the Arduino schematic was incorrect.
 
I agree the capacitor does appear to be the wrong way round.

The level shifter on my web site that Bill references above only uses a 100nF capacitor. I also note that you might need to swap that for a 47nF as I found that with the 100nF capacitor if I sent a series of 4 bytes containing all zero's, the stop bit on about the fourth byte got 'filtered'.

In practice if you don't TX and RX at the same time you don't need the capacitor at all.
 
I have it currently powered via a 9v battery that goes through the 7805 to provide the +5v for the circuit.

Could I take a second 9v battery, connect the + terminal of the battery to the circuit's ground, and use the - terminal of the battery as a -9v test power source? My thinking is that if I can simulate the negative voltage on the line coming from the PC, than I could use the multimeter to check that the voltages are kopasetic. Has a perk, it would charge up that parasitic capacitor so I could (quickly) check the voltage on the line going to the PC when sending a low signal.

Im confident the problem lies within the level shifter; Im just looking for tips on I can break up the shifter into logical, testable pieces so I can narrow the problem down, be it bad solder joint, accidental short, bad component, whatever. Any suggested tips on how to do that would be appreciated.
 
Well the second battery would work, but you may as well check out the voltages around the circuit as it is.

The transmit signal from the PC should be in the mark state when idle (-12Volts 'ish)

So with nothing being sent or received, is the top end of the capacitor at -12volts or thereabouts?

And with the PNP transistor turned off, (disconnect the input to the base resistor), the receive line into the PC (collector of PNP transistor) should also be in a mark state (-12volts 'ish)

If it is, try toggling the base resistor of the PNP transistor between Gnd and 5 volts, does the collector swing between 5volts and -12volts?
 
Okay, I removed the atmega from the board. Board is powered via the 9v going through the 7805, and the serial cable is connected to the PC with Hyperterminal going on.

Voltage on the line from uC to PC: -4.3v (PC RX <-> uC TX)
Voltage on the line from PC to uC: -9.4v (PC TX <-> uC RX)
Voltage on negative leg of parasitic capacitor: -8.8v
Voltage on RX pin of the socket the Atmega goes in: 4.9v
Voltage on TX pin of the socket the Atmega goes in: 4.9v (The Arduino schematic has a 10k pullup resistor, otherwise the only thing itd be connected to is the middle pin of the transistor)
PNP Transistor:
C: 5.01v
B: 4.9v
E: -4.32v

NPN Transistor:
C: 4.96v
B: -0.59v
E: 0v

I tried connecting the base resistor of the PNP transistor to ground by shorting the TX pin on the socket with ground. That pin is connected to the base pin through a 10k resistor. When shorted to ground, the voltage on the line to the PC goes from the at rest -4.3v to -1.2v.

That's definitely not right. Shouldn't the line to the PC be somewhere in the positive voltage range, preferably over +3v? Why, at rest, when the PNP transistor is pulled high by the 10k resistor, is the....aw crap, I gotta replace the PNP transistor and retest, huh?

Any other suggestions? Any other glaring problems with the results above?

And, stupid last question. My multimeter doesnt have any kind of transistor specific test. If there any way I can verify the pins on a transistor, like which is emitter and which is collector?
 
Another thing I just tried was checking the voltage going to the Base pin of the PNP transistor. Its pulled up by a 10k resistor. The TX pin on the Atmega socket is connected there by a 10k resistor. The total resistance between the TX pin of the Atmega socket is right around 19.5k ohm. Maybe I'm thinking weird, but if the TX pin was low, there there'd be a vcc---10k ohm---base pin---10k ohm---gnd; shouldn't that make work like a voltage divider, making the voltage at the base pin about 2.5v?

Instead, when the atmega socket TX pin is shorted to ground, the voltage at the base pin drops to around 4.4v, nowhere near what I'd expect.

Something about this is really bugging me. My understanding is that the TX line from the uC, atmega pin 3, isn't supposed to be inverted. If the TX pin from the uC is at 5v high, the line going to the RX pin on the PC serial port is supposed to be high, like +3v to +12v range.

When the TX line from uC is low, around 0v, the line going to the RX pin on the PC serial port is supposed to be very low, like -3v to -12v.

^^^ Am I correct on these?

I disconnected the serial cable to try and test out the TX half of the board around the PNP transister. When the transistor base is high, around 5v, the emitter pin that goes to the serial cable is low, like 0.4v. If I short the TX pin on the socket to ground, the emitter pin that goes to the serial cable jumps up to near 5v.

WTF??
 
Well, if Im reading right here: **broken link removed**
and here: https://www.uchobby.com/index.php/2007/06/11/ttl-to-rs232-adaptor-explained/
The PNP transistor IS supposed to invert the signal from the uC, preferably a negative voltage if high, and a high voltage if low. Unless someone tells me otherwise, I'm gonna consider that as fact.

So I'm left with the PNP. The voltage does increase when the base pin goes low, but not by enough. I pressed another 10k resistor in parallel with the 10k resistor between the IC socket pin and the PNP base pin. The output voltage increased to around +1v, up from the -1v with just the original 10k. Add a third, and we're at 2.8ish v. Use a single 1k ohm parallel with the original 10k, and we're at the happy land of 4.8ish v out. As a perk, I bridged the TX and RX pins on the socket, and with the 1k in parallel to the 10K (labelled R6 on the arduino schematic), I am now getting echoes back in hyperterminal. Im warming up the soldering iron to swap the 10k R6 with a 1k. Report back in a sec.
 
Well, its working now. I replaced the 10k R6 resistor with a 1k, and now it seems to be running. I think I may have the PNP transistor installed backwards, but if it works, I aint touching it.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…