TCP/IP Development Kit Getting Started

> ## 5. Serial Ports and Digital I/O

> Chapter 5 describes how to set up TCP/IP Development boards for serial communication, and how to use the digital I/O.

> ### 5.1 Serial Communication

> In the factory-default configuration, the TCP/IP Development Board has one RS-232 (3-wire) serial channel, one RS-485 serial channel, and one synchronous CMOS serial channel. The TCP/IP Development Board may be configured for 5-wire RS-232 or two 3-wire RS-232 channels. The exact configuration instructions depend on the version of the TCP/IP Development Board you have. This information is etched on the bottom side of the printed circuit board, or you can readily determine your version by examining the diagrams below to find the one that matches your board.

> Version 175-0188 Rev. A & B

> The RS-232 transceiver may be used as a 5-wire RS-232 channel or as two 3-wire RS-232 channels at the expense of the RS-485 channel by adding 0 W surface-mounted resistors at R61 and R62 as shown in Figure 7(a). The RS-485 chip (U10) and the associated bias and termination resistors (R58, R59, and R60) shown in Figure 7 must be removed when configuring the TCP/IP Development Board for either one 5-wire RS-232 or two 3-wire RS-232.

> Figure 7(a). RS-232/RS-485 Serial Communication Options

> Table 2(a) summarizes the options. Note that the parameters in the `serMode` software function call must also be set to match the hardware configuration being used.

> Table 2(a). Serial Communication Configurations (Version 175-0188 Rev. A & B)
> Item | Factory Default | One 3-wire RS-232 & RS-485 | Two 3-wire RS-232 | One 5-wire RS-232
> R58-R60 |  | In | Out | Out
> R61-R62 |  | Out | In | In
> U10 |  | In | Out | Out
> J7-3 & J5-3 |  | RS-485+ | TxB | TxB
> J7-4 & J5-4 |  | RS-485- | RxB | RxB
> J7-6 |  | TxC | TxC | RTS
> J7-7 |  | RxC | RxC | CTS

> Version 175-0188 Rev. C

> The RS-232 transceiver may be used as a 5-wire RS-232 channel or as two 3-wire RS-232 channels at the expense of the RS-485 channel, which is connected through 0 W surface-mounted resistors at R82 and R83 as shown in Figure 7(b). R82 and R83, shown in Figure 7(b), must be removed when configuring the TCP/IP Development Board for either one 5-wire RS-232 or two 3-wire RS-232. U10 and the associated bias and termination resistors (R58, R59, and R60) must also be removed, but R82 and R83 are left installed, if you wish the TxB and RxB RS-232 signals to be available on header J5.

> Figure 7(b). RS-232/RS-485 Serial Communication Options

> Table 2(b) summarizes the options. Note that the parameters in the `serMode` software function call must also be set to match the hardware configuration being used.

> Table 2(b). Serial Communication Configurations (Version 175-0188 Rev. C)
> Item | Factory Default | One 3-wire RS-232 & RS-485 | Two 3-wire RS-232 | One 5-wire RS-232 | RS-232 on J5
> R58-R60 |  | In | -- | -- | Out
> R61-R62 |  | Out | In | In | In
> R82-R83 |  | In | Out | Out | In
> U10 |  | In | In | In | Out
> J7-3 |  | RS-485+ | TxB | TxB | TxB
> J7-4 |  | RS-485- | RxB | RxB | RxB
> J7-6 |  | TxC | TxC | RTS | TxC or RTS
> J7-7 |  | RxC | RxC | CTS | RxC or CTS
> J5-3 |  | RS-485+ | -- | -- | TxB
> J5-4 |  | RS-485- | -- | -- | RxB

> Version 175-0206

> The RS-232 transceiver may be used as a 5-wire RS-232 channel or as two 3-wire RS-232 channels at the expense of the RS-485 channel, which is connected through jumpers across header JP7 as shown in Figure 7(c). The jumper configurations are shown in Figure 7(c).

> Figure 7(c). RS-232/RS-485 Serial Communication Options

> Table 2(c) summarizes the options. Note that the parameters in the `serMode` software function call must also be set to match the hardware configuration being used.

