bnjmnp / pysoem

Cython wrapper for the Simple Open EtherCAT Master Library
MIT License
99 stars 38 forks source link

CIA402 ControlWord Read/Write all bit's. #90

Open mithathacioglu opened 1 year ago

mithathacioglu commented 1 year ago

Hello friends.

Just i m trying servo motor enable on cia402.and this com. i need send and write some bits(x6040-Controlword) but if i try to read sdo_read,just only giving first bit.i need to read all bit.i have ABB MicroFlex e190 servo drive.

can anyone help me ?

bnjmnp commented 1 year ago

Do you (SDO)read the Controlword or the Statusword? I think reading the Controlword is not necessary.

mithathacioglu commented 1 year ago

hey @bnjmnp

yeah i dont read controlword but i need write,

for example page 7; https://library.e.abb.com/public/b4c48bcab7a34a67894a0725218170be/AN00256-ACS_drives_over_EtherCAT_via_CiA402_Rev_A_EN.pdf

this controlword dont have any subindex,but i need the control motor, seriously i dont understand PDO r/w,i think pdo r/w for this. can we solve this problem ?

mithathacioglu commented 1 year ago

can anyone help for this ?

Michaelicious commented 11 months ago

To read status you can read statusword 0x6041, after decoding with ctypes it returns whole int for me. you can try writing the int that translates to the binary you need, translate to binary using ctypes. here's my functions for enable, I have a custom readSDO() that decodes in the background using ctypes.c_uint16 for this specific object.

  def clearFaults(self):
        self.writeSDO(0x6040, 0, 128)            # Clear faults
        statusword = self.readSDO(0x6041, 0) 
        print(f'Cleared faults: 0x6040,0,value=128.\nstatusword 0x6041:\t{statusword}\n')
        # if statisword is something: return False
        # else: retrun True

    def enableSlave(self):
        print(f'Initial statusword:\n {self.readSDO(0x6041, 0)}\n')
        self.clearFaults()
        self.writeSDO(0x6040, 0, 6)
        print(f'Wrote 6. statusword:\n{self.readSDO(0x6041, 0)}\n')
        self.writeSDO(0x6040, 0, 7)
        print(f'Wrote 7. statusword:\n{self.readSDO(0x6041, 0)}\n')
        self.writeSDO(0x6040, 0, 15)
        print(f'Wrote 15. statusword:\n{self.readSDO(0x6041, 0)}\n') 

more of my code at issue #121 , Hope it helps.