I have 2 D5065 motors (from ODrive shop) controlled by a single ODrive (v3.6 56V, last devel firmware), powered by a 24V power supply (for now).
Instructions come as step/dir from an Arduino Mega, running a modified GRBL. It is only used to control M0. M1 is then mirrored form M0 encoder with an offset.
For each axis, a 8192 CPR encoder is used (AMT102-V, from ODrive shop again), directly on motor shaft.
At each end of both rails, there are min and max endstops.
Unfortunately, I can only control my ODrive with the setp/dir form the GRBL.
That is why I thought of using the homing procedure with a defined offset.
Do I use the wrong endstop parameters or maybe I understood wrong what it is supposed to do?
Move the gantry by hand to the location you want to call “0”. Measure the distance from the endstop to the gantry (the part that will touch the encoder). The encoder.config.offset will be the negative of this value, in turns. (say -1.25 for 1.25 turns). When you ask the drive to home with AXIS_STATE_HOMING, it will automatically handle this offset.
You can’t home the axis by running into the endstop while in CLOSED_LOOP.
Sorry for the delay. I had to solve new electrical issues before I could try your solution.
Sadly, it still doesn’t fully work. The AXIS_STATE_HOMING gives proper reaction when asked after a normal start (config.startup_homing = False).
However, when homed during the startup process (config.startup_homing = True, just after motor and encoder calibration), it makes erratic moves:
For each axis:
powering the ODrive
motor calibration
index search
moves toward min endstop
touches the min endstop
moves back slowly by the number of turn defined by the encoder.config.offset (and I don’t get why, but it works for me with positive values)
And that is where I encounter issues, different from my original post
After a few weeks of getting back to fresh firmware and parameters, I think I understand better what is going wrong.
It appears that, for a “standard” control method, the homing sequence works obviously well, during startup as well as any given time AXIS_STATE_HOMING is requested.
However, when coupled with step/dir control, homing at startup doesn’t properly work, and gives the sequence I originally described:
I tried switching and it gave me the same result.
For context, current GPIO are:
1:axis0.min_endstop
2:axis0.max_endstop
3:axis1.min_endstop
4:axis1.max_endstop
5:NC
6:NC
7:Dir
8:Step
For context, here are the 2 graphs for both circular_setpoints = False and True.
I tried my best to start from the same arbitrary point near the middle of my axis.
circular_setpoints = False
Here, once AXIS_STATE_HOMING is requested, it moves as it is supposed to: