Please enable JavaScript to view this site.

Introduction

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.

Limitations

When using External Mode, the WiFi Setup block cannot be used in the model for other tasks. This condition is automatically checked during the build process and an error is thrown to stop the build process.

Configuration Parameters

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.

external_mode_simulation_block_1

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

Setting Up Simulink Model for External Mode

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

external_mode_simulation_block_2

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 to start the simulation.

7.If Verbose is ‘on’, open the Diagnostic Viewer.

Demo

Demo file : esp32_extmode_demo.slx

external_mode_simulation_block_3

Description

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.

Setup

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.

What should be happening?

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.

Copyright 2022 Aimagin Co.,Ltd.