> Table 2(c). Serial Communication Configurations (Version 175-0206)
> Item | Factory Default | One 3-wire RS-232 & RS-485 | Two 3-wire RS-232 | One 5-wire RS-232 | RS-232 on J5
> Header JP7 |  | 3-5 4-6 | 1-3 2-4 | 1-3 2-4 | 1-5 2-6
> Header JP6 |  | 1-2 5-6 | -- | -- | No jumpers installed
> U10 |  | In | In | In | Out
> J7-3 |  | RS-485+ | TxB | TxB | --
> J7-4 |  | RS-485- | RxB | RxB | --
> J7-6 |  | TxC | TxC | RTS | TxC or RTS
> J7-7 |  | RxC | RxC | CTS | RxC or CTS
> J5-3 |  | RS-485+ | -- | -- | TxB
> J5-4 |  | RS-485- | -- | -- | RxB

> ### 5.1.1 RS-232

> The TCP/IP Development Board's RS-232 serial channel is connected to an RS-232 transceiver, U11. U11 provides the voltage output, slew rate, and input voltage immunity required to meet the RS-232 serial communication protocol. Basically, the chip translates the Rabbit 2000's 0 V to +Vcc signals to RS-232 signal levels. Note that the polarity is reversed in an RS-232 circuit so that +5 V is output as approximately -10 V and 0 V is output as approximately +10 V. U11 also provides the proper line loading for reliable communication.

> The maximum baud rate is 115,200 bps. RS-232 can be used effectively at this baud rate for distances up to 15 m.

> ### 5.1.2 RS-485

> The TCP/IP Development Board has one RS-485 serial channel, which is connected to the Rabbit 2000 Serial Port B through U10, an RS-485 transceiver. The chip's slew rate limiters provide for a maximum baud rate of 250,000 bps, which allows for a network of up to 1200 m (or 4000 ft). The half-duplex communication uses the Rabbit 2000's PC0 pin to control the data enable on the communication line.

> The RS-485 signals are available on pins 3 and 4 of header J7, and on J5, the RJ-12 jack.

> The TCP/IP Development Board can be used in an RS-485 multidrop network. Connect the 485+ to 485+ and 485- to 485- using single twisted-pair wires (nonstranded, tinned).

> Alternatively, the RS-485 multidrop network may be hooked up using cables with RJ-12 plugs. Note that the RJ-12 jack has +RAW_485 and GND, which means that only one TCP/IP Development Board needs to be connected to an external power source via an AC adapter. When doing so, ensure that the AC adapter has sufficient capacity for the network -- each TCP/IP Development Board nominally draws 100 mA at 24 VDC.

> NOTE | If you plan to connect a power supply to more than one TCP/IP Development Board in an RS-485 network using the RJ-12 jacks, rework the RS-485 cables so they do not connect +RAW_RS485 through the RJ-12 jack to the boards in the network.
> NOTE | The RS-485 port is available only in the factory default configuration. The RS-485 port will not be available when you select the configuration option for both 3-wire RS-232 ports or one 5-wire RS-232 port.

> The TCP/IP Development Board comes with a 220 W termination resistor and two 680 W bias resistors installed and enabled with jumpers across pins 1-2 and 5-6 on header JP6, as shown in Figure 8.

> Figure 8. RS-485 Termination and Bias Resistors

> The bias and termination resistors in a multidrop network should only be enabled on both end nodes of the network. Disable the termination and bias resistors on the intervening TCP/IP Development Boards in the network by removing both jumpers from header JP6. Note that older versions of the TCP/IP Development Board do not have this jumper feature, and the surface-mounted bias and termination resistors shown in Figure 8 have to be removed in networks containing more than 10 TCP/IP Development Boards.

> ### 5.1.3 Programming Port

> The TCP/IP Development Board has a 10-pin programming header labeled J4. The programming port uses the Rabbit 2000's Serial Port A for communication. The Rabbit 2000 startup-mode pins (SMODE0, SMODE1) are presented to the programming port so that an externally connected device can force the TCP/IP Development Board to start up in an external bootstrap mode.

> NOTE | Refer to the Rabbit 2000 Microprocessor User's Manual for more information related to the bootstrap mode.

> The programming port is used to start the TCP/IP Development Board in a mode where the TCP/IP Development Board will download a program from the port and then execute the program. The programming port transmits information to and from a PC while a program is being debugged.

> The TCP/IP Development Board can be reset from the programming port.

> The Rabbit 2000 status pin is also presented to the programming port. The status pin is an output that can be used to send a general digital signal.

> ### 5.1.4 Serial Communication Software

> Library files included with Dynamic C provide a full range of serial communications support. The `RS232.LIB` library provides a set of circular-buffer-based serial functions. The `PACKET.LIB` library provides packet-based serial functions where packets can be delimited by the 9th bit, by transmission gaps, or with user-defined special characters. Both libraries provide blocking functions, which do not return until they are finished transmitting or receiving, and nonblocking functions, which must be called repeatedly until they are finished. For more information, see the Dynamic C Premier User's Manual and Technical Note 213, Rabbit 2000 Serial Port Software.

