Sie sind auf Seite 1von 6

Proceedings of the 2012 International Conference on Machine Learning and Cybernetics, Xian, 15-17 J uly, 2012

INTERNET-BASED 8051 REMOTE IN -SYSTEM PROGRAMMING SYSTEM

YUNG-SHENG CHEN, MIN-TA SUNG, KUN-LI LIN

Department of Electrical Engineering, Yuan Ze University, Chung-Li 32003, Taoyuan, Taiwan, ROC
E-MAIL: eeyschen@saturn.yzu.edu.tw

Abstract: the place in realistic usages. However, while modification of


Traditionally, programming a microcontroller unit (MCU) system function is required, the program of MCU also needs
either requires an IC burner or such MCU is in-system to be updated.
programmable. Usually programming an ISP MCU in system is
Typical program updating manners of a MCU is
feasible only with operation of a local computer which is
generally separated into two ways. The first one requires
connected with the system via universal asynchronous
removal of the MCU from its system and use an IC burner
receiver-transmitter (UART) or universal serial bus (USB)
connected with a computer to update program. Since physical
interfaces. This paper proposes an internet-based remote
programming system which is named 8051 NET-ISP. This contact with the MCU is necessary while removing,
system consists of an Ethernet communication module and an damaging the package of the MCU during repeated testing
applicable MCU AT89S51 which is capable of ISP functions. process becomes a main drawback. In the second approach,
Therefore a remote computer user can update or download the the MCU itself must contain in-system programming (ISP)
assembled hex-code program of 89C51 or remotely control the functions, which enables directly programming by a local
applicable circuit through the Internet without reaching the
computer through the connection of universal asynchronous
system if it has been distributed faraway. Such system extends
receiver-transmitter (UART) or universal serial bus (USB)
applicability compares with modern MCU circuits and improves
interfaces without using an IC burner. Although this one does
the management convenience as the number of the same module
not require removing the MCU from its circuit, the system
rises.
still has to be taken out from where it is placed if it has been
distributed faraway. Hence considering the previous two
Keywords:
Microcontroller unit; Embedded TCP/IP; Remote typical approaches of program updating, management will
in-system programming; Internet-based remote control become an unpleasant and high-cost task as the node number
of the distributed MCU-based embedded system rises. The
1. Introduction hardware constraint that restricts general MCUs can only be
programmed with a local connected computer shall be
Microcontroller units (MCU) have low-cost and eliminated for more flexible application design. And also the
easy-using features so that nowadays are widely applied in management and program updating of numerous of nodes
various embedded systems combined with different function shall be much easier. Huang and Lai [5] implemented a DSP
type of sensors or communication interfaces to control ISP system with Ethernet interface. They used a kind of
circuits. Ahmed, Wong, et al. [1] proposed remote control of special UDP broadcast package to make a DSP MCU
the position of a DC motor with a low-cost MCU and an communicate through an Ethernet controller with computer to
embedded Ethernet IC. Many of other MCU-based remote update the executable program of DSP. However, they only
applications are related to smart home researches. Liu [2] applied limited protocol instead of normal TCP/IP so
used MCU, network controller, and various sensors for remotely control was seemly restricted.
fulfilling a smart home system which was for environment This study presented integrates an embedded TCP/IP
surveillance and electrical peripheral equipment controlling. Ethernet module with an ISP-functioned MCU AT89S5l to
On the other hand, Zhai and Cheng [3] proposed smart home implement remote in-system programming (remote-ISP)
surveillance gathering GSMlGPRS module, MCU, sensors, functions. In addition, the application program that
and digital cameras so a user could monitor the security of programmed on AT89S51 can use the Ethernet module, hence
hislher house through cellphones in real-time. Another remote control is possible. We named this system "8051
application combined ZigBee for remote control purpose is in NET-ISP." Figure 1 depicts a networking of several
[4]. These systems combined different networking interfaces individual 8051 NET-ISP system nodes. Each node can be
with programmable controllers and may be spread all over separately used for different control applications. This system

978-1-4673-1487-9/12/$31.00 2012 IEEE


1638
Proceedings of the 2012 International Conference on Machine Learning and Cybernetics, Xian, 15-17 J uly, 2012

LNMS 3 Node 9
Internet,
.. User WAN
LAN 3

LAN 1

8051
NET-ISP , Node 8
Router 1 Node 4 "
\ Router 3
\ "
\

LNMS 1
LNMS2

