Вы находитесь на странице: 1из 4

2012 International Conference on Computing, Electronics and Electrical Technologies [ICCEET]

Ethernet Enabled Digital 1/0 Control


in Embedded Systems
Mr. Suyog A. Wani

Prof. R.P.Chaudhari

Dept. of Electronics and Telecommunications,


Government College of Engineering,
Aurangabad 431001, India.
wanisuyog@gmail.com

Dept. of Electronics and Telecommunications,


Government College of Engineering,
Aurangabad 431001, India.

Abstract - This paper presents very simple and economical

II.

way to provide Ethernet connectivity to microcontroller based


embedded

systems.

This

system

uses

ATmega328p

microcontroller to store the main application source code, web

FUNDAMENTAL COMPONENTS

This section gives information about various components

pages and TCP/IP stack which is a vital element of the system

related to the system and various options available for using

software. An Ethernet controller chip, ENC 28J60 is used to

them. Some of the important components and protocols are

handle the Ethernet communications and is interfaced with the

listed below.

host microcontroller using SPI pins. There are several I/O pins
available at the microcontroller which are used to interface with
sensors and relays for monitoring and controlling operations.
Nowadays, Internet has spread worldwide and most of the
internet connections use Ethernet as media for data transfer. In
industries or in home appliances, most of the time we need to
monitor

and

control

different

parameters

using

microcontrollers. Once we enable Ethernet interface to such


systems, we can communicate with them remotely over the
internet.
Keywords

Ethernet

controller;

TCPI/P

stack;

serial

peripheral interface (SPJ); A Tmega328p.

INTRODUCTION

Ethernet's

in

offices

infrastructure,

and

SPI interface

110 system

Ethernet is a data link and physical layer protocol defined


by the IEEE 802.3 specification [2].
Ethernet is versatile enough to suit many purposes.
Ethernet can transfer any kind of data, from short messages
huge

files.

An

Ethernet

communication

can

industrial

buildings.

interoperability and

scalability

doesn't require a large or fast computer. With the addition of


an Ethernet controller chip, even an 8-bit microcontroller can
communicate in an Ethernet network.
Normal

IEEE

802.3

compliant

Ethernet

frames

are

between 64 and 1518 bytes long. They are made up of five or


six different fields: a destination MAC address, a source
MAC address, a type/length field, data payload, an optional
padding field and a Cyclic Redundancy Check (CRC).

Nlnlbe r

Red

ofB)'t-!s

