You are on page 1of 23

31/03/2009

THINKLABS ETHERNET INTERFACE BOARD V1.0

SPI based Ethernet Interface add-on module for uNiBoard v1.1 |


TRI Technosolutions Pvt. Ltd.
ThinkLABS

Introduction ........................................................................................................................................................ 3
Package contents ................................................................................................................................................. 5
Description .......................................................................................................................................................... 6
Ethernet Interface Board .............................................................................................................................................. 6
Ethernet buffer ............................................................................................................................................................. 7
Features .............................................................................................................................................................. 8
Ethernet Controller Features ........................................................................................................................................ 8
Buffer ............................................................................................................................................................................ 8
Medium Access Controller (MAC) Features .................................................................................................................. 9
Physical Layer (PHY) Features ....................................................................................................................................... 9
How To Set Up The Connection .......................................................................................................................... 10
Configurations ................................................................................................................................................... 11
Connecting uNiBoard directly to the PC ..................................................................................................................... 12
Connecting uNiBoard directly on to the Network ...................................................................................................... 12
How Ethernet Interface Board Works?................................................................................................................ 13
Reception .................................................................................................................................................................... 13
Transmission ............................................................................................................................................................... 14
Wireshark .......................................................................................................................................................... 15
Application Note ................................................................................................................................................ 18
uIP…............................................................................................................................................................................. 18
Embedded Webserver ................................................................................................................................................ 19
Appendix A – References.................................................................................................................................... 22
Appendix B - Services and Support ..................................................................................................................... 23

© TRI Technosolutions Pvt. Ltd. Page 2 of 23 http://thinklabs.in


ThinkLABS

Introduction

Ethernet is a local area technology, which is used for reliable and efficient transfer and access
of information across the devices connected to the network. Once a device is attached to the
network, it will have the ability to communicate with any other attached device. This allows
the network to expand to accommodate new devices without requiring any modification to
those devices already on the network.

Fig: Network Interface Card used in PCs

In case of embedded applications, the lightweight protocols like SPI, I2C and UART would not
add the capability of controlling your standalone device from any remote place. That is when
the need for adding an Ethernet interface to your embedded device is felt. To facilitate this
need you would need some additional hardware which would include an Ethernet PHY and a
networking protocol stack.

Ethernet controller ENC28J60 from Microchip forms the building block for our Ethernet
Interface add-on Board. It’s an SPI based add-on chip which has Ethernet PHY and MAC to
equip any embedded controller with SPI interface with network capability. Through this
interface our controller can communicate with other devices connected on the network
including PCs.

© TRI Technosolutions Pvt. Ltd. Page 3 of 23 http://thinklabs.in


ThinkLABS

NOTE: Throughout the user manual instead of development board the term uNiBoard is used,
but any development board using a controller with SPI (Serial Peripheral Interface) interface
can be interconnected with Ethernet Interface Board.

uNiBoard v1.1 is an open source development board for Embedded and Real Time Systems
programming. The uNiBoard project is hosted on this link: http://code.google.com/p/uniboard
and more details about the board can be obtained in that link.

© TRI Technosolutions Pvt. Ltd. Page 4 of 23 http://thinklabs.in


ThinkLABS

Package contents

• Ethernet Interface Board v1.0


• Network Cable (RJ45)
• CD containing Source code, User Manual, Data Sheets etc.

© TRI Technosolutions Pvt. Ltd. Page 5 of 23 http://thinklabs.in


ThinkLABS

Description

Fig: Ethernet Interface Board v1.0

Ethernet Interface Board v1.0: It contains the Ethernet Controller ENC28J60 with SPI
support and Ethernet Jack – MAG Jack (RJ45).

The Ethernet Interface Board v1.0 helps to connect a particular embedded device to the
network. If a particular embedded device is connected to the network, command or data for
that particular embedded device can be provided from any of the devices connected to that
network.