Figure 1. Depicting the networking of our proposed 8051 NET -ISP system. A LNMS is added in each LAN and serves as an intermediate connection
bridge between nodes and remote users.

provides user remotely reading, writing, and erasing program see the thick red solid path in Figure 1. While the remote user
memory of the A-MCU (applicable MCU) AT89S51 through is connecting node 9, he/she is actually connecting to LNMS
the Internet. While the node's program needs to be modified, 3. The server will retransmit internet packages from the user
the user can download the program of the A-MCU for to node 9. Contrarily, node 9 will send internet packages to
disassembling. After the program of the A-MCU has been LNMS 3 first instead of directly sending to the remote user
updated, the system will automatically restart to execute the while responding the remote user's request.
new one. It also allows user to remotely control the
applicable circuit if related control functions are written. 3. Hardware Architecture
The remainder sections are organized as follows. It first
introduces the networking of multiple nodes that are The hardware of 8051 NET-ISP is separated into two
distributed in section 2. Then hardware architecture of the parts: embedded TCP/IP Ethernet module and applicable
proposed 8051 NET-ISP is described in section 3. In section 4 controller module, see Figure 2.
general ISP manipulation of AT89S51 including both
Embedded TCP/IP Applicable
hardware and software aspects are introduced. Section 5 Ethernet Module Controller Module
proposes the software architecture inside the 8051 NET-ISP
and remote user interface. Experiments are described in P3.2 E1.J ..
section 6. Finally, conclusions and future extension are given Realtek :1 3 _ - _ Pj ..
in section 7. Ethernet _ P]! E 1.;..5 .. ISP
Ethernet

2. Networking of the Distributed 8051 NET-ISP Nodes


Controller
MCU ]..,;3&
(E-MCU)
B..T ..
Applicable
MCU
(A-MCU)
Application
Circuit

While such node is in a wide area network (WAN), e.g.,


I EEPROM I- TXD
RXD
RXD
TXD

node 4 in Figure 1, a remote user can directly reach


connection through the Internet with the system's specific IP ISP control signal - Ethernet controller 1/0
address, and remotely program the AT89S51 MCU in system Remote control command and A-MCU response data
or control the applicable circuit. However, the number of
Figure 2. The block diagram of hardware architecture of the 8051
usable IP address for general public is limited. Therefore, a
NET-ISP.
more practical situation is distributing these nodes into
different local area networks (LAN) integrated by routers,
3.1. Embedded TCPIIP Ethernet Module
such as LAN 1 in Figure 1. In other words, these nodes can
only use virtual IP addresses in their private networks, thus
This module mainly consists of a MCU SST89E516,
network address translation (NAT) traversal is a serious issue
which is called E-MCU (Ethernet MCU) in later paragraph to
[6, 7]. In order to let a remote user reach connection through
distinguish form the A-MCU, an EEPROM X5045, and an
the Internet with these nodes that are behind routers, a local
Ethernet controller RTL8019AS. Su, Yue, et al. [8] and Wang,
node management server (LNMS) in each LAN that contains
Gong, et al. [9] proposed the use of RTL8019AS for
8051 NET-ISP nodes is added to serve as an intermediate
equipping an MCU and a FPGA with Ethernet
connection bridge for the remote user's connection request,

1639
Proceedings of the 2012 International Conference on Machine Learning and Cybernetics, Xian, 15-17 J uly, 2012

