Ethernet Communication with ENC28J60 using CASP

This example project demonstrates how to establish Ethernet communication between the target board and the host (native) PC with ENC28J60 module. We try to acquire analog periodic signal from the target board to the host PC through Ethernet and plot the signal on the host PC.

Hardware Required

· Arduino Uno for interfacing with ENC28J60 is used in this project. However, any supported boards can be used.

· A suitable signal generator to test the Ethernet latency of complete setup. If no signal generator is available, user can use Arduino Due or any CASP supported micro-controller board that can generate a DAC output, to generate a sine wave periodic signal at frequencies between 1 to 100Hz

Circuit Diagram & Models

Description

Connect the circuit as shown in the circuit diagram. Since ENC28J60 module communicates in raw Ethernet frame format user may need to install Npcap drivers and libraries on the host PC before continuing.

Following are the steps to properly program the Arduino Uno.

· Connect Arduino Uno to the host PC via a USB cable.

· Note the serial port number to which the board is connected to the host PC, from the host operating system.

· Run CASP and load the ‘target_model’ project.

· Open Home->Simulation->Setup Simulation Parameters menu item. Under TargetHW->General tabs set ‘Target Hardware Programmer Port’ parameter to the serial port to which the board is connected.

· Build the model and program the board by clicking on Run button.

Following are the steps to program the Arduino Due (if used as a .signal generator)

· Connect Arduino Due to the host PC via a USB cable.

· Note the serial port number to which the board is connected to the host PC, from the host operating system.

· Run CASP and load the ‘sig_gen_model’ project. Set the Signal Generator block frequency between 1Hz to 100Hz.

· Open Home->Simulation->Setup Simulation Parameters menu item. Under TargetHW->General tabs set ‘Target Hardware Programmer Port’ parameter to the serial port to which the board is connected.

· Build the model and program the board by clicking on Run button.

Following are the steps to run the native model on the host PC

· Load the ‘native_model’ project and open the ‘native.wsp’ workspace file. Double click on the ‘SimPanel IP’ block and set local IP and Remote MAC address (i.e. ENC28J60 MAC address) as shown in below figure.

· Run the model by clicking on the Run button. A simulation panel window should open and communicate with the board.

· Screen shot of the output for 10Hz frequency sine wave source connected to A0 of Arduino Uno.

· Screen shot of the output for 100Hz frequency sine wave source connected to A0 of Arduino Uno.

· From the above screen shot, for the frequency of 100Hz, the number of sample points are around 10. This indicate that the overall sampling rate of the setup (Arduino Uno ADC sampling rate + the Ethernet communication cycle time between Arduino Uno and the host PC) is around 1000 micro seconds.

References

Please go through our video tutorials, tutorial projects and CASP main documentation for getting started with CASP.