The Ethernet Interface Board can be connected to the uNiBoard (which will be the heart of
that particular device) and by using SPI pins of the Ethernet controller (ENC28J60) the
Ethernet Interface Board communicates with the uNiBoard. This Ethernet Interface can be
used to develop different applications like embedded web server, Ethernet based Data
acquisition system, internet controlled robot (Telepresence robot) etc.

If your embedded device is a robot and you want to control that from a remote place you just
need a PC which is connected to the network. From the PC you can send commands to the
robot though your Ethernet network.

© TRI Technosolutions Pvt. Ltd. Page 6 of 23 http://thinklabs.in


ThinkLABS

Ethernet buffer: It is the memory area inside ENC28J60 and it contains transmit and
receive memory used by the Ethernet controller in a single memory space, means receive and
transmit share the same buffer (memory). The sizes of the memory areas are programmable
by the host controller using the SPI interface. It is of 8-Kbyte transmit/receive packet dual port
SRAM. The Ethernet buffer memory can only be accessed via the read buffer memory and
write buffer memory SPI commands.

Fig: Layers in OSI and TCP/IP

In ENC28J60 Network Interface(Link) Layer is present, that means Physical layer + MAC layer
(comes inside Link layer), with this we can achieve physical connection and link detection. For
application layer protocols like FTP, HTTP etc. TCP/IP stack should be ported to the embedded
device.

© TRI Technosolutions Pvt. Ltd. Page 7 of 23 http://thinklabs.in


ThinkLABS

Features

• Ethernet Controller – Microchip’s ENC28J60 with SPI interface


• Supports Data Transfer up to 10 Mb/s
• LINK/STATUS LEDs for indication/debugging

Ethernet Controller Features

• IEEE 802.3 compatible Ethernet controller


• Integrated MAC and Receiver and Supports Full and Half-Duplex modes
• Programmable padding and CRC generation
• SPI Interface with speeds up to 10 Mb/s

Buffer

• 8-Kbyte transmit/receive packet dual port SRAM

• Configurable transmit/receive buffer size

• Internal DMA for fast data movement

• Hardware assisted IP checksum calculation

© TRI Technosolutions Pvt. Ltd. Page 8 of 23 http://thinklabs.in


ThinkLABS

Medium Access Controller (MAC) Features

• Supports Unicast, Multicast and Broadcast packets

• Loopback mode

• Programmable receive packet filtering and following:

• Unicast destination address


• Multicast address
• Broadcast address
• Magic Packet TM
• Group destination addresses as defined by 64-bit hash table

Physical Layer (PHY) Features

• Wave shaping output filter

• Loopback mode

NOTE: Refer ENC28J60 datasheet for details on the above features.

© TRI Technosolutions Pvt. Ltd. Page 9 of 23 http://thinklabs.in


ThinkLABS

Setting up the Connection

Connect the pins of the Ethernet Interface board with the Development Board (uNiBoard)
accordingly (refer figure).

MOSI <-> MOSI

MISO <-> MISO

SCK <-> SCK

CS <-> SS

WOL <-> NC for current configuration (LAN interrupt o/p pin)

INT <-> NC for current configuration (Interrupt o/p pin)

CLK0 <-> NC for current configuration (Programmable clock o/p pin)

RST <-> PB7 (in case of uNiBoard)

GND <-> GND

3V3 <-> VCC (in case of uNiBoard)

© TRI Technosolutions Pvt. Ltd. Page 10 of 23 http://thinklabs.in


ThinkLABS

Load the sample program given on the CD to uNiBoard. Connect the network cable between
Ethernet Interface Board and PC. Power on the uNiBoard and if the link is up between Ethernet
Interface Board and PC, the LED on the RJ45 will start to blink, which means that the physical
layer is up and working.

RESET signal

Power connection for


Ethernet Interface Board

Fig: Ethernet Interface Board interfaced with uNiBoard

The Ethernet Interface Board can be powered from the Development Board (uNiBoard) or can
be given an external 3.3v supply.

© TRI Technosolutions Pvt. Ltd. Page 11 of 23 http://thinklabs.in


ThinkLABS

Configurations

