Understand the difference between real-time data exchange with PDOs and periodic service channel messages with SDOs in EtherCAT, and learn how to read, write, and configure these using RapidSetup and the RapidCode API.
In EtherCAT, values are sent and received from most drives using CANopen PDOโs and SDOโs. In most applications, RapidCode API users need not be aware of these low-level features.
- PDO (Process Data Object) โ Real-time data sent to/from the MotionController to each drive/node for every sample period.
- SDO (Service Data Object) โ Service Channel messages which are not exchanged every cycle.
๐น What are PDOs?
PDOs or Process Data Objects are the values exchanged cyclically with every real-time sample of the MotionController (1kHz by default). For servo drives, these are values such as control/status information and position demand/feedback.
- Warning
- Multi-Threading Note
Writing to the same PDO values is not Multi-Threading safe.
Writing to different PDO values is Multi-Threading safe.
๐น PDO - Reading & Writing
Using RapidSetup
Open the RapidSetup tool then go to Tools > Network Data
Here you can see which PDOโs are being exchanged between our controller and your device/node(s).
![Network Data Page - RapidSetup v8.1.5](https://support.roboticsys.com/assets/image (192).png)
Using RapidCode API
Reading Inputs
public void NetworkInputs()
{
for (int i = 0; i < inputCount; i++)
{
}
}
int32_t NetworkInputBitOffsetGet(int32_t index)
uint64_t NetworkInputValueGet(int32_t index)
int32_t NetworkInputCountGet()
Get the number of PDO inputs found on the network.
int32_t NetworkInputBitSizeGet(int32_t index)
Get the size (in bits) of a network input.
const char *const NetworkInputNameGet(int32_t index)
Get the name of a PDO network input.
Reading and Writing to Outputs
public void NetworkOutputs()
{
for (int i = 0; i < outputCount; i++)
{
}
}
uint64_t NetworkOutputValueGet(int32_t index)
Gets the value sent out over EtherCAT.
void NetworkOutputOverrideValueSet(int32_t index, uint64_t outputValue)
Sets a PDO output directly.
void NetworkOutputOverrideSet(int32_t index, bool outputOverride)
Set NetworkOutputValue to override RMP cyclic value.
int32_t NetworkOutputCountGet()
const char *const NetworkOutputNameGet(int32_t index)
Get the name of a PDO output.
int32_t NetworkOutputBitSizeGet(int32_t index)
Get the size (in bits) of a PDO output.
int32_t NetworkOutputBitOffsetGet(int32_t index)
Get the raw PDO offset for an output.
- Note
- Be sure you know what you are doing if you choose to Override an Output. Any automated process which was writing to it, will no longer have control and will not be aware that someone else is in charge.
๐น PDO - Injection
You can inject exchanged information by editing the EtherCATNodeInfo.xml file.
Let's say we want to read/write from the latch status, control, and positions SDOโs because communicating directly with the SDO takes too much time.
Follow the Example below for a solution.
PDO Injection Using EtherCATNodeInfo.xml File
In the EtherCATNodeInfo.xml file I can see that Yaskawa (for example) by default has the following PDOโs configuration:
<PDOs>
<PDOAssignment Index="0x1601" IsOutput="True" Include="False" />
<PDOAssignment Index="0x1a01" IsOutput="False" Include="False" />
<PDOAssignment Index="0x1600" IsOutput="True" Include="True" RemoveContent="0x6060 0x6072" />
<PDOAssignment Index="0x1a00" IsOutput="False" Include="True" />
</PDOs>
Take a look at the Yaskawa-SGD7S.xml ESI file, located in the ESI folder inside your RMP folder:
<Object>
<Index>#x60B8</Index>
<Name>Touch probe function</Name>
<Type>UINT</Type>
<BitSize>16</BitSize>
<Flags>
<Access>rw</Access>
<PdoMapping>RT</PdoMapping>
</Flags>
</Object>
<Object>
<Index>#x60B9</Index>
<Name>Touch probe status</Name>
<Type>UINT</Type>
<BitSize>16</BitSize>
<Flags>
<Access>ro</Access>
<PdoMapping>T</PdoMapping>
</Flags>
</Object>
<Object>
<Index>#x60BA</Index>
<Name>Touch probe 1 position value</Name>
<Type>DINT</Type>
<BitSize>32</BitSize>
<Flags>
<Access>ro</Access>
<PdoMapping>T</PdoMapping>
</Flags>
</Object>
<Object>
<Index>#x60BC</Index>
<Name>Touch probe 2 position value</Name>
<Type>DINT</Type>
<BitSize>32</BitSize>
<Flags>
<Access>ro</Access>
<PdoMapping>T</PdoMapping>
</Flags>
</Object>
You can add Entries by editing the EtherCATNodeInfo.xml file by making the following changes:
<PDOs>
<PDOAssignment Index="0x1601" IsOutput="True" Include="False" />
<PDOAssignment Index="0x1a01" IsOutput="False" Include="False" />
<PDOAssignment Index="0x1600" IsOutput="True" Include="True" RemoveContent="0x6060" />
<PDOAssignment Index="0x1a00" IsOutput="False" Include="True" />
<AddEntry Name="Touch probe 1 position value" Index="0x60BA" SubIndex="0" BitLen="32" DataType="DINT" />
<AddEntry Name="Touch probe status" Index="0x60B9" SubIndex="0" BitLen="16" DataType="UINT" />
<AddEntry Name="Touch probe 2 position value" Index="0x60BC" SubIndex="0" BitLen="32" DataType="DINT" />
</PDOAssignment>
</PDOs>
This works well for Inputs <Access>ro</Access> like Touch probe values and status. But it does not work currently for Outputs <Access>rw</Access> such as the Touch probe function (0x60B8). Right now if you add an output in, we will write 0 into it every cycle. Unless you Override the sent value (see next section).
๐น PDO - Output Value Override
Using RapidSetup
All you need to do is set the value under the OVERRIDE VALUE column and then check the checkbox under the OVERRIDE column. (See image below)
![Network Data Page - RapidSetup v8.1.5](https://support.roboticsys.com/assets/image (520).png)
Using RapidCode API
Enabling Override Feature
motionController.NetworkOutputOverrideSet(index, outputOverride);
- Note
- Where:
index โ the PDO Network Output index to read from. outputOverride โ boolean that will enable or disable the override feature for specific PDO index.
Setting Override Value
motionController.NetworkOutputOverrideValueSet(index, value);
- Note
- Where:
index โ the index of the PDO Network Output to Override.
outputOverride โ Your desired value (must be an unsigned 64-bit value, you may need to use a union)
๐น What are SDOs?
SDOs or Service Data Object are messages in a confirmed service with a kind of handshake. They are used for the access to entries of the object dictionary. Especially the configuration for the requested behavior of the drive adapted to the various possible applications is done by these objects.
- Note
- – SDOโs are not exchanged during every cycle, they are done periodically.
– Not as fast as PDOโs since they must wait for network response
๐น SDO - Reading & Writing
Using RapidSetup
The easiest way to read a SDO or write to an SDO is by using our RapidSetup utility then click on your drive node. (see images below)
![Node Page - RapidSetup v8.1.5](https://support.roboticsys.com/assets/image (353).png)
Using RapidCode API
SDO Writing
axis.NetworkNode.ServiceChannelWrite(index, subIndex, byteCount, value);
- Note
- Where:
index โ the memory address to write to.
subIndex โ the sub index to write to.
byteCount โ the number of bytes to write.
value โ the numeric value to write.
SDO Reading
axis.NetworkNode.ServiceChannelRead(index, subIndex, byteCount);
- Note
- Where:
index โ the memory address to read from.
subIndex โ the sub index to read from.
byteCount โ the number of bytes to read.
๐ Sample Code
- C#
for (int i = 0; i < inputCount; i++)
{
}
for (int i = 0; i < outputCount; i++)
{
}