picgui Graphical Interface Block Icon
Launch MATLAB graphical interface for interactive UART communication

Overview

The picgui block provides a convenient launcher for the MATLAB-based graphical user interface that enables interactive UART communication with Microchip devices. This GUI tool allows you to send and receive UART data interactively during development and debugging.

Block Dialog

The picgui block itself has an empty Simulink mask โ€” double-clicking it launches the MATLAB GUI shown below. Three illustrations, from most didactic to most realistic:

picgui interface โ€” annotated controls

Every control in the picgui window is labelled on this diagram โ€” connection settings (top-left), data-logging (Log.txt / Ren / Load / Delete), the M-script executed at each iteration, the Start / Stop receiver, and the idle-time (Delay) between UART reads. A companion MATLAB figure (bottom) shows the resulting real-time plot.

picgui interface โ€” annotated controls

Real-time plot window

Data received over UART can be passed through a user-supplied MATLAB script (executed once per iteration) and plotted live. This example shows an original signal plus two low-pass-filtered versions at 1 Hz and 10 Hz:

picgui real-time plot of original + filtered signals

Motor-control dashboard (real application)

When paired with a dsPIC33CK / dsPIC33AK motor-control firmware that streams measurements via the UART Tx-Matlab block, picgui becomes a live dashboard. Running at 2 000 rpm no-load, six panels show phase currents Iโ‚/I_b, speed reference vs. estimate, FFT on Iโ‚, d-q axes currents, and the E_d / E_q back-EMF decomposition:

picgui live motor-control dashboard

When to use:

  • Real-time plotting โ€” Visualize signals from UART TxMatlab block
  • Interactive testing โ€” Send commands and view responses during development
  • Data logging โ€” Record UART communication to MATLAB workspace
  • Parameter tuning โ€” Adjust device parameters via UART interface
  • Quick debugging โ€” Monitor/send UART data without full External Mode setup

When NOT to use:

  • No UART TxMatlab โ€” picgui is designed for UART TxMatlab protocol (not raw UART)
  • Standalone firmware โ€” picgui requires MATLAB environment (use terminal emulator instead)
  • Code generation โ€” Block is empty S-Function, not included in generated code
  • External Mode is preferred โ€” Simulink External Mode provides full signal access
  • Production deployment โ€” picgui is for development/debug only

Key Features:

  • Interactive UART terminal interface
  • Real-time data transmission and reception
  • Integration with UART Tx-Matlab blocks
  • MATLAB workspace variable access
  • Command history and logging
  • Multiple format support (ASCII, Hex, Decimal)

Typical Applications

  • Interactive Debugging: Send commands and view responses in real-time
  • Parameter Tuning: Adjust device parameters via UART interface
  • Data Logging: Capture and log UART communication
  • Test Scripts: Automate communication sequences
  • Protocol Development: Test communication protocols interactively

Parameters

No Parameters Required

The picgui block requires no configuration parameters. It serves as a simple launcher that opens the graphical interface when double-clicked.

Block Behavior

ActionResult
Double-click blockOpens picgui MATLAB GUI
SimulationNo effect (empty S-Function)
Code GenerationNot included in generated code

Using the picgui Interface

Launching the GUI

  1. From Simulink: Double-click the picgui block in your model
  2. From MATLAB: Type picgui in the MATLAB Command Window
  3. From Code: Call picgui function from any script

GUI Features

Communication Setup

  • COM Port Selection: Choose active serial port
  • Baud Rate: Match device UART configuration
  • Data Format: ASCII, Hexadecimal, Decimal, Binary
  • Line Endings: CR, LF, CR+LF

Data Transmission

  • Send Field: Enter text or values to transmit
  • Send Button: Transmit current field contents
  • History: Access previously sent commands
  • Workspace Variables: Send MATLAB variable contents

Data Reception

  • Receive Window: Display incoming UART data
  • Auto-scroll: Automatically scroll to latest data
  • Clear Buffer: Clear received data display
  • Save Log: Save communication log to file

Integration with UART Tx-Matlab

The picgui works in conjunction with the UART Tx-Matlab block:

  1. Add UART Tx-Matlab block to your model
  2. Configure UART settings (baud rate, parity, etc.)
  3. Launch picgui interface
  4. Data sent via picgui is automatically handled by UART Tx-Matlab block
  5. Received data appears in picgui receive window

Notes

Empty S-Function Block

The picgui block uses MCHP_EmptySFunction as its S-Function. This means:

  • Block has no effect during simulation
  • Block is not included in generated code
  • Block serves only as GUI launcher

MATLAB Dependency

The picgui GUI requires:

  • MATLAB environment (cannot run standalone)
  • Instrument Control Toolbox or similar for serial communication
  • Compatible USB-to-Serial driver for hardware connection

Real-Time vs External Mode

The picgui interface is primarily designed for:

  • External Mode: Interactive communication with running firmware
  • PIL Testing: Processor-In-Loop testing workflows
  • Standalone Operation: Direct serial communication outside Simulink

It is not designed for use during:

  • Normal Simulink simulation
  • Code generation compilation
  • Model verification tests

COM Port Configuration

Ensure your hardware is properly connected:

  1. USB-to-Serial adapter or debugger connected
  2. Correct COM port identified in Device Manager (Windows) or /dev (Linux)
  3. No other application using the COM port
  4. Appropriate driver installed

Device Support

Universal Support: The picgui interface works with all Microchip device families that support UART communication:

  • dsPIC30F/33F/33E/33C/33A
  • PIC24F/H
  • PIC32 (all variants)
  • SAM ARM devices

Examples

Basic Interactive Communication

% 1. Configure model with UART blocks
% 2. Add picgui block to model
% 3. Double-click picgui block
% 4. In picgui GUI:
%    - Select COM port
%    - Set baud rate to match device
%    - Type command in send field
%    - Click Send button
%    - View response in receive window

Sending MATLAB Variables

% Create data in MATLAB workspace
myData = [1 2 3 4 5];

% In picgui:
% 1. Select "Workspace Variable" option
% 2. Enter variable name: myData
% 3. Click Send
% Variable contents are transmitted via UART

Automated Test Script

% Open picgui programmatically
picgui;

% Configure port (example - implementation depends on GUI)
% Send test sequence
% Capture responses
% Validate communication

Troubleshooting

GUI Won’t Launch

Check:

  • MATLAB path includes blockset installation
  • picgui.m file exists in blocks folder
  • No MATLAB errors in Command Window

Cannot Connect to Device

Check:

  • COM port correctly selected
  • Baud rate matches device configuration
  • Hardware properly connected and powered
  • No other software using same COM port

No Data Received

Check:

  • Device actually transmitting data
  • Baud rate and format settings match
  • UART pins correctly configured in hardware
  • Hardware flow control settings (RTS/CTS)

Data Corruption

Verify:

  • Correct baud rate selected
  • Matching data format (8N1, etc.)
  • Stable power supply to device
  • Good quality USB cable and connections

References

  • UART Configuration Block Documentation
  • UART Tx-Matlab Block Documentation
  • MATLAB Serial Communication Documentation
  • Microchip UART Peripheral Documentation (device-specific)
  • UART Configuration: Configure UART peripheral settings
  • UART Rx: Receive UART data in model
  • UART Tx: Transmit UART data from model
  • UART Tx-Matlab: Special transmit block with picgui integration