Friday, August 24, 2012

Raspberry PI - More about Serial 3.3v, TTL and RS-232 levels

If you tried to implement the last blog post, one thing that those of you new to electronics may find strange is that when there is NO serial output, the level of the TXD pin is "high" - for the rPI GPIO pin this is around 3.3 volts. For a TTL level serial, this would be around 5 volts.  (Don't forget that you have to convert the 3.3 level to 5 if you are interfacing the rPI to TTL logic, as discussed elsewhere in this blog).

When the data is sent, the pin drops unasserted (see Ref 1)  for the "start" bit , then up and down for the 1's and 0's of the data (which may be ascii characters, see Ref 2), then back to asserted. The "asserted = 1" logic level is  3.3 or 5 volts, and the "unasserted = 0" logic level is 0 volts. This seems a bit strange, but that is how it works. More on that later down the page. 

Here is the waveform (from Ref 3):

There is also another standard for serial data, called RS-232. It is bipolar, with the positive level for the 0's and a negative for the 1's. The positive and negative voltage seings are 3 to 15 volts (Ref 4) 

There are off the shelf chips like the MAX232 (Ref 5) that facilitate the conversion to 3.3/5 and the bipolar signal. Some of these chips even use external capacitors to facilitate on board "charge pumps" to develop the +/- RS232 voltages from the 3.3 or 5 volt chip supply. 

Now here is the interesting part. The reason that the signal is held at the "asserted = 1" state when there is NO data is a holdover from the old days of mechanical Teleprinter/Teletypes (Ref 6):

" The "idle" condition of the circuit is a continuous marking state, with the start of a character signalled by a "start bit", which is always a space." 

This way, of the line connection was broken electrically, it would cause:

"a receiving teleprinter to cycle continuously". 

This would be a sign to the operator that the line was down. If it was the other way around, there would be no warning the line was down, and the op would wonder if it was just a quiet day or is there was really a problem.

Now the even more interesting part. This is apparently a carry over from old land line telegraph keys (Ref 7, 8):

" Straight keys used by telegraph operators also had a "shorting bar" that closed the electrical circuit when the operator was not actively sending messages. This was to complete the electrical path to the next station so that the sounder would operate, as in the operator receiving a message from the next town." 

So now you know the rest of the story. The state of the art SOC chip in your rPI uses a standard that can trace it's way directly back to the invention of telegraphy in 1836 (or earlier).  



Eric Pierce VA3EP - See the Disclaimer in the Introduction

© Eric Pierce and "VA3EP Amateur Radio And Other Geek Pursuits", 1952-2099. Unauthorized use and/or duplication of this material without express and written permission from this blog’s author and/or owner is strictly prohibited. Excerpts and links may be used, provided that full and clear credit is given to Eric Pierce and "VA3EP Amateur Radio And Other Geek Pursuits", with appropriate and specific direction to the original content.

No comments:

Post a Comment