Basic Serial Interface

This electronic circuit makes connecting a personal computer to the "real world" easy. By using your computer's serial port and a few simple lines of BASIC program, external devices can be monitored and controlled. You can build the BSI using the plans provided on this page. 



BASIC Serial Interface (BSI)

Introduction:

The BASIC Serial Interface (BSI) is a 6402 based UART circuit which allows the control of devices using a computer's RS232 serial port and BASIC programming language.

Theory of operation:


The BASIC Serial Interface consists of four integrated circuits: An RS232 receiver/transmitter, +5 volt regulator, 555 timer, and a 6402 UART (please refer to schematic).

Data (8 bit words) are received through the data cable from pin 2 of the computer serial port. They terminate on terminal IS (serial in) on the BSI. These RS232 signals are converted to TTL levels by IC2 and passed to pin 20 of IC1 (6402 UART). The transmission is then decoded and output to pins 12 through 5 of IC1 as 8 separate outputs, each representing one bit of the 8 bit word.

Data on the input ports of IC1(pins 26 through 33) are encoded and transmitted to the RS232 transmitter section of IC2 when Data Strobe (DS), pin 23 is pulsed low. IC2 converts the TTL signal from IC1 to RS232 level and transmits it via pin 3 of the serial port to the computer.

IC3 produces the clock signal for IC1 and must be 16 times the bit rate. For instance if the computer is set for 1200 baud the frequency of IC3 (pin 3) must be 19.2 KHz. The frequency must be within 3% for the circuit to work. Please refer to the following table for the proper frequency settings.

Baud ............. Clock frequency
bits/sec......... (pin 3 IC3)

300 .............. 4800
1200 ..............19.2 KHz
2400 ..............38.4 KHz
4800 ..............76.8 KHz
9600 ..............153.6 KHz

Transformer T1, Bridge rectifier BR1, C9, C10 and +5 volt regulator (IC4) comprise the power supply and regulator circuit. T1, BR1, C9, and C10 comprise the DC power supply portion and can be located on either end of the Data Cable. Also, the DC power supply (T1, C9, C10, and BR1) can be replaced by any +8 to +30 volt DIRECT CURRENT (DC) power supply such as the common plug mounted supplies that are frequently used with modems, telephones, and electronic games. The +5 volt regulator (IC4) is located on the BSI and regulates the voltage to +5 volts which supplies the rest of the circuit.

Programming:


The BASIC Serial Interface is designed to be operated from a computer using BASIC program language. However, any programming language will work if it can open, send and receive from the serial port. This discussion will be limited to BASIC and the reader can extend the concept to their particular programming language.
The following two programs are used to test the BSI. The first program tests the transmission from the computer to the BSI, and the second tests the transmission from the BSI to the computer.

Program 1.... computer to BSI:

10 KEY OFF:CLS:CLOSE
20 OPEN "COM1:1200,N,8,2" AS #1
30 INPUT "ENTER NUMBER 0 TO 255";A
40 PRINT #1, CHR$(A);
50 GOTO 30

Line 10 turns off the BASIC key displayed across the bottom of the screen in most versions of BASIC, Clears the screen, and closes any files that might be open. Line 20 opens the computer's serial communications port number 1 as device #1 and sets it to a bit rate of 1200, no parity, 8 bit words, and two stop bits. Line 30 accepts a number typed from the computer keyboard. Line 40 converts the number to its appropriate ASCII equivalent (which will be the value of the number typed) and outputs it to communications port 1. Line 50 starts the program over again. For instance, if 65 was typed on the computer keyboard when the "return "key is pressed pins 6 and 12 of the 6402 UART (IC1) will go high and pins 11,10,9, 8, 7,and 5 will remain low. This bit pattern represents the binary number 10000010 or 65 in decimal.

Program 2.... BSI to computer:


10 KEY OFF:CLS:CLOSE
20 OPEN "COM1:1200,N,8,2" AS #1
30 A$=INPUT$ (1,#1)
40 PRINT ASC(A$)
50 GOTO 30

This program is the same as program 1 except for lines 30 and 40. Line 30 receives the data word sent to the computer's serial communications port 1 and assigns it to the string variable A$. Line 40 prints the ASCII character code (the decimal equivalent of the BSI's input port) to the screen. for instance if pin 26 and 32 on the BSI are high and pins 27,28,29,30,31, and 33 are low the 8 bit data word transmitted would be 01000001 or 65 in decimal.

Using these basic program elements it is possible to program a variety of routines to read to and write from individual ports. Some examples are provided in the enclosed "Security System Application Note #1".


If the serial port uses a 9 pin "D" connector use the following wiring.

return to jerry's home page

Jerry Baumeister

E-Mail to:
jerry_baumeister@msn.com

Copyright ©1995, Jerry Baumeister
Revised - 4-21-96