The Rs232 Breakout Box Computer Science Essay

Published:

The project is a RS232 breakout box that allows user to connect two device that uses RS232 protocol with different handshaking signals to work.

The RS232 breakout box that is currently building will detect the states of the device connected and determine the handshaking signals that are required by both devices and make the required adjustment to enable that both devices is able to communicate with each other.

The project uses a comparator circuit to detect the state of the RS232 signal lines and passes the information to the 18F4550 PIC micro controller used. The PIC will then determine the correct pin configuration should be implemented and sends instruction to the relay arrays to switch accordingly.

This preliminary report shows the literature research and work done till date. Flow chart and block diagrams are included that shows the flow of the project. Explanations about the choice of component are also included in this report.

Lady using a tablet
Lady using a tablet

Professional

Essay Writers

Lady Using Tablet

Get your grade
or your money back

using our Essay Writing Service!

Essay Writing Service

Content

Background

Introduction

Project Description

Scopes and Limitation

Literature Research

Work Done

Background

RS232 protocol is widely used in telecommunication to connect Data Terminal Equipment (DTE) and Data Circuit terminating Equipment (DCE) for many decades. The Electronics Industry Association (EIA) and Telecommunication Industry Association (TIA) regulated the RS232 protocol in 1960s, to allow compatibility among data communication equipment made by various manufacturers.The RS232 protocol specifies:

Common voltage and signal levels

Logic 1(-15V to -3V)

Logic 0(3V to 15V)

Common pin wiring configuration

DB9 pin assignment.JPG

Figure 1(above): Pin configuration of a DB9 connector

DB25 pin assignment.JPG

Figure 2(above): Pin configuration of a DB25 connector

Minimal amount of control information between peripheral systems

TD and RD are the data transmit and receive lines

RTS and CTS are "ready to send" and "clear to send"

DTR, DSR and DCD are "data terminal ready", "data set ready" and "data carrier detect."

Control information.jpg

Figure 3(above): Shows the function each line in the RS232 protocol.

Introduction

Even though the RS232 protocol specifies the signal levels, pin configuration and control information lines it is insufficient. There are two types of flavour devices, with input pins of one type corresponding to output pins of the other; in order for both devices to communicate the two devices must be similar in type or the devices must complementary each other. Furthermore, the requirement of handshaking signal is not defined in the RS232 protocol; some devices send them out and expect to receive them back, while others ignore their inputs. To make things worse, there are five types of handshaking signals that are used in the RS232 protocol.

When connecting to two devices together we must ask ourselves a few questions:

Is the connection DTE→DCE, DTE→DTE or DCE→ DCE?

The first question is important because a DTE transmit data on pin 2 and receives on pin 3 while a DCE does in reverse. Figure 4 below shows the connection for DTE→DCE, DTE→DTE or DCE→ DCE assuming that both devices require full handshaking signal.

DTE→DCE connection

DTE→DTE connection

DCE→DCE connection

DTE-DCE,DCE-DCE,DTE-DTE.png

Figure 4: Connection that works for DTE→DCE, DTE→DTE and DCE→ DCE which both device uses full handshaking signals.

Are both devices using handshaking during the communication?

This is important because if one device uses handshaking signals and if we connect a device that ignores handshaking signals nothing will happen. There are five handshaking signals:

Data Terminal Ready (/DTR)

When the DTE is turn on this signal will be activated (goes low).

This signal is used to inform the DCE that the DTE is ready.

Data Set Ready (/DSR)

When a DCE is turned on, this signal will be activated (goes low).

This signal is used to inform the DTE that the DCE is ready to talk!!!

Request to Send (/RTS)

The DTE activates (goes low) this signal to inform the DCE that the DTE has a byte to transmit.

Lady using a tablet
Lady using a tablet

Comprehensive

Writing Services

Lady Using Tablet

Plagiarism-free
Always on Time

Marked to Standard

Order Now

Clear to Send (/CTR)

In response to the RTS signal, when the DCE has room for storing the data it is to receive, it sends out this signal to the DTE to indicate that it can receive the data now. The DTE uses this signal to initiate transmission.

Data Carrier Detect (/DCD) - for modem

The DCE activates this signal to inform the DTE that a valid carrier has been detected and that contact between it and the other DCE is established.

By knowing what each handshaking lines does and its function, there is a way to "trick" the device into providing its own handshakes, by rewiring the signals line, so that a device that uses handshaking can communicate with a device that does not. Refer to Figure 5.

DTE→DCE connection

DTE→DTE connection

DCE→DCE connection

handshakeDTE-DCE,DCE-DCE,DTE-DTE.jpg

Figure 5: Connection that works for DTE→DCE, DTE→DTE and DCE→ DCE where one device uses handshaking signals while the other does not.

Project Description

When connecting two devices that uses RS232 protocol, together the two devices may or may not work. Mention in the introduction we need must first determine the devices are a DTE or a DCE, and secondly the devices use handshaking signals. But how do we determine these information, we can always read through the user manual or we can use a RS232 breakout box. It has LED for each line so that we can see who is asserting what and make the connection that we want.

The project is to build a RS232 breakout box that uses a microcontroller to determine connectivity between the devices and to be able interfaced to a display and keypad input device so that the user can select the input-output mapping of the connection.

Block Diagram

PIC

LCD

Relay Array

DUT

Comparator

Key Pad

Shift Registers

Shift Registers

Device 1

Device 2

Figure 6: A Block Diagram of the project that shows the connection of each box to the other.

General Flow Chart

Start

Prompt User to Insert DUT

Comparator checks the RS232 lines that are used.

Set shift register to turn on/off relays array.

End

Figure 7: A general flow chart stating the flow of the project.

Scope and Limitation

Scope

To be able to detect the states of the RS232 line.

Relay arrays are able to switch the RS232 line to the correct position.

To be able to allow the user to select which connection type to switch.

Limitation

The project is not able to correct software flow control.

The baud rate between two devices has to be the same.

Literature Research

18F4550 (PIC Micro Controller)

A microcontroller is a chip that contains the processor (the CPU), non volatile memory for the program (ROM or flash), volatile memory for input and output(RAM), a clock and an I/O control unit. Microcontroller can be called a "Computer on a chip". Refer to figure 8.

Figure 8: A basic microcontroller architecture.

18F4550 microcontroller is used (Figure 9) because of its 35high-current sink/source (25mA/25mA) I/O ports that is useful in controlling the many blocks in the project. Besides that the microcontroller architecture is optimized for C Compiler which will of advantage because I am familiar with C language. Furthermore the capability of up to 100000Erase/write cycle Enhanced Flash Program Memory will be helpful during the construction of the project.

18f4550.JPGFigure 9: A pin diagram of the 18F4550 microcontroller used.

555 Timer

555.JPG

Figure 10: A pin diagram of a LM555 timer.

The LM555 (Figure 10) is a widely used IC for generating accurate time delays or oscillation. A couple of external resistors and capacitors are need to precisely control the time of the LM555. Furthermore the waveform duty cycle of the LM555 could be adjusted and it can operate in both astable and monostable modes.

Most of all, the main purpose of the LM555 is chosen is because of its ability to support high source and sink current (up to 200mA). The 555 timer is used to drive a charge pump, a network of capacitors and diodes, to obtain a negative voltage.

Lady using a tablet
Lady using a tablet

This Essay is

a Student's Work

Lady Using Tablet

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

Examples of our work

Comparator (Op Amp)

An Op Amp is used as a high-gain DC "amplifier" performing mathematical "operations" The modern op-amps are manufactured to function as a high gain, high input impedance, low output impedance amplifier.

Because of its properties the op amp can be used as:

General purpose amplifiers

Signal conditioning

Special transfer function

Comparators oscillators

ADC and DAC

Analogue instrumentation

Analogue computation

Shift Registers

Shift Register.JPG

Figure 11: A pin diagram of an 8bit serial in parallel out 74hc595 shift register.

Shift registers (Figure 11) are basically a series of Flip Flops that are cascaded together. Data is shift into the shift register bit by bit; the output of the first Flip Flop is connected to the second Flip Flop and subsequent. Each Flip Flops are connected to the same clock, data are shifted at every transition of the clock. Shifts Registers could have a single or multiple input and output. Shift registers consists of as follow:

Parallel in Serial out

Serial in Parallel out

Serial in Serial out

Universal parallel in and parallel out

Ring counter

For the project a Serial in Parallel out shift register is selected. The main purpose of the shift registers is to drive the Arrays of Relays that are required to switch the multiple lines of the RS232.

Relays

Relays are electrical switches. Most relays consist of a coil inside of them. The coils, when magnetized will attract an armature that closes or opens the connection.(Figure 12)

Relay Close.JPGRelay Open.JPG

Figure 12: On the left the coil of the relays is magnetized and attracts the armature and closes the circuit; on the right the coil is not magnetized and the connection is left open.

Relays and multiplexers are both electrical switches. Relay is chosen over the multiplexers is because the multiplexer is unable to multiplex the high voltage swing of the RS232 lines (+12V and -12V).

LCD

A 2X16 LCD is used as a display. It is chosen because of its low power consumption. The LCD is able to operate from as low as a 2.5V DC power. Besides that, the LCD can display much more characters than the typical 7-segment display. Furthermore the 2X16 character size is sufficient for displaying the required information.

Work Done

Detailed Block Diagram

Detail Block Diagram.png

Figure 13: A detail block diagram of the project that shows the connection pin of each component block that is used in the project.

Flow chart

Prompt User to Insert DUT 2

User enters relay array settings.

Start

Counter=1

User satisfied?

End

Prompt User to Insert DUT 1

Parallel in Serial out Shift Register moves data into PIC and store it.

DUT inserted?

Counter 1 or 2?

Comparator checks the RS232 lines that are used.

Counter=2?

Set Serial in Parallel out shift register to turn on/off relays array.

Counter=Counter+1

Yes

No

Yes

No

Yes

Figure 14: A detail flow chart that shows the flow of the project.

Handshaking Signal

Simulation is done to further help in the understanding of the handshaking between two devices. RealTerm software is used to simulate device that is connected to a COM Port. RealTerm is used to send and receive data. Furthermore, the user can select which hardware flow control that to be used and other more settings (Figure 15).

C:\Users\JyTeh-Laptop\Desktop\Initial Report\Attachments\Real Term.JPG

Figure 15: The GUI of the RealTerm at first run.

Virtual Serial Port Driver is used to connect two COM Port virtually. It is able to switch the pin configuration of the COM Port. (Figure 16)

C:\Users\JyTeh-Laptop\Desktop\Initial Report\Attachments\Virtual Serial Port Driver.JPG

Figure 16: The GUI of Virtual Serial Port Driver at first run.

Firstly, device is connected using the standard DTE→DTE connection as seen in Figure17 using the Virtual Serial Port Driver. Next RealTerm is used to access the two COM Ports that is connected using Virtual Serial Port Driver. Port 2 is the Transmitter while Port 1 is the Receiver.

C:\Users\JyTeh-Laptop\Desktop\Initial Report\Attachments\Standard(Virtual Serial Port Driver).JPG

Figure 17: COM1 And COM2 is connected virtually with standard pin out configuration. This can be seen at the Virtual ports tab COM1 and COM2 are connected.

Port 1 and Port 2 both does not use hardware flow control.(Figure A)

C:\Users\JyTeh-Laptop\Desktop\Initial Report\Attachments\WO handshaking(RealTerm).JPG

Figure A

The easiest method of sending data, all handshaking signals is ignored.

Port 1 and Port 2 both use RTS/CTS hardware flow control.(Figure B)

C:\Users\JyTeh-Laptop\Desktop\Initial Report\RTS(RealTerm).JPG

Figure B

RTS/CTS handshaking lines are used.

Appropriate handshaking signals are exchanged between port 1 and port 2.

Data can be sent from port 2 to port 1.

Port 1 and Port 2 both use DTR/DSR hardware flow control.(Figure C)

C:\Users\JyTeh-Laptop\Desktop\Initial Report\DTR(RealTerm).JPG

Figure C

DTR/DSR handshaking lines are used.

Appropriate handshaking signals are exchanged between port 1 and port 2.

Data can be sent from port 2 to port 1

The same connection is used again but port 1 is set not to use any hardware flow control to simulate a mismatch in devices.

