SPRACO3 October   2019 INA240 , LMG5200 , TMS320F280021 , TMS320F280021-Q1 , TMS320F280023 , TMS320F280023-Q1 , TMS320F280023C , TMS320F280025 , TMS320F280025-Q1 , TMS320F280025C , TMS320F280025C-Q1 , TMS320F280040-Q1 , TMS320F280040C-Q1 , TMS320F280041 , TMS320F280041-Q1 , TMS320F280041C , TMS320F280041C-Q1 , TMS320F280045 , TMS320F280048-Q1 , TMS320F280048C-Q1 , TMS320F280049 , TMS320F280049-Q1 , TMS320F280049C , TMS320F280049C-Q1 , TMS320F28374D , TMS320F28374S , TMS320F28375D , TMS320F28375S , TMS320F28375S-Q1 , TMS320F28376D , TMS320F28376S , TMS320F28377D , TMS320F28377D-EP , TMS320F28377D-Q1 , TMS320F28377S , TMS320F28377S-Q1 , TMS320F28378D , TMS320F28378S , TMS320F28379D , TMS320F28379D-Q1 , TMS320F28379S

 

  1.   Dual-Axis Motor Control Using FCL and SFRA On a Single C2000 MCU
    1.     Trademarks
    2. 1 Introduction
      1. 1.1 Acronyms and Descriptions
    3. 2 Benefits of the C2000 for High-Bandwidth Current Loop
    4. 3 Current Loops in Servo Drives
    5. 4 PWM Update Latency for Dual Motor
    6. 5 Outline of the Fast Current Loop Library
    7. 6 Evaluation Platform Setup
      1. 6.1 Hardware
        1. 6.1.1 LAUNCHXL-F28379D or LAUNCHXL-F280049C
          1. 6.1.1.1 DACs
          2. 6.1.1.2 QEPs
        2. 6.1.2 Inverter BoosterPack - GaN + INA240
        3. 6.1.3 Two Motor Dyno
        4. 6.1.4 System Hardware Connections
        5. 6.1.5 Powering Up the Setup
      2. 6.2 Software
        1. 6.2.1 Incremental Build
        2. 6.2.2 Software Setup for Dual-Axis Servo Drive Projects
    8. 7 System Software Integration and Testing
      1. 7.1 Incremental Build Level 1
        1. 7.1.1 SVGEN Test
        2. 7.1.2 Testing SVGEN With DACs
        3. 7.1.3 Inverter Functionality Verification
      2. 7.2 Incremental Build Level 2
        1. 7.2.1 Connecting motor to INVs
        2. 7.2.2 Testing the Motors and INVs
        3. 7.2.3 Setting Over-current Limit in the Software
        4. 7.2.4 Setting Current Regulator Limits
        5. 7.2.5 Position Encoder Feedback
      3. 7.3 Incremental Build Level 3
        1. 7.3.1 Observation One – Latency
      4. 7.4 Incremental Build Level 4
        1. 7.4.1 Observation
        2. 7.4.2 Dual Motor Run With Speed Loop
      5. 7.5 Incremental Build Level 5
        1. 7.5.1 Dual Motor Run with Position Loop
      6. 7.6 Incremental Build Level 6
        1. 7.6.1 Integrating SFRA Library
        2. 7.6.2 Initial Setup Before Starting SFRA
        3. 7.6.3 SFRA GUIs
        4. 7.6.4 Setting Up the GUIs to Connect to Target Platform
        5. 7.6.5 Running the SFRA GUIs
        6. 7.6.6 Influence of Current Feedback SNR
        7. 7.6.7 Inferences
        8. 7.6.8 Phase Margin vs Gain Crossover Frequency
    9. 8 Summary
    10. 9 References

Software Setup for Dual-Axis Servo Drive Projects

Installing Code Composer Studio and MotoControl SDK

  1. Go to http://www.ti.com/ccstudio to download the latest version of Code Composer Studio and run the installer.
  2. Go to http://www.ti.com/tool/C2000WARE-MOTORCONTROL-SDK to download and run the MotorControl SDK installer. Allow the installer to download and update any automatically checked software for C2000.

