diff --git a/canopen/objectdictionary/__init__.py b/canopen/objectdictionary/__init__.py index f394da23..ea7c3bdf 100644 --- a/canopen/objectdictionary/__init__.py +++ b/canopen/objectdictionary/__init__.py @@ -484,8 +484,12 @@ def decode_phys(self, value: int) -> Union[int, bool, float, str, bytes]: def encode_phys(self, value: Union[int, bool, float, str, bytes]) -> int: if self.data_type in INTEGER_TYPES: - value /= self.factor - value = int(round(value)) + if self.factor == 1: + pass + elif isinstance(value, int) and isinstance(self.factor, int): + value = value // self.factor + else: + value = int(round(value / self.factor)) return value def decode_desc(self, value: int) -> str: