Writing a new interface for a new EtherCAT slave

Hints

int64_t getPosition()

The position is often sent as a 32 bit signed integer (~4*e+9 different values). With a high-resolution encoder, this value can easily overflow.

To avoid this problem use a method implementation like this:

int64_t EtherCATInterfaceElmo::getPosition(int driveNumber)
{
	int32_t rawPos = ll_getPositionActualValue(driveNumber);
	int32_t diff = rawPos - drives[driveNumber].prevRawPos;
	drives[driveNumber].prevRawPos = rawPos;
	drives[driveNumber].absPos += static_cast<int64_t>(diff);
 	return drives[driveNumber].absPos + static_cast<int64_t>(drives[driveNumber].posOffset);
}