InduinoX User Guide - Interfacing with the ENC28J60 Ethernet Module

The ENC28J60 Module



The ENC28J60 Ethernet Module is a low-cost ethernet module that offers ethernet connectivity over SPI. This module is different from the ENC28J60 Ethernet Shield only in its form factor and the fact that there is no SD card slot. This module can be interfaced with any microcontroller over SPI.  We will see how to use this module with Arduino. 

Its been use with the arduino for sometime and there are a number of libraries available to work with the module.
You can download the following zip file and extract its contents to the libraries folder of your arduino installation.
There are 2 folders in this library - etherShield and ETHER_28j60. The etherShield is a base library and the ETHER_28j60 is a wrapper around this based library that simplifies the functionalities of the etherShield library for the beginner. You can program your Ethernet Shield directly using the etherShield Library however, this library requires you have a finer understanding of networking and how it works. We suggest you stick to the ETHER_28J60. You can find documentation on this here.

Module Overview

There are 10 Pins on the Module that bring out SPI interface and additional functionalities of the ENC28J60 IC. The Module is to be powered from 3.3Volts supply.

Connections Overview
Connect the pins of the module to pins of your Arduino as in the table
MODULEInduinoX / Arduino UNO (ATMEGA328) Arduino MEGA
VCC3.3V Pin3.3V Pin
GNDGNDGND
CSSS - PIN 10SS - PIN 53
SIMOSI - PIN 11MOSI - PIN 51
SCKSCK - PIN 13SCK - PIN 52
WOLPIN 5PIN 5
SOMISO - PIN 12MISO - PIN 50
INTInterrupt 0 - PIN 2Interrupt 0 - PIN 2