communication ability, respectively. The Ethernet controller 4. In-System Programming Using AT89S51
takes charge of receiving and transmitting Ethernet packages,
and the E-MCV with its program is used to implement 4.1. Serial Mode ISP Circuit of AT89S51
embedded TCP/IP stack. As the module is set for first-time
use or need to modify network attributes such as the IP MCV AT89S51 has a 4K bytes in-system programmable
address, MAC address, or connection port, we have to write flash memory and is standard 8051-compatible. It provides
them into the EEPROM and reset the module. After the two ISP programming interfaces: parallel mode and serial
module restarted, the E-MCV will access those network mode [11]. Serial mode is applied in this paper for saving I/O
attributes and write to the Ethernet controller. Then make the of both MCVs. For using its ISP function, basically the
Ethernet controller enter package receiving/transmitting hardware shall be connected as the circuit depicted in Figure
mode [10]. 3. The pin Pl.5IMOSI is used for writing ISP instructions and
After the E-MCV received a TCP package, it then stores data into AT89S51, Pl.6IMISO is used for reading the
the payload in a receiving data buffer. The application layer program memory, and Pl.7/SCK is the clock input during
of the E-MCV will handle with different tasks depends on the each serial ISP input or output bits. And during ISP functions
specific command attached at the beginning of the package's operation (no matter reading, writing, or erasing), RST must
payload. If the command is to operate ISP functions to read, be sustained with high-level voltage input till the operation is
write, or erase program memory of the A-MCV, the E-MCV fmished then RST is pulled down back to low-level voltage
uses its pins from P3.2 to P3.5 to produce ISP control and to let AT89S51 execute program in normal state.
data signal. And if the package is for controlling the + 5V
application circuit, the E-MCV will redirect the remote 89551
control command and send through serial communication Clock in P1 .7/SCK Vee
port (TXD) to the A-MCV so that the A-MCV can handle Data output P1.6/MISO
these control contents. Instruction input P1.5/MOSI
V1H RST
3.2. Applicable Controller Module
.-....-----1
.. XTAL1
33pF
This paper applies an in-system programmable MCV
AT89S51 as the A-MCV so that it is able to remotely update
33pF
the control functions of the application circuit. The pins of '--....---+
.. ---1 XTAL2
the A-MCV from Pl.5 to Pl .7 and RST are used for driving
GND
ISP control signal sent from the E-MCU. The E-MCV will
automatically restart the A-MCV while ISP process is
finished. Furthermore, if the remote user programed the
Figure 3. The serial mode programming interface of ISP circuit of
A-MCV with serial communication functions, then the user is AT89S51. This paper uses the E-MCU to drive ISP control signals, thus
able to tell the A-MCV to control the application circuit in pins Pl.5 to Pl.7 and RST of AT89S51 are connected to the E-MCU as

real-time. The control command is retransmit by the E-MCV Figure 2 shows.

through serial port. And if the A-MCV needs to generate any


response, it can also send the response data through serial 4.2. Instructions of Serial Mode ISP Operation
port to let the E-MCV packet the data send back to the
remote user. This proposed remote-ISP system only takes the
The program of the E-MCV is unchangeable remotely following four instructions to operate AT89S51, and each one
since it only performs like a network interface card (NIC), follows a 4-byte protocol, see TABLE 1. The read/write
and therefore changing the program on it is unnecessary. All program memory instructions are used in page mode (256
we need to modify for changing application of the 8051 bytes per memory page), and the page number is available
NET-ISP is to change the program of the A-MCV and the from 0 to 15 since AT89S51 has a 4K bytes program memory.
application circuit.

1640
Proceedings of the 2012 International Conference on Machine Learning and Cybernetics, Xian, 15-17 J uly, 2012

TABLE 1. THE USED ISP INSTRUCTIONS (IN HEXADECIMAL program memory through MISO byte by byte.
REPRESENTATION). BYTE 3 AND 4 OF RM AND WM ARE PROGRAM DATA
For writing program memory, the first byte of WM and
INSTEAD OF THE PART OF THE INSTRUCTION.
the page number are written to MOSI after PE. Then 256
Instruction (Abbr.) Byte I Byte 2 Byte 3 Byte 4 bytes of data can be sequentially given to MOS!. Whenever
the writing data is less than 256 bytes, the rest empty data
Programming Enable (PE) OxAC Ox53 OxOO OxOO
must be padded with OxFF to finish writing totally 256 bytes.
Chip Erase (CE) OxAC Ox80 OxOO OxOO Otherwise malfunction may occur.
Read Program Memory Page
(RM) Ox30
in Page Mode Number 4.5. Always Chip Erase Before Re-Programming

Write Program Memory Page


(WM) Ox50
in Page Mode Number While writing the program memory of the node's
AT89S51, the E-MCU will first use CE instruction to clear
the previous program. This can avoid an error occurs because
Each instruction is written to MOSI sequentially starts
of the fragment of part of the old program is left behind. For
from byte 1. However, each time before giving one of the CE,
instance, a program A with 512 bytes is already in the
RM , or WM instructions, the PE instruction shall first be
program memory of the A-MCU. And there is another
given to enable serial programming. Therefore, to erase the
program B with 256 bytes is about to be re-programming the
entire program memory, use CE instruction followed by PE.
A-MCU. See Figure 5, the contents of the program memory
before writing in program B is shown in the middle row.
4.3. Serial Programming Waveforms
Since the data length of program B is less than program A,
without chip erase before programming program B will result
Each byte of the instructions or data writing to MOSI or
in fragment Al left in the page 1. This may cause execution
data reading from MISO follow the wavefonn depicted in
error after restart the A-MCU.
Figure 4. The transmission follows the sequence that the
MSB has the first serial order. Program A Program B
To write a bit data to the A-MCU, it is first hold on (512 bytes) 2
( 56 bytes)
MOSI, and then the E-MCU pulls up SCK so the A-MCU
will read in the bit data. The E-MCU can prepare for writing Page 0 Page 1 Page 15
another one after the clock signal is end.
To read a bit data from the A-MCU, it is first output to
Before
I:
AO
:I A1
writing in B 256 bytes 256 bytes :I N/A N/A N/A
I
MISO, and then the E-MCU read in the bit data and send a Page 0 Page 1 Page 15

