TIDUF42 January   2024

 

  1.   1
  2.   Description
  3.   Resources
  4.   Features
  5.   Applications
  6.   6
  7. 1System Description
    1. 1.1 Terminology
    2. 1.2 Key System Specifications
  8. 2System Overview
    1. 2.1 Block Diagram
    2. 2.2 Design Considerations
    3. 2.3 Highlighted Products
      1. 2.3.1 EnDAT 2.2 Interface
      2. 2.3.2 SDFM Interface
      3. 2.3.3 EPWM Interface
      4. 2.3.4 ICSS-PRU IEP
      5. 2.3.5 EtherCAT CiA402 Velocity Control
  9. 3System Design
  10. 4Hardware, Software, Testing Requirements, and Test Results
    1. 4.1 Hardware Requirements
    2. 4.2 Software Requirements
    3. 4.3 Test Setup
    4. 4.4 Test Results
  11. 5Design and Documentation Support
    1. 5.1 Design Files
      1. 5.1.1 Schematics
      2. 5.1.2 BOM
    2. 5.2 Tools and Software
    3. 5.3 Documentation Support
    4. 5.4 Support Resources
    5. 5.5 Trademarks
  12. 6About the Author

System Design

R5F_0_1 Initialization

Use the following steps to initialize R5F_0_0 for motor 1 (single_chip_servo_remote_core_start):

  1. Set up GPIO pin direction and initial values (init_gpio_state)
  2. Disable EPWM (enable_pwm_buffers)
  3. Set up EPWM frequency and interrupt for motor 1 (init_pwms)
  4. Set up ICSSG0 PRU1 for EnDAT 2.2 motor 1 (channel 0, init_encoder)
    • Configure g_mux_en to 1 in ICSSG_SA_MX_REG Register. HW_WR_REG32((CSL_PRU_ICSSG0_PR1_CFG_SLV_BASE+0x40), (0x80))
    • Register & enable ICSSG EnDat PRU FW interrupt
      • Interrupt number: ICSSG_PRU_ENDAT_INT_NUM
      • Callback function: pruEncoderIrqHandler
    • Set up the EnDat 2.2 parameters
      • gEndat_multi_ch_mask = ENDAT_MULTI_CH0 | ENDAT_MULTI_CH2;
      • gEndat_is_multi_ch = CONFIG_ENDAT0_MODE & 1;
      • gEndat_is_load_share_mode = CONFIG_ENDAT0_MODE & 2;
    • Initialize ICSSG0 PRU1 (endat_pruss_init)
    • Initialize the encoder using the encoder driver API (endat_init)
    • Configure the encoder using the encoder driver API (endat_config_multi_channel_mask)
    • Configure Delays based on the ICSSG frequency
    • Load and run the EnDat 2.2 PRU FW to ICSSG0 PRU1 (endat_pruss_load_run_fw)
    • Check initialization ack from firmware, with a timeout of 5 second (endat_wait_initialization)
    • Set default frequency to 16 MHz for 2.2 encoders (endat_init_clock)
    • Set propagation delay to make 16 MHz work at 300-MHz PRU (endat_handle_prop_delay(priv, 265))
    • SetsEnDat 2.2 FW to periodic triggering (endat_config_periodic_trigger)
    • Configures parameters for EnDat 2.2 FW periodic mode (endat_config_periodic_mode)
      • IEP0 CMP3 event for channel 0 (3000ns from start of PWM period)
      • IEP0 CMP6 event for channel 2 (3000ns from start of PWM period)
    • Start receiving EnData 2.2 data (endat_handle_rx)
  5. Set up ICSSG0 PRU0 for SDFM for motor 1 (init_sddf)
    • Initialize IEP0, configure SYNC0 SD clock (init_IEP0_SYNC)
    • Initialize ICSSG0 PRU0 (initIcss)
    • Register and enable ICSSG SDFM RTU FW interrupt
      • Interrupt number: ICSSG_RTU_SDDF_INT_NUM
      • Callback function: rtuSddfIrqHandler
    • Initialize RTU/PRU core for SDFM (initPruSddf)
      • RTU sample base address: gTestSdfmPrms.samplesBaseAddress
      • PRU sample base address: gTestSdfmPrms.samplesBaseAddress+0x80
    • Start IEP0 (start_IEP0)
    • Force SW sync for EPWM0. Other PWMs are synchronized through hardware sync daisy-chain (EPWM_tbTriggerSwSync)
    • Disable the EPWM output buffer (enable_pwm_buffers)
  6. Initialize the parameters for FOC (init_pids)
  7. Enable the EPWM output buffers for motor 1 (enable_pwm_buffers(TRUE))