A Simple Test Program
Once you install the libraries, you can try the 'HelloWorld' program from ETHER_28j60 library. Upload the program, disconnect the board (make it standalone powered externally!), open your browser and type in the ip address of the board. (http://192.168.1.15).. Voila! now your arduino is on the network!
Controlling the InduinoX
The 'HelloWorld' is a simple program now to try the 'WebRemote' example. This will let you control the 6th pin on the InduinoX. You can modify this to achieve your web control needs.

InduinoX User Guide - Interfacing with the ENC28J60 Ethernet Shield

The ENC28J60 Ethernet Shield for Arduino



The ENC28J60 Ethernet Shield is a low-cost ethernet shield for the Arduino. It is based on the microchip ENC28J60 ethernet controller. 

Its been use with the arduino for sometime and there are a number of libraries available to work with this shield. 

You can download the following zip file and extract its contents to the libraries folder of your arduino installation. 

There are 2 folders in this library - etherShield and ETHER_28j60. The etherShield is a base library and the ETHER_28j60 is a wrapper around this based library that simplifies the functionalities of the etherShield library for the beginner. You can program your Ethernet Shield directly using the etherShield Library however, this library requires you have a finer understanding of networking and how it works. We suggest you stick to the ETHER_28J60. You can find documentation on this here.


Shield Overview

The Shield uses 6 pins on the Arduino. It works over SPI - 4 Pins(digital 10,11,12,13) & it uses 2 additional pins - 1 for interrupt (digital 2) and 1 for the WOL pin of ENC28J60 (digital 5). In addition the Shield also provides a SD card Slot that can be controlled using SPI. 

Chip Select Overview

To address cases where one needs to access both the SD card and the Ethernet Controller Over SPI, Chip Select Pin for the Ethernet Controller is provided with a jumper. This 3-Pin Jumper lets you choose between Digital Pins 8 & 10 of the Arduino to be used as the CS Pin. By default the Jumper Position is set to use the Digital Pin10 as CS. The SD card reader uses PIN 9 for CS. We suggest you leave the CS pin for the Ethernet Controller as 10 and modify the CS pin number in the SD example in arduino to get both working together. 

The Connections

Put the jumpers for PINS 2,5,10,11,12&13 in the off position. Place the Shield on top of your InduinoX Board. Connect an external Power supply to the board. The Ethernet Shield Requires more power than can be provided by your USB so an External Power Supply is required. Connect one end of your network cable to the Ethernet Shield and the other end to a Switch / Router (the same to which your computer / mobile is connected).

A Simple Test Program

Once you install the libraries, you can try the 'HelloWorld' program from ETHER_28j60 library. Upload the program, disconnect the board (make it standalone powered externally!), open your browser and type in the ip address of the board. (http://192.168.1.15).. Voila! now your arduino is on the network!

Controlling the InduinoX

The 'HelloWorld' is a simple program now to try the 'WebRemote' example. This will let you control the 6th pin on the InduinoX. You can modify this to achieve your web control needs. 

Serving a Webpage from the SD Card

We have created a custom example for this. Check out the 'SD_Webpage' example from the ETHER_28j60 library. Copy the web.txt file to the root directory of your SD card for this example to work.


Heres a demo video...




InduinoX User Guide - Interfacing with the Simple Labs' Servo Shield

The Simple Labs' Servo Shield is a custom designed Shield to drive Servo Motors. The Shield Can drive upto 10 servo motors at a time. It was originally designed for our Quadbot Robot Kit (8 Servos) + Mini Pan and Tilt Kit (2 Servos). In addition to this, the servo shield has suitable pin outs to be able to Connect the Compound Eye IR Sensor.




Servo Motors - What are they?


Servo motors are dc motors with a servo mechanism that lets us control the precise position of the Shaft.

A servo mechanism is a error correction mechanism that senses the negative error and applies a correction accordingly.

There are many types of Servo Motors available - depending upon applications.
They are used in areas requiring position control. While the basic working of all the servo motors is almost similar, for the scope of this tutorial we shall stick to discussing RC Servo Motors or the type of Servo motors used in Robotics / Radio Control Projects.


A Servo motor constitutes of 4 parts - a DC motor, a Gear system, A Potentiometer(for sensing feedback) and a Control Circuit. Here the Control Circuit and the Potentiometer together form the Servo Mechanism.





So How do Servo Motors Work?

The Control Circuitry on the Servo motor drives the DC motor based on input signals it receives, The output shaft of the DC motor is connected to the gear assembly and the gear assembly is such that it moves the potentiometer when it rotates. The Control Circuitry gets feedback from this potentiometer and spins the DC motor to achieve the desired angle between 0 & 180 degrees. The range of movement of the potentiometer is mechanically restrained.

And How do we Control these Servo Motors?

To Control a servo we need to give it a pulse once every 20 milliseconds. The Duration of this pulse will determine the Servo Angle which we need to achieve. For most Servo's a Pulse duration of 1millisecond will set the shaft position to 0 degrees and a pulse duration of 2 milliseconds will set the shaft position to 180 degrees. 



Controlling Servos with an Arduino

Arduino provides us with a servo control library that lets us control servos with ease. The library provides us with an option of writing both microseconds value and angle values. You can find more information on the library here - > Arduino Servo Library

Overview of the Servo Shield

The Servo Shield has clear pin mappings and polarity mappings for the Servos. It has a screw terminal for connecting an external power supply for the Servos. Servos require 4.8-6Volts and consume around 300-500milliamps. The Servo shield requires to be powered from an External Source for it to drive your servos.



The servo shield has Servo control pins on Arduino Digital Pins D2, D3, D4, D5, D6, D9, D10, D11, D12 & D13. Refer to the TOP Legend on the board "D + - " for the Orientation of the Servo Connector Connection.

Connect a Servo to D9 and an external Supply to the Battery Connector as Shown a 4xAA Battery Connector is used here in the image. The Servo shown in the image is part of the Quadbot Kit. If you are looking for a servo, you can check out the Tower Pro SG-5010



The Program

With the above setup you can load the 'Sweep' Program from within the Examples. This program is located at

File -> Examples -> Servo -> Sweep (Inside the Arduino IDE!)


InduinoX User Guide - Working with NEC Remotes

The Simple Labs InduinoX Arduino Learners' Kit comes with a small remote, the kind of remote you would find with a MP3 Player / Audio Players. Owing to their size these remotes have spread fast and hence this tutorial on how to decode these manually without using the library. If you want to use the library, check out our previous post on this

These small remotes use the NEC protocol which is a 32-bit protocol and much different from the SIRC Protocol we saw earlier. Here's the signal train of the NEC protocol

The Start Bit is a 9 ms long pulse followed by 4.5 ms space. This is  followed by a burst of 32-bit data. The 32-bit data consists of 8-bits of command and 8-bits of address which are transmitted twice for reliability. The first transmission of 8 bits is inverted when it is being transmitted the next time for increased reliability.


Heres the Pulse Modulation of the NEC Protocol

The Logical '1' is represented by a 560us long 38khz pulse (MARK) followed by a 1690us long LOW signal (SPACE). The Total Duration for the Logical '1' is 2.25us.

The Logical '0' is represented by a 560us long 38khz pulse (MARK) followed by a 560us long LOW signal (SPACE). The Total Duration for the Logical '1' is 1.12us.

So How do we read this?

For our purpose, we can read this as a 16-bit data (8-bit address & 8-bit command)


To read this signal here are the things we need to do
  • Wait till be get the start bit
  • Read the time duration for the subsequent 32bits
  • Sort through the time duration in 4 parts of 8-bits each
  • Calculate 2 values, one from the bits 0-7 and 16-23 and one from bits 8-15 & 24-31
  • Check if these values are equal. If so take the value as valid. if not ignore the value.
Here's the code for a function to read NEC remotes. This function works for the InduinoX board.


int remote()
{
  int val1=0,val2=0, dur[32], i=0, j=0;
  if(pulseIn(15,LOW)>8000)
  {
    for(i=0; i<32;i++)
    {
      dur[i]=pulseIn(15,HIGH);
    }
    
//Value Calculation

    for(i=0,j=0;i<24;i++,j++)
    {
      if(i==8)
         i=16;
      if(dur[i]>1000)
          val1 = val1+ (1<<j);
           
    }
    for(i=8,j=0;i<32;i++,j++)
    {
      if(i==16)
        i=24;
      if(dur[i]<1000)
        val2 = val2+ (1<<j);    
     }
     Serial.println(val1);
     Serial.println(val2);
     if(val1==val2)
       return val1;
     else
       return 0;
  }
  
  return 0;
}