Serial port (RS232) logic levels:
In a serial port, a logic level of 1 is denoted by any voltage between -3V to -25V and a logic level of 0 is denoted by any voltage between +3V to +25V. While, for a uC, logic level of 0 is 0V to +0.8V and logic level of 1 is 2.2V to +5V.
Now, there are two problems to be solved:
- The serial port's have a wide operating voltage -- the worst case being 50V
- The logic levels are totally different and incompatible with uCs (TTL).
A common elegant solution is to make use of a MAX232 IC that does the job for us. I got a MAX232 in PDIP 16 pins (8 + 8). The IC can drive 2 serial port I/O and make them available at TTL. The connections are fairly simple. The following is the schematic that I took from their datasheet.
PIN configurations for a standard serial port:
- PIN2 -- output pin of serial port (should go into the input pin of MAX232 -- output should be read),
- PIN3 -- input pin of serial port (should go into the output pin of MAX232 -- input should be sent),
- PIN5 -- ground
Under the board (the nasty soldering):
Before I integrate this convertor with my uC and fiddle around, I should make sure this works. Otherwise, it might become very difficult to isolate the problem if I made a software error later. The approach is pretty simple, just short-circuit the output and input PINs on the uC side in the convertor, thus creating a loopback serial convertor. Basically, this circuit will just send back whatever comes in -- in software terms, an echo server.
The circuit can be tested by connecting the circuit to the computer's serial port and then using HyperTerminal in windows to connect the COM port in which it is connected. It is important to choose 'Hardware control' as None. Now if everything goes well, just start typing on the hyperterminal and you should see what you are typing. That proves that the serial port logic convertor works fine (by looping back).
Here is the working circuit in action:
Thank You
ReplyDelete