There are two different configurations that you can have with the board as shown below of which the
first configuration can be used for testing and development purposes while the second one would be
used for application purposes.

Connecting uNiBoard directly to the PC

Ethernet
uNiBoard v1.1 Interface Board PC

Fig: Connection between the uNiBoard and Ethernet Interface Board is done as described
above and PC is interfaced with the Ethernet Interface Board using the network cable.

Connecting uNiBoard directly on to the Network

Ethernet Interface
uNiBoard v1.1 Board

Network

PC

Fig: Connection between the uNiBoard and Ethernet Interface Board is done as described
above and Ethernet Interface Board is connected to the network directly. Run Wireshark
(procedure described below) on any of the PCs connected to that network.

© TRI Technosolutions Pvt. Ltd. Page 12 of 23 http://thinklabs.in


ThinkLABS

How Ethernet Interface Board Works?

Make the connections between uNiBoard (development board), Ethernet Interface board and
PC as described above. So the data transfer between the ENC28J60 and the uNiBoard will be
carried out through the SPI interface. Whatever data is transmitted or received through the
Ethernet Interface Board will be stored in the Ethernet Buffer in the ENC28J60.

Reception: Data coming from the network through the cable will be stored in the Ethernet
Buffer, this will be done by the firmware written on the ENC28J60. From the Ethernet Buffer
we can read the data through the SPI pins of the ENC28J60 to the uNiBoard.

The following are API's used in the Source code:

o enc28j60PacketReceive() - to receive packets

 enc28j60Write() - to write register values

• enc28j60SetBank() - to set the address bank

• enc28j60WriteOp() - to do the write operation

 enc28j60ReadOp() - to read the data from the buffer

PacketReceive function would be called first and in that Write function will take the value and
address to which the write operation to be performed. SetBank will set the address bank and
the WriteOp will actually do the write. These two function calls are done within Write function
as can be seen above. In ReadOp we will provide address of the buffer as argument and it will
return with buffer values, so using this function the actual read is done from the buffer.

Using these API's all the data in the Ethernet Buffer can be read through the SPI pins.

© TRI Technosolutions Pvt. Ltd. Page 13 of 23 http://thinklabs.in


ThinkLABS

Transmission: For sending the data packets through the interface, the data should be
written on Ethernet Buffer which is done by using the SPI. Then that data will be transmitted
from the buffer through the network cable to the network, which is done by the firmware
written on the ENC28J60 controller.

The following are API's used in the Source code:

o enc28j60PacketSend() - to send packets

 enc28j60Write() - to write register values

• enc28j60SetBank() - to set the address bank

• enc28j60WriteOp() - to do the write

 enc28j60WriteBuffer() - to write into the buffer

PacketSend function will be called first and in that Write function will take the value and
address to which the write operation to be performed. SetBank will set the address bank and
the WriteOp will actually do the write. These two function calls are invoked in Write function.
WriteBuffer will write the data to be sent into the buffer.

Using these API's the data needs to be sent to the Ethernet Interface Board where it will be
stored to the Ethernet Buffer, and from there it will be sent through the cable.

© TRI Technosolutions Pvt. Ltd. Page 14 of 23 http://thinklabs.in


ThinkLABS

Wireshark

Wireshark is a software application which is used for network troubleshooting, protocol


analysis and for communication protocol development. Wireshark displays all the packets it
sends and receives and also shows sender IP address etc details associated with that protocol.
This application can be used to test the Ethernet Interface Board.

• Download Wireshark application and install it (set-up available in the CD contents).


• Run the Wireshark application. You should get an interface like the one shown below.

Fig1: Shows how the application looks like (After running the Wireshark application this
window will be opened.)

© TRI Technosolutions Pvt. Ltd. Page 15 of 23 http://thinklabs.in


ThinkLABS

Fig 2: Shows how to select the capturing interface (Select capture menu and select interfaces.)

