8 Channel D/I Card for RS232 Schematic Circuit Diagram

The author is a student at the Electronics Department, Technological Educational Institute of Piraeus, Greece. This project is a card with eight optically isolated TTL-compatible inputs for external connection to the serial port, which communicates through the RS-232 protocol. On this card, you will look in vain for a UART or microcontroller chip because the design is based on a 27C256 EPROM. Each digital input is connected to an optocoupler (IC7-IC14) through a resistor (R2-R9), and drives it with a current of 5 mA when the input voltage is 5 Vdc. A diode (D1-D8) is connected in parallel with each optocoupler input to protect against the ill effects of reversed signal polarity.

8 Channel D I Card for RS232 Schematic Circuit Diagram 1

 

The collectors of the internal optocoupler transistors drive EPROM address lines A6 to A13. The logic states of A6 to A13 are inverted (because the optocouplers work as inverters) and for this reason a second inversion is performed in software (EPROM) to cancel the total inversion effect.

8 Channel D I Card for RS232 Schematic Circuit Diagram 2

 

In this way the 8 inputs become TTL compatible. IC1, a CD4060, with the help of C1, P1, R11 and R10, forms a bitrate generator for 150, 300, 600, 1200, 2400, 4800 or 9600 bps. Preset P1 needs to be adjusted to the desired baudrate — an accuracy of 1-2% is required! The bitrate is selected using DIP switch S1. The CD4040 works as a 9-bit binary counter. The three LS bits of the counter outputs (AD0, AD1, AD2) drive the selection inputs of multiplexer IC4 (74HC151). The other counter bits (AD3-AD8) drive the LS address bits of the EPROM (A0-A5).

8 Channel D I Card for RS232 Schematic Circuit Diagram Components List

8 Channel D I Card for RS232 Schematic Circuit Diagram Table 1

 

The highest EPROM address line, A14, is connected to one of the DIP switches in S1 which defines the data transmission mode (TTY or BIN). With the above connections, counter IC2 sweeps a range of 512 bits (64 bytes) of the total of 256 kBits (32 Kbytes) contained in the EPROM. The number of 512-bit blocks (packets) equals the number of different combinations of CH0 to CH7 and MODE, and can be calculated from the following formula : Memory size = 512 packets*512 bits/packet = 256 Kbits = 32 Kbytes The data encoding unit consisting of IC1- IC4 transmits 512- bits packets (coming from the multiplexer output).

8 Channel D I Card for RS232 Schematic Circuit Diagram 3

 

 

The data in the transmitted packet depends directly on the logic states of lines CH0 to CH7 and MODE. The power supply includes a 7805 regulator so that the card will not need a separate regulated power supply. Circuit IC5 (a MAX232) works as an RS232 Driver/Receiver, converting the multiplexer’ s output data from TTL to RS232 compatible.

With the EPROM programmed with the right data, the circuit will produce messages (packets), through the RS-232 protocol, that will inform us for the logic states of the card’s inputs. The transmission used by this card is 8 data bits, 1 stop bit and no parity.

Assuming an ‘A’ is to be sent, and that your PC runs a terminal simulation program receiving (via the RXD pin of its serial port) the following 10 bits ‘0100000101’, then it will print on its screen the character ‘A’. This card transmits the logic states of its inputs in one of two modes, TTY (teletype) or BIN (binary).

In TTY Mode, the card transmits the following message to the computer: ,,,,’CH0:X’,,’CH1:X’, ,’CH2:X’,,’CH3:X’,, ‘CH4:X’,,’CH5:X’,,’CH6:X’,,’CH7:X’ Where is the character with ASCII code 255, used to synchronize the computer. Reception of this character (from the computer) causes a space to appear on the screen. and are ‘carriage return’ and ‘line feed’ with ASCII codes 13 and 10 respectively, and is the ‘space’ character with ASCII code 32. Reception of this character (from the computer) causes a space to appear on the screen. Finally, X is the logic state of each input, which will cause a ‘1’ or a ‘0’ to appear on the screen.

In BIN Mode, the card transmits the following message to the computer: ,, Where is as above and is the character with an ASCII code equal to the numerical value of the byte built from the logic states of the inputs (with the MS Bitrepresenting CH7, and LS Bit, CH0).

These two modes are used in different cases. In cases where we want just to see the logic states of the input we just set the card in TTY mode and we use a terminal program as Telix, Procomm Plus, Hyper Terminal etc. In cases where we want to do some data logging or to compose a data acquisition & control system with other DAQ & control cards then we just set the card in BIN mode (because the decoding of the data is easier done by dedicated software).

8 Channel D I Card for RS232 Schematic Circuit Diagram Table 2

8 Channel D I Card for RS232 Schematic Circuit Diagram Table 3

 

 

The characters, their ASCII codes and their bit values, as used in the two modes are shown in Table 1. The bitstreams that must be transmitted for each character appear in Table 2. The contents of the EPROM are created by a program (EPROMFMP.BAS) developed in Quick Basic, which is available from the author’s website. The program first makes a temporary file that contains all data to be written in the EPROM in bit format (08DICARD.TMP). Next, it converts this file into byte format (08DICARD.BIN) and deletes the temporary file. Finally, it runs an external program (BIN2HEX.EXE) and adapts the file from Binary to IntelHex format (08DICARD.HEX). To program your own EPROM, you may use 08DICARD.BIN or 08DICARD.HEX file. Finally, the mode and bit rate selection on S1 is shown in Table 3. The PCB designed for this project is unfortunately not available ready-made through the Publishers’ Readers Services. All software you will need to complete this project may be downloaded free of charge from the author’s website at http://members.xoom.com/robofreak/download/08dicard.htm Also, for other projects developed by Mr. Vastianos, visit this address: http://members.xoom.com/robofreak/

Leave a Reply

Your email address will not be published. Required fields are marked *