> The following function calls are specific to the TCP/IP Development Board.

> ## int serMode (int mode);

>   User interface to set up up serial communication lines for the TCP/IP Development Board. Call this function after `serXOpen()`.

> ##### Parameters

>   mode is the defined serial port configuration of the devices installed.

> Mode | Serial Port
> B | C
> 0 | RS-485 | RS-232, 3-wire
> 1 | RS-232, 3-wire | RS-232, 3-wire
> 2 | RS-232, 5-wire | CTS/RTS

> ##### Return Value

>   0 if correct mode, 1 if not.

> ##### See Also

>     serB485Tx, serB485Rx

> ## void serB485Tx();

>   Sets pin 3 (DE) high to disable Rx and enable Tx.

> ##### See Also

>     serMode, serB485Rx

> ## void serB485Rx();

>   Resets pin 3 (DE) low to enable Rx and disable Tx.

> ##### See Also

>     serMode, serB485Tx

> #### 5.1.4.1 Sample Serial Communication Programs

> RS-232

> 1. Connect RX to TX as shown in Figure 9 below.

> Figure 9. TCP/IP Development Board Setup
> for RS-232 Serial Communication Demonstration

> 1. Connect the programming cable to header J4 on the TCP/IP Development Board. Apply power to the TCP/IP Development Board.

> 2. Open the sample program `SAMPLES\ICOM\ICOM232.C` and press F9.

> This program demonstrates a simple RS-232 loopback displayed in the Dynamic C STDIO window.

> RS-485

> 1. Connect 485+ to 485+, 485- to 485-, and GND to GND as shown in Figure 10 below. If you do not have a separate wall transformer for the other board, also connect PWR to PWR as shown in Figure 10.

> Figure 10. TCP/IP Development Board Setup
> for RS-485 Serial Communication Demonstration

> 1. Connect the programming cable to header J4 on one TCP/IP Development Board. This will be the slave, the other board will be the master. Apply power to the TCP/IP Development Boards.

> 2. Open the sample program `SAMPLES\ICOM\ICOM485.C`. You will find some code for the master, and some code for the slave. Copy and save the master and slave versions separately.

> 3. Open the sample slave program and press F9.

> 4. Connect the programming cable to header J4 on the master TCP/IP Development Board.

> 5. Open the master program and press F9.

> This program demonstrates a simple RS-485 transmission of lower-case letters to a slave. The slave will send back converted upper case letters back to the master, which then displays them in the Dynamic C STDIO window.

> ### 5.2 Digital I/O

> ### 5.2.1 Digital Inputs

> Pins 8-11 on header J7 have the four digital inputs IN0-IN3. Each of the four digital 0 V to 5 V inputs is protected over a range of -36 V to +36 V. The TCP/IP Development Board is factory-configured for the digital inputs to be pulled up to +5 V, but the digital inputs can also be pulled down by moving the surface-mounted jumper at JP4. The jumper settings and the location of JP4 are shown in Figure 11.

> Figure 11. Surface-Mounted Jumper Configurations for Selecting
> Pullup/Pulldown on the Digital Inputs

> ### 5.2.2 Digital Outputs

> Pins 12-15 on header J7 have the four digital outputs OUT0-OUT3. Each of the four open-collector digital outputs can sink up to 200 mA at 40 V DC.

> ### 5.2.3 Digital I/O Software

> ## void digOut (int channel, int value);

>   Sets the state of a digital output.

> Parameters

>   channel is the output channel number (0, 1, 2, or 3).
>   value is the output value (0 or 1).

> Return Value

>   None.

> See Also

>     digIn

> ## int digIn (int channel);

>   Reads the state of a digital input.

> Parameters

>   channel is the input channel number (0, 1, 2, or 3).

> Return Value

>   The state of the input (0 or 1).

> See Also

>     digOut

> ### 5.2.4 Sample Digital I/O Programs

> 1. Connect the programming cable to header J4 on the TCP/IP Development Board. Apply power to the TCP/IP Development Board.

> 2. Open the sample program `SAMPLES\ICOM\ICOMIO.C` and press F9.

> This program demonstrates how to turn the I/O on and off.

Rabbit Semiconductor http://www.rabbitsemiconductor.com Voice: (530) 757-8400 FAX: (530) 757-8402 sales@rabbitsemiconductor.com