Getting Started with ENC28J60 Ethernet Controller with MicrocontrollersBitahwa Bindu
Figure 1: Controlling devices from the internet
Ethernet is the leading wired standard for networking as it enables to connect a very large number of computers, microcontrollers and other computer-based equipment to one another.
With just a network switch, many different devices can easily communicate with one another with Ethernet, allowing different devices and equipment to be accessed remotely and this also provides a cost-effective and reliable means of remote control and monitoring. Most of computers nowadays have an Ethernet port implemented on them so it is with many electronic devices. Many microcontrollers have built-in Ethernet peripheral, like the PIC18F97J60, this PIC18 Microcontroller has an integrated 10Mbps Ethernet communications peripheral but many other microcontrollers and the popular Arduino Uno don’t have a built-in Ethernet peripheral.
If you are using the Arduino Uno or any microcontroller which does not have an integrated Ethernet peripheral, Microchip offers a serial Ethernet chip that can easily be used by any microcontroller with an SPI interface to provide Ethernet capability to the application. The ENC28J60 is a popular 28-pin serial Ethernet chip, 10BASE-T stand alone Ethernet Controller with SPI interface, on board MAC & PHY, 8 Kbytes of Buffer RAM and an SPI serial interface. With a small foot print package size the ENC28J60 minimizes complexity, board space and cost.
ENC28J60 Ethernet Controller Features
- IEEE 802.3™ Compatible Ethernet Controller
- Fully Compatible with 10/100/1000Base-T Networks
- Integrated MAC and 10Base-T PHY
- Supports One 10Base-T Port with Automatic Polarity Detection and Correction
- Supports Full and Half-Duplex modes
- Programmable Automatic Retransmit on Collision
- SPI Interface with Clock Speeds up to 20 MHz
- Buffer: 8-Kbyte Transmit/Receive Packet Dual Port SRAM
- MAC address: Supports Unicast, Multicast and Broadcast Packets
- Operating Voltage of 3.1V to 3.6V (3.3V typical)
- Temperature Range: -40°C to +85°C Industrial, 0°C to +70°C Commercial (SSOP only)
- 28-Pin SPDIP, SSOP, SOIC, QFN Packages
More information can be obtained from the ENC28J60 datasheet. The figures below show ENC28J60 package types
Figure 2: ENC28J60 package types.
ENC28J60 Ethernet Controller Connections
The interface between the microcontroller and the Ethernet chip is based on the SPI bus protocol, The SI, SO, and SCK pins of the Ethernet chip are connected to SPI pins (SDO, SDI and SCLK) of the microcontroller. The Ethernet controller chip operates at 3.3V, its output SO pin cannot drive the microcontroller input pin without a voltage translator if the microcontroller is operated at 5V. Figure 3 below shows how the ENC28J60 Ethernet controller can be interfaced to a PIC Microcontroller.
Figure 3: ENC28J60 Ethernet Controller Connections
To make the design of Ethernet applications easy, there are ready made boards that include the EC28J60 controller, voltage translation chip and an RJ45 connector. Figure 4 belows shows the the mikroElektronika Serial Ethernet Board. This is a small board that plugs in directly to PORTC of the EasyPI CV7 development board via a 10-way IDC plug simplifying the development of embedded Ethernet projects. This board is equipped with an EC28J60 Ethernet controller chip, a 74HCT245 voltage translation chip, three LEDs, a 5 to 3.3 voltage regulator and an RJ45 connector with an integrated transformer.
Figure 4: Connecting the Serial Ethernet Board to EasyPIC7 V7 development board
Embedded Ethernet applications
With internet in mind, one can think about many applications, below a few applications are listed:
- Web-based monitoring: A person can monitor several vending machines located in different places which can be several kilometers apart. From the PC at the conform of your desk, you could monitor live every day the status and stock of each machine, without wasting time and money to travel to each machine. A simple online interface to the vending machines can allow you to monitor everything from the internet.
- Access control: Monitor and control the access of an area from a remote location
- Environmental monitoring: Environmental sensors can installed unattended in remote locations feeding data online to a control and monitoring center.
- Industrial control: The status of machines could be remotely monitored, switch on or off,…
- Home automation: Turning devices inside the house like lights ON and OFF from a remote location even from a hand held mobile device connected to internet like a smart phone.
- Voice Over IP( VoIP)
- Internet of Things (IoT) applications
Buy the ENC28J60 IC or Module from our Online Store
ENC28J60 Library Functions
Many compilers offer Library functions that you can use with your ENC28J60.
mikroC Pro for PIC Compiler
mikroC offers ENC28J60 Library functions. This library is designed to simplify handling of the underlying hardware (ENC28J60). It works with any PIC with integrated SPI and more than 4 Kb ROM memory. 38 to 40 MHz clock is recommended to get from 8 to 10 MHz SPI clock, otherwise PIC should be clocked by ENC28J60 clock output due to its silicon bug in SPI hardware. If you try lower PIC clock speed, there might be board hang or miss some requests.
For more information, please visit our tutorial:
MPLAB XC8 Compiler
The MPLAB® Code Configurator (MCC) is a user friendly Graphical User Interface (GUI) plug-in tool for MPLAB® X IDE which generates easy to understand C code that is inserted into an MPLAB® X project, based on the settings peripherals configurations and selections made in the Graphical User Interface (GUI). The generated code can be used in any application program. MPLAB® Code Configurator v3 includes TCP/IP Lite as shown on figure 5 below that can be used to configure the PCP/IP Configurations.
Figure 5: TCP/IP Lite configuration with MPLAB® Code Configurator
For more information, please visit our tutorial:
Watch the Video Tutorial
Flowcode is one of the World’s most advanced graphical programming languages for microcontrollers.
Flowcode software allows you to develop complex electronic and electromechanical systems with ease by just dragging and dropping icons on to a flowchart to create programs. The graphical programming tool allows even those with little experience to develop complex electronic systems in minutes. Flowcode has a TCP/IP (ENC28J60) component under the Comms components sub-category.You can develop Ethernet applications using the power of Flowcode in few minutes.