Port 2 uses RTS/CTS hardware flow control while Port 1 does not.(Figure D)

C:\Users\JyTeh-Laptop\Desktop\Initial Report\R_RTS L_none(RealTerm).JPG

Figure D

C:\Users\JyTeh-Laptop\Desktop\Initial Report\R_RTS L_none.JPG

Figure E

C:\Users\JyTeh-Laptop\Desktop\Initial Report\R_RTS L_manual(RealTerm).JPG

Figure F

RTS/CTS lines are used by Port 2 while Port 1 ignores RTS/CTS lines.

Data can't be sent.

Ports 2 will only send data to Port 1 when the CTS line goes high and Port 1 is not giving the appropriate handshaking signals.(Figure E)

If we manual set the RTS of Port 1 to "give" the appropriate handshaking signals to port 2,data can be sent from port 2.(Figure F)

Port 2 uses DTR/DSR hardware flow control while Port 1 does not.(Figure G)

C:\Users\JyTeh-Laptop\Desktop\Initial Report\R_dtr L_none 1.JPG

Figure G

C:\Users\JyTeh-Laptop\Desktop\Initial Report\R_dtr L_none.JPG

Figure H

C:\Users\JyTeh-Laptop\Desktop\Initial Report\R_DTR L_manual(RealTerm).JPG

Figure I

DTR/DSR lines are used by Port 2 while Port 1 ignores DTR/DSR lines.

Data can't be sent.

Ports 2 will only send data to Port 1 when the DSR line goes high and Port 1 is not giving the appropriate handshaking signals.(Figure H)

If we manual set the RTS of Port 1 to "give" the appropriate handshaking signals to port 2,data can be sent from port 2.(Figure I)

A loopback circuit can be connected to enable two devices that do not use the same handshaking signal to be able to be exchange data. The loopback connection is used to connect port 1 and port 2 where port 1 is set not to use any hardware flow control to simulate a mismatch in devices.(Figure 18)

C:\Users\JyTeh-Laptop\Desktop\Initial Report\Attachments\Loopback(Virtual Serial Port Driver).JPG

Figure 18: COM1 and COM2 are connected virtually with a Loopback pin out configuration.

Port 2 uses RTS/CTS hardware flow control while Port 1 does not.(Figure J)

C:\Users\JyTeh-Laptop\Desktop\Initial Report\(Loop)R_RTS L_none(RealTerm).JPG

Figure J

RTS/CTS lines are used by Port 2 while Port 1 ignores RTS/CTS lines.

Data can be sent even both are not using the same handshaking signal.

The loopback connection (Figure) is used to "trick" port 2 into providing its own handshaking signal.

Port 2 uses DTR/DSR hardware flow control while Port 1 does not.(Figure G)

C:\Users\JyTeh-Laptop\Desktop\Initial Report\(Loop)R_DTR L_none.JPG

DTR/DSR lines are used by Port 2 while Port 1 ignores DTR/DSR lines.

Data can be sent even both are not using the same handshaking signal.

The loopback connection (Figure) is used to "trick" port 2 into providing its own handshaking signal.

Relay Array

From the simulation done, if the 4 types of connection (DTE→DTE, DTE→DCE, DTE→DTE(Loop) and DTE→DCE(Loop)) could make almost any two device that uses RS232 to work.

The table below show the four types of connection using relays.

DTE→DTE

C:\Users\JyTeh-Laptop\Desktop\Initial Report\DTE-DTE(Loop).jpg

DTE→DCE

C:\Users\JyTeh-Laptop\Desktop\Initial Report\DTE-DCE.jpg

DTE→DTE (Loop)

C:\Users\JyTeh-Laptop\Desktop\Initial Report\DTE-DTE(Loop).jpg

DTE→DCE(Loop)

C:\Users\JyTeh-Laptop\Desktop\Initial Report\DTE-DCE(Loop).jpg

Comparator

A comparator circuit is constructed to convert the voltage level of the RS232 to TTL logic. Below is the comparator circuit that is constructed and simulated in LT spice.

C:\Users\JyTeh-Laptop\Desktop\Initial Report\Comparator.JPG

Input

A

B

+12

5V

0V

-12

0V

5V