π» Try the interactive version. This chapter also exists as an auto-graded hands-on lesson built with MATLABβs R2026a Course Builder. You start from a minimal Simulink model containing just the Master and UART blocks; three auto-graded tasks guide you through adding the Chirp, the PWM HS FEP and the ADC HS 12b with correct wiring and parameters. Each task shows green/red feedback immediately.
In MATLAB R2026a or newer, from the Command Window:
>> picCourse
This opens the lesson in the Course Builder runtime. On R2025b or older releases, picCourse prints a pointer back to this page β the Course Builder framework is not available there.
External Mode is the Simulink feature that turns MBD from “compile-flash-print-debug” into a real-time instrument. Once enabled:
Drag a gain slider to change a PI gain β watch the motor response on the scope instantly. Start recording β export the captured timeseries straight to the MATLAB workspace for analysis. That is what we will do for the Picooz.
See External Mode & PIL for the deep-dive.
β¬ tutorial_picooz_acquire.slx β¬ tutorial_picooz_acquire_extmode.slx
The model is intentionally minimal:
[ Chirp Generator ] βββΊ [ PWM HS FEP block ] βββΊ (motor on hardware)
β
βΌ
[ ADC HS 12b block ] βββΊ [ External Mode scope ]
β
(live-streamed to PC)
Everything runs on the MCU; the scope on your PC is just a viewer for the data the MCU is sending over UART.
| Block | Role | Reference |
|---|---|---|
| Master | Target chip + clock + fuses | β |
| PWM HS FEP | 20 kHz PWM carrier, duty driven by the chirp signal | β |
| ADC HS 12b | Sample BEMF during the PWM-OFF window | β |
| UART Configuration | External Mode transport | β |
| Chirp | Simulink Sources library β swept sine from 0.1 Hz to 10 Hz over 30 s | β |
A chirp (swept-sine) excites every frequency in the 0.1 Hzβ10 Hz range in one 30-second experiment. Its autocorrelation is low and it visits every operating point β exactly the property we need for grey-box identification.
Compare:
| Input signal | Frequency content | Suitable for ID? |
|---|---|---|
| Step | Only excites the dominant time constant | β Poor β misses fast dynamics |
| Multi-step sequence | Better, but discrete | ~ Ok, many experiments |
| White noise / PRBS | Excites everything | β Good β industry standard |
| Chirp | Controlled sweep, smooth, bounded | β Excellent β and visually interpretable |
For educational clarity chirps win: you can see on the scope which frequencies are still able to drive the rotor and which ones the mechanical inertia filters out.
tutorial_picooz_acquire_extmode.slx.dsPIC33AK128MC106).Within ~10 seconds the toolbox:
Open the Data Inspector, select the BEMF signal, and Export β To workspace. You now have timeseries u(t) (the chirp) and omega_meas(t) (the measured BEMF) in your MATLAB workspace β ready for identification.
If you don’t have hardware handy (or just want to reproduce the tutorial exactly), the bundled dataset below was captured on a real Picooz + Curiosity dsPIC33AK512MPS512 with this exact acquisition model. Use it unchanged through the rest of the series.
β¬ tutorial_picooz_chirp.mat (clean (t, u, omega_meas) for identification) β¬ tutorial_picooz_chirp_log.mat (raw Simulink Dataset log) β¬ tutorial_picooz_process_log.m (raw-to-clean conversion script)
What’s in tutorial_picooz_chirp.mat:
| Variable | Size | Description |
|---|---|---|
t | 6001 Γ 1 | Time vector, 5 ms period, 30 s total |
u | 6001 Γ 1 | PWM duty cycle, chirp in [β0.3, +0.3] |
u_abs | 6001 Γ 1 | abs(u) β the rotor only responds to magnitude, single-quadrant drive |
omega_meas | 6001 Γ 1 | Rotor speed proxy (BEMF-derived voltage) in [0, 3.6] V |
The waveform:

Observation: the rotor accelerates quickly at low chirp frequency (left side), then has visibly reduced amplitude at high frequency (right side) β the mechanical low-pass due to rotor inertia + aerodynamic drag. This is exactly what identification will quantify.
These go far beyond the basic acquisition above and are worth knowing even after you finish the tutorial:
| Feature | When it pays off |
|---|---|
| Live parameter tuning | Place a Slider Gain in your controller and drag it at runtime. Explore a PI gain sweep in seconds rather than minutes. |
| Log-to-disk with picgui | Simulink Data Inspector buffers in RAM. For multi-hour experiments, the blockset’s picgui tool streams the signals straight to disk. See Data Visualization
. |
| Triggered capture | Start recording on an event (rising edge of a digital signal). Useful for transient capture of one-shot startup sequences. |
| Per-signal log rate | Current at 20 kHz, setpoint at 10 Hz β each signal captured at its own rate, keeping the UART bandwidth in check. |
| XCP-on-SxI | The underlying transport is a standard automotive XCP protocol. Any CAN-bus calibration tool (CANape, INCA, β¦) can talk to your firmware. |
With t, u and omega_meas in hand, we can fit a mathematical model of the motor. The next page shows five different ways to do it β most of them needing no MATLAB add-on toolbox.
Next β 3. Identification β Five Methods
Back β 1. Hardware