LwIP Ethernet Communication using CASP

 

Download Project

 

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

 

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 the native PC

·     Load the ‘native_model’ project.

·     With the target board connected to the host PC, click on Home->Simulation->Configure Simulation IO menu item.

·     ‘Configure Simulation Hardware’ window will open. Under Native Nodes and GPIO Device Nodes, change the IP addresses marked in the below figure (by double clicking on the item) to respective local and device IP addresses.

 

·     Click on ‘Connect Device’ button and check the ‘Online Data’ check box. The program should now communicate with the target with cycle time less than 1msecs. We achieved a cycle time of around 200 micro seconds as shown in above figure. Target board is now available as end point ‘EP0’ to the native model. Native model can use this end point to connect to respective IOs on the target.

·     Click on ‘Save’ button to save the configuration and close the window.

·     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.

 

Circuit Diagram & Models

References

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