3.6. Process Data Memory

All mapped process data objects of the SubDevices are copied by the MainDevice into a process data memory image. New input values received from the SubDevices are written to the input process data image. New output values to be sent to the SubDevices are read from the output process data image.

The EC-Master uses two separate buffers where process data input values and process data output values are stored. The buffers used may either be always the same (fixed buffers) or be changed on every process data transfer cycle (dynamic buffers).

The EC-Master has different options for how the process data memory is provided.

  1. EC-Master provides process data memory (fixed buffers)

  2. User application registers an external memory provider with fixed buffers

  3. User application registers an external memory provider with dynamic buffers

3.6.1. EC-Master as process data memory provider

If the application does not register a memory provider, the EC-Master internally allocates the required memory needed to store input and output process data values during emConfigureNetwork(). The EC-Master always uses the same buffers for reading/writing process data.

skinparam monochrome true
skinparam  SequenceBoxBorderColor transparent
hide footbox

participant App as "Application"
box
participant EcMaster as "EC-Master"
database "PD-Memory"
end box

activate App

App->EcMaster : emExecJob(eUsrJob_ProcessAllRxFrames)
activate EcMaster
EcMaster->EcMaster : Receive Frames
EcMaster->"PD-Memory" : Write Input
return
|||
App->EcMaster : emGetProcessImageInputPtr()
activate EcMaster
EcMaster->"PD-Memory"
activate "PD-Memory"
EcMaster<--"PD-Memory"
deactivate "PD-Memory"
App<--EcMaster : PD Input Pointer
deactivate EcMaster
|||
App<-"PD-Memory" : **Read Input**

App->App : Process
|||
App->EcMaster : emGetProcessImageOutputPtr()
activate EcMaster
EcMaster->"PD-Memory"
activate "PD-Memory"
EcMaster<--"PD-Memory"
deactivate "PD-Memory"
App<--EcMaster : PD Output Pointer
deactivate EcMaster
|||
App->"PD-Memory" : **Write Output**
|||
App->EcMaster : emExecJob(eUsrJob_SendAllCycFrames)
activate EcMaster
EcMaster<-"PD-Memory" : Read Output
EcMaster->EcMaster : Send Frames
return

3.6.2. Application as process data memory provider with fixed buffers

The application may register a memory provider with emIoCtl - EC_IOCTL_REGISTER_PDMEMORYPROVIDER in case the EC-Master shall use externally allocated memory to store input and output process data values.

skinparam monochrome true
skinparam  SequenceBoxBorderColor transparent
hide footbox

box
database "PD-Memory"
participant App as "Application"
end box
participant EcMaster as "EC-Master"

activate App

App->EcMaster : emExecJob(eUsrJob_ProcessAllRxFrames)
activate EcMaster
EcMaster->EcMaster : Receive Frames
EcMaster->"PD-Memory" : **Write Input**
return
|||
App<-"PD-Memory" : Read Input
App->App : Process
App->"PD-Memory" : Write Output
|||
App->EcMaster : emExecJob(eUsrJob_SendAllCycFrames)
activate EcMaster
EcMaster<-"PD-Memory" : **Read Output**
EcMaster->EcMaster : Send Frames
return

The memory provider may optionally supply callback functions to synchronize memory access between the application and the EC-Master.

Receiving new input process data:
Sending new output process data:

skinparam monochrome true
skinparam  SequenceBoxBorderColor transparent
hide footbox

box
database "PD-Memory"
participant App as "Application"
end box
participant EcMaster as "EC-Master"

activate App
App->EcMaster : emExecJob(eUsrJob_ProcessAllRxFrames)
activate EcMaster
EcMaster->EcMaster : Receive Frames
EcMaster->App : pfPDInDataWriteRequest()
activate EcMaster
activate App
App-->EcMaster
deactivate App
EcMaster->"PD-Memory" : **Write Input**
EcMaster->App : pfPDInDataWriteRelease()
activate App
App-->EcMaster
deactivate App
|||
deactivate EcMaster
return
|||
App<-"PD-Memory" : Read Input
App->App : Process
App->"PD-Memory" : Write Output
|||
App->EcMaster : emExecJob(eUsrJob_SendAllCycFrames)
|||
activate EcMaster
EcMaster->App : pfPDOutDataReadRequest()
activate EcMaster
activate App
App-->EcMaster
deactivate App
EcMaster<-"PD-Memory" : **Read Output**
EcMaster->App : pfPDOutDataReadRelease()
activate App
App-->EcMaster
deactivate App
deactivate EcMaster

EcMaster->EcMaster : Send Frames
return

3.6.3. Application as process data memory provider with dynamic buffers

The application registers an external memory provider without fixed buffers via emIoCtl - EC_IOCTL_REGISTER_PDMEMORYPROVIDER with the parameters EC_T_MEMPROV_DESC::pbyPDInData and EC_T_MEMPROV_DESC::pbyPDOutData set to EC_NULL. In this case, the EC-Master requests via the callback functions the buffer addresses cyclically when reading or writing process data. This mode can be used to implement dynamic buffering mechanisms between the application and the EC-Master, e.g. double buffering, triple buffering.

skinparam monochrome true
skinparam  SequenceBoxBorderColor transparent
hide footbox

box
database "PD-Output"
database "PD-Input"
participant App as "Application"
end box
participant EcMaster as "EC-Master"

activate App
App->"PD-Input" : allocPdInBuffer()
activate "PD-Input"
App<--"PD-Input" :
|||
App->EcMaster : emExecJob(eUsrJob_ProcessAllRxFrames)
activate EcMaster
EcMaster->EcMaster : Receive Frames
EcMaster->App : pfPDInDataWriteRequest()
activate EcMaster
activate App
App->"PD-Input" : requestPdInBuffer()
"PD-Input"-->App
App-->EcMaster : return PdInBuffer
deactivate App
EcMaster->"PD-Input" : **Write Input**
EcMaster->App : pfPDInDataWriteRelease()
activate App
App->"PD-Input" : releasePdInBuffer()
App<--"PD-Input"
App-->EcMaster
deactivate App
|||
deactivate EcMaster
return
|||
App<-"PD-Input" : Read Input
activate App
App->App : Process
App->"PD-Input" : freePdInBuffer()
App<--"PD-Input"
deactivate "PD-Input"
App->"PD-Output" : allocPdOutBuffer()
activate "PD-Output"
App<--"PD-Output"
App->"PD-Output" : Write Output
deactivate App
|||
App->EcMaster : emExecJob(eUsrJob_SendAllCycFrames)
|||
activate EcMaster
EcMaster->App : pfPDOutDataReadRequest()
activate EcMaster
activate App
App->"PD-Output" : requestPdOutBuffer()
"PD-Output"-->App
App-->EcMaster : return PdOutBuffer
deactivate App
EcMaster<-"PD-Output" : **Read Output**
EcMaster->App : pfPDOutDataReadRelease()
activate App
App->"PD-Output" : freePdOutBuffer()
App<--"PD-Output"
deactivate "PD-Output"
App-->EcMaster
deactivate App
deactivate EcMaster

EcMaster->EcMaster : Send Frames
EcMaster-->App