Setting up Code Composer Studio for Project Evaluation

  1. Open Code Composer Studio. Note that this document assumes version 9.1.0 or later .
  2. Once Code Composer Studio opens, the workspace launcher may appear as Figure 9 that would ask to select a workspace location.
    1. Click the “Browse…” button as Figure.
    2. Create the path below by making new folders as necessary, like "C:\ti\mcsdk_projects\dual_axis_drive".
    3. Uncheck the box that says “Use this as the default and do not ask again”, and then click "Launch".
    4. figure_9.gifFigure 9. CCS Workspace Launcher
  3. This will open a "Getting Started" tab with links to various tasks from creating a new project, importing an existing project to watching a Tutorial on CCS.
  4. Add the motor control projects into the current workspace by clicking “Project->Import CCS Project”.
    1. Select the evaluation project by browsing as shown in Figure 10 to: "\ti\c2000\C2000Ware_MotorControl_SDK_<version>\solutions\boostxl_3phganinv\f2837x\ccs\sensored_foc".
    2. If there are multiple projects in this directory, then click and choose the projects to import. Click Finish. This copies all of the selected projects into the workspace. In Figure 10, there is only one project. Select it and click Finish.
    3. figure_10.gifFigure 10. Adding Dual-Axis Drive Project to Workspace

Setting up the Target Configuration

  1. Configure Code Composer Studio to know which MCU it will be connecting to. This is done by setting up the "Target Configuration". All of these are already set up and configured in “TMS320F28379D.ccxml” provided as part of the files in project. You can skip to step 5, if needed. However, for general information regarding setting up this configuration file, steps 1, 2 and 3 can be used.
  2. A new configuration file can be set by clicking “File → New- → Target Configuration File" on the menu bar. This will open the Target Configuration window. In this window, give a name to the new configuration file depending on the target device. If “Use shared location” checkbox is checked, then this configuration file can be stored in a common location by CCS for use by other projects as well. Then, click Finish.
  3. This should open up a new tab as shown in Figure 11. Select and enter the options as shown:
    1. Connection – Texas Instruments XDS100v2 USB Debug Probe.
    2. Device – the C2000 MCU on the control card, TMS320F28379D.
    3. Click Save and close.
    4. figure_11.gifFigure 11. New Target Configuration
  4. To use this configuration file, click “View->Target Configurations” on the menu bar. In the “User Defined” section, find the file that was created in step 1, 2 and 3. Right-click on this file and select “Set as Default”.
  5. To use the configuration file supplied with the project, click “View->Target Configurations", then expand “dual_axis_servo_drive_fcl_qep_f2837x” and right-click on the file “TMS320F28379D.ccxml” and “Set as Default”. This tab also allows you to reuse existing target configurations and link them to specific projects.

Configuring a Project

  1. The project can be configured to create code and run in either flash or RAM. You may select either of the two, however, for lab experiments use the RAM configuration most of the time and move to the FLASH configuration for production. As shown in Figure 12, right-click on an individual project and select "Build Configurations->Set Active->F2837x_RAM" configuration.
  2. figure_12.gifFigure 12. Selecting the F2837x_RAM Configuration

Build and Load the Project

  1. The example project is provided with incremental builds where different components / macro blocks of the system are pieced together one by one to form the entire system. This helps in step by step debug and understanding of the system. From the CCS Edit Perspective, open the file "dual_axis_servo_drive_settings.h" and make sure that BUILDLEVEL is set to FCL_LEVEL1.
  2. Open the "dual_axis_servo_drive.c" file and go to the function motor1ControlISR(). Locate the following piece of code in incremental build FCL_LEVEL1 and confirm that the datalog buffers are pointing to the right variables. These datalog buffers are large arrays that contain value-triggered data that can then be displayed to a graph. Note that in other incremental builds different variables may be put into this buffer to be graphed.
  3. Now Right Click on the Project Name and click on “Rebuild Project” and watch the Console window. Any errors in the project will be displayed, which needs to be fixed. There may be some warning messages about certain functions or variables not being used. Such warning messages may be ignored, as they may be used in another build level.

Connecting the Hardware to Computer

  1. Mount BoosterPack BOOSTXL-3PhGaNInv on LaunchPad headers J1-J4. DO NOT connect motor right now. Connect the LaunchPad to computer through an USB cable, this will light some LEDs on the emulator section of LaunchPad, indicating that the emulator is on. Power the BoosterPack with appropriate input dc voltage, 24V. This will glow various LEDs on both BoosterPack and LaunchPad.
  2. Continuing from step 3 of "Build and Load the Project", on successful completion of the build, click the “Debug” buttonb1_debug.png, located in the top-left side of the screen.
  3. The IDE will now connect to the target, load the output file into the device and change to the Debug perspective.
  4. Click “Tools → Debugger Options → Program / Memory Load Options”. You can enable the debugger to reset the processor each time it reloads program by checking “Reset the target on program load or restart” and click “Remember My Settings” to make this setting permanent.
  5. Now click on the “Enable silicon real-time mode” buttonb7_srtm.png which also auto selects “Enable polite real-time mode” buttonb6_prtm.png . This allows you to edit and view variables in real-time. Do not reset the CPU without disabling these real time options!
  6. A message box may appear. If so, select "YES" to enable debug events. This will set bit 1 (DGBM bit) of status register 1 (ST1) to a “0”. The DGBM is the debug enable mask bit. When the DGBM bit is set to “0”, memory and register values can be passed to the host processor for updating the debugger windows.

