Page 891 - Mechatronics with Experiments
P. 891

®
                                                               ®
                                                MATLAB , SIMULINK , STATEFLOW, AND AUTO-CODE GENERATION  877
                                 1          X_cmd
                               X_cmd
                                 2          X_fbk            DAC         1
                               X_fbk                                    DAC

                                 3          V_fbk
                               V_fbk
                                                   PD control
                                      Simulation version




                                                         X_cmd

                                     ADC                 X_fbk            DAC             DAC

                             ADC_TYPE1_M1_CON1                                      DAC_TYPE1_M1_C1
                                                         V_fbk
                                                                PD control
                                        Real time version
                                                                 ®
                             FIGURE A.48: An example model in Simulink : Simulation version (non-real time) and
                             real-time version with appropriate I/O software drivers for the target ECM (electronic control
                             module) to be used by the auto-code generation tools.


                                                                 ®
                                3. Provide initial values in the MATLAB workspace for the parameters and variables
                                  so that these initialization values can be included in the generated auto-code.
                                                                          ®
                             There are three auto-code generation tools in MATLAB :
                                          ®
                                1. Simulink Coder,
                                2. Embedded Coder, and
                                           ®
                                3. MATLAB Coder.
                             The main auto-code generation tool is the Simulink ®  Coder.The MATLAB ®  Coder
                                                            ®
                             generates C/C++ code from MATLAB language files. The Embedded Coder generates
                             optimized code specific to various microcontrollers and digital signal processors, making
                                                               ®
                                             ®
                             use of the Simulink Coder and MATLAB Coder tools in the process. Once the auto-code
                             generation tools are configured for a target embedded micro controller, they can be saved
                             and re-used without having to deal with any configuration issues.
                                  Let us consider the following target microcontroller for auto-code generation:
                             Microchip dsPIC33F. For development purposes, the following hardware and software
                             tools are needed:

                                1. Microchip dsPIC33F Starter Kit which has a development board with the target
                                  microcontroller. The board also has a built-in debugger.
                                2. PC with USB interface to communicate with the development board.
                             The additional software tools needed for this auto-code generation for the target microcon-
                             troller are (Figure A.1):
                                1. Microchip dsPIC33F Blockset for Simulink ®  (which would be integrated into the
                                         ®
                                  Simulink environment in Figure A.1).
   886   887   888   889   890   891   892   893   894   895   896