LwIP Ethernet Communication using CASP
This example project demonstrates how to establish Ethernet communication between the target board that supports LwIP and the host (native) PC. 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. UDP protocol is used for communicating between the target board and the host PC.
Hardware Required
· STM32H743 Nucleo board that supports LwIP stack 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.
Following are the steps to properly program the STM32H743 Nucleo Board.
· Connect the Nucleo Board 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 host PC
· Load the ‘native_model’ project and open the ‘native.wsp’ workspace file. Double click on the ‘SimPanel IP’ block and set Remote IP address 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 PA3 of the Nucleo Board.

· Screen shot of the output for 100Hz frequency sine wave source connected to PA3 of the Nucleo Board.

· From the above screen shot, for the frequency of 100Hz, the number of sample points are enough to plot a reasonably smooth wave form. This indicate that the overall sampling rate of the setup (Nucleo Board ADC sampling rate + the Ethernet communication cycle time between target board and the host PC) is around 200 micro seconds.
References
Please go through our video tutorials, tutorial projects and CASP main documentation for getting started with CASP.