bnjmnp / pysoem

Cython wrapper for the Simple Open EtherCAT Master Library
MIT License
96 stars 37 forks source link

How to write PDO mapping config #50

Closed tom9672 closed 2 years ago

tom9672 commented 2 years ago

We can use the default pdo mapping by this:

class OutputPdo(ctypes.Structure):
    _pack_ = 1
    _fields_ =[
        ('Control_Word',ctypes.c_uint16),
        ('Mode_Operation',ctypes.c_int8),
        ('Target_Position',ctypes.c_int32),
        ('Touch_probe_function',ctypes.c_uint16),
        ('physical_outputs',ctypes.c_uint32),
        ('bit_mask',ctypes.c_uint32)
    ]   

output_data = OutputPdo()

but how can we set the pdo mapping (write pdo mapping to device)?

I guess, use sdo to write to the address x1A00, x1600? but the pdos are lists of addresses, how to set the PDOS? so that i can select the pdos that i need instead of using the default.

rako233 commented 2 years ago

Take a look into CanOpen specs, how to to this. It doesn't work with all slaves though, because they can't be changed

bnjmnp commented 2 years ago

I think in CANOpen it is not the best direction to look into, there it is a bit different.

For each EtherCAT slave device, PDO change might be implement in another way.