1. 0 circuit overview

Дата канвертавання25.04.2016
Памер17.78 Kb.
USB to RS232 Converter Circuit Description


The USB to RS232 Converter board is a PIC microcontroller based device that receives a USB signal from a PC and converts the signal to an RS232 output. The output signal can be sent to any one of three serial ports. Devices which may be connected to the RS232 ports include the ASI Inc. X-Y Stage, the Olympus Z-Focus, and the Mai Tai LASER.

Figure 1: Current PCB Layout


2.1 Power

The circuit has two power options available. When the 0Ω Resistor noted above in Figure 1 is in place, the circuit will draw power from the USB +5V line. When the resistor is absent, power is provided via a 2 pin connector, and an AS78L 5V positive voltage regulator is used. This board uses a PIC18F4455 to receive USB commands which are converted to RS232 protocol via a DS275 Line-Powered Transceiver Chip. There is one transceiver chip associated with each RS232 port. This chip’s transmitter draws power from the receive line, so an external power source is not needed to drive the transmitter line at RS232 levels.

2.2 Cables

The connector for each port is a DB9-male connector. The type of cable needed varies depending on the device connected to the port. The XY-Stage uses a straight serial cable. The Z-focus uses a null modem cable.


3.1 Necessary Files

The PIC software is compiled using the CCS PCWH compiler. The necessary files are listed below.

  • rs232.c (main)

  • 18F4455.h

  • stdio.h

  • stdlib.h

  • pic18_usb.h

  • USB_to_RS232_desc _25.h

  • usb.c

3.2 RS-232 Settings

The default settings for RS-232 communication are set to 9600 baud, 8 bits, no parity, and no software handshaking. Only the Transmit (TX), Receive (RX), and Ground signals are used. The Request to Send (RTS) and Clear to Send (CTS) signals are tied together at the board level so that devices requiring the CTS signal will always be enabled to send data. This works because the device will set its own RTS signal high, so connecting these two signals will ensure that CTS will be held high as long as the device is connected. If an attached device requires settings different from the board default, this can be changed in the software with the exception that this board does not accommodate devices that require handshaking beyond the CTS signal.

3.2.1 Olympus Z-Probe Settings

The Z-Probe default RS-232 communication settings are not compatible with this board. However, they may be changed using the front panel DIP switches to match this board’s default settings listed above. Please see the Olympus IX2 Host I/F Specifications Document (IX2cmdNE.pdf) paragraph 4.1 for more details.

3.3 UART

The PIC18F4455 has only one hardware UART, but multiple software UARTS can be created. This is accomplished by assigning a different set of transmit and receive pins for each UART. In this device, three UARTs (one hardware and two software) are used, and each one is associated with one of the three RS232 ports. The USB command indicates which port to use, and the software sets the appropriate UART pins before each data transmission.

3.4 Command Set

Each device uses its own unique command set which is described in the device’s user manual or specification document. The purpose of this board is to pass this command on to the device without modification. The data received via USB will contain this command as well as a three-byte precursor that indicates how the command should be processed. The first byte will be an ASCII character ‘1’, ‘2’, or ‘3’ to designate the number of the port that the command is intended for. The next two bytes will be a two-character ASCII code which indicates the type of device connected to this port. This allows the embedded software to change any settings for that particular device if necessary. It also enables the host to keep track of the commands sent to each device. The ASCII command to be sent to the device follows. Each device may require a “terminator” to indicate the end of the command such as a carriage return, line feed, or combination of the two. This terminator is included as part of the command in the original USB received data and does not need to be added or modified. The maximum command length, including precursor and command with terminator, is 25 characters. The command structure is illustrated below.

Figure 2: USB Command Structure

Device Code

Device Type


ASI, Inc. MS-4400 XY Stage


Olympus Z-Focus



Table 1: Device Codes
Table 2 gives some examples of typical commands that may be used.



“1XYmovrel x=-5000” 0x13

Sends the command “movrel x=-5000” followed by carriage return to the XY-Stage on Port1

“3XYmovrel y=1000” 0x13

Sends the command “movrel y=1000” followed by carriage return to the XY-Stage on Port3

“1Z#2MOV F,200000” 0x13 0x10

Sends the command “2MOV F,200000” followed by carriage return and line feed to the Z-Focus on Port 1

“2Z#2LOG OUT” 0x13 0x10

Sends the command “2LOG out” followed by carriage return and line feed to the Z-Focus on Port 2

Table 2: Example USB Commands

4.0 PIC18F4455 Port Usage

  1. Port 1 UART

RC6 – TX Line (RS-232)

RC7 – RX Line (RS-232)

  1. Port 2 UART

RA0 – TX Line (RS-232)

RA1 – RX Line (RS-232)

  1. Port 3 UART

RA2 – TX Line (RS-232)

RA3 – RX Line (RS-232)

  1. MCLR

RE3 – Reset Switch

5.0 Notes for Future Versions

  • Connect serial pins 7 and 8 (RTS and CTS) on the board.

  • Layout so that all connectors are on one side of the board. This will make it easier if moving to system design with one large chassis rather than individual boxes for each board.

  • Put holes on each corner

  • Depending on standard cables used, may be better to have female DB9 connectors rather than male.

Rev-12/04/07 USB to RS232

База данных защищена авторским правом ©shkola.of.by 2016
звярнуцца да адміністрацыі

    Галоўная старонка