as a Word document

advertisement
Chapter 6 Introduction to 80851
Overview
To apply a single chip 8051 that had been studied previously creates a communication circuit,
which can communicate with LabVIEW, in order to help you verify and debug the serial port
communication program that had developed in the LabVIEW.
Objective
■ Use a single chip 8051 to make simple verification tool for serial port testing
■ Write a simple LabVIEW program to link the communication with 8051.
Keyword
■ Single chip 8051
■ Serial port communication
Function Explanation
Path
Explanation
Input
Output
Path
All Functions ►Instrument I/O►VISA►VISA
Advanced►Bus/Interface►Specific►Serial►Conf
igure Port
Initializes the serial port Specified by VISA
resource name to the specified settings.
VISA resource name specifies the resource to
be opened. The parameters need initialization
such as: the baud rate, flow control etc.
If there is a bug, output the error code
All Functions ►Instrument I/O►VISA►write
Explanation
Writes the data from write buffer to the device
or interface specified by VISA resource name
Input
VISA resource name specifies the resource to
be opened. write buffer contains the data to be
written to the device. Error in describes error
condition that occur before this VI or function
runs.
Output
dup VISA resource name is a copy of the
VISA resource name that VISA functions
return. return count contains the actual
number of bytes written. error out contain
error information.
Path
All Functions ►Instrument I/O►VISA►read
Reads the specified number of bytes from the
Explanation device or interface specified by VISA resource
name and returns the data in read buffer.
Input
VISA resource name specifies the resource to
be opened. byte count is the number of bytes to
be read. error in describes error condition that
occur before this VI or function runs. The
default is no error.
Output
Read in string and output error code
Brief
We have to mention that this chapter emphasizes on the communication program wiring with
the LabVIEW, so we neglect the detail description of 8051 program and circuit development, but
we still hope the user familiar with developing procedure of 8051 program and circuit.
8051 chip is widely applied both in academy and industry. There is a built-in UART inside
8051 chip; therefore we take advantage of it to design an experiment for implementing relevant
communication practices.
The zero and the first pins of port 3 inside 8051 are taken as RxD and TxD for serial port
communication respectively, and it is perfect they are only used for these purposes. Once there is a
pin shortage, you better assess some other ways to enable the practice.
The power supply of 8051 chip is DC +5V, so the input and output port of all 8051 pins are
TTL level voltage. One level transfer IC named MAX232 (MAXIM Co.) is used to transfer the
level between 8051 serial port and RS-232 interface as a result of comparability.
MAX232 is designed to use quite simply and easily, it can operate by merely mounting a
0,1μF capacitor outside. Even the power supply just uses +5V.
Ahead of being introduced the LabVIEW serial port communication experiments, you have to
construct a circuit to help yourself carry out the circuit experiments, now we are going to use 8051
as the demonstration tool.
Single-chip microcontroller 8051 is frequently used in industry field, and it also taught in colleges
and other educational institutes. Although it has been 20 years since Intel introduced the first
version 8051 ant Intel does not provide it now, 8051 chi still plays an important role and the other
semiconductor manufacturers continuously issued faster 8051 with larger addressing space to meet
market demand. The 8051 chip not only has brilliant function such as: arithmetic functions,
complete logical operation and etc., but also has built-in UART, counter and I/O function as well
several exterior interruption. All of these are necessary for automatic control system. Overall, it is
very appropriate that you can use single chip 8051 as the verification tool here. After learning the
LabVIEW communication with 8051 chip you will have the capability to communicate with the
current automatic control system in the industry nowadays.
8051 serial port is a full-duplex mode, which can simultaneously transmits and receives serial
port data. It has four different modes: mode 0, mode 1, mode 2 and mode 3.
Mode 0: This mode transmits and receives signal through RXD, and sends shifting pulse through
TXD, Its transmission rate is constant and equals 1/12 oscillation rate.
Mode 1: This mode transmits signal through TXD and receives signal through RXD. Each time it
transmits 10 bit including 8 data bit, 1 start bit and 1 stop bit. User can program its
transmission rate.
Mode 2: This mode transmits signal through TXD and receives signal through RXD.
Each time it transmits 11 bit including 8 data bit, 1 start bit, 1 TB8 bit that is programmed
by user and 1 stop bit. Its transmission rate is constant and equals 1/32 or 1/64 of
oscillation rate.
Mode 3: This mode transmits signal through TXD and receives signals through RXD. Each time it
transmits 11 bit including 8 data bit, 1 start bit, 1 TB8 bit that is programmed by user and
1
stop bit. User can program its transmission rate.
The diagram below displays the functions of UART inside 8051. According this diagram, the
functional flows of built-in UART are organized as follows:
1. After the data is written in SBUF from internal bus, UART will transmit data to shift
register and automatically output it at the programmed transmission rate. After the output,
T1 bit is set to 1.
2. After data is read into RXD from exterior, the shifting register of receiver will receive data
byte. After the reception, R1 is set to 1.
3. Write-in or read-out data from SBUF is pointed to different physical addresses. Writing in
SBUF means transmitting serial port data out, but reading out SBUF means to read the
received data back into internal bus.
4. RI bit and TI bit cannot be automatically cleared as 0, programmer has to clear them during
programming to prevent error transmission and reception.
From the above brief introduction, you can find out that both the target addresses for the serial
port data transmission or data reception are named SBUF, because SBUF for read-out and write-in
does not address the same memory space.
After understanding the function of built-in UART, you now can construct a simple serial port
circuit for experiment.
Download