The Waijung 2 ESP32 embedded target allows the user to monitor applications running in the microcontroller using External Mode. It gives the possibility for the user to modify the parameters of the application running on ESP32 and visualize results from Simulink.
There are several configuration parameters that are related to the External Mode functionality. Traditionally, these parameters are modified using the Model Configuration Dialog Box. However, for convenience Waijung 2 has included all the available configurations in Waijung2 Target Setup Block.
Configuration Parameter |
Selectable Option/Value |
Description |
Communication Interface |
TCP/IP |
Currently, only WiFi TCP/IP communication interface is available. |
WiFi mode |
WFI AP--WIFI STA |
Select the WiFi mode for communication. |
WiFi SSID |
|
Depending on the WiFi mode selected, enter the SSID of the network. |
WiFi password |
|
Depending on the WiFi mode selected, enter the password of the network. |
IP Address |
|
Enter the IP address. |
Netmask |
|
Enter the netmask. |
Port |
|
Enter the port to be used. |
Timeout |
|
Specify the timeout period when Simulink tries to connect to the target in seconds. |
Verbose |
Check--Uncheck |
To view the external mode execution progress and updates in the Diagnostic Viewer or in the MATLAB® command window, select this check box |
The following steps are required to set up any Simulink model for external mode simulation.
1.Open Waijung2 Target Setup Block mask and Set the Build options to External mode simulation in the Waijung2 tab and click Apply. Host-board connection tab would appear on the block mask.
2.From the Host-board connection tab, select the preferred communication interface (currently only WiFi TCP/IP is available), and fill in the necessary configurations for the selected interface.
3.In the Hardware tab in the Simulink model window, change the Stop Time to inf.
4.Go to Monitor & Tune dropdown under Run on Hardware group in Hardware tab and select Build for Monitoring to build, compile and upload the model to the target
5.Once the build process is finished, if WIFI AP mode is selected, connect your computer to the access point created by the esp32 using the specified SSID and password. If WIFI STA mode is selected, make sure the computer is also connected to the same network specified in the SSID parameter.
6.Select Connect button to start the simulation. If the Connect button is disabled under Monitor & Tune, use the Control Panel in Hardware tab to connect to the target ESP32.
7.If Verbose is ‘on’, open the Diagnostic Viewer.
Demo file : esp32_extmode_demo.slx
This example shows how to use the External Mode feature with the Waijung 2 block set. In the example, GPIO 2 is connected to an LED. A Simulink Index Vector is used to control the input of the GPIO pin. The control port of the Index Vector block is controlled using a Simulink Rotary Switch.
1.Go to Monitor & Tune dropdown under Run on Hardware group in Hardware tab and select Build for Monitoring to build, compile and upload the model to the target
2.Once the build process is finished, if WIFI AP mode is selected, connect your computer to the access point created by the esp32.
oSSID - esp32ssid
oPassword - password
3.Select Connect to start the simulation.
After connecting with the target, depending on the selection of the Rotary Switch, a different output will be visible at the GPIO 2. If Rotary Switch is set to,
•Off: The LED will be off
•Pulse: The LED will toggle at a frequency of 1 Hz.
•On: The LED will be on.