1www.esi-group.com
Copyright © ESI Group, 2019. All rights reserved.Copyright © ESI Group, 2019. All rights reserved.
www.esi-group.com
Faster Time to Market using Scilab/XCOS/X2C for motor
control algorithm development
Christoph Baumgartner, Microchip Technology Inc.
Scilab Conference 2019
2www.esi-group.com
Copyright © ESI Group, 2019. All rights reserved.
Class Agenda
• Rapid Prototyping Overview
• Develop and simulate your application
• IDE integration (MPLAB X, MCC, Harmony3)
• Run and verify your model on your target platform
• Sensorless field oriented control demo
• Summary
3www.esi-group.com
Copyright © ESI Group, 2019. All rights reserved.
Rapid Prototyping
Commercial:
Matlab/Simulink +
Microchip Toolboxes
OPENSOURCE:
SCILAB/Xcos + X2C
4www.esi-group.com
Copyright © ESI Group, 2019. All rights reserved.
the Goal.....
Simulate a physikal system .1
Generate code from the simulation .2
Verify simulation and real world .3
variable load
Dynamometer
algorithm
motor
5www.esi-group.com
Copyright © ESI Group, 2019. All rights reserved.
Rapid Prototyping - birds view
MPLAB XSCILAB / XCOS / X2C
X2C communicator
simulation
(PC)
realtime UART
verification
code generation
hardware
6www.esi-group.com
Copyright © ESI Group, 2019. All rights reserved.
Installation MCHP_X2C_V6.xx.yy
Select which modules you want to install:
• X2C
• X2C Demos
• X2C MCC Library
• X2Cscope (C-project UART debugging)
• X2Cscope MCC library
• X2Cscope demo projects
• X2Cscope library projects
• X2C Harmony 2
• MHC2 X2C integration
• Harmony 2 X2C demos
• X2C Harmony 3
• MHC3 X2C integration
• Harmony 3 X2C demos
• Activate X2C in Scilab
7www.esi-group.com
Copyright © ESI Group, 2019. All rights reserved.
Structure of X2C
Model INports
X2C housekeeping
X2C Blocks
Model OUTports
8www.esi-group.com
Copyright © ESI Group, 2019. All rights reserved.
X2C Libraries
OPENSOURCE
9www.esi-group.com
Copyright © ESI Group, 2019. All rights reserved.
MCHP MC library
We have developed a
MC libraries with
• 16bit fract
• 32bit fract
• 32bit float
The library is available for free.
dsPIC implementation uses
the original MCLib.
10www.esi-group.com
Copyright © ESI Group, 2019. All rights reserved.
Building Process
MPLAB X
or with batch file
right after code generation
11www.esi-group.com
Copyright © ESI Group, 2019. All rights reserved.
Realtime Tuning/Debugging
Interfaces:
UART
USB/CDC
Ethernet
CAN
12www.esi-group.com
Copyright © ESI Group, 2019. All rights reserved.
Documentation
Automatic documentation
using
MikTex
and
doxygen
13www.esi-group.com
Copyright © ESI Group, 2019. All rights reserved.
 Generated code is human readable
 Instant online parameter update to target
 Simulation with “target code” in XCOS
 Automated documentation generation
 Virtual oscilloscope
 Comprehensive libraries
 Multiple fixed and floating point implementations
 Inbuilt parameter conversion
 Parameter upload (from target), incl. model
 MISRA conformity of blocks (X2C library only)
 Multirate model support
 ANY 16 and 32 bit device from Microchip is supported
 Fully integrated into MPLAB Harmony3 and MCC
 UART, USB-CDC,TCPIP, CAN support
 dsPIC specific MClibrary
X2C Highligths
14www.esi-group.com
Copyright © ESI Group, 2019. All rights reserved.
Miktex
Software packages
X2C
Library blocks
(from LCM)
Scilab
XCOS
X2C
Communicator
Model code
X2C.c
X2C.h
Framework project
Peripheral driver
MPLAB X
MCC
Harmony2/3
doxygen
PDF documentation
15www.esi-group.com
Copyright © ESI Group, 2019. All rights reserved.
Workflow (existing project + compileandflash.bat)
1. Start MPLAB X + open project + MCC
2. Goto X2C MCC library [MPLAB X]
3. Open model [MPLAB X-X2C MCC lib]
4. Start the Communicator [XCOS]
5. Develop the model [XCOS]
6. Transform Model and push to
communicator [XCOS]
7. Generate C-code (automatically executes
the post process batch for compiling and
programming) [Communicator]
8. {Verify UART settings [Communicator]}
9. {Connect to hardware [Communicator]}
10. {Start Scope [Communicator]}
11. Modify block parameters [Communicator or
XCOS]
12. Restart at 5
4 6
1
2
3
7
9 10
16www.esi-group.com
Copyright © ESI Group, 2019. All rights reserved.
DEMO
1. Click on X2C
2. Open the Scilab model
17www.esi-group.com
Copyright © ESI Group, 2019. All rights reserved.
1st Demo (continued)
Execute initProject.sce
&
Simulate your model with
run.sce
Play with parameters
and
simulate again !!!
18www.esi-group.com
Copyright © ESI Group, 2019. All rights reserved.
1st Demo (continued)
1st start the
communicator
2nd transfer the
model to the
communicator
19www.esi-group.com
Copyright © ESI Group, 2019. All rights reserved.
Automatic programing from X2CCommunicator
Make sure you have generated code with
MCC, this has updated the
„compileandflash.bat“ file with your compiler
and programmer settings.
Add the compileandflash.bat from the .X
project directory as a Post-Generate script in
the X2CCommunicator settings
The next time you generate model code it will
automatically compiled and programmed.
20www.esi-group.com
Copyright © ESI Group, 2019. All rights reserved.
1st Demo (continued)
Parameters can also be
modified by clicking onto a
model block. Even changing
with the mousewheele is
possible.
21www.esi-group.com
Copyright © ESI Group, 2019. All rights reserved.
Code structure
main
init
communicate
mainTask()
Inports.x
handling
*Outports.y
handling
X2C_update();
interrupt:
execution rate:
X2C_sampletime
Model execution
Communication with
the scope.
22www.esi-group.com
Copyright © ESI Group, 2019. All rights reserved.
Class Summary
• Today we covered:
• Rapid Prototyping based on SCILAB/X2C
• Develop a model
• Simulate and generate code
• Verify the simulation results on the real
hardware
• POWERFULL INTEGRATION in
MICROCHIP IDE
23www.esi-group.com
Copyright © ESI Group, 2019. All rights reserved.
don‘t forget:
WE spin motors!!!
24www.esi-group.com
Copyright © ESI Group, 2019. All rights reserved.
LEGAL NOTICE
SOFTWARE:
You may use Microchip software exclusively with Microchip products. Further, use of Microchip software is subject to the copyright notices, disclaimers, and any license terms
accompanying such software, whether set forth at the install of each program or posted in a header or text file.
Notwithstanding the above, certain components of software offered by Microchip and 3rd parties may be covered by “open source” software licenses – which include licenses
that require that the distributor make the software available in source code format. To the extent required by such open source software licenses, the terms of such license will
govern.
NOTICE & DISCLAIMER:
These materials and accompanying information (including, for example, any software, and references to 3rd party companies and 3rd party websites) are for informational
purposes only and provided “AS IS.” Microchip assumes no responsibility for statements made by 3rd party companies, or materials or information that such 3rd parties may
provide.
MICROCHIP DISCLAIMS ALL WARRANTIES, WHETHER EXPRESS, IMPLIED, OR STATUTORY, INCLUDING ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY DIRECT OR INDIRECT, SPECIAL,
PUNITIVE, INCIDENTAL, OR CONSEQUENTIAL LOSS, DAMAGE, COST, OR EXPENSE OF ANY KIND RELATED TO THESE MATERIALS OR ACCOMPANYING
INFORMATION PROVIDED TO YOU BY MICROCHIP OR OTHER THIRD PARTIES, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE POSSIBLITY OF SUCH
DAMAGES OR THE DAMAGES ARE FORESEEABLE. PLEASE BE AWARE THAT IMPLEMENTATION OF INTELLECTUAL PROPERTY PRESENTED HERE MAY
REQUIRE A LICENSE FROM THIRD PARTIES.
TRADEMARKS:
The Microchip name and logo, the Microchip logo, AnyRate, AVR, AVR logo, AVR Freaks, BeaconThings, BitCloud, CryptoMemory, CryptoRF, dsPIC, FlashFlex, flexPWR,
Heldo, JukeBlox, KEELOQ, KEELOQ logo, Kleer, LANCheck, LINK MD, maXStylus, maXTouch, MediaLB, megaAVR, MOST, MOST logo, MPLAB, OptoLyzer, PIC, picoPower,
PICSTART, PIC32 logo, Prochip Designer, QTouch, RightTouch, SAM-BA, SpyNIC, SST, SST Logo, SuperFlash, tinyAVR, UNI/O, and XMEGA are registered trademarks of
Microchip Technology Incorporated in the U.S.A. and other countries.
ClockWorks, The Embedded Control Solutions Company, EtherSynch, Hyper Speed Control, HyperLight Load, IntelliMOS, mTouch, Precision Edge, and Quiet-Wire are
registered trademarks of Microchip Technology Incorporated in the U.S.A.
Adjacent Key Suppression, AKS, Analog-for-the-Digital Age, Any Capacitor, AnyIn, AnyOut, BodyCom, chipKIT, chipKIT logo, CodeGuard, CryptoAuthentication,
CryptoCompanion, CryptoController, dsPICDEM, dsPICDEM.net, Dynamic Average Matching, DAM, ECAN, EtherGREEN, In-Circuit Serial Programming, ICSP, Inter-Chip
Connectivity, JitterBlocker, KleerNet, KleerNet logo, Mindi, MiWi, motorBench, MPASM, MPF, MPLAB Certified logo, MPLIB, MPLINK, MultiTRAK, NetDetach, Omniscient
Code Generation, PICDEM, PICDEM.net, PICkit, PICtail, PureSilicon, QMatrix, RightTouch logo, REAL ICE, Ripple Blocker, SAM-ICE, Serial Quad I/O, SMART-I.S., SQI,
SuperSwitcher, SuperSwitcher II, Total Endurance, TSHARC, USBCheck, VariSense, ViewSpan, WiperLock, Wireless DNA, and ZENA are trademarks of Microchip
Technology Incorporated in the U.S.A. and other countries.
SQTP is a service mark of Microchip Technology Incorporated in the U.S.A.
Silicon Storage Technology is a registered trademark of Microchip Technology Inc. in other countries.
GestIC is a registered trademark of Microchip Technology Germany II GmbH & Co. KG, a subsidiary of Microchip Technology Inc., in other countries.
All other trademarks mentioned herein are property of their respective companies.
© 2017, Microchip Technology Incorporated, All Rights Reserved.
25www.esi-group.com
Copyright © ESI Group, 2019. All rights reserved.
Thank you

