End switches an interrupts

Well I don’t seem to be able to flash my board. I followed al the directions for for both Mac & Linux, but I’m getting the same result:

> SepeMacBookPro-7:Firmware thomassepe$ make flash
> 
> openocd -f interface/stlink-v2.cfg -f target/stm32f4x.cfg -c init \
> 
> -c 'reset halt' \
> 
> -c 'flash write_image erase build/ODriveFirmware.elf' \
> 
> -c 'reset run' \
> 
> -c exit
> 
> Open On-Chip Debugger 0.10.0
> 
> Licensed under GNU GPL v2
> 
> For bug reports, read
> 
> http://openocd.org/doc/doxygen/bugs.html
> 
> Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
> 
> Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
> 
> adapter speed: 2000 kHz
> 
> adapter_nsrst_delay: 100
> 
> none separate
> 
> Info : Unable to match requested speed 2000 kHz, using 1800 kHz
> 
> Info : Unable to match requested speed 2000 kHz, using 1800 kHz
> 
> Info : clock speed 1800 kHz
> 
> Info : STLINK v2 JTAG v34 API v2 SWIM v7 VID 0x0483 PID 0x3748
> 
> Info : using stlink api v2
> 
> Info : Target voltage: 3.262921
> 
> Error: init mode failed (unable to connect to the target)
> 
> in procedure 'init' 
> 
> in procedure 'ocd_bouncer'
> 
> make: *** [flash] Error 1

hey
I upload with an STlink success, but I can not find any endstop commands in the odrv#.axis#.config
here is the config:
startup_motor_calibration = False (bool)

startup_encoder_index_search = False (bool)

startup_encoder_offset_calibration = False (bool)

startup_closed_loop_control = False (bool)

startup_sensorless_control = False (bool)

startup_homing = True (bool)

enable_step_dir = False (bool)

counts_per_step = 2.0 (float)

watchdog_timeout = 0.0 (float)

step_gpio_pin = 1 (int)

dir_gpio_pin = 2 (int)

lockin:

current = 10.0 (float)

ramp_time = 0.4000000059604645 (float)

ramp_distance = 3.1415927410125732 (float)

accel = 20.0 (float)

vel = 40.0 (float)

finish_distance = 100.0 (float)

finish_on_vel = False (bool)

finish_on_distance = False (bool)

finish_on_enc_idx = False (bool)

Hi,
did you use the ODrivetool coming with the firmware?

You can start the new ODrivetool by manually navigating to the ODrive/tools folder and calling ipython -i ./odrivetool

Greetings / Zennix

1 Like

Hi Zennix,
I have flashed the latest version, but it didn’t work.Switches are read correctly. I tested GPIO 1-8, none of them is recognized. when I pressed the switch , output is false, when I release the button, output state is false too.

In [5]: odrv0.axis0.min_endstop
Out[5]:
endstop_state = False (bool)
config:
gpio_num = 5 (int)
enabled = True (bool)
offset = -100 (int)
is_active_high = False (bool)
debounce_ms = 100.0 (float)

In [3]: odrv0.axis0.min_endstop
Out[3]:
endstop_state = False (bool)
config:
gpio_num = 6 (int)
enabled = True (bool)
offset = -100 (int)
is_active_high = False (bool)
debounce_ms = 100.0 (float)

If I set the state of startup_homing true, the motor will start homing after calibration, but still can not recognize the endstop.

So here is my questions:
Do I need erase the config after flashing?
or I need place a capacitor between GND and the GPIOs?

Cheers
Viffon

Hi

Try first changing NO and NC config.

Cheers

Hi,
your config: is_active_high = False (bool) means your switch connects Ground to the GPIO when it’s pressed. Is this correct? Otherwise you have to set it to True.

Please test with GPIO 6 - 8, I had problems with GPIOs below 6. Maybe you have to disable the UART port to get the ports free. I didn’t tested it yet.

Greetings / Zennix

1 Like

Hi,
I try to use configuration 2 shown below. Startup_homing is working now. And I tried GPIO 1- 8, all of them is recognized.
image