Configuring Expressions Window

  1. Click "View- → Expressions" on the menu bar to open an Expressions window to view the variables being used in the project. Add variables to the expressions window as shown below. It uses the number format associated with variables during declaration. You can select a desired number format for the variable by right clicking on it and choosing. Figure 13 shows a typical expressions window.
  2. figure_13.gifFigure 13. Configuring the Expressions Window
  3. Alternately, a group of variables can be imported into the Expressions window, by right clicking within Expressions Window and clicking Import, and browse to the .txt file containing these variables. Here, browse to the directory of the project at "\ti\c2000\C2000Ware_MotorControl_SDK_<version>\solutions\common\sensored_foc\debug\" and pick "dual_axis_servo_drive_vars.txt" and click OK to import the variables shown in Figure 14.
  4. figure_14.gifFigure 14. Variables Import for Project
  5. The structure variables 'motorVars[0]' and 'motorVars[1]' have references to all peripherals and variables that are related to controlling dual motor. By expanding this variable, you can see them all and edit as needed.
  6. Click on the Continuous Refresh button b10_csrefresh.pngin the expressions window. This enables the window to run with real-time mode. By clicking the down arrow in this expressions window, you may select “Customize Continuous Refresh Interval” and edit the refresh rate of the expressions window. Note that choosing too fast an interval may affect performance.

Setting up Graphs

  1. The datalog buffers point to different system variables depending on the build level. They provide a means to visually inspect the variables and judge system performance. Open and setup time graph windows to plot the data log buffers as shown below. Alternatively, the graph configurations files can be imported in the project folder by clicking 'Tools → Graph → DualTime" on the menu bar and select import and browse to the following location at "\ti\c2000\C2000Ware_MotorControl_SDK_<version>\solutions\common\sensored_foc\debug" and select "dual_axis_servo_drive_graph1.graphProp", the Graph Properties window should now look like the Figure 15. Click OK, this should add the Graphs to your debug perspective. Click on Continuous Refresh button b10_csrefresh.pngon the top left corner of the graph tab. If there is no real time graph in the window, click the Reset Graph buttonb8_resetGraph.png, and then click Continuous Refresh button b11_enrefresh.pngagain.
  2. figure_15.gifFigure 15. Graph Window Settings

NOTE

  • If a second graph window is used, you could import dual_axis_servo_drive_graph2.graphProp, the start Addresses for this should be DBUFF_4CH3 and DBUFF_4CH4.
  • The default 'dlog.prescaler' is set to 5 which will allow the dlog function to only log one out of every five samples.
  • The default 'dlog.trig_value' should be set to the right value to generate trigger for the plot as in oscilloscopes.

Run the Code

  1. Run the code by clicking Run Button b2_run.png in the Debug Tab
  2. In the Expressions window, set the variable ‘enableFlag’ to 1.
  3. The project should now run, and the values in the graphs and expressions window should continuously update. Figure 16 and Figure 17 are some screen captures of typical CCS perspectives while using this project. You may want to resize the windows according to your preference. At this time, details of variables and graph are not discussed as they will be discussed in later sections
  4. Once complete, turn off Real Time mode, then reset the processor (Run->Reset->CPU Reset) and then terminate the debug session by clicking Terminateb4_terminate.png in the Debug Tab. This halts the program and disconnects Code Composer from the MCU.
  5. figure_16.gifFigure 16. CCS IDE Showing Edit Perspective
    figure_17.gifFigure 17. CCS IDE Showing Debug Perspective

Step 10. Next Operations

  1. It is not necessary to terminate the debug session each time you change or run the code again. Instead the following procedure can be followed.
    1. Disable real time options, terminate the project, reset CPU (Run->Reset->CPU Reset) , rebuild and reload the project if changed the code.
    2. Disable real time options, terminate the project, reset CPU (Run->Reset->CPU Reset) , (Run->Restart ), and enable realtime options if without changing the code.
    3. Terminate the project if the target device or the configuration is changed (Ram to Flash or Flash to Ram) prior to shutting down CCS.
  2. The header file "dual_axis_servo_drive_settings.h" and "dual_axis_servo_drive_user.h" in the CCS Edit Perspective has macro definitions for motor control. You can change these parameters as needed after thinking through the impact of such change.
  3. You can proceed to experiment various build levels in detail.