Faster Time to Market using Scilab/XCOS/X2C for motor control algorithm development

  • 1.
    1www.esi-group.com Copyright © ESIGroup, 2019. All rights reserved.Copyright © ESI Group, 2019. All rights reserved. www.esi-group.com Faster Time to Market using Scilab/XCOS/X2C for motor control algorithm development Christoph Baumgartner, Microchip Technology Inc. Scilab Conference 2019
  • 2.
    2www.esi-group.com Copyright © ESIGroup, 2019. All rights reserved. Class Agenda • Rapid Prototyping Overview • Develop and simulate your application • IDE integration (MPLAB X, MCC, Harmony3) • Run and verify your model on your target platform • Sensorless field oriented control demo • Summary
  • 3.
    3www.esi-group.com Copyright © ESIGroup, 2019. All rights reserved. Rapid Prototyping Commercial: Matlab/Simulink + Microchip Toolboxes OPENSOURCE: SCILAB/Xcos + X2C
  • 4.
    4www.esi-group.com Copyright © ESIGroup, 2019. All rights reserved. the Goal..... Simulate a physikal system .1 Generate code from the simulation .2 Verify simulation and real world .3 variable load Dynamometer algorithm motor
  • 5.
    5www.esi-group.com Copyright © ESIGroup, 2019. All rights reserved. Rapid Prototyping - birds view MPLAB XSCILAB / XCOS / X2C X2C communicator simulation (PC) realtime UART verification code generation hardware
  • 6.
    6www.esi-group.com Copyright © ESIGroup, 2019. All rights reserved. Installation MCHP_X2C_V6.xx.yy Select which modules you want to install: • X2C • X2C Demos • X2C MCC Library • X2Cscope (C-project UART debugging) • X2Cscope MCC library • X2Cscope demo projects • X2Cscope library projects • X2C Harmony 2 • MHC2 X2C integration • Harmony 2 X2C demos • X2C Harmony 3 • MHC3 X2C integration • Harmony 3 X2C demos • Activate X2C in Scilab
  • 7.
    7www.esi-group.com Copyright © ESIGroup, 2019. All rights reserved. Structure of X2C Model INports X2C housekeeping X2C Blocks Model OUTports
  • 8.
    8www.esi-group.com Copyright © ESIGroup, 2019. All rights reserved. X2C Libraries OPENSOURCE
  • 9.
    9www.esi-group.com Copyright © ESIGroup, 2019. All rights reserved. MCHP MC library We have developed a MC libraries with • 16bit fract • 32bit fract • 32bit float The library is available for free. dsPIC implementation uses the original MCLib.
  • 10.
    10www.esi-group.com Copyright © ESIGroup, 2019. All rights reserved. Building Process MPLAB X or with batch file right after code generation
  • 11.
    11www.esi-group.com Copyright © ESIGroup, 2019. All rights reserved. Realtime Tuning/Debugging Interfaces: UART USB/CDC Ethernet CAN
  • 12.
    12www.esi-group.com Copyright © ESIGroup, 2019. All rights reserved. Documentation Automatic documentation using MikTex and doxygen
  • 13.
    13www.esi-group.com Copyright © ESIGroup, 2019. All rights reserved.  Generated code is human readable  Instant online parameter update to target  Simulation with “target code” in XCOS  Automated documentation generation  Virtual oscilloscope  Comprehensive libraries  Multiple fixed and floating point implementations  Inbuilt parameter conversion  Parameter upload (from target), incl. model  MISRA conformity of blocks (X2C library only)  Multirate model support  ANY 16 and 32 bit device from Microchip is supported  Fully integrated into MPLAB Harmony3 and MCC  UART, USB-CDC,TCPIP, CAN support  dsPIC specific MClibrary X2C Highligths
  • 14.
    14www.esi-group.com Copyright © ESIGroup, 2019. All rights reserved. Miktex Software packages X2C Library blocks (from LCM) Scilab XCOS X2C Communicator Model code X2C.c X2C.h Framework project Peripheral driver MPLAB X MCC Harmony2/3 doxygen PDF documentation
  • 15.
    15www.esi-group.com Copyright © ESIGroup, 2019. All rights reserved. Workflow (existing project + compileandflash.bat) 1. Start MPLAB X + open project + MCC 2. Goto X2C MCC library [MPLAB X] 3. Open model [MPLAB X-X2C MCC lib] 4. Start the Communicator [XCOS] 5. Develop the model [XCOS] 6. Transform Model and push to communicator [XCOS] 7. Generate C-code (automatically executes the post process batch for compiling and programming) [Communicator] 8. {Verify UART settings [Communicator]} 9. {Connect to hardware [Communicator]} 10. {Start Scope [Communicator]} 11. Modify block parameters [Communicator or XCOS] 12. Restart at 5 4 6 1 2 3 7 9 10
  • 16.
    16www.esi-group.com Copyright © ESIGroup, 2019. All rights reserved. DEMO 1. Click on X2C 2. Open the Scilab model
  • 17.
    17www.esi-group.com Copyright © ESIGroup, 2019. All rights reserved. 1st Demo (continued) Execute initProject.sce & Simulate your model with run.sce Play with parameters and simulate again !!!
  • 18.
    18www.esi-group.com Copyright © ESIGroup, 2019. All rights reserved. 1st Demo (continued) 1st start the communicator 2nd transfer the model to the communicator
  • 19.
    19www.esi-group.com Copyright © ESIGroup, 2019. All rights reserved. Automatic programing from X2CCommunicator Make sure you have generated code with MCC, this has updated the „compileandflash.bat“ file with your compiler and programmer settings. Add the compileandflash.bat from the .X project directory as a Post-Generate script in the X2CCommunicator settings The next time you generate model code it will automatically compiled and programmed.
  • 20.
    20www.esi-group.com Copyright © ESIGroup, 2019. All rights reserved. 1st Demo (continued) Parameters can also be modified by clicking onto a model block. Even changing with the mousewheele is possible.
  • 21.
    21www.esi-group.com Copyright © ESIGroup, 2019. All rights reserved. Code structure main init communicate mainTask() Inports.x handling *Outports.y handling X2C_update(); interrupt: execution rate: X2C_sampletime Model execution Communication with the scope.
  • 22.
    22www.esi-group.com Copyright © ESIGroup, 2019. All rights reserved. Class Summary • Today we covered: • Rapid Prototyping based on SCILAB/X2C • Develop a model • Simulate and generate code • Verify the simulation results on the real hardware • POWERFULL INTEGRATION in MICROCHIP IDE
  • 23.
    23www.esi-group.com Copyright © ESIGroup, 2019. All rights reserved. don‘t forget: WE spin motors!!!
  • 24.
    24www.esi-group.com Copyright © ESIGroup, 2019. All rights reserved. LEGAL NOTICE SOFTWARE: You may use Microchip software exclusively with Microchip products. Further, use of Microchip software is subject to the copyright notices, disclaimers, and any license terms accompanying such software, whether set forth at the install of each program or posted in a header or text file. Notwithstanding the above, certain components of software offered by Microchip and 3rd parties may be covered by “open source” software licenses – which include licenses that require that the distributor make the software available in source code format. To the extent required by such open source software licenses, the terms of such license will govern. NOTICE & DISCLAIMER: These materials and accompanying information (including, for example, any software, and references to 3rd party companies and 3rd party websites) are for informational purposes only and provided “AS IS.” Microchip assumes no responsibility for statements made by 3rd party companies, or materials or information that such 3rd parties may provide. MICROCHIP DISCLAIMS ALL WARRANTIES, WHETHER EXPRESS, IMPLIED, OR STATUTORY, INCLUDING ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY DIRECT OR INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL, OR CONSEQUENTIAL LOSS, DAMAGE, COST, OR EXPENSE OF ANY KIND RELATED TO THESE MATERIALS OR ACCOMPANYING INFORMATION PROVIDED TO YOU BY MICROCHIP OR OTHER THIRD PARTIES, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE POSSIBLITY OF SUCH DAMAGES OR THE DAMAGES ARE FORESEEABLE. PLEASE BE AWARE THAT IMPLEMENTATION OF INTELLECTUAL PROPERTY PRESENTED HERE MAY REQUIRE A LICENSE FROM THIRD PARTIES. TRADEMARKS: The Microchip name and logo, the Microchip logo, AnyRate, AVR, AVR logo, AVR Freaks, BeaconThings, BitCloud, CryptoMemory, CryptoRF, dsPIC, FlashFlex, flexPWR, Heldo, JukeBlox, KEELOQ, KEELOQ logo, Kleer, LANCheck, LINK MD, maXStylus, maXTouch, MediaLB, megaAVR, MOST, MOST logo, MPLAB, OptoLyzer, PIC, picoPower, PICSTART, PIC32 logo, Prochip Designer, QTouch, RightTouch, SAM-BA, SpyNIC, SST, SST Logo, SuperFlash, tinyAVR, UNI/O, and XMEGA are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. ClockWorks, The Embedded Control Solutions Company, EtherSynch, Hyper Speed Control, HyperLight Load, IntelliMOS, mTouch, Precision Edge, and Quiet-Wire are registered trademarks of Microchip Technology Incorporated in the U.S.A. Adjacent Key Suppression, AKS, Analog-for-the-Digital Age, Any Capacitor, AnyIn, AnyOut, BodyCom, chipKIT, chipKIT logo, CodeGuard, CryptoAuthentication, CryptoCompanion, CryptoController, dsPICDEM, dsPICDEM.net, Dynamic Average Matching, DAM, ECAN, EtherGREEN, In-Circuit Serial Programming, ICSP, Inter-Chip Connectivity, JitterBlocker, KleerNet, KleerNet logo, Mindi, MiWi, motorBench, MPASM, MPF, MPLAB Certified logo, MPLIB, MPLINK, MultiTRAK, NetDetach, Omniscient Code Generation, PICDEM, PICDEM.net, PICkit, PICtail, PureSilicon, QMatrix, RightTouch logo, REAL ICE, Ripple Blocker, SAM-ICE, Serial Quad I/O, SMART-I.S., SQI, SuperSwitcher, SuperSwitcher II, Total Endurance, TSHARC, USBCheck, VariSense, ViewSpan, WiperLock, Wireless DNA, and ZENA are trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. SQTP is a service mark of Microchip Technology Incorporated in the U.S.A. Silicon Storage Technology is a registered trademark of Microchip Technology Inc. in other countries. GestIC is a registered trademark of Microchip Technology Germany II GmbH & Co. KG, a subsidiary of Microchip Technology Inc., in other countries. All other trademarks mentioned herein are property of their respective companies. © 2017, Microchip Technology Incorporated, All Rights Reserved.
  • 25.
    25www.esi-group.com Copyright © ESIGroup, 2019. All rights reserved. Thank you