ZHCU563B March   2015  – December 2018

 

  1.   A
    1.     A.1 Field Oriented Control (FOC)
    2.     A.2 Position and Speed Motor Control
  2.   修订版本 B 历史记录

Running the Single Chip Motor-Control Application With TwinCAT 3 EtherCAT Master on a PC

To test the single-chip motor-control application, use TwinCAT or another compatible EtherCAT master with CiA402 Drive profile support.

Additional details on TwinCAT configuration can be found at Configuring TwinCAT For TI EtherCAT Slave.

To use TI slave with TwinCAT, do the following:

  1. Install TwinCAT3. (A one-month evaluation is available for free download from TwinCAT3 Download.)
    1. Select the eXtended Automation Engineering (XAE) mode of installation
  2. Copy [EtherCAT SDK]\protocols\ethercat_slave\ecat_appl\esi\TI_ESC.xml to <Drive>:\TwinCAT\3.1\Config\Io\EtherCAT folder.
  3. Start the TwinCAT system manager.
  4. Create a new TwinCAT XAE project.
    • Select New under the File menu option.
    • Select Project.
    • Select TwinCAT Project.
  5. Navigate to Options.
  6. Select Show Real-Time Ethernet Compatible Devices
  7. Install the TwinCAT RT Ethernet intermediate driver.
  8. NOTE

    TI recommends to using a NIC-compatible card listed at Supported Network Controller by Beckhoff Ethernet Driver. Check that the ethernet adapter is listed under Installed and ready to use devices before run running the TwinCAT demonstration.

  9. Connect the CAT5 Ethernet cable from the TwinCAT PC to the EtherCAT IN/Port0 (J6) of the IDK. (If you have multiple IDKs in the chain, connect from the EtherCAT OUT/Port1 [J9] to the Port0 of the next IDK. For the last IDK in chain, leave Port1 open.)
  10. In Solution Explorer, go to a new TwinCAT project.
  11. Select I/O.
  12. Right-click Device1 (EtherCAT).
  13. If Scan Boxes is grayed out, select Restart TwinCAT (Config Mode).

      NOTE

      TI Box n (ti-esc) is automatically detected.

    • If running TwinCAT 2 on Windows XP, select Device1 (EtherCAT)
      1. Navigate to TwinCAT.
      2. Select Reload Devices.
    • If running TwinCAT 3 on Windows 7, select Device1 (EtherCAT).
      1. Navigate to TwinCAT.
      2. Select Reload Devices.
  14. Select Scan Boxes.
  15. When asked to load I/O devices, select Yes.
  16. When asked to confirm to activate free run, select Yes. (TI ESC will enter OP mode.)
  17. The application turns on the digital out LEDs 1 through 8. (This indicates that slave is on and in INIT state.)
    1. To display the EtherCAT device state, select a device.
    2. Select the Online tab. (The device should be in the OP state with no lost frames or Tx / Rx / Errors.)
  18. TIDEP0025 tidu800_fig6.png
    If another mode is shown or if errors appear, reinitialize the interface by performing step 13.
    Figure 6. TwinCAT Status UI
  19. Right-click on MOTION → Select "Add new Item..."
  20. Select "NC/PTP NCI Configuration" to put "NC-Task 1 SAF" under MOTION.
  21. TIDEP0025 nci_confg.pngFigure 7. NC/PTP NCI Configuration
  22. Right-click on "MOTION→ NC-Task 1 SAF→ Axes" and select Add new Item...
  23. Select "Continuous Axis" Type and Click on OK. This adds "Axis 1" under Axes.
  24. Go to the Settings Tab under Axis 1. Select "CANopen DS402/Profile MDP 742" as the Axis Type.
  25. TIDEP0025 select_axis_type.pngFigure 8. Select Axis Type
  26. Now the Device variables must be linked to the axis variables, as shown in Table 1.
  27. Table 1. Axis Variables

    Device NC Axis
    Box1 → Module 1→ Inputs → Status Word Axis 1 → Drive → In → nState1 + nState2
    Box1 → Module 1→ Inputs → ActualPosition Axis 1 → Enc → In → nDataIn1
    Box1 → Module 1→ Outputs → Control Word Axis 1 → Drive → Out → nCtrl1 + nCtrl2
    Box1 → Module 1→ Outputs → TargetPosition (required only in csp mode) Axis 1 → Drive → Out → nDataOut1
    Box1 → Module 1→ Outputs → TargetVelocity (required only in csv mode) Axis 1 → Drive → Out → nDataOut2

    For the Status Word and Control Word, continuous process data mapping is required. This can be performed in the linking window (for example, the Status Word link window in Figure 9). Enable “All Types”, “Continuous” and select the desired variables. TwinCAT maps “nState1” to the low byte and “nState2” to the high byte of the Status Word.

    TIDEP0025 status_word_link.pngFigure 9. Status Word Link Window
  28. Update the Operation Mode of the Device to DC-Synchron: Box 1 → DC Tab → Operation Mode → Select DC-Synchron.
  29. Update the Encoder Scaling Factor: Axis 1 → Enc → Parameter Tab → Set value of "Scaling Factor Numerator" to "0.000343323".
  30. The formula to calculate the Scaling Factor is enc.scaling = (mm/rev)/encoder resolution. In this application, the encoder resolution is set to 2^20 = 1048576. Taking 360 mm per rev. The scaling factor is calculated as (360/1048576) = 0.000343323.

    (Only required for csv mode) Update the Output Velocity Scaling Factor : Axis 1 → Drive → Parameter Tab → Position and Velocity Scaling → Set value of "Output Scaling Factor (Velocity)" to "7500.007152564"

    The formula to calculate the Output Velocity Scaling Factor is velo.scaling = (2^20 / encoder resolution) * (velo resolution / 139.81). In this application, the encoder and velocity resolution are both set to 2^20 - 1048576. Therefore, the scaling factor is calculated as (2^20/2^20) * (2^20/139.81) = 7500.007152564. The encoder and velocity resolution are set as macros in the the patched cia402appl.c.

    #define TWINCAT_SINGLE_TURN_RES pow(2, 20) #define TWINCAT_VELOCITY_RES pow(2, 20)

    Updating these values will also require updating the scaling factors accordingly.

    The formula to calculated the scaling factor is described in the EtherCAT Slave Stack Code Application Note ET9300

    TIDEP0025 Scaling_factor.pngFigure 10. Scaling Factor
  31. Start the TwinCAT System in Run Mode. Click on "Activate Configuration" to do the same.
  32. TIDEP0025 active_config.png
  33. The default module added in the Box is the combined "csv, csp - axis". To select either csv or csp, the Box 1 → Module 1 → Outputs → ModeOfOperation variable must be set..
  34. For csp → ModeOfOperation = 8

    For csv → ModeOfOperation = 9

    Refer to the ETG 6010 CiA402 Implementation Directive for details on the ModeOfOperation variable values.

    TIDEP0025 set_value_dialog.pngFigure 11. Set Mode of Operation
  35. To enable the axis control, Select "Online" Tab under "Axis 1". Click on Set button under Enabling section. Tick all the options and set Override % to 100.
  36. TIDEP0025 set_enabling.pngFigure 12. Enable Axis Control
  37. The setup is now complete. To test the Motor Control, set the Target Position and Target Velocity. Click on Start Button (F5). The Motor turns and stops at the specified target position.
  38. TIDEP0025 setup_complete.pngFigure 13. Setup Complete