External Mode provides real-time parameter tuning and data visualization while your generated code runs on the target.
For code-generation accuracy and timing verification, see the companion PIL (Processor-in-the-Loop) guide.
External Mode creates a bidirectional communication link between Simulink and your embedded target while the code is running. This enables:
The toolbox provides MathWorks External Mode for real-time parameter tuning and signal monitoring.
MathWorks External Mode provides tight integration with Simulink, enabling parameter tuning and signal monitoring directly from the Simulink model interface.
External Mode uses the industry-standard XCP protocol, which provides:
1. Open Model Configuration Parameters (Ctrl+E)
2. Navigate to: Code Generation โ Interface
3. Check "External mode"
4. Configure transport layer:
- Transport: "XCP on Serial" (for UART)
- Transport: "XCP on TCP/IP" (for Ethernet)
5. Set baud rate (serial) or IP address (TCP/IP)
For Serial (UART):
- Baud rate: 115200 (or higher)
- COM port: Detected automatically or set manually
- Data bits: 8
- Stop bits: 1
- Parity: None
For TCP/IP (Ethernet):
- Target IP address: e.g., 192.168.1.100
- Port: 17725 (default XCP port)
Use the Microchip toolstrip tab (see Microchip Toolstrip ):
1. Microchip tab -> Ext-Mode -> Ext Mode settings
- Verify External Mode is active, host COM port, baud rate,
transport, and the target UART Config block.
2. Microchip tab -> Ext-Mode -> Monitor & Tune (the one-click "go")
- Builds + deploys as needed, connects External Mode, starts
execution, and streams live signals to the Simulink scopes.
3. Observe signals in Simulink scopes.
4. Modify tunable parameters in real-time.
The Ext Mode settings button is a split button: its drop-down opens the native MathWorks External Mode Control Panel for manual connect / start / stop control, if you prefer the classic dialog over one-click Monitor & Tune.
To allow real-time tuning of a parameter:
1. Right-click the block parameter or constant block
2. Select "Tune Parameter..."
3. Check "Tunable" checkbox
4. Optional: Set min/max limits for safety
5. Rebuild model
During External Mode:
- Double-click parameter to open slider
- Adjust value while code runs
- Observe effect immediately
โ ๏ธ Safety Warning: When tuning parameters in real-time for motor control or other safety-critical applications:
Set appropriate min/max limits on tunable parameters
Have emergency stop mechanism ready
Start with safe operating conditions
Monitor system behavior continuously
| Aspect | Impact | Recommendation |
|---|---|---|
| CPU Overhead | 5-15% depending on logged signals | Minimize number of logged signals |
| Communication Latency | 10-100ms depending on transport | Use TCP/IP for lower latency than Serial |
| Maximum Sample Rate | Limited by baud rate / network speed | Serial: ~10 kHz max, Ethernet: ~100 kHz max |
| Buffer Size | Limits burst logging capability | Configure in External Mode settings |
Problem: Cannot connect to target
Solutions:
๐น See it in action: XCP External Mode (2:18) ยท All demos โ
Quick Start Guide | Board Templates | PIL Simulation | User Guide