PNS Diagnostics Example

1. Example project

In this example, the application activates the PROFINET indications. For that, the application needs to call the request "Register Application".

The extendedConfig example can be found in the Knowledge Base on the following website:

netX 90: https://hilscher.atlassian.net/wiki/display/NXLFWHST/netX+90+-+PROFINET+IO+Device+-+Examples



This can alternatively be found under:

kb.hilscher.com → Software → LFW Host Examples → Profinet IO-Device → netX 90 APP / netX 51 → PROFINET IO Device - extendedConfig Vx.x.x.x

The extendedConfig project can be opened by double-clicking the ".solproject" file. This requires the latest version of netXStudio (https://hilscher.atlassian.net/wiki/display/NDT/).


2. PROFINET Sources

A GSDML file is required for this example. The GSDML file can be found in the netXStudio project in Project Explorer at:

netXxx_PNSVx_extendedConfig → Components → cifXApplicationDemoPNS → DeviceDescription → GSDML-V2.3x-HILSCHER-NETX xx-RE PNS-20xxxxxx.xml


The PacketHandler describes the acyclic packages and can be found in the Project Explorer under:

netXxx_PNSVx_extendedConfig → Components → cifXApplicationDemoPNS → Sources → AppPNS_DemoApplicationFunctions.c


The IO Data Handler describes the IO data that is exchanged between the application and the stack and can be found in the Project Explorer under:

    long SetModulConfig( void* pvPck )


The terminal handler uses the interface used by UART to display debug messages and is located in Project Explorer under:

netXxx_PNSVx_extendedConfig → Components → cifXApplicationDemo → Sources → App_TerminalHandler.c


The event handler shows the diagnoses and alarms, which can be found in the Project Explorer under:

netXxx_PNSVx_extendedConfig → Components → cifXApplicationDemo → Sources → App_EventHandler.c


3. Configuration packet

In the configuration can be set ptSetConfig->usMaxDiagRecords = 16;

This number need be smaler or same like the value used in the taglist of the firmware

In the example only the use of one diagnostic alarm ist demonstrated.

4. Add and Remove Diagnostics service

With the function Add Channel Diagnosis Request() the application can add a diagnosis to the stack. The stack will send an alarm frame to the IO Controler.

The Add Channel Diagnosis Request can be programmed in the AppPNS_DemoApplicationFunctions.c:

/**************************************************************************************
function:    AddChannelDiagnosisReq
description: Send AddChannelDiagnosisResponse.
 global:      none
input:       APP_DATA_T* ptAppData    - pointer to the packet
 output:      none
return:      void
**************************************************************************************/
void AppPNS_HandleAppAddChannelDiagnosisReq( uint16_t usSlot , uint16_t usSubslot, APP_DATA_T* ptAppData)
{
  ...
}


The conformation to this Add diagnostics service has a handle which is needed for remove the diagnostics. It is necessary to save this handle.

The Add Channel Diagnosis Confirmation can be programmed in the AppPNS_DemoApplicationFunctions.c:

/**************************************************************************************
function:    AddChannelDiagnosisCnf
description: Save DiagHandle
 global:      uint32_t  s_abDiagHandle - Handle for diagnostics alarms
input:       APP_DATA_T* ptAppData    - pointer to the packet
 output:      none
return:      void
**************************************************************************************/
void AppPNS_HandleAddChannelDiagnosisCnf( APP_DATA_T* ptAppData)
{
  ...
}


With the Handle from the Add diagnostics service it is possbile to remove the diagnostiv from the stack. After

call of remove diagnisis request, the stack sends a Alarm disappears to the controller.

The Remove Channel Diagnosis Request can be programmed in the AppPNS_DemoApplicationFunctions.c:

/**************************************************************************************
function:    RemoveDiagnosisReq
description: Send RemoveDiagnosis Reqest
 global:      uint32_t  s_abDiagHandle - Handle for diagnostics alarms
input:       APP_DATA_T* ptAppData    - pointer to the packet
 output:      none
return:      void
**************************************************************************************/
void AppPNS_HandleRemoveDiagnosisReq( APP_DATA_T* ptAppData)
{
  ...
}


5. Values from GSDML file

Please add the following colored keywords in the GSDML file:

Note: The diagnostic functions and diagnostic texts can be adapted and changed as required.


          <ChannelDiagList>


          <!--User Diagnosis - Example-->

               <ChannelDiagItem ErrorType="256">

                    <Name TextId="IDT_DIAG_EXAMPLE" />
                    <Help TextId="IDT_DIAG_HELP_EXAMPLE" />

               </ChannelDiagItem>

          </ChannelDiagList>

          <GraphicsList>
          </GraphicsList>

          <CategoryList>
          </CategoryList>

          <ExternalTextList>


                <PrimaryLanguage>

                     ...
                     <!--Generic Diagnosis-->
                     <!--#256-->
                     <Text TextId="IDT_DIAG_EXAMPLE" Value="Diagnosis is active" />
                     <Text TextId="IDT_DIAG_HELP_EXAMPLE" Value="Dip 3 in NXHX 90 Board is switched on" />           
         

                </PrimaryLanguage>

                <Language xml:lang="de">

                     ...
                     <!--Generic Diagnosis→
                     <!--#256-->

                    
<Text TextId="IDT_DIAG_EXAMPLE" Value="Diagnose ist aktiv"/>
                    
<Text TextId="IDT_DIAG_HELP_EXAMPLE" Value="Dip 3 im NXHX 90 Board ist eingeschaltet"/>

                </Language>

          <ExternalTextList>

7. Event Handler

In this example is the Protocol_EventHandler() used. This function can be found in AppPNS_DemoApplication.c.

The event handler case APP_EVENT_SET_ALARM3 and APP_EVENT_CLEAR_ALARM3 can be triggered with use of the DIP switch S700.3

S700.3 ON adds the diagnostics

S700.3 OFF removes the diagnostics


8. Trace

An alarm frame can be found with use of filter pn_rt.frame_id==0xfe01

If the application has implemented diagnostic alarms, then it is easy to produce an alarm.


Diagnostic Alarm.pcap

A dip switch is used to add an application diagnostic to the PROFINET IO Device stack. The device sends an alarm to the PLC. The PLC acknowledges this alarm.

After some seconds the dip switch was changes again to remove from application side the diagnostic from the PROFINET IO device stack. The device sends an Alarm disappears to the controller.


9. TIA Portal

In the code for add diagnostic request the value ErrType can be changed to show different diagnostics.

ptReq->tData.usChannelErrType = 0x100; (= 256) is the diagnostic defined in the GSDML file.

ptReq->tData.usChannelErrType = 0x2; is a standard definition for under voltage

Go online and connect to the device. Click on the device and go to the 10 Byte input. Open the online diagnosis.


Switch to diagnose status

Change DIP S700.3 to on and add the diagnosis on the Device.

10. SYCON.net

Here a netHost with SYCON.net is used. Connect to the netHost and open diagnosis of the PROFINET IO Controller

Switch to the Station Diagnosis. If the status is green, that means no diagnosis is on the device


Change DIP S700.3 to on and add the diagnosis on the device. In SYCON.net the status changes to yellow.