| Family | Series | Architecture ID | Implementation |
|---|---|---|---|
| dsPIC | 30F, 24F, 33F, 33E, 33C, 33A | 1, 2, 3, 4, 8 | Same as UART Tx (PIC implementations) |
| PIC32 | MK, MZ, MX, PIC32A | Included in dsPIC arch | Same as UART Tx (PIC implementations) |
| SAM E7x/S7x | SAME70, SAMS70, V71, PIC32CZ MC70 | 5 | USART/UART variants (SAMx7) |
| SAM E5x/D5x | SAME5x, SAMD5x | 6 | SERCOM USART (SAMx5) |
| SAM C2x/D2x | SAMC2x, SAMD2x, SAMDA1 | 7 | SERCOM USART (SAMx5 variant) |
The number and labels of input ports are determined by the CHANNELS parameter. Each specified channel creates a corresponding input port.
| Port Name | Supported Data Types | Description |
|---|---|---|
| CH 1 | int8, uint8, int16, uint16, int32, uint32, single, double, boolean | Channel 1 data (if channel 1 in CHANNELS) |
| CH 2 | Same as above | Channel 2 data (if channel 2 in CHANNELS) |
| … | Same as above | Additional channels (up to 16) |
| CH 16 | Same as above | Channel 16 data (if channel 16 in CHANNELS) |
| Parameter | Format | Description | Example |
|---|---|---|---|
| CHANNELS | Vector [1 to 16] | List of channel numbers to transmit | [1 2 5] creates CH 1, CH 2, CH 5 inputs |
| Parameter | Options | Description |
|---|---|---|
| SampleTime | Numeric (seconds) | Block execution rate (affects bytes/step calculation) |
| AllOrNothing | On/Off checkbox | Only transmit if entire packet can be sent |
Each channel is packetized with a control character followed by data bytes:
| Bits | Field | Description |
|---|---|---|
| 0-1 | Signature | Protocol signature (always |
| 2-3 | Data Type | 0=int8/uint8, 1=int16/uint16, 2=int32/uint32, 3=single/double |
| 4-7 | Channel ID | Channel number - 1 (0-15 for channels 1-16) |
| Data Type | Type Code | Bytes Sent | Notes |
|---|---|---|---|
| int8 / uint8 | 0 | 1 (+1 control) | 8-bit integer |
| int16 / uint16 | 1 | 2 (+1 control) | 16-bit integer |
| int32 / uint32 | 2 | 4 (+1 control) | 32-bit integer |
| single | 3 | 4 (+1 control) | 32-bit float |
| double (64-bit) | 3 | 8 (+1 control) | If doubleIs64Bits enabled |
| double (32-bit) | 3 | 4 (+1 control) | If doubleIs64Bits disabled (default dsPIC) |
| boolean | 0 | 1 (+1 control) | Treated as uint8 |
The block automatically calculates and displays transmission rate:
BytesPerModelStep = TotalBytes × (FixedStep / SampleTime)
Add UART Config block:
UART: 1
Baud Rate: 115200
Tx Implementation: Circular Buffer
Add UART TxMatlab block:
UART Module: 1
CHANNELS: [1 2 3]
SampleTime: 0.001 (1 kHz)
AllOrNothing: Off
Connect inputs:
CH 1: Motor speed (int16)
CH 2: Motor current (single)
CH 3: Temperature (uint8)
In MATLAB, run: picgui
Select COM port, baud rate 115200, start acquisition
Real-time plots appear for all 3 channels
Configure UART TxMatlab:
CHANNELS: [1]
SampleTime: 0.0001 (10 kHz)
Connect CH 1 input to vector [100x1] of type single
Block calculates:
Data bytes: 100 × 4 = 400 bytes
Control byte: 1 byte
Total: 401 bytes per execution
If model step = 0.0001s: 401 bytes/step
Required baud rate: 401 × 8 × 10000 = 32 Mbps (needs high-speed UART)
UART TxMatlab configuration:
CHANNELS: [1 2 5 10]
SampleTime: 0.01 (100 Hz)
Input connections:
CH 1: Position setpoint (double)
CH 2: Actual position (double)
CH 5: Error (single)
CH 10: Control mode (uint8)
picgui displays:
Channels 1 & 2: Position tracking plot
Channel 5: Error magnitude plot
Channel 10: Mode indicator
>> picgui
ControlChar = 1 + (DataTypeCode << 2) + (ChannelID << 4)
Example: Channel 3, single precision (type 3):
ControlChar = 1 + (3 << 2) + (2 << 4) = 1 + 12 + 32 = 45 (0x2D)
The block uses the same transmission infrastructure as UART Tx:
Problem: picgui runs but shows no data.Solutions:
Problem: picgui shows incorrect values or noise.Solutions:
Problem: Data loss or transmission gaps.Solutions:
Problem: picgui shows incorrect data type interpretation.Solutions:
[Communication Blocks] | [UART Config] | External Mode | Code Generation