Pin assignments matching the physical board layout
Example algorithms demonstrating typical use cases (motor control, sensor interfaces)
Validated configurations tested on actual hardware
Key Benefit: Templates eliminate hours of configuration work, allowing you to start developing control algorithms immediately. Simply select your board template, customize the algorithm, and build.
Why Use Board Templates?
Benefit
Description
Fast Prototyping
Start coding control algorithms in minutes instead of hours spent on peripheral configuration
Validated Hardware
All pin assignments and peripheral settings verified on actual hardware - reduces debugging time
Best Practices
Templates follow Microchip recommended configurations for optimal performance
Learning Tool
Study working examples to understand peripheral configuration patterns
Easy Portability
Switch between boards by simply loading a different template - same algorithm, different hardware
Available Board Templates
MCLV-2 (Motor Control Low Voltage)
Target Applications: Low-voltage motor control, BLDC/PMSM development
One of the key advantages of templates is easy portability. To migrate an algorithm from one board to another:
Save Current Model: Backup your algorithm implementation
Extract Algorithm: Copy your control algorithm subsystem (without peripheral blocks)
Open Target Template: Load the template for your new target board
Paste Algorithm: Insert your control algorithm into the new template
Verify Connections: Ensure algorithm inputs/outputs connect to peripheral blocks
Adjust Parameters: Update scaling factors, sample times if board specs differ
Build & Test: Compile for new target and verify functionality
Example: Moving a FOC algorithm from MCLV-2 (dsPIC33CK) to MCLV-300W48V (dsPIC33A) requires only:
Updating current sensor scaling (different op-amp gains)
Adjusting PWM frequency (different board power stage limits)
Optionally switching from fixed-point to floating-point (utilizing dsPIC33A's FPU)
The core control algorithm remains unchanged!
Template Customization
Common Customization Tasks
Task
Steps
Change PWM Frequency
Double-click PWM block
Add ADC Channel
Double-click ADC block
Enable CAN Communication
Add “CAN Config” block from MCHP library
Change Clock Speed
Double-click Master block
Advanced Customization
Multi-rate Scheduling: Add subsystems with different sample times to implement multi-tasking
Fixed-Point Optimization: Use Fixed-Point Tool to convert floating-point to fixed-point for faster execution
Pin Mismatch: Verify template pin assignments match your board revision
Scaling Errors: Check ADC/PWM scaling factors match your hardware (sensor gains, voltage levels)
Timing Issues: Verify sample times and peripheral frequencies are correctly configured
Real-time Violations: Use MCU Load block to check for overload conditions
Creating Custom Templates
Once you’ve configured a model for a custom board, you can save it as a template for reuse:
Configure Model: Set up all peripherals and verify working on hardware
Clean Algorithm: Replace specific control logic with generic placeholder algorithm
Add Documentation: Include block comments explaining peripheral configuration
Create Template File: Save as .sltx template file (File โ Save As โ Simulink Template)
Add Metadata: Fill in template description, tags, and preview image
Share: Distribute template to team or organization
Custom Board Note: When creating templates for custom hardware, thoroughly document:
Pin assignments and their mapping to board connectors
Clock configuration rationale and limitations
Scaling factors for analog inputs (sensor gains, voltage dividers)
Known hardware limitations or errata workarounds
Example Use Case: DC Motor Control
Using the MCLV-2 template, you can implement a cascaded PI controller for DC motor speed control in under 30 minutes:
Load Template: Open “MCLV2_dsPIC33CK_MotorControl_Template”
Pre-configured Peripherals:
PWM: 20kHz, center-aligned, 1ยตs dead-time
ADC: Synchronized to PWM, measuring motor current (AN0) and potentiometer (AN13)
QEI: 1000-line encoder, speed measurement at 2ms rate
UART: 115200 baud for picgui data logging
Add Control Algorithm:
Inner current loop: PI controller at 50ยตs (20kHz)
Outer speed loop: PI controller at 1ms (1kHz)
Speed reference from potentiometer
Build & Deploy: Press Ctrl+B to generate code and program board
Tune & Visualize: Use picgui to monitor speed/current in real-time and adjust PI gains
Result: Working motor control system in 30 minutes instead of several hours of manual configuration!
See Also
[MCHP Blockset Overview] | [Quick Start Guide] | [Motor Control Examples] | [External Mode & PIL] | User Guide