Fig 3: Shows which device should be selected (Click the start button associated with your
network adaptor (Ethernet).

• Connect the Ethernet Interface Board to the system where Wireshark is running (using the
network cable), also connect Ethernet interface board and the Development Board
(uNiBoard) as described in the earlier section.

© TRI Technosolutions Pvt. Ltd. Page 16 of 23 http://thinklabs.in


ThinkLABS

Fig 4: Shows how packets are sent and received

• Whenever a link is up that corresponding Network or PC will start sending an ARP request
first to the board through Ethernet interface and in reply an ARP and an IP packet is sent
from the board and received which is shown in the above figure as the 3rd and 4th packets.
(These ARP and IP packets are generated by our source code). You can get the details of the
packet by clicking on them and on the lower half details like the target PC's IP address and
sender's IP address etc. are displayed.

© TRI Technosolutions Pvt. Ltd. Page 17 of 23 http://thinklabs.in


ThinkLABS

Application Note

uIP: Data transfer over the network is achieved through the implementation of TCP/IP
application layer. Porting TCP/IP stack on to our board is needed for the data transfer (using
protocols like FTP (file transfer protocol), HTTP (Hypertext Transfer protocol). These are all
implemented in TCP/IP application layer. Due to memory constraints we port uIP (The open-
source uIP TCP/IP by Mr. Adam Dunkels stack provides TCP/IP connectivity to tiny embedded 8-
bit microcontrollers) on to our board, which is a small and simple.

The uIP TCP/IP stack is intended to make it possible to communicate using the TCP/IP protocol
suite even on small 8-bit micro-controllers. Despite being small and simple, uIP does not
require their peers to have complex, full-size stacks, but can communicate with peers running
a similar light-weight stack. The code size is of the order of a few kilobytes and RAM usage can
be configured to be as low as a few hundred bytes.

© TRI Technosolutions Pvt. Ltd. Page 18 of 23 http://thinklabs.in


ThinkLABS

Embedded Web server


uNiBoard can be used to develop an Embedded Web server since you can port uIP on to uNiBoard.

A high-performance Embedded Web server allows users to monitor and control their
embedded applications using any standard browser. By using an embedded Web server,
developers can format and display the data in any standard browser. The user’s response to
the data can include input to modify the embedded device’s configuration.

Moreover, communication with the embedded application can use Ethernet or fast serial
connections. In addition, you can use any of the TCP/IP application layer protocol to handle the
transfer of larger amounts of data to any device on the same network. Protocols like FTP (file
transfer protocol), HTTP (hyper text transfer protocol) helps to transfer data through the
network, and these protocols are implemented in the TCP/IP application layer.

Fig: uNiBoard

uNiBoard v1.1 can be used as the embedded device controller since Atmega128 port for uIP
exists(http://www.sics.se/~adam/uip/index.php/Main_Page) and this Ethernet Interface Board
can be used to implement an embedded web server.

© TRI Technosolutions Pvt. Ltd. Page 19 of 23 http://thinklabs.in


ThinkLABS

The following is an example of how Embedded Web Server works; it shows how to control the
room temperature in different conditions from a different location. The details from the
Embedded Web Server can be received using the Ethernet Interface and it will be shown in a
GUI, from the details received corresponding actions can be taken.

Fig: How Embedded Web server connection is made.

© TRI Technosolutions Pvt. Ltd. Page 20 of 23 http://thinklabs.in


ThinkLABS

Fig: Shows how the user interface in the system should look like

© TRI Technosolutions Pvt. Ltd. Page 21 of 23 http://thinklabs.in


ThinkLABS

Appendix A – References

www.microchip.com

www.microchip.com/downloads/en/DeviceDoc/39662b.pdf

http://www.sics.se/~adam/uip/index.php/Main_Page

http://www.avrfreaks.net/

© TRI Technosolutions Pvt. Ltd. Page 22 of 23 http://thinklabs.in


ThinkLABS

Appendix B - Services and Support

www.thinklabs.in/forums

www.thinklabs.in/resources

www.thinklabs.in/roboshop

http://code.google.com/p/uniboard/

© TRI Technosolutions Pvt. Ltd. Page 23 of 23 http://thinklabs.in

You might also like