But I have another problem. After axis_homing, the current state is closed loop, then I set pos_setpoint = 102400, then the motor spin, and stopped when I pressed the max endstop. Then endstop thrown a error 8196 and the current state was IDLE. I want clear this error and get the state back to closed loop or axis_homing. But I set odrv0.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL or
odrv0.axis0.requested_state = 11, it not working , the current state still was IDLE. so what can I do, except reboot odrive.

Cheers

I can’t get homing to work. :frowning:

my micro switches are working, connected to pins 7 & 8 with 10K external pull-up resistors
I tried in both NC & NO positions. and configurations 1 & 2 respectively. I get “False” when they are not triggered and “True” when they are. So it does not appear to be the switches…

So after I run a full calibration and set closed loop control
then I initiate homing, firstly it ALWAYS moves in the positive direction.

even when I try:
odrv0.axis0.controller.config.homing_speed = -2000
it still moves in the positive direction when homing

and activating either of the switches does NOTHING. it just keeps moving in the positive direction once homing has been initiated.

Anyone have any suggestions?

I had the sam problem and it was because I was using git clone to get the endstop repository but it didn’t download the right tree! however just downloading the zip file from here https://github.com/Wetmelon/ODrive/tree/Endstops and then building from scratch and uploading I was able to get the endstop features

Try running odrv0.axis1.controller.home_axis(). If you looks at the code, it calls

bool Controller::home_axis() {
if (axis_->min_endstop_.config_.enabled) {
    config_.control_mode = CTRL_MODE_VELOCITY_CONTROL;
    input_pos_ = 0.0f;
    input_pos_updated();
    input_vel_ = -config_.homing_speed;
    input_current_ = 0.0f;
    axis_->homing_state_ = HOMING_STATE_HOMING;
} else {
    return false;
}
return true;
}

So; after rebooting the ODrive run a full calibration, then try testing if a negative input_vel moves in the correct direction. If it does, then try running home_axis().

1 Like

Hi, I new to using motor controllers and also github. I want to implement endstops in my project. I downloaded the zip file from here:

But I don’t know which file I am actually supposed to flash onto the odrive. I have been looking over the firmware developer guide, but as I said I am new to this and I need more explicit instruction. Any help would be appreciated.

The endstop support is in an experimental branch called RazorsFrozen, which is not distributed in the zip files.
You need to learn how to use the Git version control system to download this specific branch from GitHub.

If you’re on Windows, then you should download both “Git for Windows” and “TortoiseGit” to get a user-friendly interface in Windows explorer.
You should also follow the ODrive Firmware Developer’s Guide to find out how to build the source code for the version you want.

I wouldn’t use RazorsFrozen, btw, use RazorsEdge instead https://github.com/Wetmelon/ODrive

Also, I highly recommend GitKraken over any other git GUI

I’ll reply to myself here in case anyone has the same question. You need the .hex file for flashing. The easiest way I found to compile and flash the firmware is this video. https://www.youtube.com/watch?v=czsCG6QWvY4

1 Like

Thank you @Wetmelon for this package.

I would like whoever is wondering why homing is not working or if you are thinking that ODrive thinks it is already home, if you are in closed loop control and you give homing command (AXIS_STATE_HOMING) it will go to idle! (no errors)

What you need to do is to put the axis in closed loop AGAIN and it will automatically start homing!
I am using 3.5-24v ODrive

So to recap…
1- Calibrate axis
2- Calibrate min_endstop configs
3- Closed loop state
4- Homing state (will go to idle)
5- Closed loop AGAIN (will start homing)

hope this helps people!

Oh BTW on the 3.5-24v board, all 3-8 GPIOs work just fine.

Hi Wetmelon,

I intend to use limit switches so i will need to use the Endstops. I am confused on how to use the branch. I know that i will need to install all of the dependencies noted in the startup guide. Can you explain what i would need to do to use the branch on my Linux based (Ubuntu) pc? Is it a simple git clone command?

Yep, just git clone the RazorsEdge fork, then build it (make), then flash it (make flash)