I I I I
clock signal to SCK. At the end of the clock signal, the After writing in B BO A1
N/A N/A N/A
without CE first 256 bytes 256 bytes
A-MCU will prepare for outputting the next bit. . . .
Program Memory Pages of the A-MCU
Serial
Data Input Figure 5. The program fragment Al that left in the program memory
P1.5/MOSI after writing in program B may cause execution error. N/A represents
Serial all data are OxFF, which are not available.
Clock Input
P1. 7/SCK
5. Software Architecture
Serial
Data Output
P1.6/MISO 5.1. 8051 NET-ISP Software
Serial Order o 2 3 4 5 6 7

As depicted in Figure 6, a remote user sends commands


Figure 4. The waveforms of serial programming I/O. The MSB are the
through the Internet using TCP protocol to an 8051 NET-ISP
first bit to be written to MOSI or be read from MISO.
node. While the Ethernet controller accepts the Ethernet
package, the E-MCU will access the package from the
4.4. Read and Write Program Memory Operations
Ethernet controller by using "remote direct memory access"
(RDMA) technology [10] and decompose the package. The
The RM and WM instructions do not contain the third
implemented protocols of embedded TCPIIP stack [12] are
and the fourth bytes. Right after a PE instruction is given to
shown in the upper part of Figure 6. For an accepted TCP
MOSI, the first byte of RM and the page number that
package, if the target IP address and the target MAC address
specifies which page of the memory is trying to be read are
are all confinned, the payload of the TCP package will be
written to MOS!. Then 256 bytes of data can be read from the

1641
Proceedings of the 2012 International Conference on Machine Learning and Cybernetics, Xian, 15-17 J uly, 2012

given to application control handler to distinguish the user 5.2. Remote Interface for Remote User
command. The application handler will execute
corresponding task according to the command-task definition This study implements the windows-based remote user
given in TABLE 2. program with Microsoft Visual Basic with .NET framework.
There are two registers stated in Figure 6. The status The internet communication is driven by a Sockets class
register is for saving the operation status after executing WM defined in namespace System.NET.Sockets and uses TCP/IP
and CE instructions. And the data register is for saving the protocol. The LNMS handles remote user's connection
read program or the circuit responses from the A-MCU. The request. Therefore the user can remote programming or
contents of both registers will be sent back to the Embedded control the nodes that are in the same LAN as the LNMS.
TCPIIP handler to compose a TCP package. Thus the remote The hex-code program or control commands are attached to
user can reach the ISP operation status or remote control the payload of TCP package. While downloading program
responses. from a node, the user interface will reconstruct the sent back
Internet data and stores in normal hex-code program format. The
downloaded program can be disassembled with specific
disassembler software so that modification of the program is
possible.
Embedded
TCPIIP
6. Experiments
Handler

Due to digital circuits are driven with logical signal, we


verified the proposed system function of 8051 NET-ISP with
a LED controller as the applicable circuit. And we sent a
program, which is for controlling LEDs, of the A-MCV
through the Internet to the node for programming. Both ISP
Operation
status Transmit and control functions were verified stable.
Write Program
system
Memory status
Status
Operation
Application Register 6.1. The Functions of Remote ISP
status
Control Chip Erase
Handler
Hex-code To verify program updating functions, we prepared three
program
Read Program
Transmit kinds of different LED twinkling patterns, and sent from a
Memory
Circuit
Data data local computer to an 8051 NET-ISP node through the Internet
Register
response to update the A-MCV program. Each program is executed
normally as the program memory of the A-MCV is written.
Then we download the written program back to the local
computer and disassemble with a disassembling program.
The three sent back programs are check correspond with the
original ones.

Figure 6. The block diagram of the software architecture of 8051


NET-ISP. 6.2. Remote Controlling the Applicable Circuit

The applicable circuit has eight LEDs connected with