R5F_0_1 Initialization

Use the following steps to initialize R5F_0_1 for motor 2 (single_chip_servo_remote_core_start):

  1. Set up EPWM frequency and interrupt (init_pwms) for motor 2
  2. Register and enable ICSSG EnDat PRU FW interrupt for motor 2
    • Interrupt number: ICSSG_PRU_ENDAT_INT_NUM+2
    • Callback function: pruEncoderIrqHandler2
  3. Register & enable ICSSG SDFM PRU FW interrupt for motor 2
    • Interrupt number: ICSSG_PRU_SDDF_INT_NUM
    • Callback function: pruSddfIrqHandler
  4. Initialize the parameters for FOC (init_pids)

Set up Interrupts

Use the following instructions to set the Interrupts and Handlers:

EPWM interrupt (50 kHz), ISR - App_epwmIntrISR (Motor 1) or App_epwmIntrISR2 (Motor 2)

  • Clear the EPWM interrupt

SDFM interrupts (50 kHz), ISR - rtuSddfIrqHandler (Motor 1) or pruSddfIrqHandler (Motor 2)

  • From sample 8192 to 16384, compute the SDFM channel offsets (0–2 or 3–5). The SDFM channel offsets are used in the FOC loop when PRECOMPUTE_LEVEL == NO_PRECOMPUTE
  • At sample 16384, write EPWM for Phase A, Phase B, and Phase C to lock the rotor to electrical 0 and disable SDFM interrupts
  • Clear interrupt at source

EnDAT 2.2 interrupt (50 kHz), ISR – pruEncoderIrqHandler (for Motor 1)

  1. Clear interrupt at source
  2. For sample 0 – 8192 doing nothing
  3. For sample 8193–16383:
    • Calculate mechanical and electrical angle offset (localEnDatGetSingleMulti)
  4. For sample 16384:
    • Find the average of the mechanical and electrical angle offset
    • Turn off all phases
    • Save the mechanical and electrical angle offset
  5. For sample after 16384:
    • Start FOC loop and unlock the rotor
    • Get the latest mechanical theta and multiturn position from the encoder (localEnDatGetSingleMulti)
    • Use calculated offset from electrical 0, 4 pole pairs
    • Running FOC loop to compute the space vector
    • Write next CMPA values. Swap cmp0 and cmp2 because the HW connect EPWM0 to Phase C and EPWM2 to Phase A
    • EPWM0 is actually uses EHRPWM2; EPWM1 is using EHRPWM1 and EPWM2 is using EHRPWM0
    • See the EPWM settings in example_syscfg of single_chip_servo_am243x-lp_r5fss0-0_nortos_ti-arm-clang for details
      GUID-20231023-SS0I-LDSJ-JZMW-SN7KDMK62R36-low.png Figure 3-1 EPWM Settings for Motor 1

EnDAT 2.2 interrupt (50 kHz), ISR – pruEncoderIrqHandler (for Motor 2)

  • Clear interrupt at source
  • For sample 0–8192 doing nothing
  • For sample 8193–16383:
    • Calculate mechanical and electrical angle offset (localEnDatGetSingleMulti)
  • For sample 16384:
    • Find the average of the mechanical and electrical angle offset
    • Turn off all phases
    • Save the mechanical and electrical angle offset
  • For sample after 16384:
    • Start FOC loop and unlock the rotor
    • Get the latest mechanical theta and multi-turn position from the encoder (localEnDatGetSingleMulti)
    • Use calculated offset from electrical 0, 4 pole pairs
    • Running FOC loop to compute the space vector
    • Write next CMPA values. Swap cmp0 and cmp2 because the HW connect EPWM0 to Phase C and EPWM5 to Phase A
    • EPWM0 is actually uses EHRPWM5; EPWM1 is using EHRPWM4 and EPWM2 is using EHRPWM3
    • See the EPWM settings in example_syscfg of single_chip_servo_am243x-lp_r5fss0-1_nortos_ti-arm-clang for details
      GUID-20231023-SS0I-QCCH-2Z63-KSKSFP5Z70N0-low.png Figure 3-2 EPWM Settings for Motor 2