Application Note V4.1.0.0

Basis

The PROFIdrive Application Example is based on:

Target Specifics

  • XCTRIGGER0_IRQHandler activation done in main.c.

((trigger_irq_app_Type*) trigger_irq_app_BASE)->trigger_irq_cfg_b.xc_trigger_out_polarity = 1u; ((trigger_irq_app_Type*) trigger_irq_app_BASE)->trigger_irq_msk_set_b.xc_trigger_out_edge = 1u; DRV_NVIC_EnableIRQ(trigger_out_edge0_IRQn); DRV_NVIC_SetPriority(trigger_out_edge0_IRQn, XCTRIGGER_IRQ_PRIORITY, 0);

Application Demo Specifics

  • Backward compatibility: Standard Telegrams 1 and 2 correspond to AC1. These are also supported for AC4. They do not require IRT (Isochronous mode).

    • PNS runs in free-run mode;

    • One timer (1ms) is initialized and started by the application. xChannelIORead/Write happen on this timer interrupt. PROFIdrive processing (State Machines, etc.) and setting/getting speed setpoint/actual speed to/from FOC happens on this timer interrupt as well;

    • Acyclic stuff (PROFIdrive parameters) happen in the main “while” loop.

  • Standard Telegram 3 (needed for AC4) requires IRT (isochronous mode). Implementing isochronous application needs:

    • Synchronization with the Bus Cycle:

      • Done via interrupt function for Sync 0 (XCTRIGGER0_IRQHandler);

      • In case of IRT, in the XCTRIGGER0_IRQHandler Controller Outputs are read (xChannelIORead), values are converted to PROFIdrive values and PROFIdrive processing is done (Axis State Machine, etc.).

    • Applying Controller Outputs (e.g. speed setpoint) on a specific time T_IO_Output within the Bus Cycle. It is configured via the engineering system (e.g. TIA Portal), depends on the GSDML and, finally, is communicated by the PLC to the device via record with index 0x8030:

      • At Bus Cycle start (XCTRIGGER0_IRQHandler), Timer 2 is started (timer period = T_IO_Output - T_AO, see the diagram “Processing Controller Outputs“. T_AO is the time it takes to apply the outputs to the motor). On timer interrupt, speed setpoint is applied to the motor (FOC) and the timer is stopped.

    • Fetching Controller Inputs (e.g. actual speed) on a specific time T_IO_Input. Sent in the next Bus Cycle. Also communicated by the PLC to the device via record with index 0x8030.

      • At Bus Cycle start (XCTRIGGER0_IRQHandler), Timer 1 is started (configured with a specific time T_IO_Input, see the diagram “Processing Controller Inputs“). On timer interrupt, speed and position actual values are fetched, xChannelIOWrite is called and the timer is stopped.

Processing Controller Outputs (DPM Input)

Processing Controller Inputs (DPM Outputs)

Timer 1 and 2 Sequence

Timings and Bus Cycle period are exemplary. They can be changed via TIA Portal configuration.

Measured Timings

The following diagrams depict measured timings in Debug and Release modes.

Please note that measured durations change between some limits during the measurement. The measured limits are shown on the diagrams (no statistical observations were performed).

Changes

This section lists briefly the changes made in the PROFIdrive Application Example compared to the examples in the previous section.

HOSTAL

  • Declared are three timers:

/* Arm Timer 1 is used for handling the registered Timer1 callback - * cyclic output process data (Controller input). */ static DRV_TIM_HANDLE_T s_tArmTimer1; /* Arm Timer 2 is used for handling the registered Timer2 callback - * cyclic input process data (Controller output). */ static DRV_TIM_HANDLE_T s_tArmTimer2; /* Systick is used for counting 1 ms ticks. */ static DRV_TIM_HANDLE_T s_tSystick;
  • Implemented are the callbacks:

DRV_TIM_TIMER1_Callback DRV_TIM_TIMER2_Callback
  • Function for timer initialization is added:

  • Functions for registering timer callback, enabling and disabling callbacks are added:

cifXApplicationDemo Component

  • Defined are callback functions for two “Application Job”-s: for applying Inputs and Outputs separately, with specific timings. Needed for the IRT mode (Application Class 4).

  • In function App_ApplicationDemo: the callbacks are registered with the two ARM Timers: ARM Timer 1 and 2. Timer 1 (only) is started here with a period of 1ms.

cifXApplicationDemoPNS Component

See also the section PNS Specifics.

  • AppPNS_ConfigureStack: in case of PROFIdrive Standard Telegram 3, activated is getting the stack cycle counter value in the DPM Input image (OEM 6). Needed for the proper IRT implementation of sending Controller Inputs;

  • AppPNS_DemoApplication.c implements:

- In IRT mode xChannelIORead and subsequent PROFIdrive calculations (like Ramp generator, State Machine state, etc.) happen here;

- In non IRT mode this function does nothing.

  • AppPNS_DemoApplication_IOTask is called on Timer 1 and 2 interrupt to apply Controller Outputs and prepare and send (xChannelIOWrite) the Controller Inputs respectively.

PROFIdrive Component

  • pdrv_application.c: the former PdrvApp_Main() function did all the PROFIdrive processing (Ramp function generator, Axis State Machine, applying setpoint value, getting speed actual value, Sensor State Machine and actual position value). In order to implement properly the IRT mode, this function is separated in:

  • PdrvApp_ProcessInputs : PROFIdrive processing based on process data values read from the bus (Ramp function generator, Axis State Machine, Sign-of-Life calculation).

  • PdrvApp_ApplyInputs: Applies speed setpoint value to the motor.

  • PdrvApp_ProcessOutputs: Gets speed and position actual values from the Motor Control layer (FOC), calculates ZSW Bit 10 (speed reached), drives the Sensor State Machine.

PNS Specifics

  • In case of Standard Telegram 3 (PROFIdrive AC4, IRT mode), “Set Trigger Type Request“ service is used to disable Free-run mode and enable synchronization to the Bus cycle start:

  • In case of Standard Telegram 3 (PROFIdrive AC4, IRT mode), the “Set OEM parameterservice with parameter 6 is called before channel init to map the PROFINET cycle counter in the DPM Input data;

  • Handled is the “Write Record“ indication for Index 0x8030 (Isochronous Mode Data). The values for Data cycle, IO_Input, IO_Output and CACF are stored by the Application. Based on these, timings for Timer 1 and 2 initialization are calculated afterwards, in “Parameter End“ indication.

  • “Parameter End“ indication handling:

    • In case of IRT mode (Record with index 0x8030 received from the PLC): calculate Timer 1 and 2 period, initialize the timers (without starting them);

    • In case of IRT mode: set the Bus Cycle period to FOC (needed for MPWM synchronization).

GSDML

  • Added is IsochroneModeInRT_Classes="RT_CLASS_3" in the InterfaceSubmoduleItem node;

  • Added is ApplicationClass="Isochronous" to the node CertificationInfo;

  • Added a submodule definition for PROFIdrive Standard Telegram 3;

  • The latter has a child node:

<IsochroneMode IsochroneModeRequired="true" T_DC_Base="8" T_DC_Max="16" T_DC_Min="1" T_IO_Base="1000" T_IO_InputMin="300" T_IO_OutputMin="300"/>