TABLE 2. T HE COMMAND-TASK DEFINITION TABLE. COMMANDS ARE THE
FIRST BYTE OF THE RECEIVED TCP PAYLOADS.
the port 2 of the A-MCU. The remote user interface has
control buttons and LED indication items correspond to each
Command Task LED in the 8051 NET-ISP applicable circuit. With each
button pressed in the remote user interface, the corresponding
# Write the program memory oftheA-MCU.
LED will invert its status. And the system node will also
& Erase the program memory oftheA-MCU.
return the status of that LED and the user interface shows on
* Read the program memory oftheA-MCU. the corresponding indication item so the remote user can
confirm the operation.
% Send the accepted control signal to theA-MCU.

1642
Proceedings of the 2012 International Conference on Machine Learning and Cybernetics, Xian, 15-17 J uly, 2012

7. Conclusions Computing, Proceedings of the the IEEE 2nd


International Conference on Control and Industrial
This paper presents a new design, 8051 NET-ISP, Engineering, pp. 41-44, 20-21 Aug. 2011.
integrates embedded TCPIIP Ethernet, ISP functions of the [4] J. Han, C.-S. Choi, and I. Lee, "More efficient home
low-cost MCV AT89S51, and serial communication to energy management system based on ZigBee
implement a remote programmable and controllable system. communication and infrared remote controls," IEEE
Such system can combine with various extensive applications Transactions on Consumer Electronics, Vol 57, No. 1, pp.
such as those program updating and remote controlling are 85-89.
simultaneously necessary. It not only provides a solution for
[5] H. Huang and X. Lai, "In-system programming
the constraint that traditional MCV programming only can be
outer-chip flash of DSP with Ethernet interface,"
operated nearby a computer, but also makes use of TCP/IP
Proceedings of the WRI Wodd Congress on Computer
network and serial communications to extend the flexibility
Science and Information Engineering, pp. 230-233,
and applicability.
March 31 2009-Apri12 2009.
Currently, this 8051 NET-ISP is only designed for MCS
[6] Y.-C. Chen and W.-K. Jia, "Challenge and solutions of
AT89S51 as an in-system programmable system. In the future
NA T traversal for ubiquitous and pervasive applications
we can involve different types of ISP-based MCVs so that the
on the internet," Journal of Systems and Software, Vol
applicable circuit control functions can become more
powerful. With substitution of wireless network module for 82, No. 10, pp. 1620-1626, Oct. 2009.

current Ethernet module, lots of twisted pairs can be removed, [7] W. Goralski, "Chapter 27 - network address translation,"
and therefore the distribution of our node can be wider and Morgan Kaufmann, Boston, pp. 681-696, 2009.
more convenient. [8] Y. Su, J. Yue, and J. Hao, "Application of RTL8019AS
to Ethernet communications node based on single chip
Acknowledgments microcomputer," Proceedings of the IEEE 6th Circuits
and Systems Symposium on Emerging Technologies:
This work was supported in part by the National Science Frontiers of Mobile and Wireless Communication, pp.
Council, Taiwan, Republic of China, under Grant No. 225-227 YoU, 31 May-2 June 2004.
NSC99-2221-E-155-080. [9] T. Wang, C. Gong, et aI., "A design of network remote
control system," Proceedings of the International
References Conference on Consumer Electronics, Communications
and Networks, pp. 3819-3822, 16-18 April 2011.
[1] I. Ahmed, H. Wong, and V. Kapila, "Internet-based [10] "RTL8019AS realtek full-duplex Ethernet controller
remote control using a microcontroller and an embedded with plug and play function (ReaIPNP)," Realtek
Ethernet,". Proceedings of the American Control Semiconductor Corporation, May 10, 2001,
Conference, pp. 1329-1334 vol.2, June 30 2004-July 2 http://www.realtek.com.tw/.
2004. [11] "AT89S51 8-bit microcontroller with 4k bytes in-system
[2] Y. Liu, "Design of the smart home based on embedded programmable flash," ATMEL Corporation, Jun. 2008,
system," Proceedings of the 7th International Conference http://www.atmel.comldevices/at89s51.aspx.
on Computer-Aided Industrial Design and Conceptual [12] "Internetworking with tcp/ip. Principles, protocols, and
Design,.pp. 1-3, 17-19 Nov. 2006. architecture / vol. I," D.E. Comer and D.L. Stevens,
[3] Y. Zhai and X. Cheng, "Design of smart home remote Prentice-Hall, New Jersey, 2000.
monitoring system based on embedded system,"

1643

Das könnte Ihnen auch gefallen