Overview

Key Benefit: Design, simulate, and deploy control algorithms directly to Microchip hardware without hand-coding peripheral drivers.

Key Features

  • Automatic C Code Generation - Generate optimized embedded C code for dsPIC, PIC32, and SAM devices
  • Comprehensive Peripheral Library - PWM, ADC, UART, SPI, I2C, CAN, Timers, and more
  • External Mode - Real-time parameter tuning and signal monitoring
  • Processor-in-the-Loop (PIL) - Validate generated code on actual hardware
  • Hardware Optimizations - Assembly code replacement for dsPIC families
  • Multitasking Scheduler - Rate monotonic scheduler for multi-rate applications

Supported Device Families

FamilyArchitectureSeriesTypical Applications
dsPIC33A32-bit DSC with FPU33AKAdvanced Motor Control, Digital Power, Floating-Point DSP
dsPIC16-bit DSC30F, 33F, 33E, 33CH, 33CK, 33CDVMotor Control, Power Conversion, Digital Power
PIC3232-bit MCUMK, MZ, MXIoT, Industrial Control, Audio Processing
SAMARM Cortex-ME5x, E7x, C2x, D2xIndustrial Automation, Motor Control
Note on dsPIC33A: The dsPIC33A family represents a significant architectural advancement with its 32-bit core and hardware FPU, offering 10-100x faster floating-point performance compared to 16-bit dsPIC families. See Supported Devices for details.

Model-Based Design Workflow

The MCHP Blockset implements a complete Model-Based Design (MBD) workflow, enabling seamless transition from algorithm simulation to embedded code execution. The workflow follows three main phases:

Model-Based Design Complete Workflow
Model-Based Design Complete Workflow

1. Simulation Phase

Develop and validate your control algorithm in the Simulink environment:

  • Plant Modeling - Create mathematical models of your physical system (motor, power converter, etc.)
  • Controller Design - Implement control algorithms using standard Simulink blocks
  • Closed-Loop Simulation - Test controller performance with simulated plant dynamics
  • Parameter Tuning - Optimize gains and parameters in fast simulation cycles

2. Code Generation Phase

Transform your validated algorithm into embedded C code:

  • Add Peripheral Blocks - Replace simulated inputs/outputs with MCHP hardware blocks (ADC, PWM, UART, etc.)
  • Configure Target - Select Microchip device, set clock frequency, choose compiler
  • Automatic Code Generation - Embedded Coder generates optimized C code including peripheral drivers and scheduler
  • One-Click Build - Press “Build” button to compile and program your hardware

Key Advantage: The same Simulink model serves both simulation and embedded code generation. No manual code translation required - drastically reduces development time and eliminates human errors in code conversion.

3. Verification & Testing Phase

Validate that your embedded implementation matches simulation expectations:

  • Hardware Testing - Run algorithm on actual microcontroller with real sensors/actuators
  • External Mode - Monitor signals and tune parameters in real-time using XCP protocol
  • Processor-in-the-Loop (PIL) - Compare simulation results with actual execution on target hardware
  • Timing Analysis - Measure CPU load and verify real-time constraints are met
  • Data Logging - Stream runtime data to MATLAB for analysis using picgui interface

Typical Development Steps

  • Start from Template - Load pre-configured board template (see [Board Templates])
  • Model Design - Create or import control algorithm in Simulink
  • Add Peripherals - Drag and drop MCHP blocks for hardware interfaces (PWM, ADC, UART, etc.)
  • Configure Target - Select device, set clock, configure peripherals
  • Simulate - Verify algorithm behavior in simulation with plant model
  • Generate Code - Automatic C code generation with Embedded Coder
  • Build & Deploy - Compile and program target device (single button press)
  • Test & Tune - Use External Mode or picgui for real-time optimization
  • Validate - Run PIL tests to verify numerical accuracy and timing performance

MCHP Block Library

The blockset provides a comprehensive library of peripheral blocks for Microchip microcontrollers, enabling graphical configuration of hardware resources without writing driver code:

MCHP Block Library Overview

The library includes blocks for all major peripheral categories:

CategoryBlocksPurpose
SystemMaster, Clock Configuration, MCU Load, Task StateChip selection, timing configuration, performance monitoring
PWMHigh-Speed PWM, PWM with FEP, Standard PWM, MC PWMMotor drive, power conversion, precise waveform generation
ADCHigh-Speed 12-bit, SAR ADC, Standard ADC, AFECAnalog-to-digital conversion for sensors and measurements
CommunicationUART, SPI, I2C, CANSerial communication with peripherals and host systems
EncodersQEI, PDEC, Hall SensorsMotor position and speed measurement
Digital I/ODigital Input, Digital Output, Change NotificationGPIO control, button inputs, LED outputs
TimersTimer, Timer Input Capture, Timer Output ComparePeriodic interrupts, event capture, pulse generation
AnalogDAC, Op-Amp, Comparator, Voltage ReferenceAnalog output, signal conditioning, threshold detection
UtilityData Visualization (picgui), External Mode, PILReal-time debugging, parameter tuning, code verification

Graphical Configuration: Each peripheral block provides a user-friendly dialog box for configuration - no need to read datasheets or calculate register values manually. The blockset automatically generates correct initialization code based on your high-level settings.

Target Applications

  • Motor Control - FOC, BLDC, PMSM, Stepper motors
  • Power Conversion - SMPS, PFC, DC-DC converters, inverters
  • Digital Power - Advanced control loops, adaptive algorithms
  • Signal Processing - Filters, FFT, sensor fusion
  • Communication - CAN, LIN, Ethernet, USB

See Also

[Installation] | [Quick Start Guide] | [Board Templates] | [Supported Devices] | [External Mode & PIL] | User Guide