Hello and thanks for your sharing your own experiences. Would you mind sharing the technical information below?
Switch limit type
Is your limit switch wired to an arduino board and then the arduino is connected to the odrive?If so, can you share the wiring From -To pinouts?
Would you be able to show a video how switch works?
If you are using arduino, would you mind sharing the sketch?
@Wetmelon
I had a look to your code, but couldn’t find why the GPIO 7 and 8 isn’t working as expected.
But one idea to void Axis::set_min_endstop_enabled(bool enable) in axis.cpp
you set interrupt_mode = GPIO_MODE_IT_RISING_FALLING. For debouncing isn’t it better to set it like:
I’ve updated the endstop branch again. To make the code cleaner, I’ve made each endstop an object. This means they now exist as objects within the axis context:
@Zennix@hbtousa Please pull the most recent Endstops branch to test with. I was able to fix the saving issue on my end, but I don’t have a good way to test the other settings. I also updated this branch to the most recent devel version, so it has other fixes.
I double checked that the correct states are shown. Thank for integrating the states again.
In [44]: odrv0.axis0.min_endstop.endstop_state_
Out[44]: False
In [45]: odrv0.axis0.min_endstop.endstop_state_
Out[45]: True
After giving a:
odrv0.axis0.requested_state = AXIS_STATE_HOMING
The motor is spinning, but no reaction to the min or max switch.
Emergency stop
Want to test the moving but the commands didn’t move the motor anymore.
AXIS_STATE_CLOSED_LOOP_CONTROL seems to be working, the motor holds it’s position.
But no move.
Reconnected to ODrive 375F365A3137 as odrv0
In [54]: odrv0.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL
In [55]: odrv0.axis0.controller.set_pos_setpoint = 0
In [56]: odrv0.axis0.controller.set_pos_setpoint = 1000
Seems that my version from 22th September isn’t the same as yours.
pressed min_switch
In [28]: odrv0.axis0.min_endstop.endstop_state_
Out[28]: True
released min_switch
In [29]: odrv0.axis0.min_endstop.endstop_state_
Out[29]: False
pressed max_switch
In [30]: odrv0.axis0.max_endstop.endstop_state_
Out[30]: True
released max_switch
In [31]: odrv0.axis0.max_endstop.endstop_state_
Out[31]: False
Homing
GPIO5 is not recognised. Motor didn’t stop by pressing the min_switch
Emergency stop
Reconnected to ODrive 375F365A3137 as odrv0
In [52]: odrv0.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL
In [53]: odrv0.axis0.controller.set_pos_setpoint = 1000
has no effect. Motor is not spinning.
With an ASCII command the motor is spinning. The max_switch stops the motor. The min_switch has no effect.
odrv0.axis0.controller.set_pos_setpoint = 1000 does nothing
odrv0.axis0.controller.set_pos_setpoint(1000, 0, 0) or odrv0.axis0.controller.pos_setpoint = 1000 are the correct commands
I specifically tested GPIO5, so that’s weird. I will check the differences with ASCII commands but I don’t think that should have any difference from USB (just your incorrect command)
Oh Sorry You are right, thats the wrong command. I’m testing mostly with the ASCII interface.
Homing and emergency stop is working with GPIO 6 - 8. -> Great work!!!
GPIO 5 and 4 are recognised in AXIS_STATE_IDLE only. In AXIS_STATE_HOMING they have no effect.
For debouncing I had to add two caps 47nF between the GPIOs and GND.
I checked also if I can use one GPIO for both max_switches. That works. That stops both axis.
Just updated to firmware 4.6, was hoping this would be in it, but I can’t seem to find odrv0.axis0.max_endstop. Any news on when this branch will be merged into the main branch?
there is still a problem with GPIO less than 6. Could you verify that?
If you only need 3 switches your are fine. But some applications will need four switches and I can’t get these GPIOs to work.