Introduction to Microchip-SIMULINK Blocksets and MATLAB Plug-in for MPLAB® IDE
Introduction & Agenda• Introduction to Microchip Device Blocksets• Introduction to MATLAB Plug-In in MPLAB®IDE• Creating a SIMULINK model with Microchip Blocksetand building them• Learning Goal: To create a SIMULINK model usingMicrochip Blockset, generate C code from it and build it
Vocabulary• MATLAB/SIMULINK• SIMULINK Model• RTW- Real Time Workshop• RTW Embedded Coder
MATLAB/SIMULINKThis is popularly used tool for mathematic computationand model based design.SIMULINK ModelThis is in general a pictorial representation of an application.Created using blocks provided by MATLAB as well as thirdparties.RTW- Real Time WorkshopThis is a optional product of MATLAB which can generate ANSI Ccode from SIMULINK models.RTW Embedded CoderThis is an optional add-on to RTW. Code generated by RTW isgeneric in nature. Embedded coder generates optimized codesuitable for embedded targets.4
7» You can pull these blocks into your models and configurethem as per your requirements.» Peripherals supported here include, but are not limited to:ADC, UART, SPI, Output Compare, CAN, Timers, DMA, I2C™,DCI, motor Control PWM etc,. This library also has a block‘cCall’ to import user developed C routines into SIMULINKmodels. These routines would be compiled and built alongwith files generated from the model.» ‘dsPIC33fxx Main’ block found here is essential componentfor every application model that you create. This allows youto configure clocks, Oscillators etc.
• The picture here shows dsPIC33f General library.• You can pull these blocks into your models and configurethem as per your requirements.• Blocks found under this library generally have one or moreinput/output ports, which have to be connected toappropriate source/sink blocks.E.g.,: UART transmit block has an input port whichaccepts ‘uint16/int16’ data type and transmits it on everytimer expire event.This timer has to be configured in dspic33f Main block.
1. Start Plug-InTools>Matlab/Simulink2. Open Simulink ModelMatlab/Simulink>Specify Simulink Model Name3. Open up a ProjectProject->New or Project->Open4. Generate Code and Import filesMatlab/Simulink>Generate Code and Import Files5. Build, program, debug
Here is an overview of the steps to use MATLAB Plug-In for MPLAB.1. Select Tools>Matlab/Simulink from the menu.2. Select Matlab/Simulink>Specify Simulink Model Name to specifythe SIMULINK model to be opened for code generation.3. Open up a Project, either fresh one or an existing one. The codegenerated will be added to this project.4. Click on Generate Code. The plug-in will generate code throughRTW embedded coder.5. Click on Import Generated files. The plug-in will include allgenerated files into the active project.You can edit (if required) and build the code generated. Youcan program the hex/coff through MPLAB® IDE. You can also dosource-level debugging in the same way you would do with handwritten code.
Summary1. Use Microchip Device Blockset and MATLAB Plug-In forCode generation2. Learning Goal: To create SIMULINK models, generatecode, build and debug
To Get More Information• Other webinarshttp://www.microchip.com/webi• Discussion boardhttp://forum.microchip.com >Development Tools > MATLAB• Support (Knowledge Base andTicket) http://support.microchip• Collaboration WIKIhttp://www.microchip.com/wiki