Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

1. Example project

Basis for this exampe example is the Extended Config Example netX 90 - PROFINET IO Device - extendedConfig V2.2.0.0 , because an acyclic handling will be necessary to get the isochron isochronous data parameter.

Example for netX90:

netXStudio_PNSV5_extendedConfig Isochron isochronous - V1.0.0.2.zip


Basis for this exampe example is the Extended Config Example netX 90 - PROFINET IO Device - extendedConfig V3.0.0.0

netXStudio_PNSV5_extendedConfig Isochron isochronous - V1.1.0.0.zip

2. Changes for this example

There are many changes necessary. An interrupt function for sync0 signal is necessary which shall start timers to do the IO data update at the correct timepointtime point. For this, the following things have changed:

  1. The GSDML is changed to support isochron isochronous mode and the output module gets the option to let it run isochronisochronous.
  2. The IO data handler function is splitted split in 2 IO data handler. One for inputs and one for outputs. Each handler has its own timer which runs in RT and IRT connection with 1ms. Only in IRT isochron isochronous connection the timer timings will be changed.
  3. The set OEM parameter service with parameter 6 is called up before channel init is called up to map the Profinet cycle counter in the input data (plc to device).
  4. The set trigger type request is called up before channel init to disable freerun FreeRun mode.
  5. The hardware configuration maps the mmio MMIO to xtrigger0/Sync0 and the main function now calls up some functions to activate an interrupt service routine for xtrigger0.
  6. In the function for write record indication the parameter with index 0x8030 has been added.
  7. In the function for parameter end indication the values from index 0x8030 are used to calculate new timer settings.

...

As soon as a submodule supports isochron isochronous mode, the synchron synchronous mode for this submodule can be activated in the plc. The plc will write down the parameter with index 0x8030 in the connection establishment. The fuction function for write record indication is necessary to receive the parameter with the index 0x8030 from the plc.

For each isochron isochronous submodule a parameter with Index 0x8030 (Isochronus Isochronous Mode Data) will be sent from the plc to the device. The parameter with Index 0x8030 (isochronus isochronous mode data) consists of these informations:

...

}__HIL_PACKED_POST PNS_IF_PDU_ISOCHRONOUS_DATA_T;


Very important Essential are the slot and the subslot Subslot information. With this the application knows which IO data are requested to run as isochronisochronous.

The values for DatacycleData cycle, IO_Input, IO_Output and CACF need to be saved in the application. After receiving all 0x8030 parameter over the function write record indication, the application needs to calculate timings in the parameter end indication.

...

<IsochroneMode IsochroneModeRequired="false" T_DC_Base="8" T_DC_Max="16" T_DC_Min="1" T_IO_Base="1000" T_IO_InputMin="125" T_IO_OutputMin="60" />

T_IO_Output_Min + Spare spare is an application-specific timing. Start with setting this value to a high value. Later this value can be measured and reduced in the GSDML.

T_IO_Output - T_IO_Output_Min = This is the time the plc has calculated for the network and other timeoffsets time offsets to achieve that all isochron all isochronous devices apply data at the same point of time. This time can be diffent different in each network setup.


What does the application developer need to do now?

The application gets in the parameter with Index 0x8030 the time for T_IO_Output. T_IO_Output starts with Sync0 signal and the application needs to apply data if timepoint time point of T_IO_Output is reached. The application needs to start a timer with sync0 signal. Now the question ist, what time shall be used to configurate configure the timer? Here are some options:

...

There is a lot Jitter possible , because the time for processing the data can be different. 

...

It is better to call up xChannelIORead and data processing as soon as possible and to save the data for apply outputs until the correct point of time has come. Measure only the application-specific time to apply outputs. T_AO = time apply outputs which will be a short time.

Set the timer to T_IO_Output - T_AO. Then the application only needs to apply outputs as soon as the timerinterrupt timer interrupt is reached and there will be less Jitterjitter.


Parameter end indciationindication:

In this example the calculation for the times which are used for the output data handler timer is done in the parameter end indication.

T_IO_Output_Event = s_ab_RecordIsochronusData_Slot2_Subslot1.ulIO_Output -T_AO; //in nano secondsnanoseconds

with T_AO = 0

The application developer needs to set a value for T_AO. He can take, for example, the same value like as in the GSDML T_IO_OutputMin="60". The value T_AO must be in nano secondsnanoseconds.

5. Calculate Time for call of Input Handler 

...

T_IO_Input_Min is an application-specific timing. In the development process it is good to start with setting this value to a high value. Later this value can be measured and reduced in the GSDML.

...

The application gets in the parameter with Index 0x8030 the time for T_IO_Input. But the application needs the time from beginning with Sync0 signal. With the cycletime the cycletime, the application needs to calculate the correct time for the timer.

...

This calculation will be done in the parameter end indciationindication function:

T_IO_Input_Event = ((((uint32_t) s_ab_RecordIsochronusData_Slot2_Subslot1.usDataCycle) * 3125)*10) - T_IO_Input; //in nano secondnanosecond

6. Some more changes in GSDML

...

Add "IsochroneModeInRT_Classes="RT_CLASS_3" in the InterfaceSubmoduleItem.

Add IsochroneMode in the modulmodule, that shall support isochrone isochronal mode. Put it behind </ModuleInfo>

...

The Timings T_IO_InputMin="125" T_IO_OutputMin="60" are device-specific and need to be measured from the developer.

