I am unable to read the encoder parameters in a project using TIA Portal Openness v16

81 Views Asked by At

I am trying to read the encoder parameters "p408[0]", "p421[0]", "p423[0]" and "p407[0]" using TIA openenss and I am out of ideas on how to make it work. I have tried different approaches for example:

I have tried reading the parameters the same way I find them in the project using TIA Portal V16 itself meaning the same way I find parameters in the drive where the motor and its encoder are located

DeviceItem selectedDeviceItem = null;
Invoke(new MethodInvoker(delegate
{
selectedDeviceItem = GetSelectedDeviceItem(); /*this looks at the treenode selected by the user and determines which drive is represented by that node*/
}));
DriveObject SelectedDrive = TiaServer.GetDriveObjectService(selectedDeviceItem);
DriveParameter deviceParameter;
selectedDeviceItemName = selectedDeviceItem.Name;
deviceParameter = SelectedDrive.Parameters.Find(ParSingleOnline);

This results in the program simply not finding the parameter.

I have tried reading the encoder configuration

DeviceItem selectedDeviceItem = null;
Invoke(new MethodInvoker(delegate
{
selectedDeviceItem = GetSelectedDeviceItem();
}));
DriveObject cuDriveObject = selectedDeviceItem.GetService().DriveObjects[0];
DriveFunctionInterface cuDriveFunctionInterface = cuDriveObject.GetService();
HardwareProjection encoderProjection = cuDriveFunctionInterface.HardwareProjection;
EncoderConfiguration encoderConfiguration = encoderProjection.GetCurrentEncoderConfiguration(1);
EncoderConfiguration config = EncoderProjection.GetCurrentEncoderConfiguration(1);

This results in the config.RequiredConfigurationEntries.ToList() being an empty list.

I have also tried looking for the parameters in the motor(It's the selectedDeviceItem.Items[1]) and motorConfiguration, and the selectedDeviceItem is definitely not mistakenly choosing a different or empty drive as I cross-checked by debugging and using the TIAOpennessExplorer.

What should I do to read the encoder parameters?

Thank you in advance.

0

There are 0 best solutions below