{ I'''m
p::
:::=:== 1 }

..... .-( I
{

SFD

J.

fitere.d Out by the Module


Stln.-Of-Fr.mK" jmilfLf
(filtered out by the morule)
Destina1ion Address,
such as MI.Aticasl Broadcast or U nica.st

DA
SA

Type ofPacket orme length oflhe

TypeJLength

Used in the
Calculation
ot the FCS

"'"
Pacl;etPay50ad
(with Clp60nal padding)

46-1500

ensure ease of development. Once equipment is connected to


a Ethernet network, it can be monitored or controlled through

Padding

the Internet removing any distance barrier that may have

FCS(1)

inhibited remote communication previously.

Note 1: The FCS is transrritted staning wilt! bit 31

frame O'IecK Sequence - eRe

and ending with

bit. O.

Figure 1. Ethernet Packet Format

978-1-4673-0210-4112/$31.00 2012 IEEE

take

IP, or it can use an application-specific protocol. Ethernet

for remote communication. Ethernet is the most widely


network

Ethernet controller Chip

advantage of existing higher-level protocols such as TCP and

For many years, embedded systems and Ethernet


networks existed in separate worlds. Ethernet was available
only to desktop computers and other large computers.
Embedded systems that needed to exchange information with
other computers were limited to interfaces with low speed,
limited range, or lack of standard application protocols.
But developments in technology and the marketplace now
make it possible for embedded systems to communicate in
local Ethernet networks as well as on the Internet. Network
communications can make an embedded system more
powerful and easier to monitor and control [I].
Ethernet solves the problem of remote communication
with the embedded application. Challenges like application
monitoring, control, diagnostics and data logging can all be
accomplished from a remote, centralized location. With the
ability to access the application remotely, corporations can
eliminate the need to send a service person to the application
and thus save labor time and money.
There are compelling reasons behind considering Ethernet
deployed

Ethernet

A. Ethernet

to
I.

634

Paclle-t

2012 International Conference on Computing, Electronics and Electrical Technologies [ICCEET]

C.

SPI (Serial Peripheral Interface) Standard


The SP[ has a 4-wire synchronous serial interface. Data

communication is enabled with a low active Slave Select or


Chip Select Signal (SS) or (CS). Data is transmitted with a 3-

MCU

wire interface consisting of wires for serial data input


(MOSI), serial data output (MISO) and serial clock (SCI<).

TfIT,WOC

SCLK

..
p

SCLK

SPI

MOSI

..

MOS I

SPI

)laste,"

MISO

MISO

S la ve

..

SS

Stand-Alone Ethernet Controller

SS

Figure3. Serial Peripheral Interface

Figure 2. ENC 2SJ60 Ethernet controller


B.

III.

Ethernet Controller Chip

HARDWARE ARCHITECTURE

The ENC2SJ60 is a stand-alone Ethernet controller with an

This system utilizes a Stand-Alone Ethernet Controller [C

industry standard Serial Peripheral Interface (SP[). [t has on

which handles most of the network protocol requirements.

chip [0 Mbps Ethernet Physical Layer Device (PHY) and

The [C communicates directly to the microcontroller using a

Medium

Access

Controller

(MAC),

providing

reliable

standard SP[ interface. The system hardware includes an

packet-data transmission/reception based on an industry

Ethernet

standard Ethernet protocol [6].


The PHY contains analog circuitry to encode and decode

link/activity

the data on the twisted pair interface while the MAC contains

sensors and relays for monitoring and controlling purpose.

digital

handle

This system enables user to connect a particular embedded

automatic retransmission when a collision occurs, calculates

device (equipped with SP[ support) on to a network. By

and validates CRCs (Cyclical Redundancy Check), and do

using this Ethernet enabled digital I/O control system,

circuitry

to

control

when

to

transmit,

other necessary tasks.


A total of S kilobytes of RAM is present on the device.

controller

[C

lights,

ENC2SJ60,
Ethernet

RJ45

socket

transformer,

host

microcontroller (ATmega32Sp) and input/output devices like

applications like Embedded Web server [9] can be easily


developed.

The microcontroller can configure how much of the SKB is


allocated to the receive hardware.

AT me gal28

ENe 28J60

RELAYS

SLSORS

with

DRI\1NG

_ IOSI

CIRCUITRY

SI

MISO
SCK
OPTO
ISOLATORS

Figure 4. Block diagram of Ethernet enabled digital I/O control system

635

EJ

2012 International Conference on Computing, Electronics and Electrical Technologies [ICCEET]

parameters and devices on the field. It is interfaced with

A. RJ-45 Connector socket


Ethernet uses a bus (old coaxial cable) or star topology

microcontroller using different 110 ports. Driving circuitry

use

consist of relay drivers, signal conditioners etc. At the end of

unshielded twisted pair (UTP) cable. Category 5 (CAT5)

the system, relays and opto-isolators are used to switch ON

cable widely used,

(standard

UTP

cable).

Most

Ethernet

networks

but other variations are available.

or OFF different devices connected to them. Different

EIA/TIA specifies RJ-45 connectors - properly called 8P8C -

sensors are used to sense the physical data such as

(ISO 8877) for UTP (unshielded twisted pair) cable. A

temperature, light etc.

standard LAN cable can be connected here using RJ-45


connector.
B.

Figure 5. User interface in internet browser

I'5GECA: ETHERNET ENABLED DIGITAL 1/0 CONlROL SYSTEM Windows Internet Explorer

Ethernet transformer

@@

On the TPIN+/TPIN- and TPOUT+/TPOUT- pins of ENC

Eile

28J60, I: I center taped pulse transformers, rated for Ethernet

dit

favorites

operations, are required. When the Ethernet module is

lID 10.1.1.1
fgvorites
lools
t1elp
Ix ..
j ieGECA: ETHERNET ENABLED DIGITAL I/O CONTROL s -[ l

.iew

...

GECA: ETHERi....'ET ENABLED DIGITAL 110 CONTROL SYSTEM

enabled, current is continually sunk through both TPOUT


pins. When the PHY is actively transmitting, a differential

RELAY 1. OFF [0. -]. RELAY 2

voltage is created on the Ethernet cable by varying the


relative current sunk by TPOUT+ compared to TPOUT-. A

ADC= 0516

common-mode choke on the TPOUT interface, placed

Temparature = 29cC

between the TPOUT pins and the Ethernet transformer, is not

OFF [ON]

recommended. If a common-mode choke is used to reduce


EMI emissions, it should be placed between the Ethernet

1101.11

II AVRIP I

transformer and pins I and 2 of the RJ-45 connector. Many

1101.1.76

II

Ethernet transformer modules include common-mode chokes

inside the same device package [5].


C.

Server IP

Refresh

ENC28J60
The ENC28J60 is a stand-alone Ethernet controller with an

IV.

industry standard Serial Peripheral Interface (SPI). It is


designed to serve as an Ethernet network interface for any
controller equipped with SPI. The ENC28J60 meets all of the
IEEE 802.3 specifications.
It incorporates a number of packet filtering schemes to
limit incoming packets. It also provides an internal DMA
module for fast data throughput and hardware assisted
checksum calculation, which is used in various network
protocols.

Communication

with

the

host

controller

is

implemented via an interrupt pin and the SPI, with clock


rates of up to 20 MHz. Two dedicated pins are used for LED
link and network activity indication [5]. A typical application
using the device (lC) is shown in Figure 4. With the
ENC28J60, two pulse transformers and a few passive
components are required to connect a microcontroller to an
Ethernet network.

The ATmega328 is 28 pin microcontroller from Atmel


sufficient to accommodate our configured TCP/IP stack
(explained later) as well as our main application source code.
It is a low-power CMOS 8-bit microcontroller based on the
enhanced

contains

program

code

that

manages

communications

between the controller chip and a higher level in the network


protocol stack [I]. For internet communication over Ethernet,
a Transmission Control Protocol/Internet Protocol (TCP/IP)
software stack is necessary. This stack resides on the Host
MCU.
Microchip's

TCP-IP

stack,

need

to

be

configured

according to the host microcontroller used in the system.


Microchip provides a driver for the ENC28J60 and a TCP/IP
stack including an HTTP web server.
Web pages need to be stored in external or internal
EEPROM. These pages can be accessed using internet
browser by accessing the IP address assigned to the system.
system IP address and server IP address can be configured by

AVR family. It has 32 Kbytes of flash memory which is

powerful

In an Ethernet network, the interface to the network is an


Ethernet controller chip and its driver. The Ethernet driver

Figure 5 shows user interface in an internet browser. The

D. MCV A Tmega328p

AVR

SOFTWARE REQUIREMENT

RISC

instructions

architecture
in

single

[4].

By

clock

executing
cycle,

the

ATmega328p achieves throughputs approaching I MIPS per


MHz allowing the system designer to optimize power
consumption versus processing speed.

E. Data Acquisition and Control system (I/O system)


This is a simple circuitry to monitor and control different

making changes in the program. This firmware is written in


C (Compatible with Microchip CI8 compiler).

A. TCP/IP Download and support


Microchip offers a free licensed TCP/IP stack optimized
for the PIC18, PIC24, dsPIC and PIC32 microcontroller
families.

As

we

are

using

AVR

ATmega328p

microcontroller, the stack need to be configured. There are at


least three files that will need to be edited and modified. The
first is config.h file, second is the particular hardware
configuration file for our system hardware and third is main
application source code. The stack is divided into multiple
layers, where each layer accesses services from one or more
layers directly below it.Per specifications, many of the

636

2012 International Conference on Computing, Electronics and Electrical Technologies [ICCEET]

V.

TCP/IP layers are "live", in the sense that they not only act
when a service is requested, but also when events like time
out or new packet arrival occurs.
The stack is modular in design and is written in the 'C'
programming language. Effective implementations can be
accomplished in roughly 25-30 KB of code, depending on
modules used,

leaving plenty of code space on host

microcontroller for the user application.


B.

IDE for microcontroller 's program development


Atmel

AVRStudio

is

the

Integrated

Development

Environment (IDE) for developing and debugging embedded


Atmel AVR applications [3], [8]. The AVR Studio IDE gives
a seamless and easy-to-use environment to write, build, and
debug C/C++ and assembly code.

Ethernet enabled digital I/O control system is designed for


multiple input and output arrangements for industrial as well
as non industrial applications. The module is small, simple
and flexible which can perform different I/O operations
remotely over Ethernet.
Our system can be extended for sensing malfunctioning in
industrial machines and making corrective measures in it.
Wireless Ethernet enabled interface can also be developed.
There is no limit for future scope in the monitoring and
control operation. Industrial automation is no longer limited
by the walls of the production facility. More and more
automation is being handled via remote communication.
This Ethernet Embedded system paves the way to
numerous applications to be developed in the area of
monitoring and automation.

REFERENCES

" DW[2ndSem\[NC\PractltepIORl4l1ls\avr
// GIClb".l 'Janables
M.l.C_ADDR avr_"ac
IPj.DDR ""r_ip;

[I]
[2]

IIIlC_IlDDR "",rv",r_""c;
IP_llDDR ''''':rv!!r_ip;

// Chang!! I'ClUr "vI' and _rr ip "dd...",. h"r!!


// "VI' and ""TV"1' lP d
s ar" stClrM in _pr",,,
BYTE =_avr_ip[q WEll
10, 1, 1, 1

a d
{

},

!;.::.::;;:;;i;l!!.;:.:.!.;.;.;.:.........

.:I;;::POATA
JI::gPORT8
JIPORTC
.:I;;gPORTD
.:ISF1
.:IGTIHER_courHl
.:IGTIHEA_COUNTI
"TIHERCOUtHl"

n............

// Funchon
"".VeT_process
// De"cription
Run web =rver and listen on port 80

<
<

>

[3]
[4]
[5]
[6]
[7]
[8]
[9]

Eu:i.ld :succeededvitll 0 \Ia"nin. . .


an-gee

-u.cua""ga3:8p -Vall -gdwad-:

CONCLUSION AND FUTURE SCOPE

-DF_CPU-4000000UL-O. -f.iQDe:d-char -I!D -IIP-lITaai

IIUildsuccccd.dvithOhrninq. . .

>
<. 1.".g.
==------I
Ot
"i findin fil" I Li Br,,point '.ndT'","POlnts

lnSO,Coll

Figure 6. AVR studio window after successful building of


program [8]

ETHERNET
CONTROLLER
(ENC28J60)

Figure 7. ENC28J60 connected with ATmega328

637

Jan Axelson ,"Embedded Ethernet and Internet Complete", 2003.


Andrew Tanenbaum, "Computer Networks", 4th Edition, 2003, pp.
271-292
Richard H. Barnett, Larry O'CuII, Sarah Cox, "Embedded C
Programming and The Atmel AVR". 2nd Ed. 2007. pp. 249-253.
Atmel Corporation, "ATmega328p Data Sheet", 2011.
Microchip Technology Inc. "ENC 28J60 Data Sheet", 2008.
www.microchip.com
www.embeddedmarket.com
AVR Studio 4, for AVR microcontrollers http://www.atme1.coml
dyn/productsl tools_card.asp?tool_id=2725
Basanta Mahato, Sachin Sharma, Gaurav Chitranshi, "An Embedded
Web controllable heater interface for Industry application", 2010
Annual IEEE India Conference (INDICON), 978-1-4244-90745/101$26.00 2010 IEEE

Вам также может понравиться