analogdevicesinc / PyTrinamic

TRINAMIC's Python Technology Access Package.
Other
61 stars 36 forks source link

Missing reference search for module 6214 #96

Open petertumfart opened 1 year ago

petertumfart commented 1 year ago

Hi, there is no command for the reference search implemented for module 6214.

JeffPS13 commented 1 year ago

Hello, was the reference search implemented for module 6214?

trinamic-bp commented 1 year ago

Hi. There is no TMCL command that triggers some kind of homing routine (reference search). Something like this only exists for the CANopen firmware variant. With the TMCL firmware the host system must command such a procedure. Alternatively one could implement a homing routine with a TMCL script.

trinamic-bp commented 1 year ago

Sorry, this was not correct, the TMCM-6214 does implement the RFS command.

petertumfart commented 1 year ago

Hi you have to call it via the interface, not via the motor (which was kind of unintuitive to me).

interface.reference_search(0, axis_nr) starts the reference search interface.reference_search(1, axis_nr) stops the reference search interface.reference_search(2, axis_nr) returns the status

motor[i].set_axis_parameter(motor.AP.ReferenceSearchMode, val) Sets the homing mode

trinamic-bp commented 1 year ago

Right, this is not very nice.

This is how it would look like in a minimal script:

from pytrinamic.connections import ConnectionManager
from pytrinamic.modules import TMCM6214

connectionManager = ConnectionManager("--interface kvaser_tmcl")

with connectionManager.connect() as myInterface:
    module = TMCM6214(myInterface)

    for i, motor in enumerate(module.motors):
        motor.set_axis_parameter(motor.AP.ReferenceSearchMode, 2)  # Search right stop switch, then search left stop switch.
        module.interface.reference_search(0, i)  # Start reference search

We could add a per motor function like with the TMCM-3110: TMCM3110.py#L42, to make it look better.

JeffPS13 commented 1 year ago

Thank you both for the support. It would be great to have it implemented as a per motor function.