...

and add in main.c the interrupt fuction function for XCTIGGER_IRQHandler.

The XCTIGGER_IRQHandler starts 2 timers for the 2 IO data handler.

...

Disable the 1ms Input data handler and 1ms output data handler. Calculate the new timings for IO data handler timers and reconfigurate reconfigure the timers. The timers will be startet start with sny0/xtrigger0 signal in the interrupt service XCTRIGGER0_IRQHandler.

Code Block
languagecpp
void AppPNS_HandleParameterEndInd( APP_DATA_T* ptAppData)
{
  if (Get_Isochron_Data_available() == 1)
  {
    //calculate Timongs for isocron application
    T_IO_Input_Event = ((((uint32_t) s_ab_RecordIsochronusData_Slot2_Subslot1.usDataCycle) * 3125)*10) - T_IO_Input; //in nano seconds
    T_IO_Output_Event = s_ab_RecordIsochronusData_Slot2_Subslot1.ulIO_Output -T_AO; //in nano seconds
    HOSTAL_Callbacks_Disable(); // Disable 1ms timer
    HOSTAL_Callbacks_Disable2(); // Disable 1ms timer
    HOSTAL_Init_Isochron_Input_Timer( T_IO_Input_Event); // set Timer with new timing
    HOSTAL_Init_Isochron_Output_Timer( T_IO_Output_Event); // set Timer with new timing
    Set_Timer_Configuration_true();
  }

  PNS_IF_PARAM_END_RSP_T* ptParameterEndRes=( PNS_IF_PARAM_END_RSP_T*) &(ptAppData->tPacket);

  ptParameterEndRes->tHead.ulCmd |= 0x01; //PNS_IF_PARAM_END_RES;
  ptParameterEndRes->tHead.ulLen  = 8;
  ptParameterEndRes->tHead.ulSta  = SUCCESS_HIL_OK;
  ptParameterEndRes->tData.fSendApplicationReady = 1;

  (void)Pkt_SendPacket(ptAppData->hChannel[0], &ptAppData->tPacket, TX_TIMEOUT);


  return;
}

10. IO data

...

handlers

In the input IO data handler not much has changed. The input data handler now reads the input data and the stack cycle counter:

...

Another change of this input data handler is, that in case of isochron isochronous connection, the timer will be disabled , because the time shall restart with XCTRIGGER0_IRQHandler.

The output data handler is different. In case of isochron isochronous connection, the application needs to check if the correct cycle is reached. For that, the Index 0x8030 has the CACF value. If this value is not 1, the application needs to check for the correct cycle like this: if((App_stackcyclecounter % (Get_Isochron_DataCycle() * Get_CACF()))==0)

In the output data handler, in case of isochron isochronous connection, the timer will be disabled , because the time shall restart with XCTRIGGER0_IRQHandler.

Code Block
languagecpp
// Do update of RT modules isochron modules in the if cycle counter matches to CACF
    if((App_stackcyclecounter % (Get_Isochron_DataCycle() * Get_CACF()))==0)
    {
      HOSTAL_Sensor_GetData(0, &ptAppData->tOutputData.usSensor_1_Output);
      ptAppData->tOutputData.bSensor_1_State = HOSTAL_Sensor_GetState(0, &ptAppData->tAcyclicData.usSensor1_StatusCode);

      HOSTAL_Sensor_GetData(1, &ptAppData->tOutputData.usSensor_2_Output);
      ptAppData->tOutputData.bSensor_2_State = HOSTAL_Sensor_GetState(1, &ptAppData->tAcyclicData.usSensor2_StatusCode);

      ptAppData->tOutputData.bActuator_1_State = HOSTAL_Actuator_GetState(0, &ptAppData->tAcyclicData.usActuator1_StatusCode);
      ptAppData->tOutputData.bActuator_2_State = HOSTAL_Actuator_GetState(1, &ptAppData->tAcyclicData.usActuator2_StatusCode);

      lRet = xChannelIOWrite(ptAppData->hChannel[0], 0, 0, sizeof(ptAppData->tOutputData), &ptAppData->tOutputData, 0);
      if(lRet != CIFX_NO_ERROR)
      {
        /** Something failed?
         * Reason for error could be:
         * 1) netX is not "ready" yet. May happen during startup.
         * 2) netX is not "running" yet. May happen during startup in case the netX is not fully configured yet.
         * 3) netX has not yet established an IO connection. */
      }
    }
    else
    {
      // If an only RT module exists, do the update of this data. This example does not have 2 modules.
    }
    HOSTAL_Callbacks_Disable2(); // Disable Timer. Timer will be restarted as soon as Syn0/XCTRIGGER0_IRQHandler() comes

11

...

. SYCON.net cifX Card and netHost

Follow these steps:

PNS Configure Profinet IO Controller in IRT mode

and for isochron isochronous only activate the isochron isochronous mode:

12. TIA Portal

Create first a Synchronous Cycle OB.

...

Go to the device and set it to IRT mode. Under domain settings it is possbile possible to set the send clock sendclock for the plc.


Go to the isochronous mode. Activate isochronous mode and the modules that shall run isochronisochronous. Here the plc send clock is set to 500µs and the applicaton application cycle is 1ms. That will lead to a CACF = 2.


Go to the output submodul submodule and connect it with the Synchronous Cycle OB.

...